:root {
  --ground: #edeff2;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #15181e;
  --ink-2: #4a515c;
  --ink-3: #79818e;
  --line: #d7dbe2;
  --line-strong: #b9c0ca;
  --accent: #a86000;
  --accent-ink: #ffffff;
  --accent-soft: #f6e7d2;
  --done: #0e6e64;
  --done-soft: #d8ece9;
  --active: #a86a08;
  --active-soft: #f9ead0;
  --stuck: #a32b21;
  --stuck-soft: #f7dedb;
  --todo-soft: #e6e9ee;
  --chart-bar: #0d8a78;
  --shadow-sm: 0 1px 2px rgba(21, 24, 30, .07);
  --shadow-lg: 0 1px 2px rgba(21, 24, 30, .06), 0 14px 34px -18px rgba(21, 24, 30, .35);
  --rail: 216px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #11141a;
    --surface: #191d24;
    --surface-2: #1f242c;
    --ink: #e8ebf0;
    --ink-2: #a7afbb;
    --ink-3: #78818e;
    --line: #2a3038;
    --line-strong: #3b434e;
    --accent: #f0a33c;
    --accent-ink: #1a1206;
    --accent-soft: #362a15;
    --done: #4dc4b1;
    --done-soft: #12312d;
    --active: #e2a544;
    --active-soft: #33280f;
    --stuck: #f0877b;
    --stuck-soft: #3a201d;
    --todo-soft: #242a32;
    --chart-bar: #2f9d8c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  --ground: #11141a;
  --surface: #191d24;
  --surface-2: #1f242c;
  --ink: #e8ebf0;
  --ink-2: #a7afbb;
  --ink-3: #78818e;
  --line: #2a3038;
  --line-strong: #3b434e;
  --accent: #f0a33c;
  --accent-ink: #1a1206;
  --accent-soft: #362a15;
  --done: #4dc4b1;
  --done-soft: #12312d;
  --active: #e2a544;
  --active-soft: #33280f;
  --stuck: #f0877b;
  --stuck-soft: #3a201d;
  --todo-soft: #242a32;
  --chart-bar: #2f9d8c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

:root { color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: Archivo, "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
  margin: 0;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; }

.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- shell ---------- */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; flex-direction: column; gap: 3px; padding: 0 8px; }
.brand h1 { font-size: 19px; line-height: 1.15; }
.brand .eyebrow { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  text-align: left;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button[aria-current="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav button[aria-current="true"] .glyph { color: var(--accent); }
.nav .glyph { width: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0; }

.rail-focus {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 8px;
  transition: background .15s ease, border-color .15s ease;
}
.rail-focus:hover { background: var(--surface-2); border-color: var(--line); }
.rail-focus .line { display: flex; justify-content: space-between; align-items: baseline; }
.rail-focus strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.rail-focus .mono { color: var(--ink-3); font-size: 12px; }
.rail-focus .go { font-size: 11.5px; color: var(--ink-3); opacity: 0; transition: opacity .15s ease; }
.rail-focus:hover .go, .rail-focus:focus-visible .go { opacity: 1; color: var(--accent); }
#theme-toggle { margin-left: 8px; display: inline-flex; align-items: center; gap: 6px; }

.disclaimer {
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.65;
  max-width: 74ch;
  margin: 6px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

/* ---------- timer ---------- */

.timer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px;
  border-radius: 9px;
  background: var(--active-soft);
  border-left: 3px solid var(--active);
}
.timer .tname { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer b {
  font-family: "IBM Plex Mono", monospace;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: var(--active);
}
.timer .btn { margin-top: 3px; }

/* ---------- exam plan ---------- */

.plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) auto auto;
  gap: 20px;
  align-items: center;
}
.plan.is-empty { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
.plan.is-empty p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; }

.countdown { display: flex; flex-direction: column; gap: 1px; min-width: 104px; }
.countdown b {
  font-family: Archivo, sans-serif;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.countdown .when { font-size: 11.5px; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; }
.countdown.over b { color: var(--ink-3); }

.timeline { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.track {
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: var(--todo-soft);
  overflow: visible;
}
.track .elapsed { position: absolute; inset: 0 auto 0 0; background: var(--line-strong); border-radius: 99px; }
.track .filled { position: absolute; inset: 0 auto 0 0; background: var(--done); border-radius: 99px; opacity: .9; }
.track .marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: var(--accent);
  border-radius: 1px;
  transform: translateX(-1px);
}
.track .marker.today { background: var(--ink); }
.ticks { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; }
.ticks span { white-space: nowrap; }

.pace { display: flex; flex-direction: column; gap: 1px; min-width: 150px; }
.pace b { font-size: 14px; }
.pace b.behind { color: var(--stuck); }
.pace b.ahead { color: var(--done); }
.pace small { color: var(--ink-3); font-size: 11.5px; }

.plan-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.plan-form .field { min-width: 150px; }
.plan-form .actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- notes ---------- */

.notes-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 16px; align-items: start; }

.note-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden auto;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
}
.note-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  background: transparent;
}
.note-item:last-child { border-bottom: 0; }
.note-item:hover { background: var(--surface-2); }
.note-item[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.note-item .nhead { display: flex; align-items: center; gap: 7px; }
.note-item .dot.note-draft { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink-3); }
.note-item .dot.note-done { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent); }
.note-item .nflag { font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.note-item .nflag.done { color: var(--accent); background: var(--accent-soft); }
.note-item .nflag.draft { color: var(--ink-3); background: var(--todo-soft); font-weight: 500; }
.note-editor .btn.done { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.note-item .nname { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .nmeta { font-size: 11px; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; margin-left: auto; }
.note-item .npeek {
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.note-item .npeek.blank { font-style: italic; }

.note-editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 320px;
}
.note-editor .nhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.note-editor h3 { font-size: 18px; }
.note-editor .facts { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.note-editor textarea {
  flex: 1;
  min-height: 340px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.65;
  resize: vertical;
}
.note-editor .toolrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note-editor .toolrow .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.note-md {
  flex: 1;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  background: var(--surface-2);
  overflow-y: auto;
  line-height: 1.7;
}
.note-md > :first-child { margin-top: 0; }
.note-md > :last-child { margin-bottom: 0; }
.note-md h1, .note-md h2, .note-md h3 {
  font-family: Archivo, "Noto Sans TC", sans-serif;
  line-height: 1.3;
  margin: 18px 0 8px;
}
.note-md h1 { font-size: 20px; }
.note-md h2 { font-size: 16px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.note-md h3 { font-size: 14px; }
.note-md p { margin: 8px 0; }
.note-md ul, .note-md ol { margin: 8px 0; padding-left: 22px; }
.note-md li { margin: 3px 0; }
.note-md a { color: var(--accent); }
.note-md code {
  font-family: "IBM Plex Mono", monospace;
  font-size: .88em;
  background: var(--todo-soft);
  padding: 1px 5px;
  border-radius: 4px;
}
.note-md pre {
  background: var(--todo-soft);
  border-radius: 7px;
  padding: 11px 13px;
  overflow-x: auto;
  margin: 10px 0;
}
.note-md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.note-md blockquote {
  margin: 10px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
}
.note-md strong { font-weight: 600; }
.note-md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.note-md .md-empty { color: var(--ink-3); font-style: italic; }

.note-blank { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; justify-content: center; flex: 1; color: var(--ink-3); }

@media (max-width: 940px) {
  .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .note-list { max-height: 260px; }
}

/* ---------- charts ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar-mark { fill: var(--chart-bar); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar-mark, .chart .bar-mark.hot { filter: brightness(1.15); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart text { fill: var(--ink-3); font-family: "IBM Plex Mono", monospace; font-size: 9px; }
.chart text.value { fill: var(--ink); font-weight: 500; }

.chart-tip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  background: var(--ink);
  color: var(--ground);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity .12s ease;
  box-shadow: var(--shadow-lg);
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-family: "IBM Plex Mono", monospace; }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--chart-bar); display: block; }
.chart-legend i.goal { height: 0; width: 14px; border-radius: 0; background: none; border-top: 2px dashed var(--ink-3); }

/* ---------- phase breakdown ---------- */

.phase-list { display: flex; flex-direction: column; gap: 9px; }
.phase-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: baseline; }
.phase-row .pname { font-size: 13px; font-weight: 500; }
.phase-row .pnum { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.phase-row .pbar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--todo-soft); overflow: hidden; }
.phase-row .pbar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.phase-row small { grid-column: 1 / -1; color: var(--ink-3); font-size: 11.5px; }

.phase-picks { display: flex; gap: 5px; flex-wrap: wrap; }
.phase-picks button {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
}
.phase-picks button:hover { border-color: var(--ink-3); color: var(--ink); }
.phase-picks button[aria-pressed="true"] { background: var(--stuck-soft); border-color: transparent; color: var(--stuck); font-weight: 600; }

/* ---------- backup ---------- */

.badge { padding: 2px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--done-soft); color: var(--done); }
.badge.warn { background: var(--active-soft); color: var(--active); }
.badge.off { background: var(--todo-soft); color: var(--ink-3); }

.backup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.backup-head h3 { margin: 0; font-size: 14px; }
.backup-body { color: var(--ink-2); font-size: 13px; max-width: 68ch; margin: 0 0 12px; }
.backup-body b { color: var(--ink); }
.backup-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  margin-bottom: 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nudge {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-radius: 9px;
  background: var(--active-soft);
  border-left: 3px solid var(--active);
  font-size: 13px;
}
.nudge b { color: var(--ink); }
.nudge .btn { margin-left: auto; flex: 0 0 auto; }

.main { flex: 1; min-width: 0; padding: 26px 30px 64px; max-width: 1180px; }
.view { display: none; flex-direction: column; gap: 20px; }
.view.is-active { display: flex; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-head h2 { font-size: 24px; }
.view-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 62ch; }

/* ---------- generic bits ---------- */

.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--todo-soft);
  overflow: hidden;
  display: flex;
}
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s ease; }
.bar span.done { background: var(--done); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 7px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.os-linux { color: var(--ink-2); }
.chip.os-windows { color: var(--ink-2); }
.chip.required { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip.warn { background: var(--stuck-soft); border-color: transparent; color: var(--stuck); }

.dot { width: 8px; height: 8px; border-radius: 99px; flex: 0 0 8px; background: var(--line-strong); }
.dot.done { background: var(--done); }
.dot.active { background: var(--active); }
.dot.stuck { background: var(--stuck); }

/* ---------- overview ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
}

.focus-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  gap: 22px;
  align-items: center;
  box-shadow: var(--shadow-lg);
}
.focus-card .copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.focus-card h3 { font-size: 17px; }
.focus-card p { margin: 0; color: var(--ink-2); font-size: 13px; }

.ring { position: relative; width: 118px; height: 118px; flex: 0 0 118px; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.ring .label b { font-family: Archivo, sans-serif; font-size: 27px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.ring .label span { font-size: 10.5px; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat b { font-family: Archivo, sans-serif; font-size: 23px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .unit { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.stat small { color: var(--ink-3); font-size: 11.5px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split.even { align-items: stretch; }
.split.even .panel { display: flex; flex-direction: column; }
.split.even .chart { flex: 1; display: flex; flex-direction: column; justify-content: center; }

.panel h3 { font-size: 14px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.panel-head h3 { margin: 0; }

.platform-list { display: flex; flex-direction: column; gap: 11px; }
.platform-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: baseline; }
.platform-row .name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platform-row .num { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.platform-row .bar { grid-column: 1 / -1; }

.feed { display: flex; flex-direction: column; }
.feed li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.feed li:last-child { border-bottom: 0; }
.feed .when { margin-left: auto; font-size: 11.5px; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; white-space: nowrap; }
.feed .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul { list-style: none; margin: 0; padding: 0; }

.empty { color: var(--ink-3); font-size: 13px; padding: 10px 0; }

/* ---------- filters + table ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .search { position: relative; flex: 1 1 220px; min-width: 180px; }
.toolbar .search input {
  width: 100%;
  padding: 8px 11px 8px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}
.toolbar .search .glyph { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 12px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 13px;
  user-select: none;
}
.toggle:hover { border-color: var(--ink-3); }
.toggle:has(input:checked) { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  display: grid;
  place-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.toggle input::after {
  content: "";
  width: 9px;
  height: 9px;
  transform: scale(0);
  transition: transform .12s ease;
  background: var(--accent-ink);
  clip-path: polygon(14% 46%, 0 60%, 40% 100%, 100% 22%, 85% 8%, 38% 70%);
}
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::after { transform: scale(1); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; color: var(--ink-2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

.result-line { color: var(--ink-3); font-size: 12.5px; font-family: "IBM Plex Mono", monospace; }

/* ---------- active filters + list summary ---------- */

.list-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.list-summary .bar { flex: 1 1 160px; min-width: 120px; max-width: 320px; }

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px 3px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}
.filter-chips button .x { color: var(--ink-3); font-size: 13px; line-height: 1; }
.filter-chips button:hover .x { color: var(--stuck); }
.filter-chips .clear-all { background: transparent; border-color: var(--line-strong); color: var(--ink-2); font-weight: 400; }

/* ---------- grouped rows ---------- */

.group-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
}
.group-head:first-child { border-top: 0; }
.group-head .gname { font-weight: 600; font-size: 12.5px; }
.group-head .gsec {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.group-head .gbar { flex: 0 0 90px; margin-left: auto; }
.group-head .gnum { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.row.state-done .n { color: var(--ink-3); }
.row.state-done .lvl, .row.state-done .os-cell { opacity: .6; }

.row .quick {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease;
}
.row:hover .quick, .row .quick:focus-visible { opacity: 1; }
.row .quick:hover { color: var(--done); border-color: var(--done); }
.row.state-done .quick { opacity: 1; color: var(--done); }

.row .title .open {
  margin-left: 7px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease;
}
.row:hover .title .open, .row.is-open .title .open, .row .title .open:focus-visible { opacity: 1; }
.row .title .open:hover { color: var(--accent); }

.detail-open { margin-bottom: 12px; }
.detail-open .btn { text-decoration: none; }

/* ---------- rating buttons ---------- */

.rating-row { display: flex; gap: 5px; flex-wrap: wrap; }
.rating-row button {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
}
.rating-row button:hover { border-color: var(--ink-3); color: var(--ink); }
.rating-row button[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--ink); font-weight: 600; }

.table { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table-head, .row {
  display: grid;
  grid-template-columns: 22px minmax(130px, 1.3fr) 96px 132px minmax(120px, 1.5fr) 30px 100px;
  gap: 12px;
  align-items: center;
  padding: 9px 14px;
}
.table-head {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.row { border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-of-type { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.is-open { background: var(--surface-2); }
.row .title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .title .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .tags { display: flex; gap: 5px; flex-wrap: wrap; }
.row .status-cell { display: flex; justify-content: flex-end; }

/* ---------- custom select ---------- */

.sel { position: relative; display: inline-flex; max-width: 210px; }
.sel > button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  flex: 1;
  min-width: 0;
  transition: border-color .15s ease, background .15s ease;
}
.sel > button:hover { border-color: var(--ink-3); }
.sel > button .val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.sel > button .caret { color: var(--ink-3); font-size: 9px; flex: 0 0 auto; transition: transform .15s ease; }
.sel.is-open > button { border-color: var(--accent); }
.sel.is-open > button .caret { transform: rotate(180deg); }
.sel.is-set > button { background: var(--accent-soft); border-color: transparent; font-weight: 600; }

#assign-machine { max-width: none; }

.sel-pop {
  position: absolute;
  z-index: 60;
  top: calc(100% + 5px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sel-pop.up { top: auto; bottom: calc(100% + 5px); }
.sel-pop.right { left: auto; right: 0; }
.sel-pop input.sel-search {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--surface-2);
  font-size: 13px;
}
.sel-list { max-height: 296px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.sel-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.sel-list li:hover, .sel-list li.cursor { background: var(--surface-2); }
.sel-list li[aria-selected="true"] { background: var(--accent-soft); font-weight: 600; }
.sel-list li .hint { margin-left: auto; color: var(--ink-3); font-size: 11.5px; font-family: "IBM Plex Mono", monospace; padding-left: 12px; }
.sel-list .group {
  padding: 8px 9px 3px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: default;
}
.sel-list .group:hover { background: transparent; }
.sel-empty { padding: 10px; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ---------- status pill ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--todo-soft);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  min-width: 82px;
}
.status-pill .caret { margin-left: auto; font-size: 8px; opacity: .55; }
.status-pill[data-status="done"] { background: var(--done-soft); color: var(--done); border-color: transparent; }
.status-pill[data-status="active"] { background: var(--active-soft); color: var(--active); border-color: transparent; }
.status-pill[data-status="stuck"] { background: var(--stuck-soft); color: var(--stuck); border-color: transparent; }

.detail { padding: 14px 14px 18px 48px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-family: "IBM Plex Mono", monospace; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--surface);
  width: 100%;
}
.field textarea { min-height: 62px; resize: vertical; }
.detail .wide { grid-column: 1 / -1; }

.load-more { display: flex; justify-content: center; padding: 14px; }

/* ---------- draw ---------- */

.draw-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }

.slot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  min-height: 268px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(168, 96, 0, .035) 3px 4px);
  pointer-events: none;
}
:root[data-theme="dark"] .slot::before { background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(240, 163, 60, .05) 3px 4px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .slot::before { background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(240, 163, 60, .05) 3px 4px); }
}

.slot .reel {
  font-family: "IBM Plex Mono", monospace;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--accent);
  min-height: 46px;
  word-break: break-word;
}
.slot.is-spinning .reel { opacity: .72; }
.slot .meta { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.slot .hint { color: var(--ink-3); font-size: 13px; max-width: 44ch; }
.slot .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.pool-note { display: flex; flex-direction: column; gap: 10px; }
.pool-stat { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.pool-stat:last-child { border-bottom: 0; }
.pool-stat b { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

.history li { display: flex; gap: 8px; align-items: center; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.history li:last-child { border-bottom: 0; }

/* ---------- schedule ---------- */

.week-nav { display: flex; align-items: center; gap: 8px; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day.past { opacity: .72; }
.day .day-head { display: flex; align-items: baseline; justify-content: space-between; }
.day .dow { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.day .dnum { font-family: Archivo, sans-serif; font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.day.today .dnum { color: var(--accent); }
.day ul { display: flex; flex-direction: column; gap: 5px; }
.day li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  border-left: 2px solid var(--line-strong);
}
.day li.done { border-left-color: var(--done); }
.day li.active { border-left-color: var(--active); }
.day li.stuck { border-left-color: var(--stuck); }
.day li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.day li .x { border: 0; background: transparent; color: var(--ink-3); padding: 0 2px; line-height: 1; font-size: 14px; }
.day li .x:hover { color: var(--stuck); }
.day .add { border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-3); border-radius: 6px; padding: 5px; font-size: 12px; margin-top: auto; }
.day .add:hover { color: var(--accent); border-color: var(--accent); }

.assign-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.assign-bar select { flex: 1 1 240px; min-width: 200px; }

/* ---------- data view ---------- */

.data-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.io-area { width: 100%; min-height: 180px; font-family: "IBM Plex Mono", monospace; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px; background: var(--surface); }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--ground);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 940px) {
  .plan, .plan.is-empty { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .plan.is-empty .btn { justify-self: start; }
  .plan .countdown { flex-direction: row; align-items: baseline; gap: 10px; }

  .hero, .split, .draw-layout { grid-template-columns: minmax(0, 1fr); }
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-head { display: none; }
  .row { grid-template-columns: 18px minmax(0, 1fr) auto auto; grid-template-areas: "d t q s" ". g q s" ". x x x"; row-gap: 4px; }
  .row .quick { grid-area: q; opacity: 1; }
  .row .title .open { opacity: 1; }
  .row .dot { grid-area: d; }
  .row .title { grid-area: t; }
  .row .tags { grid-area: x; }
  .row .status-cell { grid-area: s; }
  .row .os-cell, .row .section-cell { display: none; }
  .row .lvl-cell { grid-area: g; }
  .detail { padding-left: 14px; }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .rail {
    width: 100%;
    flex: none;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand h1 { font-size: 15px; white-space: nowrap; }
  .brand .eyebrow { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav button { padding: 7px 10px; white-space: nowrap; }
  .nav .count, .rail-focus { display: none; }
  #timer-slot { display: none; }
  .rail-foot { margin: 0; }
  .rail-foot #theme-toggle { margin-left: 0; white-space: nowrap; }
  .main { padding: 18px 14px 56px; }

  /* 瀏海／圓角手機的安全區 */
  .rail { padding-top: calc(10px + env(safe-area-inset-top)); }
  .main {
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 460px) {
  .main { padding: 14px 12px 48px; }
  .view { gap: 16px; }
  .view-head { gap: 10px; }
  .view-head h2 { font-size: 21px; }
  .view-head p { font-size: 13px; }
  /* 標題與主要按鈕在窄螢幕整行排開，按鈕靠左不被擠壓 */
  .view-head > div { width: 100%; }
  .view-head .btn { width: auto; }
  .stat b { font-size: 20px; }
  .focus-card { flex-direction: column; align-items: flex-start; gap: 14px; }
  .ring { align-self: center; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .sel, .toolbar .seg, .toolbar .toggle { flex: 1 1 auto; }
  .week-grid { grid-template-columns: minmax(0, 1fr); }
  .assign-bar select, .assign-bar input, .assign-bar .sel { flex: 1 1 100%; }
  .countdown b { font-size: 26px; }
  .plan-form .field { min-width: 0; flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- difficulty meter ---------- */

.lvl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
}
.lvl .bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.lvl i {
  display: block;
  width: 4px;
  height: 10px;
  border-radius: 1px;
  background: var(--todo-soft);
  border: 1px solid var(--line);
}
.lvl i.on { background: var(--ink-2); border-color: var(--ink-2); }
.lvl[data-lv="100"] i.on { background: var(--done); border-color: var(--done); }
.lvl[data-lv="300"] i.on,
.lvl[data-lv="400"] i.on { background: var(--stuck); border-color: var(--stuck); }
.lvl.unknown { color: var(--ink-3); }

.lvl-legend { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 10px; margin-top: 2px; border-top: 1px dashed var(--line); }

.lvl-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; }
.lvl-item b { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.slot .chip .lvl { font-size: 11.5px; }
