:root {
  --bg: #f6f1e7; --surface: #fffdf8; --ink: #1d2b2a; --muted: #5f6f6c; --line: #e2d9c5;
  --brand: #0f6b62; --brand-ink: #fff; --accent: #e08a1e; --accent-soft: #fbe9cc; --danger: #b3261e;
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(40 30 10 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #111a19; --surface: #182423; --ink: #eaf1ef; --muted: #9db0ac; --line: #2a3b39;
    --brand: #3ec1b2; --brand-ink: #06201d; --accent: #f2a74a; --accent-soft: #3a2c14; --danger: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-in { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; padding-block: 12px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--brand); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: 15px; margin-right: 4px; }
.tag { margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: minmax(300px, 440px) 1fr; gap: 24px; padding-block: 24px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.panel, .empty, .card, .summary, .cost { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 20px; }
h1 { font-size: 22px; margin: 0 0 12px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 200px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex: 1 1 120px; }
input[type=text], input[type=date], input[type=time], input[type=number], select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-height: 40px;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { border-style: dashed; background: transparent; width: 100%; justify-content: center; }
.btn[disabled] { opacity: .6; cursor: progress; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.actions .primary { flex: 1; justify-content: center; }
.stops { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 0; }
.stop { position: relative; padding: 10px 0 10px 38px; }
.stop::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 2px; background: repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 10px); }
.stop:first-child::before { top: 24px; } .stop:last-child::before { bottom: calc(100% - 24px); }
.pin { position: absolute; left: 0; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; display: grid; place-items: center; font-size: 13px; z-index: 1; }
.stop-head { display: flex; gap: 6px; }
.ac { position: relative; flex: 1; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.ac-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ac-list li:hover, .ac-list li[aria-selected=true] { background: var(--accent-soft); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; width: 34px; min-height: 40px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { color: var(--ink); border-color: var(--brand); }
.leg { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.leg select, .leg input { width: auto; min-height: 34px; padding: 5px 8px; font-size: 13px; }
.leg label { display: inline-flex; gap: 6px; align-items: center; }
.leg .num { width: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 7px 14px; font: inherit; cursor: pointer; }
.chip[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
details { margin-top: 14px; } summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.error { color: var(--danger); font-weight: 600; margin: 12px 0 0; }
.share { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.share input { flex: 1 1 180px; }
.results { min-width: 0; display: grid; gap: 16px; }
.empty { padding: 28px; } .empty h2 { margin: 0 0 8px; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); } .empty p { margin: 0; color: var(--muted); max-width: 52ch; }
.summary { padding: 16px 20px; display: flex; gap: 24px; flex-wrap: wrap; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; } .stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
#map { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 16px; z-index: 0; }
.warn { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.timeline { display: grid; gap: 12px; }
.card { padding: 16px 18px; }
.leg-card { border-left: 5px solid var(--brand); }
.wait-card { border-left: 5px solid var(--accent); }
.card h3 { margin: 0; font-size: 16px; }
.meta { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.steps { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.steps li::before { content: "›"; color: var(--brand); font-weight: 800; margin-right: 8px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); margin-right: 8px; }
.budget { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; font-size: 14px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.opts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.opt.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--bg)); }
.opt.off { opacity: .45; }
.opt input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brand); }
.opt b { font-size: 15px; } .opt small { display: block; color: var(--muted); }
.opt a { color: var(--brand); font-weight: 600; font-size: 13px; }
.cost { padding: 16px 20px; } .cost h2 { margin-top: 0; }
.cost table { width: 100%; border-collapse: collapse; } .cost td { padding: 6px 0; border-bottom: 1px solid var(--line); } .cost td:last-child { text-align: right; white-space: nowrap; }
.cost .total td { font-weight: 800; border: 0; font-size: 17px; }
.src { font-size: 11px; color: var(--muted); margin-left: 6px; }
.loading { padding: 20px; display: flex; gap: 10px; align-items: center; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .bar > i { transition: none; } }
.foot { color: var(--muted); font-size: 12px; padding-block: 20px 40px; } .foot a { color: inherit; }
.mk { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font: 700 12px/26px system-ui; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .4); }
.mk.sug { background: var(--accent); width: 20px; height: 20px; line-height: 16px; }
@media print {
  .top, .panel, .foot, #map, .share, .opt:not(.on) { display: none !important; }
  .grid { display: block; } body { background: #fff; color: #000; } .card, .summary, .cost { box-shadow: none; break-inside: avoid; }
  .opt input { display: none; }
}

/* ---- v2 polish ---- */
[hidden] { display: none !important; }
.brand-mark svg { width: 16px; height: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: var(--shadow); font-weight: 600; }
.stop.invalid input[data-ac] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.ac-list li[aria-selected=true] { outline: 2px solid var(--brand); outline-offset: -2px; }
.quiet { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.quiet b { color: var(--ink); }
.day { font-size: 11px; font-weight: 700; color: var(--accent); margin-left: 4px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools .btn { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; }
.timeline { position: relative; }
.opt[title] { cursor: help; }
.opt.off input { cursor: not-allowed; }
.over { color: var(--danger); font-weight: 700; }
@media (max-width: 900px) {
  .actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--surface) 70%, transparent); padding: 12px 0 calc(8px + env(safe-area-inset-bottom, 0px)); margin-inline: -4px; z-index: 5; }
  #map { height: 260px; }
}

:root[data-theme="dark"] {
  --bg: #111a19; --surface: #182423; --ink: #eaf1ef; --muted: #9db0ac; --line: #2a3b39;
  --brand: #3ec1b2; --brand-ink: #06201d; --accent: #f2a74a; --accent-soft: #3a2c14; --danger: #ff8a80;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
}
.top-in { position: relative; } .theme-btn { margin-left: auto; width: 38px; min-height: 36px; font-size: 16px; }
.nextup { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 14px 18px; font-weight: 600; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nextup b { font-size: 22px; letter-spacing: -.02em; }
.recent { margin-top: 16px; font-size: 13px; } .recent h2 { margin: 0 0 6px; }
.recent a { display: block; padding: 6px 0; color: var(--brand); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.recent small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.stop-eta { font-size: 12px; color: var(--muted); margin: 4px 0 0; } .stop-eta b { color: var(--ink); }
.print-head { display: none; }
@media print { .print-head { display: block; font-size: 22px; font-weight: 800; margin-bottom: 8px; } .nextup { display: none !important; } }
