/* ---------- Design tokens ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e5e7eb;
  --brand: #2563eb;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);

  /* Transport colours: tint for icons on light surfaces, solid for filled shapes */
  --flight: #2563eb; --flight-solid: #2563eb;
  --train: #059669;  --train-solid: #047857;
  --bus: #ea580c;    --bus-solid: #c2410c;
  --ferry: #0891b2;  --ferry-solid: #0e7490;
  --other: #7c3aed;  --other-solid: #6d28d9;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #141a24;
    --surface-2: #1b2230;
    --text: #e8ecf3;
    --muted: #9aa6b8;
    --faint: #64748b;
    --line: #253043;
    --brand: #4f8cff;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --flight: #60a5fa; --train: #34d399; --bus: #fb923c; --ferry: #22d3ee; --other: #a78bfa;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.i { flex: none; display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; border-radius: 12px; }
[hidden] { display: none !important; }

@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-in > * { animation: view-in .28s ease both; }
.view-in > :nth-child(n+3) { animation-delay: .04s; }
.view-in > :nth-child(n+5) { animation-delay: .08s; }

#app {
  max-width: 720px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 20px calc(120px + env(safe-area-inset-bottom));
}
body[data-route="add"] #app, body[data-route="edit"] #app { padding-bottom: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px;
  font-weight: 600; font-size: 15px; white-space: nowrap; text-align: center;
  transition: transform .1s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.04); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.secondary { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn.light { background: #fff; color: #0f172a; }
.btn.glass { background: rgba(255, 255, 255, .16); color: #fff; }
.btn.dashed { border: 1.5px dashed var(--line); color: var(--muted); }
.btn.dashed:hover { color: var(--text); border-color: var(--faint); }
.btn.danger-text { color: var(--danger); font-weight: 600; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.icon-btn:hover { color: var(--text); }
.icon-btn.dark { background: rgba(255, 255, 255, .12); color: #fff; border: 0; }
.link-btn { color: var(--brand); font-weight: 600; font-size: 14px; padding: 8px 0; }

/* ---------- Headers ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 21px; letter-spacing: -.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.greeting { margin: 12px 0 22px; }
.greeting h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.greeting p { color: var(--muted); margin-top: 4px; }
.navbar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.back {
  display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 12px 0 4px; margin-left: -8px;
  border-radius: 12px; font-weight: 600; color: var(--brand);
}
.page-title { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.page-sub { color: var(--muted); margin-top: 6px; }
.arrow { color: var(--faint); }

/* ---------- Banners ---------- */
.banner {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 14px 16px; border-radius: 16px; font-size: 14px;
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--line));
}
.banner > div { flex: 1; }
.banner p { color: var(--muted); margin-top: 2px; }
.banner.warn { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); }

/* ---------- Pills & tags ---------- */
.pill {
  display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill.soft { background: var(--surface-2); border: 1px solid var(--line); }
.pill.now { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }

/* ---------- Route (from → to), used on the hero and ticket ---------- */
.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.pt { min-width: 0; }
.pt + .path + .pt { text-align: right; }
.pt .time { font-size: 15px; font-weight: 500; }
.pt .time sup { font-size: 11px; margin-left: 2px; }
.pt .city { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.pt .sub { font-size: 13px; margin-top: 2px; }
.path { display: flex; align-items: center; gap: 4px; width: 76px; }
.path .line { flex: 1; border-top: 2px dashed currentColor; opacity: .35; }
.path-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }

/* ---------- Home: next departure ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 28px; padding: 22px;
  background: linear-gradient(150deg, var(--cs), color-mix(in srgb, var(--cs) 40%, #020617));
  box-shadow: 0 20px 40px -20px color-mix(in srgb, var(--cs) 80%, transparent);
}
.hero::before {
  content: ""; position: absolute; right: -70px; top: -70px; width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255, 255, 255, .07); pointer-events: none;
}
.hero > * { position: relative; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-label { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .85; }
.hero .pill { background: rgba(255, 255, 255, .18); }
.hero-route { margin: 26px 0 22px; }
.hero .pt .time, .hero .pt .sub { opacity: .8; }
.hero .path-icon { background: rgba(255, 255, 255, .18); }
.hero-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 14px;
  padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .18);
}
.hero-meta span { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .7; }
.hero-meta b { display: block; margin-top: 2px; font-size: 15px; font-weight: 600; }
.hero-meta .hero-type { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; letter-spacing: 0; text-transform: none; opacity: 1; }
.hero-actions { display: flex; gap: 10px; margin-top: 20px; }
.hero-actions .btn { flex: 1; min-width: 0; padding: 0 14px; }

/* ---------- Sections & trip cards ---------- */
.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.trip-card {
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.trip-card:hover { transform: translateY(-1px); border-color: var(--faint); }
.trip-card.is-past { opacity: .65; }
.trip-card-top { display: flex; align-items: flex-start; gap: 12px; }
.trip-card-main { flex: 1; min-width: 0; }
.trip-when { font-size: 13px; font-weight: 500; color: var(--muted); }
.trip-card h3 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.trip-dest { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.trip-dest span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted);
}
.trip-card-foot .trip-when { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600; }
.trip-count { display: inline-flex; align-items: center; gap: 8px; }
.type-stack { display: flex; }
.type-dot {
  width: 26px; height: 26px; margin-left: -7px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 2px solid var(--surface);
}
.type-dot:first-child { margin-left: 0; }
.type-dot.more { --c: var(--muted); }
.past-toggle { display: flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: 8px; font-weight: 600; color: var(--muted); }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 24px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 24px; margin-top: 20px;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin-bottom: 4px;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.empty h2 { font-size: 20px; }
.empty p { color: var(--muted); max-width: 340px; margin-bottom: 8px; }

/* ---------- Timeline ---------- */
.timeline { --time-w: 70px; --node-w: 40px; list-style: none; margin: 24px 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; top: 12px; bottom: 24px; width: 2px; background: var(--line);
  left: calc(var(--time-w) + 12px + var(--node-w) / 2 - 1px);
}
.tl-item > a, .tl-day, .tl-gap {
  display: grid; grid-template-columns: var(--time-w) var(--node-w) minmax(0, 1fr); column-gap: 12px; position: relative;
}
.tl-text { grid-column: 3; }
.tl-day { align-items: center; padding: 14px 0 10px; }
.tl-day:first-child { padding-top: 0; }
.tl-mark {
  grid-column: 2; justify-self: center; width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--faint);
}
.tl-day b { font-size: 15px; }
.tl-day em { font-style: normal; margin-left: 8px; font-size: 13px; color: var(--muted); }
.tl-time { padding-top: 12px; text-align: right; font-size: 13px; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-node { display: flex; justify-content: center; padding-top: 4px; }
.tl-node .dot {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--cs); box-shadow: 0 0 0 4px var(--bg);
}
.tl-card {
  display: block; margin-bottom: 12px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); transition: border-color .12s;
}
.tl-item a:hover .tl-card { border-color: var(--faint); }
.tl-route { display: block; font-weight: 650; line-height: 1.3; }
.tl-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.tl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tl-gap .tl-text { display: flex; align-items: center; gap: 6px; padding: 0 0 14px 2px; font-size: 13px; font-weight: 500; color: var(--muted); }

/* ---------- Trip detail ---------- */
.trip-header { margin: 4px 0 8px; }
.trip-header .trip-when { margin-bottom: 4px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stats span { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); }
.stack { display: grid; gap: 8px; }

/* ---------- Booking detail (ticket) ---------- */
.ticket { margin-top: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.ticket-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; color: #fff;
  background: linear-gradient(135deg, var(--cs), color-mix(in srgb, var(--cs) 55%, #020617));
}
.ticket-head .badge { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .18); flex: none; }
.ticket-title { flex: 1; min-width: 0; }
.ticket-title b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-title span { font-size: 13px; opacity: .85; }
.ticket-head .pill { background: rgba(255, 255, 255, .18); }
.ticket-route { padding: 24px 18px 22px; }
.ticket .pt .time, .ticket .pt .sub { color: var(--muted); }
/* Booking page: slightly smaller city names that never split mid-word (fitCityNames shrinks long ones further). */
.ticket .pt .city { font-size: 22px; overflow-wrap: normal; }
.ticket .path { color: var(--c); }
.ticket .path-icon { background: color-mix(in srgb, var(--c) 14%, transparent); }
.ticket-perf { position: relative; margin: 0 18px; border-top: 2px dashed var(--line); }
.ticket-perf::before, .ticket-perf::after {
  content: ""; position: absolute; top: -12px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg);
}
.ticket-perf::before { left: -30px; }
.ticket-perf::after { right: -30px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin: 0; padding: 20px 18px 22px; }
.fields .full { grid-column: 1 / -1; }
.fields dt { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fields dd { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.fields dd .mono { font-size: 20px; }
.fields .notes { display: block; font-weight: 400; white-space: pre-wrap; }
.copy {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 10px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.hint { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 12px; }
.doc { position: relative; }
.doc-open {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow);
}
.doc-thumb { display: grid; place-items: center; height: 112px; background: var(--surface-2); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.doc-icon { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--danger); }
.doc-icon b { font-size: 11px; letter-spacing: .08em; }
.doc-name { display: block; padding: 10px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-remove {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(15, 23, 42, .55);
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.trip-link {
  display: flex; align-items: center; justify-content: space-between; margin: 12px 0 8px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--muted);
}
.trip-link small { display: block; font-size: 12px; }
.trip-link b { color: var(--text); }

/* ---------- Form ---------- */
.form { display: grid; gap: 16px; margin-top: 20px; }
.type-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.type-opt { position: relative; }
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 2px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 600; transition: all .12s;
}
.type-opt input:checked + .type-tile { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.type-opt input:focus-visible + .type-tile { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; }
.card-group { display: grid; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.field label, .label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.label-row label { margin: 0; }
.opt { font-weight: 500; color: var(--faint); }
.swap { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; font-size: 13px; font-weight: 600; color: var(--brand); }
input, select, textarea {
  display: block; width: 100%; min-height: 50px; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: 12px; appearance: none; -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 88px; }
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background-color: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.invalid { border-color: var(--danger) !important; }
.err { color: var(--danger); font-size: 13px; font-weight: 500; }
.err:not(:empty) { margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.more summary {
  display: flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; color: var(--brand);
}
.more summary::-webkit-details-marker { display: none; }
.more[open] summary .i { transform: rotate(180deg); }
.more-body { display: grid; gap: 14px; padding-top: 8px; }
.pending { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pending:empty { display: none; }
.pending li { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; background: var(--surface-2); border-radius: 12px; font-size: 14px; }
.pending li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending li button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.form-footer {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -20px; padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 28%);
}

/* ---------- Add a booking ---------- */
.add-options { display: grid; gap: 12px; margin-top: 24px; }
.add-option {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 20px 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  color: var(--text); transition: transform .12s ease, border-color .12s ease;
}
.add-option:hover { border-color: var(--faint); }
.add-option:active { transform: scale(.99); }
.add-option > .i { color: var(--faint); }
.add-option.primary {
  padding: 24px 18px; color: #fff; border: 0;
  background: linear-gradient(150deg, var(--flight-solid), color-mix(in srgb, var(--flight-solid) 45%, #020617));
  box-shadow: 0 18px 36px -18px color-mix(in srgb, var(--flight-solid) 80%, transparent);
}
.add-option.primary > .i { color: rgba(255, 255, 255, .7); }
.ao-icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.add-option.primary .ao-icon { color: #fff; background: rgba(255, 255, 255, .16); }
.ao-text { flex: 1; min-width: 0; }
.ao-text b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.ao-text small { display: block; margin-top: 3px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.add-option.primary .ao-text small { color: rgba(255, 255, 255, .8); }
.form-banner { margin: 16px 0 0; }

.reading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 8px 0; text-align: center; }
.reading .page-sub { overflow-wrap: anywhere; }
.reading .stack { width: 100%; max-width: 360px; margin-top: 16px; }
.spinner {
  width: 56px; height: 56px; margin-bottom: 12px; border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--brand) 20%, transparent); border-top-color: var(--brand);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.reading-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin-bottom: 8px; }
.reading-icon.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.review { display: grid; gap: 16px; }
.review-head { display: grid; gap: 6px; margin-bottom: 4px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ok); }
.attn {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 12px 14px; border-radius: 14px;
  font-size: 14px; font-weight: 600; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.attn.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.seg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg-head b { font-size: 16px; }
.link-btn.danger { color: var(--danger); padding: 4px 0; }
.flag { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.flag.need { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.flag.check { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.field.is-need input { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); }
.field.is-check input { border-color: color-mix(in srgb, var(--warn) 70%, var(--line)); }
.field.is-need .type-tile { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.type-picker.compact { gap: 6px; }
.type-picker.compact .type-tile { padding: 9px 2px; gap: 4px; font-size: 12px; border-radius: 12px; }
.attached { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); color: var(--muted); }
.attached span { min-width: 0; }
.attached b { display: block; color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attached small { font-size: 13px; }
.form-footer .err { text-align: center; margin-bottom: 8px; }
.form-footer .err:empty { display: none; }

/* ---------- Bottom navigation ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}
body[data-route="add"] .tabbar, body[data-route="edit"] .tabbar { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 84px; padding: 7px 14px;
  border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tab.active { color: var(--text); background: var(--surface-2); }
.tab-add { min-width: 0; padding: 0 6px; }
.add-circle {
  width: 60px; height: 60px; margin: -22px 0 -2px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: var(--brand); border: 4px solid var(--bg);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 50%, transparent);
  transition: transform .12s ease;
}
.tab-add:hover .add-circle { transform: translateY(-1px); }
.tab-add:active .add-circle { transform: scale(.95); }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(2, 6, 23, .55); }
dialog.sheet {
  width: 100%; max-width: 520px; max-height: 90vh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--surface);
}
.sheet-inner { padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 20px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 0; text-align: left; border-bottom: 1px solid var(--line); }
.menu-item b { display: block; font-weight: 600; }
.menu-item small { display: block; font-size: 13px; color: var(--muted); }
.mi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.fine { display: flex; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.fine .i { margin-top: 3px; }
dialog.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(2, 6, 23, .96); color: #fff; display: flex; flex-direction: column;
}
dialog.viewer:not([open]) { display: none; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px 20px; }
.viewer-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; background: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px;
  background: #0f172a; color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(2, 6, 23, .25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .i { color: #4ade80; }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  #app { padding-left: 32px; padding-right: 32px; }
  .form-footer { margin: 0 -32px; padding-left: 32px; padding-right: 32px; }
  dialog.sheet { margin: auto; border-radius: 24px; }
  .hero { padding: 28px; }
  .pt .city { font-size: 32px; }
  .ticket .pt .city { font-size: 28px; }
  .path { width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.label-row .label { margin: 0; }
