/* Java 面试手册 — 移动优先样式 */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16181d;
  --ink-2: #5b6270;
  --ink-3: #8a919e;
  --line: #e6e8ee;
  --brand: #3b5bdb;
  --brand-soft: #eef2ff;
  --ok: #12805c;
  --ok-soft: #e6f7f0;
  --warn: #b45309;
  --warn-soft: #fff6e6;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --radius: 16px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --card: #171a21;
    --ink: #e9ecf1;
    --ink-2: #a3acbb;
    --ink-3: #6d7686;
    --line: #262b35;
    --brand: #7c9bff;
    --brand-soft: #1a2130;
    --ok: #4ade80; --ok-soft: #12241b;
    --warn: #fbbf24; --warn-soft: #241d0e;
    --bad: #f87171; --bad-soft: #2a1616;
  }
  meta[name="theme-color"] { content: #0e1014; }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(66px + var(--safe-b));
  overscroll-behavior-y: contain;
}

button { font: inherit; color: inherit; }

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  height: 52px; display: flex; align-items: center; gap: 8px;
  padding: 0 10px; max-width: 760px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.logo { font-size: 20px; }
.title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border: 0; background: none; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:active { background: var(--brand-soft); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.dailybar { height: 3px; background: transparent; }
.dailybar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #3b5bdb, #6d8bff); transition: width .35s ease; }

/* ── 底栏 ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-3); text-decoration: none; font-size: 11px; position: relative;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--brand); }
.tab .badge {
  position: absolute; top: 8px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; font-style: normal; text-align: center;
}

/* ── 通用 ── */
main { max-width: 760px; margin: 0 auto; padding: 12px 12px 24px; }
.muted { color: var(--ink-3); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--ink-3); letter-spacing: .04em; margin: 18px 4px 8px; }
.text-btn { border: 0; background: none; color: var(--brand); padding: 8px 6px; cursor: pointer; font-size: 14px; }

/* ── 分类 chips ── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-size: 13.5px; white-space: nowrap; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ── 卡片 ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 14px; margin-bottom: 12px;
}
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 10px; flex-wrap: wrap; }
.pill { padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11.5px; font-weight: 600; }
.pill.lv1 { background: var(--ok-soft); color: var(--ok); }
.pill.lv2 { background: var(--warn-soft); color: var(--warn); }
.pill.lv3 { background: var(--bad-soft); color: var(--bad); }
.q { font-size: 18px; line-height: 1.5; font-weight: 650; letter-spacing: -.01em; margin: 0 0 12px; }
.answer { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; animation: fade .25s ease; }
.answer ul { margin: 0; padding-left: 20px; }
.answer li { margin: 7px 0; font-size: 15px; line-height: 1.62; color: var(--ink); }
.answer li b { color: var(--brand); font-weight: 650; }
.answer code {
  background: var(--brand-soft); color: var(--brand); padding: 1px 5px; border-radius: 5px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .12s ease, background .2s;
}
.btn:active { transform: scale(.975); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); color: var(--ok); background: var(--ok-soft); }
.btn.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); color: var(--warn); background: var(--warn-soft); }
.btn.bad { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); color: var(--bad); background: var(--bad-soft); }
.btn.sm { flex: 0 0 auto; min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }

.hint { color: var(--ink-3); font-size: 12.5px; margin: 10px 2px 0; text-align: center; }

/* ── 进度 / 统计 ── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; text-align: center;
}
.stat .n { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b5bdb, #6d8bff); }

.cat-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .name { width: 82px; font-size: 14px; flex: 0 0 auto; }
.cat-row .progress { flex: 1; }
.cat-row .num { width: 62px; text-align: right; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ── 专题 ── */
.topic-item {
  display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.topic-item .ico {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px; background: var(--brand-soft);
  display: grid; place-items: center; font-size: 19px;
}
.topic-item h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 650; }
.topic-item p { margin: 0; font-size: 12.5px; color: var(--ink-3); }

.article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 22px; }
.article h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.01em; }
.article .lead { color: var(--ink-3); font-size: 13px; margin: 0 0 16px; }
.article h2 { font-size: 17px; margin: 26px 0 10px; padding-left: 10px; border-left: 3px solid var(--brand); }
.article h3 { font-size: 15px; margin: 18px 0 8px; }
.article p { margin: 10px 0; font-size: 15px; line-height: 1.75; }
.article ul, .article ol { padding-left: 22px; margin: 10px 0; }
.article li { margin: 6px 0; font-size: 15px; line-height: 1.7; }
.article code { background: var(--brand-soft); color: var(--brand); padding: 1px 5px; border-radius: 5px; font: 13px ui-monospace, Menlo, Consolas, monospace; }
.article pre {
  background: #11151c; color: #d7e0ef; padding: 14px; border-radius: 12px; overflow-x: auto;
  font: 12.5px/1.6 ui-monospace, Menlo, Consolas, monospace; margin: 12px 0;
}
.article pre code { background: none; color: inherit; padding: 0; }
.article blockquote { margin: 12px 0; padding: 10px 14px; background: var(--brand-soft); border-radius: 10px; color: var(--ink-2); font-size: 14px; }
.article table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 12px 0; }
.article th, .article td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.article th { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }

/* ── 搜索弹层 ── */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(8, 10, 14, .45); display: flex; align-items: flex-start; justify-content: center; }
.sheet-panel {
  width: 100%; max-width: 760px; max-height: 86vh; margin-top: env(safe-area-inset-top, 0px);
  background: var(--card); border-radius: 0 0 18px 18px; display: flex; flex-direction: column;
  animation: drop .22s ease;
}
@keyframes drop { from { transform: translateY(-12px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-head input {
  flex: 1; height: 42px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); padding: 0 14px; font-size: 15px; outline: none;
}
.sheet-head input:focus { border-color: var(--brand); }
.sheet-body { overflow-y: auto; padding: 6px 10px 20px; }
.result { padding: 12px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result .rq { font-size: 14.5px; font-weight: 600; }
.result .rm { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%);
  background: #11151c; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13.5px;
  z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 10px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.switch { position: relative; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ── 阅读版新增 ── */
.hero { border-radius: var(--radius); padding: 20px 18px 18px; margin: 4px 0 16px; color: #fff; }
.hero-bank { background: linear-gradient(135deg, #1d2a5c, #36498f); }
.hero-tech { background: linear-gradient(135deg, #33255c, #5b3f8f); }
.hero-cards { background: linear-gradient(135deg, #14532d, #1f7a4d); }
.hero-k { font-size: 12px; letter-spacing: .08em; opacity: .7; }
.hero h2 { margin: 6px 0 8px; font-size: 20px; letter-spacing: -.01em; }
.hero p { margin: 0; font-size: 13.5px; line-height: 1.72; opacity: .88; }

.topic-item { align-items: flex-start; }
.ti-main { flex: 1; min-width: 0; }
.ti-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.ti-arrow { color: var(--ink-3); font-size: 20px; line-height: 44px; }

.article h2, .article h3 { scroll-margin-top: 70px; }
.toc {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px;
}
.toc-title { width: 100%; font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.toc a {
  font-size: 13px; color: var(--brand); background: var(--brand-soft);
  padding: 5px 11px; border-radius: 999px; text-decoration: none;
}
.toc a:active { opacity: .7; }

details.qa {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; margin-bottom: 8px;
}
details.qa summary {
  cursor: pointer; font-size: 15px; font-weight: 600; line-height: 1.55; list-style: none;
  position: relative; padding-right: 22px;
}
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::after {
  content: "＋"; position: absolute; right: 0; top: 0; color: var(--ink-3); font-weight: 400;
}
details.qa[open] summary::after { content: "－"; }
details.qa[open] summary { color: var(--brand); }
.qa-body ul { margin: 10px 0 4px; padding-left: 20px; }
.qa-body li { margin: 6px 0; font-size: 14.5px; line-height: 1.68; }

.article-end { text-align: center; color: var(--ink-3); font-size: 12.5px; margin: 36px 0 10px; letter-spacing: .1em; }

@media (max-width: 480px) {
  .article pre { font-size: 11px; line-height: 1.55; padding: 12px; }
  .article h2 { font-size: 16.5px; margin: 22px 0 8px; }
  .toc a { font-size: 12.5px; padding: 5px 10px; }
  .hero { padding: 18px 16px; }
  .hero h2 { font-size: 18.5px; }
}
