/* ============ AI 面试知识库 · book-style 纸感设计系统 ============ */
:root {
  --paper: #F6F1E7;
  --surface: #FFFDF8;
  --surface-2: #FBF7EE;
  --ink: #2E2823;
  --ink-soft: #6B5F52;
  --ink-faint: #9A8D7C;
  --accent: #8A5A2B;
  --accent-deep: #633806;
  --amber: #BA7517;
  --amber-soft: #EF9F27;
  --amber-bg: #FAEEDA;
  --line: #E7DDC9;
  --line-soft: #EFE7D6;
  --green: #5C7A4A;
  --red: #A32D2D;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;
  --radius: 14px;
  --content-size: 17px;
}
[data-theme="dark"] {
  --paper: #201B15;
  --surface: #2A241C;
  --surface-2: #332B21;
  --ink: #EDE4D3;
  --ink-soft: #B8A992;
  --ink-faint: #8A7C68;
  --accent: #D9A05B;
  --accent-deep: #E5B878;
  --amber: #D9A05B;
  --amber-soft: #EF9F27;
  --amber-bg: #3D2F1C;
  --line: #3F362A;
  --line-soft: #362E24;
  --green: #9DB88A;
  --red: #E08A7A;
}
* { box-sizing: border-box; }
html { font-size: var(--content-size); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  font-family: var(--serif); font-weight: 700; font-size: 1.06rem;
  color: var(--accent-deep); white-space: nowrap;
}
[data-theme="dark"] .brand { color: var(--accent); }
.searchbox { flex: 1; max-width: 460px; position: relative; }
.searchbox input { width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(60, 40, 15, .12);
  max-height: 380px; overflow-y: auto; padding: 6px;
}
.sr-item {
  display: block; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.sr-item:hover, .sr-item.active { background: var(--amber-bg); }
.sr-item .t { font-size: .82rem; color: var(--ink); font-weight: 500; }
.sr-item .s { font-size: .72rem; color: var(--ink-soft); margin-top: 2px; }
.sr-item .s mark, .sr-item .t mark { background: none; color: var(--amber); font-weight: 700; }
.sr-empty { padding: 14px; text-align: center; color: var(--ink-faint); font-size: .8rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mastered-total { font-size: .76rem; color: var(--ink-soft); white-space: nowrap; }
.font-ctrl { display: flex; gap: 2px; }
.font-ctrl button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 6px; padding: 2px 7px; font-size: .72rem; cursor: pointer;
}
.font-ctrl button:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 6px 14px; font-size: .8rem; cursor: pointer;
  font-family: var(--sans); transition: all .15s;
}
.btn:hover { border-color: var(--amber); color: var(--accent-deep); }
[data-theme="dark"] .btn:hover { color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFF8EE; }
.btn-primary:hover { background: var(--accent-deep); color: #FFF8EE; }
[data-theme="dark"] .btn-primary { color: #211B12; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 3px 10px; font-size: .74rem; border-radius: 7px; }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 22px 20px 80px;
  display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 26px;
}
.sidebar { position: sticky; top: 74px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.sidebar .grp { font-size: .68rem; font-weight: 700; color: var(--accent); letter-spacing: .08em; margin: 14px 0 5px; padding-left: 8px; }
.sidebar .grp:first-child { margin-top: 0; }
.sidebar a {
  display: flex; align-items: center; gap: 7px;
  font-size: .78rem; color: var(--ink-soft); padding: 5px 8px; border-radius: 7px;
}
.sidebar a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.sidebar a.cur { background: var(--amber-bg); color: var(--accent-deep); font-weight: 500; }
[data-theme="dark"] .sidebar a.cur { color: var(--accent); }
.sidebar a .no { font-family: var(--serif); font-size: .68rem; color: var(--ink-faint); width: 18px; }
.sidebar a.cur .no { color: var(--amber); }
.sidebar a .dot { margin-left: auto; font-size: .62rem; color: var(--ink-faint); }

.main { min-width: 0; }
.breadcrumb { font-size: .74rem; color: var(--ink-faint); display: flex; gap: 8px; margin-bottom: 10px; }

/* ---------- 专题头 ---------- */
.sec-head h1 {
  font-family: var(--serif); font-size: 1.5rem; font-weight: 700;
  margin: 0 0 10px; line-height: 1.4; color: var(--ink);
}
.sec-meta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: .76rem; color: var(--ink-soft); }
.diff { display: inline-flex; gap: 3px; align-items: center; }
.diff i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.diff i.on { background: var(--amber); }
.sec-progress { display: flex; align-items: center; gap: 8px; }
.sec-progress .bar { width: 110px; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.sec-progress .bar i { display: block; height: 100%; background: var(--amber); border-radius: 3px; }

.toc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 20px; }
/* ---------- 题目目录（顶部面板，窄屏用） ---------- */
.toc-bar { display: flex; align-items: flex-start; gap: 12px; }
.toc-bar .toc-chips { flex: 1; margin-bottom: 12px; }
.toc-toggle { flex-shrink: 0; margin-top: 14px; font-size: .78rem; }
.toc-toggle.open { border-color: var(--amber); color: var(--accent-deep); }
[data-theme="dark"] .toc-toggle.open { color: var(--accent); }
.toc-panel {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px;
  max-height: 420px; overflow-y: auto;
}
.toc-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-size: .82rem; line-height: 1.45;
}
.toc-item:hover { background: var(--amber-bg); }
.toc-item .t-no {
  font-family: var(--mono); font-size: .7rem; color: var(--accent);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 6px; flex-shrink: 0;
}
.toc-item .t-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item .t-cat { font-size: .68rem; color: var(--ink-faint); flex-shrink: 0; }
.toc-item .t-st { flex-shrink: 0; min-width: 30px; text-align: right; font-style: normal; }
.toc-item .t-ok { color: var(--green); font-style: normal; font-size: .78rem; }
.toc-item .t-star { color: var(--amber-soft); font-style: normal; font-size: .78rem; }
@media (max-width: 960px) { .toc-panel { grid-template-columns: 1fr; max-height: 340px; } }
/* ---------- 右侧跟随目录（宽屏用） ---------- */
.toc-side { display: none; }
@media (min-width: 1240px) {
  .layout { max-width: 1540px; grid-template-columns: 208px minmax(0, 1fr) 240px; }
  .layout.index { max-width: 1240px; grid-template-columns: 208px minmax(0, 1fr); }
  .toc-side {
    display: block; position: sticky; top: 74px; align-self: start;
    max-height: calc(100vh - 96px); overflow-y: auto;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 10px;
  }
  .layout:not(.index) .toc-bar .toc-toggle { display: none; }
  .layout:not(.index) .toc-panel { display: none; }
  .toc-side-title {
    font-size: .7rem; font-weight: 700; color: var(--accent);
    letter-spacing: .08em; padding: 0 8px 8px; border-bottom: 1px solid var(--line-soft);
    margin-bottom: 6px;
  }
  .toc-side-nav { display: flex; flex-direction: column; gap: 1px; }
  .toc-side-nav .toc-item { font-size: .76rem; padding: 6px 8px; }
  .toc-side-nav .toc-item.cur { background: var(--amber-bg); }
  .toc-side-nav .toc-item.cur .t-title { color: var(--accent-deep); font-weight: 500; }
  [data-theme="dark"] .toc-side-nav .toc-item.cur .t-title { color: var(--accent); }
  .toc-side-nav .toc-item .t-st { min-width: 26px; }
}
.chip {
  font-size: .74rem; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface);
  cursor: pointer;
}
.chip:hover { border-color: var(--amber); color: var(--accent-deep); }
.chip.on { background: var(--amber-bg); border-color: var(--amber-soft); color: var(--accent-deep); font-weight: 500; }
[data-theme="dark"] .chip.on { color: var(--accent); }

/* ---------- 题卡 ---------- */
.qcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 18px; position: relative;
  border-left: 3px solid var(--line);
  scroll-margin-top: 84px;
}
.qcard.mastered { border-left-color: var(--green); }
.qcard.starred { box-shadow: inset 0 0 0 1px var(--amber-soft); }
.qhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.qno { font-family: var(--serif); font-weight: 700; color: var(--amber); font-size: .92rem; white-space: nowrap; }
.qtitle { font-family: var(--serif); font-size: 1.08rem; font-weight: 700; line-height: 1.55; margin: 0; flex: 1; min-width: 200px; }
.qacts { margin-left: auto; display: flex; gap: 6px; }
.qacts button {
  border: 1px solid var(--line); background: transparent; color: var(--ink-faint);
  border-radius: 7px; font-size: .72rem; padding: 3px 10px; cursor: pointer; white-space: nowrap;
}
.qacts button:hover { border-color: var(--amber); color: var(--accent-deep); }
.qacts button.on-star { color: var(--amber); border-color: var(--amber-soft); background: var(--amber-bg); }
.qacts button.on-master { color: var(--green); border-color: var(--green); }
.qcat { font-size: .68rem; color: var(--ink-faint); }
.qbody { margin-top: 12px; font-size: .92rem; line-height: 2.0; color: var(--ink); }
.qbody p { margin: 0 0 .65em; }
.qbody h4 {
  font-family: var(--serif); font-size: .98rem; font-weight: 700;
  margin: 1.3em 0 .5em; color: var(--accent-deep);
}
[data-theme="dark"] .qbody h4 { color: var(--accent); }
.qbody ul, .qbody ol { margin: 0 0 .8em; padding-left: 1.4em; }
.qbody li { margin-bottom: .3em; }
.qbody li::marker { color: var(--amber); }
.qlabel {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .76rem; font-weight: 700; color: var(--accent-deep);
  margin: 1.1em 0 .5em;
}
[data-theme="dark"] .qlabel { color: var(--accent); }
.qlabel::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--amber-soft); }
.qbody blockquote {
  margin: .8em 0; padding: 10px 16px;
  border-left: 3px solid var(--amber-soft); background: var(--surface-2);
  border-radius: 0 10px 10px 0;
  font-family: var(--serif); color: var(--ink-soft); line-height: 1.9;
}
.qbody pre {
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: .8em 0;
  font-family: var(--mono); font-size: .76rem; line-height: 1.65; color: var(--ink);
}
.qbody pre.ascii { font-size: .68rem; line-height: 1.4; color: var(--ink-soft); }
.qbody figure { margin: 1em 0; }
.qbody figure img { width: 100%; border-radius: 10px; border: 1px solid var(--line-soft); display: block; }
.qbody figcaption { text-align: center; font-size: .74rem; color: var(--ink-faint); margin-top: 6px; }
.qbody table {
  width: 100%; border-collapse: collapse; margin: .9em 0; font-size: .8rem; line-height: 1.6;
}
.qbody th, .qbody td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.qbody th { background: var(--amber-bg); color: var(--accent-deep); font-weight: 500; white-space: nowrap; }
[data-theme="dark"] .qbody th { color: var(--accent); }
.qbody tr:nth-child(even) td { background: var(--surface-2); }

/* ---------- 附录 ---------- */
.appendix {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; margin-top: 26px;
}
.appendix h2 { font-family: var(--serif); font-size: 1.05rem; margin: 0 0 12px; }
.appendix .qbody { margin-top: 0; }

/* ---------- 首页 ---------- */
.hero { padding: 34px 0 10px; }
.hero h1 { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; margin: 0 0 10px; }
.hero p { color: var(--ink-soft); font-size: .88rem; line-height: 1.8; margin: 0 0 18px; max-width: 640px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 26px; }
.metric { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.metric .k { font-size: .72rem; color: var(--ink-soft); }
.metric .v { font-size: 1.4rem; font-weight: 500; margin-top: 3px; font-family: var(--serif); }
.metric .v small { font-size: .78rem; color: var(--ink-faint); font-weight: 400; }
.metric.continue { display: flex; flex-direction: column; }
.metric.continue .bar { height: 6px; border-radius: 3px; background: var(--line-soft); margin: 8px 0 6px; }
.metric.continue .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.seccard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; display: block; color: inherit; transition: all .15s;
}
.seccard:hover { text-decoration: none; border-color: var(--amber-soft); transform: translateY(-1px); }
.seccard .row1 { display: flex; align-items: baseline; gap: 8px; }
.seccard .no { font-family: var(--serif); color: var(--amber); font-size: .78rem; }
.seccard .name { font-weight: 500; font-size: .92rem; }
.seccard .cnt { margin-left: auto; font-size: .72rem; color: var(--ink-faint); white-space: nowrap; }
.seccard .sub { font-size: .72rem; color: var(--ink-soft); margin: 7px 0 10px; line-height: 1.5; min-height: 2.2em; }
.seccard .row3 { display: flex; align-items: center; gap: 8px; }
.seccard .pct { margin-left: auto; font-size: .72rem; color: var(--ink-faint); }
.seccard .bar { height: 4px; border-radius: 2px; background: var(--line-soft); margin-top: 9px; }
.seccard .bar i { display: block; height: 100%; border-radius: 2px; background: var(--amber); }
.seccard.todo { opacity: .62; }
.seccard.todo:hover { transform: none; border-color: var(--line); cursor: default; }
.grid-note { font-size: .74rem; color: var(--ink-faint); margin-top: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .grp { width: 100%; margin: 8px 0 2px; }
  .sec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .sec-grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .searchbox { order: 3; max-width: none; flex-basis: 100%; }
}

/* ---------- Back to Portfolio FAB ---------- */
.home-fab {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, #8A5A2B, #5f3d1c);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: all 0.3s ease;
  opacity: 0.85;
}
.home-fab:hover { opacity: 1; transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.24); }
[data-theme="dark"] .home-fab { background: linear-gradient(135deg, #a5713a, #6e4a24); }
@media (max-width: 640px) {
  .home-fab { bottom: 14px; left: 14px; padding: 7px 13px; font-size: 0.8rem; }
}
