/* =========================================================
   选题大师 · IP Radar V3 — 设计变量、基础样式与应用外壳
   两种场景共用一个外壳：
   · 影院（首页、官方精选）：html[data-stage="cinema"]，固定深色
   · 驾驶舱（片库、工坊、选品单、后台）：跟随 data-theme 深 / 浅
   唯一强调色：琥珀金
   ========================================================= */

:root,
html[data-theme="dark"],
html[data-stage="cinema"] {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-side: rgba(12, 13, 17, 0.72);
  --surface: #14151a;
  --surface-2: #1a1b21;
  --surface-3: #24252d;
  --pop: rgba(22, 23, 29, 0.86);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-2: rgba(255, 255, 255, 0.065);
  --glass-line: rgba(255, 255, 255, 0.08);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.11);
  --line-3: rgba(255, 255, 255, 0.2);

  --text: #ececf0;
  --text-2: #a6a7b1;
  --text-3: #767782;
  --text-4: #4d4e58;

  --accent: #e8b04b;
  --accent-2: #f3c672;
  --accent-soft: rgba(232, 176, 75, 0.12);
  --accent-line: rgba(232, 176, 75, 0.36);
  --accent-grad: linear-gradient(180deg, #f5cd7d 0%, #e0a23a 100%);
  --on-accent: #1a1206;

  --pos: #5cc98a;
  --pos-soft: rgba(92, 201, 138, 0.13);
  --neg: #f07167;
  --neg-soft: rgba(240, 113, 103, 0.13);
  --male: #7ea6dc;
  --male-soft: rgba(126, 166, 220, 0.14);
  --female: #e08fae;
  --female-soft: rgba(224, 143, 174, 0.14);
  --general: #a3a3ac;

  --grade-s: var(--accent);
  --grade-a: #d9dae2;
  --grade-b: #8fa6ad;
  --grade-c: #6e6e77;

  --shadow-pop: 0 30px 80px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 18px 40px -24px rgba(0, 0, 0, 0.7);
  --glow: rgba(232, 176, 75, 0.22);
  --spot: rgba(255, 255, 255, 0.05);
  --skeleton: rgba(255, 255, 255, 0.045);
  --skeleton-hi: rgba(255, 255, 255, 0.09);
  --ambient-a: rgba(232, 176, 75, 0.085);
  --ambient-b: rgba(96, 128, 176, 0.05);
  --arc: rgba(243, 198, 114, 0.3);
}

html[data-theme="light"]:not([data-stage="cinema"]) {
  color-scheme: light;
  --bg: #f4f2ed;
  --bg-side: rgba(250, 249, 246, 0.78);
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --surface-3: #ecE9e2;
  --pop: rgba(255, 255, 255, 0.92);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-2: rgba(255, 255, 255, 0.82);
  --glass-line: rgba(40, 30, 12, 0.08);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --line: rgba(40, 30, 12, 0.075);
  --line-2: rgba(40, 30, 12, 0.12);
  --line-3: rgba(40, 30, 12, 0.22);

  --text: #1a1814;
  --text-2: #57534b;
  --text-3: #8b867c;
  --text-4: #b8b3a8;

  --accent: #b57617;
  --accent-2: #9a6210;
  --accent-soft: rgba(181, 118, 23, 0.1);
  --accent-line: rgba(181, 118, 23, 0.36);
  --accent-grad: linear-gradient(180deg, #e9b75a 0%, #c98a24 100%);
  --on-accent: #ffffff;

  --pos: #23834f;
  --pos-soft: rgba(35, 131, 79, 0.1);
  --neg: #c2413a;
  --neg-soft: rgba(194, 65, 58, 0.09);
  --male: #3f6fb0;
  --male-soft: rgba(63, 111, 176, 0.1);
  --female: #b5506e;
  --female-soft: rgba(181, 80, 110, 0.1);
  --general: #6b6b74;

  --grade-s: var(--accent);
  --grade-a: #3c3c44;
  --grade-b: #5f7a82;
  --grade-c: #8a8790;

  --shadow-pop: 0 30px 70px rgba(60, 44, 16, 0.16), 0 2px 8px rgba(60, 44, 16, 0.08);
  --shadow-card: 0 14px 34px -22px rgba(60, 44, 16, 0.28);
  --glow: rgba(214, 150, 40, 0.18);
  --spot: rgba(214, 150, 40, 0.07);
  --skeleton: rgba(40, 30, 12, 0.05);
  --skeleton-hi: rgba(40, 30, 12, 0.09);
  --ambient-a: rgba(232, 168, 60, 0.16);
  --ambient-b: rgba(120, 150, 200, 0.12);
  --arc: rgba(214, 150, 40, 0.35);
}

:root {
  --font-sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "STSong", "SimSun", serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", "SF Mono", "Consolas", ui-monospace, monospace;

  --r-xs: 5px;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --side-w: 76px;
  --top-h: 64px;
  --blur: blur(20px) saturate(140%);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --t-fast: 140ms;
  --t: 240ms;
}

/* ---------- Reset & 基础 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 驾驶舱背景：右上琥珀暖光、左下冷灰蓝、右上角一道极细的光弧 */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}
body::before {
  inset: 0;
  background:
    radial-gradient(900px 620px at 88% -8%, var(--ambient-a), transparent 66%),
    radial-gradient(760px 560px at 6% 108%, var(--ambient-b), transparent 64%);
}
body::after {
  width: 1500px;
  height: 1500px;
  right: -760px;
  top: -1120px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: linear-gradient(200deg, var(--arc), transparent 42%) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  filter: drop-shadow(0 0 14px var(--glow));
  opacity: 0.9;
}
html[data-stage="cinema"] body::before,
html[data-stage="cinema"] body::after { display: none; }

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

::selection { background: rgba(232, 176, 75, 0.28); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 数字：无衬线 + 等宽数位，不再用等宽字体 */
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }
.muted { color: var(--text-3); }
.sm { font-size: 12.5px; }
.t-pos { color: var(--pos); font-weight: 600; }
.t-neg { color: var(--neg); font-weight: 600; }
.t-accent { color: var(--accent); }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  line-height: 17px;
  text-align: center;
  color: var(--text-2);
  background: var(--glass-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
}

html[data-theme="dark"] .only-light,
html[data-theme="light"] .only-dark { display: none; }

/* ---------- 应用外壳 ---------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* 窄图标侧栏：图标在上、两字标签在下 */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px 14px;
  background: var(--bg-side);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--line);
  z-index: 30;
}
html[data-stage="cinema"] .sidebar { background: rgba(8, 8, 11, 0.62); border-right-color: rgba(255, 255, 255, 0.05); }

.brand { display: grid; place-items: center; padding: 2px 0 18px; }

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, rgba(243, 198, 114, 0.28), transparent 60%), linear-gradient(160deg, #2a2418, #121014);
  border: 1px solid rgba(232, 176, 75, 0.3);
  box-shadow: 0 8px 24px -8px rgba(232, 176, 75, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  flex: none;
}
.brand-mark svg { width: 26px; height: 26px; fill: none; stroke: rgba(243, 198, 114, 0.55); stroke-width: 1.4; }
.brand-mark .sweep { stroke: #f3c672; stroke-width: 1.9; stroke-linecap: round; transform-origin: 16px 16px; animation: sweep 6s linear infinite; }
.brand-mark .core { fill: #f3c672; stroke: none; }
@keyframes sweep { to { transform: rotate(360deg); } }

.nav { display: flex; flex-direction: column; gap: 4px; width: 100%; }

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 58px;
  border-radius: 14px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.04em;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item .i { width: 21px; height: 21px; stroke-width: 1.55; }
.nav-item:hover { color: var(--text); background: var(--glass-2); }
.nav-item.is-active {
  color: var(--accent);
  background: linear-gradient(180deg, rgba(232, 176, 75, 0.16), rgba(232, 176, 75, 0.06));
  box-shadow: inset 0 0 0 1px var(--accent-line), 0 10px 26px -14px var(--glow);
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.nav-label { white-space: nowrap; }
.nav-count { display: none; }
#navCountBasket:not(:empty) {
  display: grid;
  place-items: center;
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-foot { margin-top: auto; width: 100%; padding-top: 12px; border-top: 1px solid var(--line); }

/* 账号区（侧栏底部，窄栏竖排） */
.account { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.account-user { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(243, 198, 114, 0.35), transparent 60%), linear-gradient(145deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--accent-line);
  font-weight: 650;
  font-size: 14px;
  color: var(--accent);
}

.account-meta { display: none; }
.account-name { font-weight: 600; font-size: 13px; }
.account-role { font-size: 11px; color: var(--text-3); }

.credit-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding: 8px 2px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.credit-btn:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.credit-btn .credit-label { display: flex; color: var(--accent); }
.credit-btn .credit-label span { display: none; }
.credit-btn .credit-val { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px; color: var(--text); display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.credit-btn .credit-frozen { font-size: 9.5px; color: var(--text-3); font-weight: 400; }
.account .account-actions { color: var(--text-3); }

.login-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-cta .btn { width: 52px; height: 52px; padding: 0; flex-direction: column; gap: 3px; border-radius: 14px; font-size: 10.5px; }
.login-cta .btn .nav-label { font-size: 10.5px; }
.login-cta small { display: none; }

.account--compact { display: none; }

/* 主区 */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid transparent;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.topbar.is-solid { border-bottom-color: var(--line); }

/* 影院：顶栏透明叠在海报上，滚动后才变毛玻璃 */
html[data-stage="cinema"] .topbar {
  position: fixed;
  left: var(--side-w);
  right: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html[data-stage="cinema"] .topbar.is-solid {
  background: rgba(10, 10, 13, 0.72);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.omni {
  flex: 1;
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 8px 0 16px;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  box-shadow: var(--glass-hi);
  color: var(--text-3);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.omni:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft), var(--glass-hi); color: var(--text-2); background: var(--glass-2); }
html[data-stage="cinema"] .omni { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.1); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.omni input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--text); font-size: 13.5px; }
.omni input::placeholder { color: var(--text-3); }
.omni input::-webkit-search-cancel-button { display: none; }
.omni-clear { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--text-3); }
.omni-clear:hover { background: var(--surface-3); color: var(--text); }
.omni-clear .i { width: 13px; height: 13px; }
.omni-kbd { margin-right: 4px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); }
.status-pill.is-on .dot { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft), 0 0 8px var(--pos); }
.status-pill.is-on { color: var(--text-2); }

.content { position: relative; padding: 8px 32px 88px; min-width: 0; }
html[data-stage="cinema"] .content { padding: 0 0 88px; }

.page { display: none; }
/* 只做淡入且不保留填充：transform 会让页面内的 fixed 元素（弹出面板、批量条）错位 */
.page.is-active { display: block; animation: pageFade 320ms var(--ease); }
@keyframes pageFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 响应式外壳 ---------- */
@media (max-width: 1180px) {
  .status-pill .status-text { display: none; }
  .status-pill { padding: 0 10px; }
  .topbar, .content { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 760px) {
  :root { --top-h: 58px; --side-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    flex-direction: row;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; gap: 2px; }
  .nav-item { flex: 1; height: 52px; font-size: 10.5px; border-radius: 12px; }
  .nav-item .i { width: 20px; height: 20px; }
  .nav-item.is-active::before { display: none; }
  #navCountBasket:not(:empty) { right: calc(50% - 22px); top: 3px; }
  .topbar { padding: 0 12px; gap: 8px; }
  html[data-stage="cinema"] .topbar { left: 0; }
  .omni { height: 38px; }
  .omni-kbd, .status-pill { display: none; }
  .account--compact { display: flex; flex-direction: row; }
  .content { padding: 6px 14px 110px; }
  html[data-stage="cinema"] .content { padding: 0 0 110px; }
}
