:root {
  --bg: #0b0e14;
  --surface: #121722;
  --surface-2: #181e2b;
  --border: #242c3b;
  --text: #e3e7ef;
  --muted: #8a93a6;
  --faint: #5c6578;
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, .14);
  --easy: #3fbf86;
  --medium: #e4a63b;
  --hard: #ef5f5f;
  --alone: #3fbf86;
  --help: #c08bff;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: rgba(11, 14, 20, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 650; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
  font: 700 12px var(--mono); color: var(--bg); background: var(--accent);
  padding: 3px 6px; border-radius: 6px;
}
.overall { flex: 1; display: flex; align-items: center; gap: 12px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.overall .bar { width: 180px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.loading { color: var(--muted); }

/* ---------- progress bars ---------- */
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .alone { background: var(--alone); }
.bar .help { background: var(--help); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 24px; font-weight: 650; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ---------- filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
}
.search {
  flex: 1 1 260px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; outline: none;
}
.search:focus, select:focus, textarea:focus, input[type=date]:focus { border-color: var(--accent); }
select, input[type=date] {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
.chips { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.chip {
  border: 0; background: none; padding: 4px 11px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); color: var(--text); }
.btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- topic sections ---------- */
.topic { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.topic > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: grid; grid-template-columns: 18px 1fr auto 140px; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.topic > summary::-webkit-details-marker { display: none; }
.topic > summary .chev { color: var(--faint); transition: transform .15s; font-size: 12px; }
.topic[open] > summary .chev { transform: rotate(90deg); }
.topic > summary h2 { font-size: 15px; margin: 0; font-weight: 600; }
.topic > summary h2 .tid { color: var(--faint); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }
.topic > summary .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.qtable { width: 100%; border-collapse: collapse; }
.qtable td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.qtable tr { cursor: pointer; }
.qtable tr:hover td { background: var(--surface-2); }
.qtable .c-status { width: 44px; text-align: center; padding-left: 16px; }
.qtable .c-num { width: 48px; color: var(--faint); font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
.qtable .c-title { font-weight: 520; }
.qtable .c-title .lc { margin-left: 6px; color: var(--faint); font-size: 12px; }
.qtable .c-title .lc:hover { color: var(--accent); text-decoration: none; }
.qtable .c-pattern { color: var(--muted); font-size: 13px; }
.qtable .c-diff { width: 76px; }
.qtable .c-flags { width: 64px; text-align: right; padding-right: 16px; color: var(--faint); font-size: 13px; white-space: nowrap; }
.qtable .c-date { width: 104px; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.diff { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.diff.E { color: var(--easy); background: rgba(63, 191, 134, .12); }
.diff.M { color: var(--medium); background: rgba(228, 166, 59, .12); }
.diff.H { color: var(--hard); background: rgba(239, 95, 95, .12); }
.tag { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 99px; }

/* status dot / toggle */
.sdot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint);
  background: none; cursor: pointer; display: inline-grid; place-items: center;
  font-size: 12px; line-height: 1; padding: 0; color: var(--bg); font-weight: 800;
}
.sdot:hover { border-color: var(--text); }
.sdot.alone { background: var(--alone); border-color: var(--alone); }
.sdot.help { background: var(--help); border-color: var(--help); }

/* status menu */
.menu {
  position: absolute; z-index: 50; min-width: 210px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5); padding: 5px;
}
.menu button {
  display: flex; width: 100%; gap: 10px; align-items: center;
  background: none; border: 0; padding: 7px 10px; border-radius: 7px; cursor: pointer; text-align: left; font-size: 14px;
}
.menu button:hover, .menu button.current { background: var(--accent-soft); }
.menu .sdot { pointer-events: none; width: 16px; height: 16px; font-size: 9px; }

/* ---------- detail ---------- */
.crumbs { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-size: 14px; }
.crumbs .nav { display: flex; gap: 8px; }
.qhead h1 { font-size: 26px; margin: 0 0 8px; line-height: 1.25; }
.qhead h1 .n { color: var(--faint); font-weight: 500; margin-right: 8px; }
.qhead .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.qhead .pattern { color: var(--muted); margin: 0 0 18px; }

.statusbox {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 18px;
}
.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; gap: 8px; font-size: 14px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.seg .sdot { width: 14px; height: 14px; font-size: 8px; pointer-events: none; }
.statusbox .since { font-size: 13px; color: var(--muted); margin-left: auto; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; overflow-x: auto; scrollbar-width: thin; }
.tab {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); padding: 22px 26px; min-height: 240px;
}

/* spoiler guard */
.guard { text-align: center; padding: 48px 16px; }
.guard h3 { margin: 0 0 6px; }
.guard p { color: var(--muted); margin: 0 0 18px; }

/* code panel */
.codehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.codehead code { color: var(--muted); font-size: 12.5px; }
pre.code { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 75vh; }
pre.code code.hljs { padding: 16px 18px; font-size: 13.5px; line-height: 1.6; background: #0d1117; tab-size: 4; }

/* notes */
.notes textarea {
  width: 100%; min-height: 320px; resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font: 14px/1.6 var(--mono); outline: none;
}
.notes .bar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.notes .saved { font-size: 13px; color: var(--muted); }
.notes .preview { min-height: 320px; border: 1px dashed var(--border); border-radius: 8px; padding: 14px 18px; }

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history .when { color: var(--faint); font-family: var(--mono); font-size: 12px; margin-left: auto; }

/* ---------- rendered markdown ---------- */
.md { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 22px; margin: 0 0 12px; }
.md h2 { font-size: 18px; margin: 30px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 16px; margin: 22px 0 8px; }
.md p { margin: 10px 0; }
.md code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.md code.filelink { cursor: pointer; color: var(--accent); border-color: rgba(124, 140, 255, .35); }
.md code.filelink:hover { background: var(--accent-soft); }
.md pre { background: #0d1117; border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
.md pre code { background: none; border: 0; padding: 14px 16px; display: block; font-size: 13.5px; }
.md table { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }
.md blockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.md ul, .md ol { padding-left: 22px; }
.md strong { color: #fff; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; font-size: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, .5); z-index: 60;
}
.toast.err { border-color: var(--hard); }

kbd { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.hint { font-size: 12px; color: var(--faint); margin-top: 18px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .qtable .c-pattern, .qtable .c-date { display: none; }
  .topic > summary { grid-template-columns: 18px 1fr auto; }
  .topic > summary .bar { display: none; }
}
@media (max-width: 560px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .overall .bar { width: 70px; }
  .overall .txt-long { display: none; }
  .qtable .c-flags { display: none; }
  .qtable td { padding: 9px 8px; }
  .panel { padding: 16px; }
  .qhead h1 { font-size: 21px; }
  .statusbox .since { margin-left: 0; }
}
