/* 设计 token 借鉴 shanks-web：冷感浅色内容区 + 深色学习舞台 */
@font-face {
  font-family: "Space Grotesk";
  src: url("/public/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-surface-2: #eef1f4;
  --color-line: rgb(24 33 38 / 0.12);
  --color-line-strong: rgb(24 33 38 / 0.22);
  --color-text: #182126;
  --color-soft: #3a464e;
  --color-muted: #56636b;
  --color-accent: #1d4ed8;
  --color-accent-2: #4b6b92;
  --color-ok: #1e7b4f;
  --color-warn: #a66a00;
  --color-bad: #b3261e;
  --color-stage: #10181d;
  --color-stage-line: rgb(255 255 255 / 0.16);
  --color-stage-soft: #b9c4c9;
  --color-ink: #0d1117;
  --color-ink-2: #151c25;
  --color-ink-strong: #f2f5f8;
  --color-ink-text: #d5dde3;
  --color-ink-muted: #9aa7b2;
  --color-ink-accent: #7cc4ff;
  --color-ink-line: rgb(255 255 255 / 0.14);
  --color-control-line: #77828c;
  --color-ink-control-line: #748190;

  --font-sans: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, Consolas, monospace;
  --font-display: "Space Grotesk", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-editorial: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;

  --nav-w: 216px;
  --tips-w: 240px;
  --radius: 4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--color-bg); color: var(--color-text); }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-width: 0;
}

h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; }
img, svg { display: inline-block; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, [role="button"], summary, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.on-ink :focus-visible { outline-color: var(--color-ink-accent); }

::selection { background: rgb(29 78 216 / 0.15); }

/* 页面淡冷渐变背景 */
.site-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% -12%, rgb(255 255 255 / 0.7), transparent 70%),
    linear-gradient(180deg, #fafbfc 0%, var(--color-bg) 38%);
}

.ic { width: 1.15em; height: 1.15em; flex: none; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  border-radius: var(--radius); background: var(--color-accent); color: #fff;
  padding: 0.5rem 1rem; font-size: 14px; transition: top 0.15s;
}
.skip-link:focus-visible { top: 0.75rem; }

/* ============ 布局：左导航 + 主区 + 右提示 ============ */
.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--tips-w);
  min-height: 100vh;
}

.side-nav {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--color-line);
  padding: 1.25rem 0.875rem;
  background: rgb(255 255 255 / 0.6);
}
.side-brand { display: flex; align-items: center; gap: 0.625rem; padding: 0 0.375rem 1.25rem; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 6px; background: var(--color-ink); color: var(--color-ink-accent);
  font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
}
.brand-text { font-weight: 600; font-size: 15px; line-height: 1.3; }
.brand-text small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 12px; color: var(--color-muted); }

.side-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-list a {
  display: flex; align-items: center; gap: 0.625rem;
  min-height: 44px; padding: 0 0.75rem;
  border-radius: var(--radius);
  color: var(--color-soft); text-decoration: none; font-size: 15px;
}
.side-list a:hover { background: var(--color-surface-2); color: var(--color-text); }
.side-list a[aria-current="page"] {
  background: rgb(29 78 216 / 0.09); color: var(--color-accent); font-weight: 600;
}
.side-foot {
  margin-top: auto; padding: 0.75rem 0.375rem 0;
  border-top: 1px solid var(--color-line);
  font-size: 12px; line-height: 1.7; color: var(--color-muted);
}

.main { min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; }
.view { max-width: 880px; margin: 0 auto; }
.view[hidden] { display: none; }

.tips {
  border-left: 1px solid var(--color-line);
  padding: 1.5rem 1rem;
}
.tips-inner { position: sticky; top: 1.5rem; }
.tips-title { font-size: 12px; letter-spacing: 0.12em; color: var(--color-muted); font-weight: 600; }
.tips-list { padding-left: 1.25rem; margin-top: 0.75rem; font-size: 13px; color: var(--color-soft); }
.tips-list li + li { margin-top: 0.4rem; }
.tips-list b { color: var(--color-accent); margin-right: 0.25rem; }
.tips-note { margin-top: 1rem; font-size: 12px; line-height: 1.8; color: var(--color-muted); }

/* ============ 移动端底部导航 ============ */
.bottom-nav { display: none; }

@media (max-width: 1023px) {
  .layout { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .tips { display: none; }
}
@media (max-width: 719px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-nav { display: none; }
  .main { padding: 1rem 0.875rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    border-top: 1px solid var(--color-line);
    background: var(--color-surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; min-height: 56px; color: var(--color-muted);
    text-decoration: none; font-size: 11px; line-height: 1.2;
  }
  .bottom-nav a span {
    display: block; max-width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .bottom-nav a[aria-current="page"] { color: var(--color-accent); font-weight: 600; }
}

/* ============ 通用组件 ============ */
.card {
  position: relative;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgb(24 33 38 / 0.04);
}
.panel { border: 1px solid var(--color-line); border-radius: var(--radius); background: var(--color-surface); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--color-line); padding: 0.625rem 1rem;
  font-size: 12px; letter-spacing: 0.12em; color: var(--color-muted);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; border: 0; border-radius: var(--radius);
  padding: 0 1.25rem; font-size: 15px; font-weight: 500; cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn-primary { background: var(--color-accent); color: #fff; box-shadow: 0 10px 24px -14px rgb(29 78 216 / 0.5); }
.btn-primary:hover { background: #1e40af; }
.btn-ghost { border: 1px solid var(--color-control-line); background: var(--color-surface); color: var(--color-text); }
.btn-ghost:hover { border-color: rgb(29 78 216 / 0.45); color: var(--color-accent); }
.btn-stage { border: 1px solid var(--color-ink-control-line); background: rgb(255 255 255 / 0.08); color: #eef2f4; }
.btn-stage:hover { background: rgb(255 255 255 / 0.16); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sm { min-height: 40px; padding: 0 0.875rem; font-size: 13px; }

.tag {
  display: inline-flex; align-items: center;
  border: 1px solid var(--color-line); border-radius: 3px;
  background: var(--color-surface-2); padding: 0.125rem 0.5rem;
  font-size: 12px; line-height: 1.6; color: var(--color-soft);
}
.tag-accent { border-color: rgb(29 78 216 / 0.35); background: rgb(29 78 216 / 0.07); color: var(--color-accent); }
.tag-ok { border-color: rgb(30 123 79 / 0.35); background: rgb(30 123 79 / 0.08); color: var(--color-ok); }
.tag-warn { border-color: rgb(166 106 0 / 0.4); background: rgb(166 106 0 / 0.08); color: var(--color-warn); }

.seg { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--color-line); border-radius: var(--radius); background: var(--color-surface); padding: 2px; flex-wrap: wrap; }
.seg button {
  min-height: 40px; border: 0; border-radius: 3px; background: transparent;
  padding: 0 0.75rem; font-size: 13px; color: var(--color-soft); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--color-ink); color: var(--color-ink-strong); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--color-muted); }
.small { font-size: 13px; }
.caption { font-size: 12px; }

.rule { display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; color: var(--color-muted); }
.rule::after { content: ""; height: 1px; flex: 1; background: var(--color-line); }

input[type="file"] { min-height: 44px; }
input[type="search"], input[type="text"], select, textarea {
  border: 1px solid var(--color-control-line); border-radius: var(--radius);
  background: var(--color-surface); padding: 0.5rem 0.75rem;
  font-size: 16px; min-height: 44px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.6; }
select { width: auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(4.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; max-width: min(90vw, 420px);
  border: 1px solid var(--color-line-strong); border-radius: var(--radius);
  background: var(--color-ink); color: var(--color-ink-text);
  padding: 0.625rem 1rem; font-size: 14px;
  box-shadow: 0 12px 32px -16px rgb(13 17 23 / 0.5);
}
@media (min-width: 720px) { .toast { bottom: 2rem; } }

/* 模态确认框 */
.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 1rem;
  background: rgb(13 17 23 / 0.5);
}
.modal-box {
  width: min(92vw, 440px);
  border: 1px solid var(--color-line); border-radius: 8px;
  background: var(--color-surface); padding: 1.25rem;
  box-shadow: 0 24px 64px -24px rgb(13 17 23 / 0.5);
}
.modal-box h2 { font-size: 17px; margin-bottom: 0.5rem; }
.modal-box p { font-size: 14px; color: var(--color-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; flex-wrap: wrap; }
@media (max-width: 719px) { .modal-actions .btn { flex: 1 1 8rem; } }

/* 深色区块（学习 hero / 面试台） */
.on-ink {
  background-color: var(--color-ink);
  color: var(--color-ink-text);
  border-radius: 8px;
}
.ink-field {
  background-image:
    radial-gradient(60% 55% at 85% 0%, rgb(124 196 255 / 0.14), transparent 70%),
    linear-gradient(rgb(255 255 255 / 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.045) 1px, transparent 1px);
  background-size: auto, 56px 56px, 56px 56px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
