/* Layout: a pocket timetable. Sticky header, one scrolling column, bottom tab bar.
   Colour: cool station-sign paper, indigo ink, one maple-red accent. Each place has a line colour, like a rail map. */
:root {
  --paper: #eceff2;
  --card: #ffffff;
  --ink: #17203a;
  --muted: #586179;
  --line: #d3d8e0;
  --accent: #c2432a;
  --accent-ink: #ffffff;
  --ok: #2c7a58;
  --warn: #a75f00;
  --bad: #b3261e;
  --c-fly: #6b7280;
  --c-tokyo: #3a5db8;
  --c-seto: #1b8a91;
  --c-matsu: #cf7a22;
  --c-kyoto: #8747a0;
  --c-taka: #3b8447;
  --c-mtmt: #56687a;
  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10141d; --card: #181e2c; --ink: #e6e9f2; --muted: #9ba4b9; --line: #2a3246;
    --accent: #ef7b5f; --accent-ink: #1a0f0c; --ok: #5cc29a; --warn: #e6a545; --bad: #f28b82;
    --c-fly: #98a0ae; --c-tokyo: #7d9bf0; --c-seto: #4cc0c7; --c-matsu: #eda254; --c-kyoto: #c08bd8; --c-taka: #72c27f; --c-mtmt: #93a5b8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10141d; --card: #181e2c; --ink: #e6e9f2; --muted: #9ba4b9; --line: #2a3246;
  --accent: #ef7b5f; --accent-ink: #1a0f0c; --ok: #5cc29a; --warn: #e6a545; --bad: #f28b82;
  --c-fly: #98a0ae; --c-tokyo: #7d9bf0; --c-seto: #4cc0c7; --c-matsu: #eda254; --c-kyoto: #c08bd8; --c-taka: #72c27f; --c-mtmt: #93a5b8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; padding-inline: 16px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 680px; margin-inline: auto; }

/* header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); margin-inline: -16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--serif); font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
.brand small { font-family: var(--mono); font-weight: 400; font-size: .72rem; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.pill { font-family: var(--mono); font-size: .7rem; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; background: var(--card); }
.pill.live { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

main { padding-block: 18px 110px; display: flex; flex-direction: column; gap: 18px; }
h2 { font-family: var(--serif); font-size: 1.25rem; font-weight: 800; margin: 0; text-wrap: balance; }
h3 { font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
p { margin: 0; }
.sec { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* bottom nav */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
nav.tabs .wrap { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
nav.tabs button { background: none; border: 0; padding: 9px 2px 7px; border-radius: 8px; font-size: .78rem; font-weight: 500; color: var(--muted); position: relative; min-height: 44px; }
nav.tabs button[aria-current="page"] { color: var(--ink); font-weight: 700; }
nav.tabs button[aria-current="page"]::before { content: ''; position: absolute; top: -7px; left: 22%; right: 22%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: .68rem; line-height: 18px; }

/* place chips and route */
.loc { --c: var(--c-tokyo); display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--ink); }
.loc::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.route { display: flex; overflow-x: auto; padding-bottom: 4px; gap: 3px; }
.seg { --c: var(--c-tokyo); flex: 1 0 auto; min-width: calc(var(--n) * 3.6rem); }
.seg i { display: block; height: 6px; border-radius: 3px; background: var(--c); margin-bottom: 4px; }
.seg span { display: block; font-size: .72rem; line-height: 1.25; white-space: nowrap; }
.seg b { font-family: var(--mono); font-weight: 400; color: var(--muted); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.chip { --c: var(--c-tokyo); flex: 0 0 auto; width: 50px; padding: 6px 0 8px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 8px; position: relative; }
.chip .w { display: block; font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.chip .n { display: block; font-family: var(--mono); font-size: 1.05rem; font-weight: 500; }
.chip::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--c); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] .w { color: inherit; opacity: .75; }
.chip.today { border-color: var(--accent); }

/* day header */
.dayhead { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.bigdate { font-family: var(--serif); font-weight: 800; font-size: 2.6rem; line-height: 1; }
.bigdate small { font-size: 1rem; font-weight: 600; margin-left: 4px; color: var(--muted); }
.wk { color: var(--muted); font-size: .85rem; }

/* legs */
.legs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.legs li { display: grid; grid-template-columns: 4.6rem 1fr; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); }
.legs li:first-child { border-top: 0; padding-top: 0; }
.legs li:last-child { padding-bottom: 0; }
.legs .t { font-family: var(--mono); font-size: .82rem; color: var(--accent); font-weight: 500; padding-top: 1px; overflow-wrap: anywhere; }
.legs .d { min-width: 0; }
.legs .d b { font-weight: 700; }
.legs .d span { display: block; color: var(--muted); font-size: .85rem; }
ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

/* stay card */
.stay { display: flex; flex-direction: column; gap: 8px; }
.stay .nm { font-weight: 700; font-size: 1.02rem; }
.kv { display: grid; grid-template-columns: 6.2rem 1fr; gap: 4px 10px; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
details.more summary { cursor: pointer; font-size: .85rem; font-weight: 700; color: var(--accent); padding: 6px 0; min-height: 32px; }
.copy { margin-left: 8px; font-size: .72rem; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); }
a.lnk { color: var(--accent); font-weight: 700; text-decoration: none; font-size: .88rem; }
a.lnk:hover { text-decoration: underline; }

/* checklist */
.items { display: flex; flex-direction: column; }
.item { position: relative; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); min-height: 44px; cursor: pointer; }
.item:first-child { border-top: 0; }
.item input { position: absolute; left: 0; top: 10px; opacity: 0; width: 26px; height: 26px; margin: 0; }
.box { width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 6px; display: grid; place-items: center; background: var(--card); margin-top: 0; }
.item input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.item input:checked + .box { background: var(--ok); border-color: var(--ok); }
.item input:checked + .box::after { content: ''; width: 6px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.item .txt { min-width: 0; overflow-wrap: anywhere; }
.item input:checked ~ .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.tag { display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; margin-right: 8px; vertical-align: 1px; border: 1px solid var(--line); color: var(--muted); }
.tag.buy { color: var(--c-tokyo); border-color: var(--c-tokyo); }
.tag.book { color: var(--accent); border-color: var(--accent); }
.tag.fix { color: var(--bad); border-color: var(--bad); }
.tag.check { color: var(--warn); border-color: var(--warn); }
.by { font-family: var(--mono); font-size: .72rem; color: var(--warn); white-space: nowrap; padding-top: 3px; }
.xdel { background: none; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 4px 8px; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }
.addrow input, textarea { width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-width: 0; }
textarea { min-height: 96px; resize: vertical; }
.btn { background: var(--ink); color: var(--paper); border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 700; white-space: nowrap; min-height: 40px; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.pager { display: flex; justify-content: space-between; gap: 8px; }

/* hero countdown */
.hero { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.hero .num { font-family: var(--serif); font-weight: 800; font-size: 4.4rem; line-height: .9; color: var(--accent); }
.hero .cap { font-size: .95rem; }

/* deadlines */
.dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.dl:first-child { border-top: 0; }
.dl .when { font-family: var(--mono); font-size: .8rem; text-align: right; }
.dl .when.soon { color: var(--bad); font-weight: 500; }
.dl .when.mid { color: var(--warn); }
.dl .when.past { color: var(--muted); }
.dl .sub { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.f { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: .82rem; font-weight: 500; min-height: 34px; }
.f[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr:first-child td { border-top: 0; }
.tbl td:first-child { padding-right: 12px; font-weight: 700; }
.scroll { overflow-x: auto; }
.status { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.status.ok { color: var(--ok); }
.status.todo { color: var(--bad); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: 8px; font-size: .85rem; z-index: 9; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: no-preference) { .chip, .f, .btn { transition: background .15s, color .15s; } }

/* standalone page additions */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
.top { top: 0; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.gate { display: flex; flex-direction: column; gap: 12px; margin-top: 12vh; }
.gate input { width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 1rem; }
.gatemsg { font-size: .88rem; color: var(--bad); }
