/* ============ 设计变量与全局重置 ============ */
:root {
  /* —— 主题皮肤变量（随整套主题一键切换） —— */
  --body-bg: #EEF0F4;            /* 应用外壳外的页面底色 */
  --bg: #F7F8FA;                 /* 应用内页面底色 */
  --card: #FFFFFF;               /* 卡片 / 容器底色 */
  --line: #EBEEF5;               /* 常规细边框 */
  --line-strong: #E3E8F2;        /* 稍深边框 / 按钮边 */
  --header-bg: rgba(255, 255, 255, 0.97); /* 顶栏底色 */
  --text: #1A1D24;               /* 主文字 */
  --text-2: #6B7280;             /* 次要文字 */
  --text-3: #9CA3AF;             /* 弱化文字 */
  --accent: #3B66F5;             /* 主强调色（按钮/链接/选中） */
  --accent-2: #6384FF;           /* 主色渐变第二端 */
  --accent-soft: #EEF2FF;        /* 主色浅底 */
  --accent-line: #C7D6FF;        /* 主色浅边框 */
  --accent-soft-2: #F6F9FF;                    /* 主色浅底第二端（渐变层次） */
  --on-accent: #FFFFFF;          /* 主色底上的文字色 */
  /* —— 内容类型 / 状态区分色（跨主题保持不变） —— */
  --warm: #FF5A36;
  --warm-soft: #FFF1ED;
  --green: #10B981;
  --green-soft: #ECFDF5;
  --amber: #F59E0B;
  --amber-soft: #FFFBEB;
  --red: #EF4444;
  --red-soft: #FEF2F2;
  --app-max: 480px;
}

/* 主题二：暖纸书香 */
html[data-theme="warm"] {
  --body-bg: #EFE9DE;
  --bg: #F7F1E7;
  --card: #FDFBF6;
  --line: #EAE0D0;
  --line-strong: #DDCFB8;
  --header-bg: rgba(253, 251, 246, 0.97);
  --text: #3A2F22;
  --text-2: #7A6A55;
  --text-3: #A8967D;
  --accent: #B4632A;
  --accent-2: #D98A4B;
  --accent-soft: #F6E8D8;
  --accent-line: #E8C9A6;
  --accent-soft-2: #FBF3E8;
}

/* 主题三：护眼森系 */
html[data-theme="forest"] {
  --body-bg: #E7EDE8;
  --bg: #F2F6F1;
  --card: #FBFDFB;
  --line: #DEE7DF;
  --line-strong: #CBD8CC;
  --header-bg: rgba(251, 253, 251, 0.97);
  --text: #1F2D24;
  --text-2: #55685A;
  --text-3: #8A9B8E;
  --accent: #2F7D5B;
  --accent-2: #4FA37E;
  --accent-soft: #E6F2EB;
  --accent-line: #BBD9C6;
  --accent-soft-2: #F0F7F2;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--body-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", sans-serif;
  line-height: 1.5;
  font-size: 14px;
}
input, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ============ 居中应用容器：移动端满宽，PC 居中留白 ============ */
.app-shell {
  position: relative;
  max-width: var(--app-max);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 30px rgba(26, 29, 36, 0.06);
}
#app { min-height: 100vh; }
.page-root { min-height: 100vh; padding-bottom: 20px; }
.page { min-height: 100vh; }
/* ============ 共享头部 ============ */
.top-shell {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo {
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--on-accent); font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(59, 102, 245, 0.28);
}
.brand-name { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-2); }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-action-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 7px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line-strong);
  color: var(--text-2); font-size: 10.5px; font-weight: 600; line-height: 1;
}
.header-action-btn:active { opacity: 0.75; }
.header-action-btn.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.account-btn {
  font-size: 13px; padding: 5px 8px; line-height: 1;
  background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent);
}


.main { padding: 14px 14px 20px; }
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 2px 10px rgba(26, 29, 36, 0.04);
}
.section-title { font-size: 16px; font-weight: 800; }

.progress-track { height: 7px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); border-radius: 999px; transition: width .35s ease; }

.pill {
  font-size: 11px; font-weight: 600; padding: 4px 9px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2); cursor: pointer;
}
.pill.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  padding: 9px 14px; box-shadow: 0 3px 8px rgba(26, 29, 36, 0.12);
}
.btn-primary:active { opacity: 0.88; }
.btn-ghost {
  background: var(--card); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 13px; padding: 9px 12px;
}

.empty-box {
  background: var(--card); border: 2px dashed var(--line-strong); border-radius: 12px;
  padding: 40px 20px; text-align: center; color: var(--text-2); font-size: 13.5px;
}

.scc-empty-state {
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 38px 20px;
  text-align: center;
  color: var(--text-2);
}
.scc-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.scc-empty-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.scc-empty-desc {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-3);
}

/* ============ Toast & Modal ============ */
.scc-toast {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(0.9);
  background: rgba(17, 24, 39, 0.86); color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; z-index: 2000; pointer-events: none;
  opacity: 0; transition: opacity .2s, transform .2s; max-width: 80vw; text-align: center;
}
.scc-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.scc-modal-mask {
  position: fixed; inset: 0; z-index: 1500; background: rgba(17, 24, 39, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.scc-modal-card {
  width: 100%; max-width: 340px; background: var(--card); border-radius: 14px;
  padding: 18px 15px 14px; box-shadow: 0 10px 30px rgba(17, 24, 39, 0.24);
}
.scc-modal-title { font-size: 16px; font-weight: 800; text-align: center; }
.scc-modal-content { font-size: 13px; color: var(--text-2); line-height: 1.7; margin-top: 10px; white-space: pre-line; }
.scc-modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.scc-modal-btn {
  flex: 1; text-align: center; font-size: 14px; font-weight: 700;
  padding: 10px 0; border-radius: 10px; cursor: pointer;
}
.scc-modal-btn.cancel { background: var(--line); color: var(--text-2); }
.scc-modal-btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 8px rgba(26, 29, 36, 0.12); }

/* ============ 全局固定 Header ============ */
/* 所有页面（除 login）固定显示：品牌 + 4 tab + 右侧 2 按钮
   尺寸严格和 app-shell 对齐：max-width: var(--app-max) 居中悬浮 */
.global-header {
  position: fixed;
  top: 0;
  /* 关键：只占 480px 居中盒子，不是全屏 */
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: var(--app-max); /* 480px */
  max-width: 100vw;
  z-index: 90;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .2s ease;
}
.global-header.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.gh-inner {
  padding: 10px 16px 8px;
}
.gh-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gh-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 900;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.gh-brand-text { display: flex; flex-direction: column; }
.gh-name { font-size: 15px; font-weight: 800; color: var(--text); line-height: 1.2; }
.gh-sub { font-size: 11px; color: var(--text-3); line-height: 1.2; }

.gh-tabs {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}
.gh-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  padding: 6px 0;
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s;
  position: relative;
}
.gh-tab:hover { background: var(--accent-soft-2); }
.gh-tab.on {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
}

.gh-toprow { display: flex; align-items: center; gap: 8px; }
.gh-back {
  width: 30px; height: 30px; border-radius: 9px;
  display: none; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--card); border: 1px solid var(--line);
  flex-shrink: 0; cursor: pointer; padding: 0;
}
.gh-back:active { opacity: .7; }
.gh-brand { flex: 1; min-width: 0; }
.gh-actions { display: flex; gap: 6px; flex-shrink: 0; }
.gh-btn {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
.gh-btn:hover { color: var(--accent); border-color: var(--accent); }
.gh-btn.gh-shelf { position: relative; }
.gh-shelf-badge {
  position: absolute; top: -5px; right: -7px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--warm); color: var(--on-accent);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--card); font-variant-numeric: tabular-nums;
}
.gh-shelf-badge[hidden] { display: none; }
.gh-btn.gh-account {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

/* 手机视口下 header 宽度撑满 */
@media (max-width: 500px) {
  .global-header { width: 100%; }
}
@media (max-width: 420px) {
  .gh-sub { display: none; }
  .gh-btn { padding: 4px 8px; font-size: 11px; }
  .gh-back { width: 28px; height: 28px; }
  .gh-toprow { gap: 6px; }
}

/* body 有全局 header 时给内容区留 88px 空间 */
body.gh-present .app-shell { padding-top: var(--gh-h, 92px); }

/* body 有全局 header 时，隐藏各页面自己的 app-header */
body.gh-present .app-header { display: none !important; }

/* ============ 全站 SVG 图标对齐 ============ */
/* 手写内联 SVG 的描边兜底：统一 1.75px 线性描边（fill 由各图标内联或局部样式控制，避免误伤实心圆点） */
.icon {
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-svg {
  vertical-align: -2px;
  margin-right: 3px;
  display: inline-block;
  flex-shrink: 0;
}
/* 徽标 / 徽章里用的稍大图标（如 badge-emoji） */
.badge-emoji .i-svg,
.gh-logo .i-svg { margin-right: 0; vertical-align: middle; }
/* 某些按钮里的图标不需要右边距 */
.excerpt-btn .i-svg,
.btn-ghost .i-svg,
.btn-export-notes .i-svg { margin-right: 2px; }
