:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #EDF0F4;
  --line: #DDE2E9;
  --text: #151B24;
  --muted: #5D6A7C;
  --faint: #8A96A6;
  --write: #B87615;
  --read: #1E8577;
  --expire: #C24A33;
  --out: #6E5AA8;
  --read-soft: #E4F1EE;
  --shadow: 0 1px 2px rgba(20, 28, 40, .06), 0 8px 24px -12px rgba(20, 28, 40, .18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101520;
    --surface: #171E2A;
    --surface-2: #1E2634;
    --line: #2C3646;
    --text: #DFE6F0;
    --muted: #8B99AD;
    --faint: #69778C;
    --write: #E8A33D;
    --read: #4FBFAC;
    --expire: #E2705A;
    --out: #A08FD8;
    --read-soft: #17332E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  --bg: #101520;
  --surface: #171E2A;
  --surface-2: #1E2634;
  --line: #2C3646;
  --text: #DFE6F0;
  --muted: #8B99AD;
  --faint: #69778C;
  --write: #E8A33D;
  --read: #4FBFAC;
  --expire: #E2705A;
  --out: #A08FD8;
  --read-soft: #17332E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "PingFang TC", "Noto Sans TC", "Hiragino Sans TC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 40px 24px 80px; }

.masthead {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 28px;
}
h1 { font-size: 27px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.01em; text-wrap: balance; }
.tagline { color: var(--muted); font-size: 14px; margin: 0; max-width: 60ch; }

.ghost-btn {
  font: 500 12.5px/1 "IBM Plex Sans", "PingFang TC", sans-serif;
  padding: 8px 13px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; flex: none;
  transition: border-color .15s, color .15s;
}
.ghost-btn:hover { border-color: var(--read); color: var(--read); }
.ghost-btn:focus-visible { outline: 2px solid var(--read); outline-offset: 2px; }

.grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
@media (max-width: 880px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.card + .card { margin-top: 22px; }
.card-h {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.card-t {
  font-size: 12px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--faint); margin: 0;
}
.card-t.soft { color: var(--muted); letter-spacing: .04em; text-transform: none; font-weight: 500; }
.card-b { padding: 18px; }

.fields { display: flex; flex-direction: column; gap: 19px; }
.f-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
label { font-size: 13px; font-weight: 500; color: var(--text); }
.hint { font-size: 11.5px; color: var(--faint); margin: 5px 0 0; line-height: 1.5; }
.num-row {
  display: flex; align-items: stretch; margin-top: 7px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  transition: border-color .15s;
}
.num-row:focus-within { border-color: var(--read); box-shadow: 0 0 0 1px var(--read); }
.num-row input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  padding: 9px 0 9px 12px; font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 14px; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.num-row input::-webkit-outer-spin-button,
.num-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-row input::placeholder { color: var(--faint); opacity: 1; }
.unit {
  display: flex; align-items: center; padding: 0 12px;
  font-size: 12px; color: var(--faint); flex: none;
}

.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 3px;
  border-radius: 2px; background: var(--line); outline: none;
  margin: 12px 0 0; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--read); border: 2px solid var(--surface); cursor: pointer;
  box-shadow: 0 0 0 1px var(--read);
}
.slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--read);
  border: 2px solid var(--surface); cursor: pointer; box-shadow: 0 0 0 1px var(--read);
}
.slider:focus-visible { outline: 2px solid var(--read); outline-offset: 4px; }
/* 還沒填值時滑桿是灰的，看得出來是「沒動過」而不是「選了最小值」 */
.slider.untouched::-webkit-slider-thumb { background: var(--faint); box-shadow: 0 0 0 1px var(--faint); }
.slider.untouched::-moz-range-thumb { background: var(--faint); box-shadow: 0 0 0 1px var(--faint); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button {
  flex: 1; font: 500 12.5px/1 "IBM Plex Sans", "PingFang TC", sans-serif; padding: 9px 4px;
  background: var(--surface); color: var(--muted); border: 0; border-right: 1px solid var(--line);
  cursor: pointer; transition: background .15s, color .15s;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--read); color: var(--surface); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--read); outline-offset: -2px; }

.head-fig { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.big {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 44px; font-weight: 600;
  letter-spacing: -.02em; line-height: 1;
}
.big-note { font-size: 13px; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.bar-row { display: grid; grid-template-columns: 88px 1fr 94px; gap: 12px; align-items: center; }
.bar-lab { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.track { height: 9px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.fill { height: 100%; border-radius: 2px; transition: width .25s ease; }
.bar-num {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 12.5px; text-align: right; color: var(--text);
}

.scroll { overflow-x: auto; margin-top: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 380px; }
th {
  text-align: right; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; padding: 0 0 9px; border-bottom: 1px solid var(--line);
}
th:first-child { text-align: left; }
td {
  padding: 9px 0; border-bottom: 1px solid var(--line); text-align: right;
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
td:first-child { text-align: left; font-family: inherit; color: var(--muted); }
tfoot td { font-weight: 600; color: var(--text); border-top: 1px solid var(--line); border-bottom: 0; padding-top: 11px; }

.cmp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
@media (max-width: 700px) { .cmp { grid-template-columns: 1fr; } }
.cmp-c { border: 1px solid var(--line); border-radius: 7px; padding: 14px 15px; background: var(--surface); }
.cmp-c.now { border-color: var(--read); background: var(--read-soft); }
.cmp-t { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.cmp-v {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 23px; font-weight: 600; line-height: 1.1;
}
.cmp-n { font-size: 11.5px; color: var(--faint); margin: 5px 0 0; line-height: 1.45; }

.trip-chart { display: flex; flex-direction: column; gap: 3px; }
.trip { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; }
.trip-i {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--faint); text-align: right;
}
.trip-bar { display: flex; height: 11px; border-radius: 2px; overflow: hidden; background: var(--surface-2); }
.seg-r { background: var(--read); }
.seg-w { background: var(--write); }
.seg-e { background: var(--expire); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }

.note {
  margin-top: 22px; padding: 15px 17px; border: 1px solid var(--line);
  border-left: 3px solid var(--write); border-radius: 0 7px 7px 0;
  background: var(--surface); font-size: 13px; color: var(--muted); line-height: 1.65;
}
.note b { color: var(--text); font-weight: 600; }

footer {
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--faint); line-height: 1.75;
}
footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
