:root {
  --sky: #E9EEF3;
  --paper: #F7F9FB;
  --ink: #13233A;
  --slate: #5B6B7F;
  --line: #CDD6E0;
  --sign: #F5C400;
  --sign-ink: #13233A;
  --teal: #2B7A86;
  --alert: #C2412D;
  --ok: #2F7D4F;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Figtree', system-ui, sans-serif;
  --r-sm: 6px;
  --r-lg: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky: #0F1B2B; --paper: #15243A; --ink: #E6ECF3; --slate: #93A3B8; --line: #26384F;
    --teal: #5FB3BF; --alert: #F07A63; --ok: #6CC08F;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
.sprite { position: absolute; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-family: var(--display); font-size: 1.75rem; letter-spacing: .01em; line-height: 1.1; }
h3 { font-size: 1rem; }
.muted { color: var(--slate); }
.err { color: var(--alert); min-height: 1.5em; margin: .25rem 0; font-size: .9rem; }

/* ---------- buttons & inputs ---------- */
.btn {
  font: 600 .95rem var(--body); border-radius: var(--r-sm); padding: .6rem 1rem; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
}
.btn.primary { background: var(--ink); color: var(--sky); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: wait; }
.link-btn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: .6rem .75rem; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .35rem; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login-card { width: min(360px, 100%); background: var(--sky); padding: 2rem; border-radius: var(--r-lg); }
.login-card h1 { font-family: var(--display); font-size: 2.5rem; margin: .25rem 0 1.25rem; }
.login-mark { width: 40px; height: 40px; color: var(--ink); transform: rotate(45deg); }
.login-card .btn { width: 100%; margin-top: .5rem; }

/* ---------- shell ---------- */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem max(16px, env(safe-area-inset-left)); background: var(--ink); color: var(--sky);
}
@media (prefers-color-scheme: dark) { .bar { background: #0A1320; color: var(--ink); } }
.brand { font: 700 1.5rem var(--display); text-decoration: none; letter-spacing: .02em; }
.bar nav { display: flex; gap: 1.1rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.bar nav a { text-decoration: none; opacity: .7; white-space: nowrap; padding: .25rem 0; border-bottom: 2px solid transparent; }
.bar nav a.active { opacity: 1; border-bottom-color: var(--sign); }
.badge { display: inline-block; background: var(--alert); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; vertical-align: 2px; }
#logout { font-size: .85rem; opacity: .7; }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 16px 4rem; outline: none; }

@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: .5rem 1rem; }
  .bar nav { order: 3; flex-basis: 100%; }
}

/* ---------- next departure (the signature element) ---------- */
.next {
  background: var(--sign); color: var(--sign-ink); border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem 1.4rem; margin-bottom: 2rem; display: grid; gap: .35rem;
  text-decoration: none;
}
.next-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-weight: 600; }
.next-route {
  font: 700 clamp(2.6rem, 9vw, 5.5rem)/0.95 var(--display); letter-spacing: -.01em;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .1em .35em;
}
.next-route { align-items: center; gap: .1em .5em; }
.next-route .end { display: grid; }
.next-route .time { font: 600 clamp(1.1rem, 3vw, 1.6rem)/1.2 var(--display); letter-spacing: .01em; }
.next-route .time small { font: 500 .8rem var(--body); opacity: .75; }
.next-route .arrow { font-weight: 500; opacity: .5; }
.next-sub { font-size: 1.05rem; }
.next.quiet { background: var(--paper); color: var(--ink); border: 1.5px dashed var(--line); }
.next.quiet .next-route { font-size: clamp(2rem, 6vw, 3.25rem); }

/* ---------- home layout ---------- */
.home { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.5rem; }
@media (max-width: 860px) { .home { grid-template-columns: 1fr; gap: 2rem; } }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .9rem; }

/* agenda */
.day { margin-bottom: 1.4rem; }
.day-label { font: 600 1.15rem var(--display); color: var(--slate); margin-bottom: .35rem; display: flex; gap: .6rem; align-items: baseline; }
.day-label .rel { font: 500 .85rem var(--body); }
.seg {
  display: grid; grid-template-columns: 4.2rem 2rem minmax(0, 1fr); gap: .75rem; align-items: start;
  padding: .7rem 0; border-top: 1px solid var(--line); text-decoration: none;
}
.seg:first-of-type { border-top: 0; }
.seg-time { font: 600 1.35rem/1.1 var(--display); }
.seg-time small { display: block; font: 500 .72rem var(--body); color: var(--slate); }
.ico { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--sky); }
.ico svg { width: 1.05rem; height: 1.05rem; }
.ico.lodging { background: var(--teal); color: #fff; }
.ico.restaurant, .ico.activity { background: var(--slate); color: #fff; }
.seg-title { font-weight: 600; overflow-wrap: anywhere; }
.seg-meta { color: var(--slate); font-size: .9rem; overflow-wrap: anywhere; }
.seg.cancelled .seg-title { text-decoration: line-through; color: var(--slate); }
.conf { font-variant-numeric: tabular-nums; letter-spacing: .04em; font-weight: 600; color: var(--ink); }

/* trips list */
.trip-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .85rem 0;
  border-top: 1px solid var(--line); text-decoration: none;
}
.trip-row:hover .trip-name { text-decoration: underline; text-underline-offset: 3px; }
.trip-name { font: 600 1.5rem/1.1 var(--display); }
.trip-when { color: var(--slate); font-size: .9rem; }
.trip-count { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-size: .85rem; color: var(--slate); }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 999px; padding: .05rem .55rem; border: 1.5px solid currentColor; }
.pill.now { color: var(--ok); }
.pill.failed { color: var(--alert); }
.pill.pending { color: var(--slate); }
.pill.parsed { color: var(--ok); }
.pill.not_travel, .pill.ignored { color: var(--slate); }

/* ask */
.ask { background: var(--paper); border-radius: var(--r-lg); padding: 1.1rem; margin-bottom: 2rem; }
.ask form { display: flex; gap: .5rem; }
.ask input { flex: 1; }
.answer { margin-top: .9rem; white-space: pre-wrap; line-height: 1.55; }
.answer:empty { display: none; }

/* ---------- trip page ---------- */
.trip-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; border-bottom: 3px solid var(--ink); padding-bottom: 1rem; }
.trip-head h1 { font: 700 clamp(2.5rem, 8vw, 4.5rem)/0.95 var(--display); }
.trip-head .dates { font-size: 1.1rem; margin-top: .35rem; }
.trip-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.trip-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.5rem; }
@media (max-width: 860px) { .trip-body { grid-template-columns: 1fr; } }
details.seg-detail { border-top: 1px solid var(--line); }
details.seg-detail summary { list-style: none; cursor: pointer; }
details.seg-detail summary::-webkit-details-marker { display: none; }
details.seg-detail summary .seg { border-top: 0; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .25rem 1rem; padding: 0 0 1rem 7rem; font-size: .9rem; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-actions { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; align-items: center; }
.kv-actions select { width: auto; padding: .3rem .5rem; font-size: .85rem; }
@media (max-width: 560px) { .kv { padding-left: 0; } }
.notes { background: var(--paper); border-radius: var(--r-lg); padding: 1.1rem; }
.notes textarea { min-height: 9rem; resize: vertical; }

/* ---------- inbox & connections ---------- */
.panel { background: var(--paper); border-radius: var(--r-lg); padding: 1.25rem; margin-bottom: 1.5rem; }
.panel h2 { margin-bottom: .5rem; }
.panel p { margin: .25rem 0 .9rem; max-width: 70ch; }
.mail-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.mail-row:first-child { border-top: 0; }
.mail-subj { font-weight: 600; overflow-wrap: anywhere; }
.mail-meta { color: var(--slate); font-size: .85rem; overflow-wrap: anywhere; }
.mail-side { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: .5rem; align-items: center; }
.paste textarea { min-height: 10rem; font-size: .9rem; }
.paste .row { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.paste .row input { flex: 1; min-width: 12rem; }
.code {
  font: .85rem/1.5 ui-monospace, 'SF Mono', Menlo, monospace; background: var(--sky); border-radius: var(--r-sm);
  padding: .75rem; overflow-x: auto; white-space: pre; margin: .5rem 0;
}
.token-new { border: 2px solid var(--sign); border-radius: var(--r-sm); padding: .75rem; margin: .75rem 0; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto auto; gap: .6rem; align-items: end; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: .4rem; align-items: center; font-weight: 500; margin: 0; padding-bottom: .6rem; }
.check input { width: auto; }
.status-line { display: flex; gap: .5rem; align-items: center; margin: .3rem 0; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--slate); flex: none; }
.dot.on { background: var(--ok); }
.dot.bad { background: var(--alert); }

.empty { padding: 2rem 0; color: var(--slate); max-width: 52ch; }
.empty strong { color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--sky); padding: .7rem 1.1rem; border-radius: var(--r-sm); font-weight: 600; z-index: 50;
  max-width: calc(100vw - 32px);
}
.dialog-form { display: grid; gap: .75rem; }
dialog { border: 0; border-radius: var(--r-lg); padding: 1.5rem; width: min(440px, calc(100vw - 32px)); background: var(--sky); color: var(--ink); }
dialog::backdrop { background: rgb(10 19 32 / .55); }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

@media (prefers-reduced-motion: no-preference) {
  .next { animation: board .5s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes board { from { transform: translateY(-6px); opacity: 0; } }
}
.section-head.spaced { margin-top: 2.5rem; }

/* ---------- v0.2: quick add, weather, getting around ---------- */
main:focus, main:focus-visible { outline: none; }
.small { font-size: .85rem; }
.quick { margin-bottom: 1.75rem; }
.quick label { color: var(--slate); font-weight: 600; }
.quick-row { display: flex; gap: .5rem; }
.quick-row input { flex: 1; }
.quick-msg { margin: .4rem 0 0; min-height: 1.4em; font-size: .9rem; color: var(--slate); }
.quick-msg.warn { color: var(--alert); }
.side-block:empty { display: none; }
.side-block { margin-bottom: 1.75rem; }
.side-block h2 { margin-bottom: .6rem; }
.wx-card { margin-bottom: 1.75rem; }
.wx-card h2 { margin-bottom: .6rem; }
.wx-card h2 a { text-decoration: none; }
.wx { list-style: none; margin: 0; padding: 0; }
.wx li {
  display: grid; grid-template-columns: 3.2rem 1.6rem 4.2rem minmax(0, 1fr); align-items: center; gap: .6rem;
  padding: .45rem 0; border-top: 1px solid var(--line);
}
.wx li:first-child { border-top: 0; }
.wx-day { font: 600 1.05rem/1.05 var(--display); }
.wx-day small { display: block; font: 500 .72rem var(--body); color: var(--slate); }
.wx-ico { width: 1.5rem; height: 1.5rem; color: var(--slate); }
.wx-ico.sun { color: #E0A400; }
.wx-ico.rain, .wx-ico.storm { color: var(--teal); }
.wx-temp { font: 600 1.25rem var(--display); }
.wx-temp small { font-weight: 500; color: var(--slate); margin-left: .35rem; font-size: 1rem; }
.wx-label { color: var(--slate); font-size: .9rem; }
.xfer { padding: .8rem 0; border-top: 1px solid var(--line); }
.xfer:first-of-type { border-top: 0; padding-top: 0; }
.xfer-title { font-weight: 600; }
.xfer-route { color: var(--slate); font-size: .9rem; margin-bottom: .5rem; }
.xfer-modes { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.xfer-modes a {
  display: grid; grid-template-columns: 1.4rem 1fr; grid-template-rows: auto auto; column-gap: .5rem; align-items: center;
  text-decoration: none; background: var(--paper); border-radius: var(--r-sm); padding: .55rem .7rem; border: 1.5px solid var(--line);
}
.xfer-modes a:hover { border-color: var(--ink); }
.xfer-modes svg { width: 1.3rem; height: 1.3rem; grid-row: 1 / span 2; }
.xfer-modes span { font-size: .8rem; color: var(--slate); }
.xfer-modes strong { font: 600 1.3rem/1.1 var(--display); }
.xfer-modes strong small { font: 500 .7rem var(--body); color: var(--slate); }
.xfer-leave { margin-top: .5rem; font-size: .9rem; }
.mail-side { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .mail-row { grid-template-columns: 1fr; }
  .mail-side { grid-row: auto; grid-column: 1; justify-content: flex-start; margin-top: .4rem; order: 3; }
}
