/* Design tokens: every color and spacing decision lives here.
   Identity (user-chosen reference): lavender playfulness — soft purple
   gradient background, white cards floating on diffuse purple shadows,
   very round corners, a chunky rounded typeface. Ink is a purple-tinted
   graphite; labels use a muted lilac. The app's own mark and its controls
   wear the sunset of the icon (--brand, see the tokens below), set against
   that lavender world. Compliance colors (amber warn, coral danger) stay
   loud on purpose: they are the point of the app.
   The log uses a SINGLE hue for row meaning (lavender at three strengths
   for tracked / today / draft) so amber and coral numbers never clash.
   Theme: the data-theme attribute (user choice) wins, otherwise the system
   preference. color-scheme keeps native controls (date pickers) matching
   the palette instead of rendering light-on-dark; booking checkboxes are
   drawn (see input[type="checkbox"][data-book]). */
:root {
  color-scheme: light;
  --bg: #f0edfa;
  --bg-grad: linear-gradient(180deg, #e9e3fa 0%, #f2effc 45%, #f5f3fb 100%);
  --surface: #ffffff;
  --text: #3b3658;
  --text-muted: #6b6590;
  /* Settled work: dimmer than --text-muted, still ~3.5:1 on --surface, so a
     done row reads as spent without becoming unreadable. The two palettes
     land on the same hex from opposite sides — dimmed toward white here,
     toward the card fill in dark. */
  --text-faint: #8b86a8;
  --gold: #b8860b;
  --gold-ink: #8a6508;
  --border: #e7e2f7;
  /* Two hues with two jobs. The lavender accent is the world: the page, the
     map, the city scenes, the day bars, the log's row tints, the assistant's
     bubbles. The sunset brand is the app's own mark and everything you act
     on: checked boxes, the active tab, buttons, links, focus rings, your own
     chat bubbles, and the "today / you are here" markers. The brand pink
     leans magenta on purpose: coral and amber are the alert colors, and a
     checked box must never read as a limit crossed. */
  --accent: #8b7ff0;
  --accent-soft: #c9c2f7;
  --brand: #d23c84;
  --brand-soft: #f1b3cf;
  /* The app icon's sky, for the one brand surface big enough to carry it. */
  --brand-grad: linear-gradient(120deg, #ea6c45 0%, #d23c84 100%);
  /* Ink on a brand fill: white on the light brand, the page's deep purple
     on the brighter dark-theme brand. */
  --on-brand: #ffffff;
  /* The calendar link (R12) and every other link. A shade deeper than
     --brand in light: as 0.9rem of line art on white the fill color reads
     too pale for a control. */
  --link: #b52d6f;
  --link-hover: #8f1f56;
  --ok: #45a06f;
  --warn: #d9821f;
  --danger: #e05a5a;
  --warn-bg: color-mix(in srgb, var(--warn) 12%, var(--surface));
  --danger-bg: color-mix(in srgb, var(--danger) 12%, var(--surface));
  --shadow: 0 10px 28px rgba(90, 70, 180, .10);
  /* Raised surface for popovers (the booking picker): white on a firmer
     shadow in light; in dark a near-card fill outlined in the accent with a
     halo, so it reads as floating over the card stack (R31). */
  --pop-surface: #ffffff;
  --pop-border: #ddd7f5;
  --pop-shadow: 0 10px 28px rgba(60, 40, 140, .22);
  --pop-text: var(--text);
  --pop-muted: var(--text-muted);
  --radius: 18px;
  --gap: 1rem;
  /* Both ends of the location chip are this wide, so the place panel between
     them reads as centred however short "Sep 6" or the theme glyph is. */
  --pill-end: 5.6rem;
  /* The chip's first row: every one of its three parts is a box of exactly
     this height, hung exactly this far from the top. That is what puts the
     date, the place and the theme glyph on one axis — by construction, not
     by nudging one of them. */
  /* The two pills in the header — the tabs and the location chip — are the
     same object at different widths, so one token gives them one height. */
  --chip-h: 4.07rem;
  --chip-row: 1.6rem;
  --font: "Baloo 2", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171331;
    --bg-grad: linear-gradient(180deg, #1b1538 0%, #171331 55%, #151129 100%);
    --surface: #221d40;
    --text: #edeaff;
    --text-muted: #b9b4d9;
    --text-faint: #8b86a8;
    --gold: #f2c14e;
    --gold-ink: #f7d68a;
    --border: #383165;
    --accent: #a99df8;
    --accent-soft: #5b519e;
    --brand: #ff7fb0;
    --brand-soft: #7d3d68;
    --brand-grad: linear-gradient(120deg, #ffa070 0%, #ff7fb0 100%);
    --on-brand: #171331;
    /* Dark runs the other way: the brand itself is the readable link on
       the card fill, and hover lightens it. */
    --link: #ff8fba;
    --link-hover: #ffc2da;
    --ok: #57c690;
    --warn: #f0a850;
    --danger: #f37c7c;
    --shadow: 0 10px 28px rgba(0, 0, 0, .35);
    --pop-surface: #262048;
    --pop-border: #a99df8;
    --pop-shadow: 0 0 0 4px rgba(169, 157, 248, .16), 0 14px 34px rgba(0, 0, 0, .55);
    --pop-text: #edeaff;
    --pop-muted: #c3bde3;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171331;
  --bg-grad: linear-gradient(180deg, #1b1538 0%, #171331 55%, #151129 100%);
  --surface: #221d40;
  --text: #edeaff;
  --text-muted: #b9b4d9;
  --text-faint: #8b86a8;
  --gold: #f2c14e;
  --gold-ink: #f7d68a;
  --border: #383165;
  --accent: #a99df8;
  --accent-soft: #5b519e;
  --brand: #ff7fb0;
  --brand-soft: #7d3d68;
  --brand-grad: linear-gradient(120deg, #ffa070 0%, #ff7fb0 100%);
  --on-brand: #171331;
  --link: #ff8fba;
  --link-hover: #ffc2da;
  --ok: #57c690;
  --warn: #f0a850;
  --danger: #f37c7c;
  --shadow: 0 10px 28px rgba(0, 0, 0, .35);
  --pop-surface: #262048;
  --pop-border: #a99df8;
  --pop-shadow: 0 0 0 4px rgba(169, 157, 248, .16), 0 14px 34px rgba(0, 0, 0, .55);
  --pop-text: #edeaff;
  --pop-muted: #c3bde3;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 82rem;
  padding: var(--gap) var(--gap) 3rem;
  background: var(--bg-grad) fixed var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

/* The header and the tabs travel together as one sticky stack (R36): the
   tabs are how you move around, so they stay reachable at any scroll depth.
   The stack is pulled out over the body's own top padding so nothing slides
   through above it, and it paints the very same fixed gradient the body
   paints — because the attachment is fixed, both layers are anchored to the
   viewport, so the stack's slice lands exactly on top of the page's: no
   seam, no second tone. --topbar-h is measured from this element (app.js)
   because the log's sticky table head has to park below the whole stack. */
.topbar-stack {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: calc(var(--gap) * -1) calc(var(--gap) * -1) 0;
  padding: .55rem var(--gap) var(--gap);
  background: var(--bg-grad) fixed var(--bg);
}
/* One row: the brand, the tabs, the chip. The tabs take equal air on both
   sides through auto margins, which centres them in the space LEFT OVER
   rather than in the window: the chip is far wider than the wordmark, so
   window-centring left a big gap on one side and none on the other. */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.topbar .tabs { margin-inline: auto; }
/* Two corner pieces hang off the header's bottom edge, at the content
   column's left and right. Each is a --radius square painted in the page's
   own (fixed) gradient with a quarter-disc masked out, so a white card
   scrolling under the header appears to keep its rounded top corners
   instead of ending in a hard square edge. Where nothing white is passing,
   they paint page colour on page colour and cannot be seen. */
.topbar-stack::before,
.topbar-stack::after {
  content: "";
  position: absolute;
  top: 100%;
  width: var(--radius);
  height: var(--radius);
  background: var(--bg-grad) fixed var(--bg);
  pointer-events: none;
}
/* The circle needs its radius spelled out: a gradient's colour stops are
   percentages of the GRADIENT's own radius, and an unsized circle defaults to
   farthest-corner (~25px across an 18px box), which made the whole square
   transparent and the piece invisible. */
.topbar-stack::before {
  left: var(--gap);
  -webkit-mask-image: radial-gradient(circle var(--radius) at 100% 100%, transparent 98%, #000 100%);
  mask-image: radial-gradient(circle var(--radius) at 100% 100%, transparent 98%, #000 100%);
}
.topbar-stack::after {
  right: var(--gap);
  -webkit-mask-image: radial-gradient(circle var(--radius) at 0 100%, transparent 98%, #000 100%);
  mask-image: radial-gradient(circle var(--radius) at 0 100%, transparent 98%, #000 100%);
}

h1 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
h2 { margin: 0 0 .6rem; font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; }
h3 { margin: 1rem 0 .25rem; font-size: .95rem; font-weight: 700; }

.sub, .detail { margin: .25rem 0; font-size: .85rem; }
.section-sub { margin: -.45rem 0 .8rem; font-size: .85rem; line-height: 1.5; color: var(--text-muted); }

/* Trips tab: the booking to-do list. The shared Travel log's booking
   columns render the same on both tabs. */
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.todo-list .todo { font-weight: 400; }
.todo-list .todo b { font-weight: 700; }
.todo-list .todo label { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.todo-list .todo.all-set { color: var(--text-muted); font-weight: 500; }
.todo-icon { font-size: .95rem; }
.todos { display: flex; flex-direction: column; gap: .6rem; }
/* Trip cards: one per planned trip, four fixed rows. The width is fixed —
   picker offset (2.2rem) + picker (19.5rem) + the same offset on the right,
   so the popover sits under a row with equal margins — and cards wrap. */
.trips { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; }
.trip { position: relative; width: 23.9rem; max-width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: .7rem .9rem .8rem; }
/* The undecided window: same card, no rows — a dashed outline and the one
   line centred in the same box, so the trip holds its place in the date
   order while the destination is still open. min-height matches a card
   with four rows, which is what every other card in the run is. */
.trip.decide {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 10.7rem; border-style: dashed; color: var(--text-muted);
}
.trip.decide .decide-line { font-size: 1.02rem; line-height: 1.45; }
.trip.decide .decide-line b { color: var(--text); font-weight: 700; }
/* The window's notes from the log, one per line under the prompt. */
.trip.decide { flex-direction: column; gap: .35rem; }
.trip.decide .decide-note { font-size: .88rem; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.trip .th { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .45rem; }
.trip .th b { font-size: 1.05rem; }
.trip .th .dates { color: var(--text-muted); font-size: .85rem; }
.trip .th .count { margin-left: auto; font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.trip .rows { display: flex; flex-direction: column; gap: .35rem; }
.trip .row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .55rem; min-height: 1.5rem; }
.trip .row .ic { font-size: .95rem; width: 1.2rem; text-align: center; }
/* Label and tail wrap inside their own box: a long via ("Airbnb + Hotel
   Conterrâneo (Mike, WhatsApp)") drops under the label, flush with it and
   close, so it reads as that row's note, not as a loose line back at the
   checkbox column with the row's full gap above it. The receipt notes and
   error lines live in the same box, so every line under a row starts at
   one edge. */
.trip .row .body { flex: 1; min-width: 0; min-height: 1.5rem; display: flex; flex-wrap: wrap; align-items: center; column-gap: .55rem; row-gap: .05rem; }
/* With a wrapped body, centring would float the box and icon between the
   two lines; they sit on the label's line instead (1.5rem line box). */
.trip .row > input[data-book] { margin-top: .225rem; }
.trip .row > .ic { line-height: 1.5rem; }
.trip .row .via { font-size: .8rem; color: var(--ok); font-weight: 600; }
.trip .row .step { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.trip .row .todo-error,
.trip .row .todo-note { flex-basis: 100%; margin: 0; }
/* Drawn booking checkbox, one rule set for the card row and the log cell
   (KTD11): the native control renders a grey box in dark mode. Every visual
   keys on data-state — outlined open, accent fill with a white check when
   done, dashed and faint when not needed, dimmed while a receipt runs —
   never on :disabled, which marks not-needed boxes and running cells alike.
   A not-needed box lets the click through to its row or cell, which is the
   control that brings it back (R29). The picker's LATAM Pass flag shares
   the drawing, keyed on :checked and the locked class. */
input[type="checkbox"][data-book], .book-picker .picker-flag input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 1.05rem; height: 1.05rem; margin: 0; padding: 0; flex: none; cursor: pointer;
  border: 1.5px solid var(--brand-soft); border-radius: 5px; background: transparent;
  display: inline-grid; place-content: center; vertical-align: middle; transition: background .12s, border-color .12s;
}
input[type="checkbox"][data-book]::before, .book-picker .picker-flag input[type="checkbox"]::before { content: ""; width: .55rem; height: .55rem; transform: scale(0); transition: transform .12s; background: #fff; clip-path: polygon(14% 44%, 0 62%, 40% 100%, 100% 20%, 84% 6%, 40% 70%); }
input[type="checkbox"][data-book]:focus-visible, .book-picker .picker-flag input[type="checkbox"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type="checkbox"][data-book][data-state="open"]:hover { border-color: var(--brand); }
input[type="checkbox"][data-book][data-state="done"] { background: var(--brand); border-color: var(--brand); }
input[type="checkbox"][data-book][data-state="done"]::before { transform: scale(1); }
input[type="checkbox"][data-book][data-state="done"]:hover { background: color-mix(in srgb, var(--brand) 85%, var(--surface)); }
/* Not needed is not an empty box: any box, dashed or not, reads as "still to
   do" at a glance. The control keeps its size and its place in the column so
   the grid does not shift, drops the border, and draws one dash — nothing to
   check here, on purpose. It brightens on hover, where the row or cell offers
   to bring it back (R29). */
input[type="checkbox"][data-book][data-state="na"] { pointer-events: none; cursor: default; border-color: transparent; background: none; }
input[type="checkbox"][data-book][data-state="na"]::before {
  transform: none; clip-path: none; border-radius: 1px;
  width: .62rem; height: 1.5px; background: var(--text-faint);
}
input[type="checkbox"][data-book][data-state="running"] { cursor: progress; opacity: .45; border-color: var(--brand); }
.book-picker .picker-flag input[type="checkbox"]:hover { border-color: var(--brand); }
.book-picker .picker-flag input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.book-picker .picker-flag input[type="checkbox"]:checked::before { transform: scale(1); }
.book-picker .picker-flag.locked input[type="checkbox"] { cursor: default; background: color-mix(in srgb, var(--brand) 55%, var(--pop-surface)); border-color: transparent; }
/* The ✕ is quiet until the row is hovered; the global button is a filled
   accent pill, which would shout on every row. */
.trip .row .x {
  margin: 0 0 0 auto; padding: .05rem .4rem; font-size: .78rem; line-height: 1.2;
  background: transparent; color: var(--text-muted); border: 1px solid transparent; opacity: .55;
}
.trip .row:hover .x, .trip .row .x:focus-visible { opacity: 1; }
.trip .row .x:hover { color: var(--danger); }
/* The control that adds another place to a done lodging row (R17). It is
   the ✕'s quiet twin: transparent, muted, and only fully visible while the
   row is under the pointer or the control has keyboard focus — a done row
   should read as settled, not as a row still asking to be worked on. */
.trip .row .edit-book, .stays td.book .edit-book {
  padding: 0 .3rem; font-size: .8rem; line-height: 1.2;
  background: transparent; color: var(--text-muted); border: 1px solid transparent; opacity: 0;
  /* Invisible means untouchable. In the log this control is positioned over
     the booking cell and its box overlaps the checkbox, so leaving it
     hit-testable at rest would put an unseen target on top of the control
     the user is actually aiming at. */
  pointer-events: none;
}
/* The control is emitted next to the checkbox because both surfaces share
   one bookControl, but in the card it belongs at the far end of the row —
   where the ✕ sits on an open row. Ordering it there keeps every row's
   emoji and label on the same left edge instead of pushing the lodging
   row's across by the width of a button. */
.trip .row .edit-book { order: 99; margin-left: auto; }
.trip .row:hover .edit-book, .trip .row .edit-book:focus-visible,
.stays td.book:hover .edit-book, .stays td.book .edit-book:focus-visible { opacity: .75; pointer-events: auto; }
.trip .row .edit-book:hover, .stays td.book .edit-book:hover { opacity: 1; color: var(--brand); }
/* In the log the control is taken out of flow: the booking columns are
   2.2rem wide by design and an inline button would widen every one of
   them. Absolute keeps the table's geometry exactly as it is. */
.stays td.book { position: relative; }
.stays td.book .edit-book { position: absolute; right: -.1rem; top: calc(.3rem + 3px); }
/* A done row reads as spent: the whole line — label, emoji and provider —
   fades to a dim muted, and the rule through the label is that same colour
   rather than a fainter one, so the state is legible from the weight of
   the row and not from a hairline. The checkbox keeps its full accent
   fill: it is what says "marked". The rows still open stay at full --text,
   which is where the eye should land. */
.trip .row[data-state="done"] { color: var(--text-faint); }
.trip .row[data-state="done"] .lbl { text-decoration: line-through; text-decoration-color: currentColor; }
.trip .row[data-state="done"] .ic { opacity: .45; }
.trip .row[data-state="done"] .via { color: currentColor; font-weight: 500; }
/* A not-needed row is itself the control that brings it back: pointer over
   its whole width, "bring back" on hover and on keyboard focus. */
.trip .row[data-state="na"] { color: var(--text-muted); opacity: .6; border-radius: 8px; cursor: pointer; }
.trip .row[data-state="na"] * { cursor: pointer; }
.trip .row[data-state="na"] .lbl { text-decoration: line-through; }
.trip .row[data-state="na"] .undo, .trip .row[data-state="na"] .undo * { cursor: auto; }
.trip .row[data-state="na"] .undo button { cursor: pointer; }
.trip .row[data-state="na"]:hover, .trip .row[data-state="na"]:focus-visible { opacity: 1; }
.trip .row[data-state="na"]:hover .lbl, .trip .row[data-state="na"]:focus-visible .lbl { text-decoration: none; }
.trip .row[data-state="na"]:hover input[data-book]::before,
.trip .row[data-state="na"]:focus-visible input[data-book]::before { background: var(--brand); }
.trip .row[data-state="na"]:not(:has(.undo)):hover::after,
.trip .row[data-state="na"]:not(:has(.undo)):focus-visible::after { content: "bring back"; margin-left: auto; align-self: center; font-size: .75rem; color: var(--brand); }
.trip .row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* "not needed · undo" with a bar that drains over the 5 s undo window; a
   redraw resumes it through a negative animation-delay set inline. */
.trip .row .undo { margin-left: auto; font-size: .78rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.trip .row .undo button { margin: 0; font-size: .75rem; padding: .02rem .5rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.trip .row .undo button:hover { border-color: var(--brand); }
.trip .row .undo .bar { width: 2.4rem; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--brand) 25%, transparent); overflow: hidden; }
.trip .row .undo .bar i { display: block; height: 100%; background: var(--brand); animation: drain 5s linear forwards; }
@keyframes drain { from { width: 100%; } to { width: 0; } }
@media (prefers-reduced-motion: reduce) { .trip .row .undo .bar i { animation: none; width: 100%; } }
/* A card whose four rows are all done or not needed collapses to one line. */
.trip.allset { color: var(--text-muted); }
.trip.allset .th { margin-bottom: 0; }
.trip.allset .rows { display: none; }
.trip.allset .count { color: var(--ok); }
.trip .th .reopen { margin: 0 0 0 .4rem; padding: 0 .5rem; font-size: .75rem; background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.trip .th .reopen:hover { color: var(--brand); }
/* The log is ONE table shared by the Dashboard and Trips tabs and must look
   identical on both (only the row filter differs, in app.js): no rule in
   this file may style it per tab. Guarded by test/ui-invariants.test.js. */
/* The rank carries on from the cards above, so it reads as a position, not
   as data: quiet, narrow, right-aligned against the city names. */
.stays th.c-rank, .stays td.c-rank { width: 1%; text-align: right; padding-right: .6rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.stays th.book, .stays td.book { text-align: center; width: 2.2rem; }
.stays td.book { padding-top: calc(.3rem + 3px); }
/* The log cell of a not-needed booking is the revive control (R29). */
.stays td.book:has(input[data-state="na"]) { cursor: pointer; }
.stays td.book:has(input[data-state="na"]):hover input[data-book]::before { background: var(--brand); }
/* The four booking columns hide as one group behind a single eye, which
   lives in the last of them (🚗). Three columns leave the table; the fourth
   stays as the narrow strip that carries the eye — a toggle inside the thing
   it hides has to outlive it. Collapsed cells stop taking clicks: a hidden
   checkbox must not be revivable by clicking where it used to be. */
#stays-table.book-collapsed th.book-lodging, #stays-table.book-collapsed td.book-lodging,
#stays-table.book-collapsed th.book-flight, #stays-table.book-collapsed td.book-flight,
#stays-table.book-collapsed th.book-bus, #stays-table.book-collapsed td.book-bus { display: none; }
#stays-table.book-collapsed th.book-car .th-label,
#stays-table.book-collapsed td.book-car input[data-book] { display: none; }
#stays-table.book-collapsed th.book-car,
#stays-table.book-collapsed td.book-car { width: 2rem; padding-left: 0; padding-right: 0; }
#stays-table.book-collapsed td.book-car { pointer-events: none; cursor: default; }
/* Booked-with columns: collapsed by default, each behind its own eye
   toggle (same content-hiding trick as the deadline/notes columns). */
.stays th.bookvia, .stays td.bookvia { white-space: nowrap; }
.stays td.bookvia { padding-top: calc(.3rem + 3px); }
/* Long free-text providers must not widen the table: cap and ellipsize
   (the full name stays in the cell tooltip). The cap is on the NAME, not on
   the span wrapping it: the calendar link leads that span (KTD9), and a cap
   over both would put the control inside what the ellipsis eats. */
.stays td.bookvia span { vertical-align: bottom; }
.stays td.bookvia .via-text {
  display: inline-block;
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
/* The app's only link: the calendar block a receipt produced (R12). It
   takes its own colour token rather than currentColor, because on a done
   card row currentColor is --text-faint — the one row state where the only
   control present still has to read as a control. The focus ring is the
   house one (2px solid var(--brand)); the glyph is line art in the link
   colour, so nothing else has to change for dark. */
.cal-link { display: inline-flex; align-items: center; color: var(--link); text-decoration: none; vertical-align: bottom; }
.cal-link:hover { color: var(--link-hover); }
.cal-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.cal-link-glyph { width: .9rem; height: .9rem; flex: none; }
.stays td.bookvia .cal-link { margin-right: .2rem; }
.trip .row .cal-link { margin-right: .15rem; }
#stays-table.via-transport-collapsed td.via-transport span,
#stays-table.via-transport-collapsed th.via-transport .th-label,
#stays-table.via-lodging-collapsed td.via-lodging span,
#stays-table.via-lodging-collapsed th.via-lodging .th-label { display: none; }
#stays-table.via-transport-collapsed td.via-transport,
#stays-table.via-transport-collapsed th.via-transport,
#stays-table.via-lodging-collapsed td.via-lodging,
#stays-table.via-lodging-collapsed th.via-lodging { width: 2rem; padding-left: 0; padding-right: 0; }
/* The who-was-it-booked-with picker, floated under the checkbox just ticked.
   One row's category, one provider: its width is fixed (the card is sized
   to it plus equal margins, R5) and it never grows past the viewport. */
.book-picker {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  width: 19.5rem;
  max-width: calc(100vw - 16px);
  padding: .6rem;
  background: var(--pop-surface);
  color: var(--pop-text);
  border: 1px solid var(--pop-border);
  border-radius: 12px;
  box-shadow: var(--pop-shadow);
  font-size: .85rem;
}
.book-picker .picker-title { margin: 0 0 .05rem; font-weight: 700; font-size: .9rem; }
.book-picker .picker-row { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.book-picker button { margin: 0; padding: .3rem .7rem; font-size: .85rem; text-align: left; }
.book-picker button:hover { border-color: var(--brand); }
/* Options are quiet until picked, filled and ticked once chosen, so the
   picker never looks like everything is already selected. */
.book-picker button[data-pick] {
  background: var(--pop-surface);
  color: var(--pop-text);
  border: 1px solid var(--pop-border);
}
.book-picker button[data-pick][aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}
.book-picker button[data-pick][aria-pressed="true"]::before { content: "\2713\00a0"; }
.book-picker .picker-done { margin-top: .15rem; text-align: center; }
.book-picker .picker-done:disabled { opacity: .45; cursor: default; }
/* "Other:" keeps its content's minimum width (label + a usable field), which
   is what lets the row WRAP it onto its own line when the provider buttons
   fill the first one. With min-width: 0 it shrank below its content instead,
   and the field spilled out past the picker's edge. The basis is min-content
   too, because wrapping is decided before shrinking: with the field's
   preferred 9rem as the basis, even a row that would fit once shrunk (one
   short airline plus the field) was pushed onto a second line. */
.book-picker .picker-other { display: flex; align-items: center; gap: .4rem; font-size: .85rem; white-space: nowrap; flex-grow: 1; flex-shrink: 1; flex-basis: min-content; min-width: min-content; }
.book-picker .picker-other input { flex: 1; min-width: 5.5rem; width: auto; max-width: 100%; padding: .25rem .5rem; font-size: .85rem; background: var(--pop-surface); color: var(--pop-text); border-color: var(--pop-border); }
/* R16: the reserved literal typed as a name. */
.book-picker .picker-reserved { margin: 0; font-size: .75rem; color: var(--danger); }
/* The LATAM Pass flag (R15): locked (checked and disabled) while LATAM is
   the pressed provider, free for any other airline. */
.book-picker .picker-flag { display: flex; align-items: center; gap: .4rem; font-size: .82rem; padding-left: .1rem; }
.book-picker .picker-flag.locked { color: var(--pop-muted); }
.book-picker .picker-flag input { margin: 0; }
.book-picker:focus { outline: none; }
/* Receipt capture inside the picker: the category's one dashed zone. It is
   the drop target, the click target (hidden file input) and the paste
   target; its states are idle, dragover, has-file, rejected and sent (a
   kept receipt from a reopened row, still a drop target for a replacement). */
.book-picker .drop-zone {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .4rem .6rem;
  border: 1.5px dashed var(--accent-soft);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--pop-surface));
  font-size: .8rem;
  cursor: pointer;
}
.book-picker .drop-zone:hover, .book-picker .drop-zone:focus-visible { border-color: var(--brand); outline: none; }
.book-picker .drop-zone.dragover { border-style: solid; border-color: var(--brand); background: color-mix(in srgb, var(--accent) 14%, var(--pop-surface)); }
.book-picker .drop-zone.has-file { border-style: solid; cursor: default; }
.book-picker .drop-zone.rejected { border-color: var(--danger); }
.book-picker .zone-body { display: flex; flex-direction: column; gap: .1rem; }
.book-picker .zone-label { font-weight: 700; }
.book-picker .zone-hint { color: var(--pop-muted); }
.book-picker .zone-reject { color: var(--danger); font-size: .75rem; }
.book-picker .file-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  padding: .1rem .2rem .1rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--pop-surface));
  color: var(--pop-text);
}
.book-picker .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-picker .chip-remove {
  margin: 0;
  padding: 0 .35rem;
  font-size: .95rem;
  line-height: 1.2;
  background: transparent;
  color: var(--pop-muted);
  border: none;
  border-radius: 999px;
}
.book-picker .chip-remove:hover { color: var(--danger); border-color: transparent; }
.book-picker .picker-note { margin: 0; font-size: .75rem; color: var(--pop-muted); }
.book-picker .picker-error { margin: 0; font-size: .78rem; color: var(--danger); }
.book-picker .picker-actions { display: flex; gap: .3rem; margin-top: .15rem; }
.book-picker .picker-actions button { flex: 1; text-align: center; }
/* Progress on the to-do: the spinner stands where the checkbox was. */
.spinner {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  border: 2.5px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.book-picker .file-chip .spinner { width: .8rem; height: .8rem; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.todo-list .todo .todo-row { display: flex; align-items: center; gap: .55rem; }
.todo-step { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.todo-error { margin: .15rem 0 0 1.6rem; font-size: .8rem; color: var(--danger); }
/* A receipt that was filed but hangs on nothing is not an error — the file
   is in Drive and on the row — so it says so in the muted voice, not the
   red one. */
.todo-note { margin: .15rem 0 0 1.6rem; font-size: .8rem; color: var(--text-faint); }
/* An error whose stay no longer exists (trip_changed after an edit) has no
   to-do to hang off, so it gets its own muted line and a discreet Dismiss:
   the global button is a filled accent pill, which would shout on an error. */
.todo-list .todo.todo-orphan { color: var(--text-muted); }
.todo-dismiss {
  margin: 0 0 0 auto;
  padding: .05rem .6rem;
  font-size: .75rem;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.todo-dismiss:hover { color: var(--danger); border-color: var(--danger); }
.todo-dismiss:disabled { opacity: .45; cursor: default; }
/* The kept receipt of a reopened row (R11): the chip turns green and ticked,
   with no remove button, and the zone stays a drop target for a replacement. */
.book-picker .drop-zone.sent { border-color: var(--ok); border-style: solid; }
.book-picker .file-chip.sent { background: color-mix(in srgb, var(--ok) 16%, var(--pop-surface)); }
.book-picker .chip-sent { padding: 0 .35rem; color: var(--ok); font-weight: 700; }
/* The clear on a kept chip (R12): the ✕'s quiet twin in size and voice —
   transparent, muted, danger only under the pointer — so the chip grows by
   one small icon and never by a pill. flex: none keeps it whole beside the
   tick on a narrow picker; the name is what gives way, through its own
   ellipsis. The global button is a filled accent pill, which would make an
   irreversible control the loudest thing in the picker. */
.book-picker .chip-clear {
  flex: none;
  display: inline-grid;
  place-content: center;
  margin: 0;
  padding: .1rem .3rem;
  line-height: 1;
  background: transparent;
  color: var(--pop-muted);
  border: none;
  border-radius: 999px;
}
.book-picker .chip-clear svg { width: .85rem; height: .85rem; display: block; }
.book-picker .chip-clear:hover { color: var(--danger); }
.book-picker .chip-clear:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.book-picker .chip-clear:disabled { opacity: .45; cursor: progress; color: var(--pop-muted); }
/* A failed clear's Dismiss sits at the end of its error line, not pushed to
   the row's far edge the way the orphan line's is. */
.todo-error .todo-dismiss { margin-left: .5rem; vertical-align: baseline; }
.muted { color: var(--text-muted); }

/* One chip with two ends and a panel between them (R37): the date on the
   left, the place in the middle, the theme on the right. The chip is the
   .topbar-right group and not the .location div, because .location's markup
   is rebuilt on every render — the theme button has to stay the same element
   or its listener would be thrown away with the innerHTML. The two ends
   share one width token so the middle sits optically centred. */
.topbar-right {
  justify-self: end;
  position: relative;
  display: flex;
  /* centre, not stretch: the ends are boxes of the shared row height, and
     under stretch a fixed-height box falls to the top of the chip. The seams
     override it with align-self: stretch. */
  align-items: center;
  height: var(--chip-h);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: var(--shadow);
}
#theme-toggle {
  flex: none;
  min-width: var(--pill-end);
  height: var(--chip-row);
  margin: 0;
  /* The extra pixel on the left is the chip's own border: the button's box
     stops at the inner edge while the visible end runs to the outer one, so
     without it the glyph sits half a pixel to the left of the end it is
     centred in. Mirrored on the date end. */
  padding: 0 1rem 0 calc(1rem + 1px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0 999px 999px 0;
}
.theme-icon { display: block; }
/* The seam left the button when the button stopped being full height. */
.chip-seam { width: 1px; align-self: stretch; flex: none; background: var(--border); }
#theme-toggle:hover { color: var(--brand); }

/* Current location as a glass chip, like the reference's floating pills. */
/* The mark beside the wordmark is the favicon itself, one file for the tab
   and the header: they can never drift apart. Both sit on the header's own
   axis — the nudge that used to lift the mark was for the two-line header,
   where an "as of" line hung under the wordmark. */
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark { display: block; border-radius: 8px; flex: none; }
.location {
  position: relative;
  display: flex;
  align-items: center;
  /* Fills the chip so its own seam runs as tall as the theme's, which is a
     sibling of this panel rather than a child. */
  align-self: stretch;
  /* No padding or gap out here: each cell carries its own, so a cell's box
     runs edge to edge between the seams. That is what lets its content centre
     in the area the reader actually sees. */
  gap: 0;
  padding: 0;
  font-size: .95rem;
  font-weight: 700;
  text-align: center;
}
/* Both seams span the chip's content box exactly: this one reaches back over
   the cell's own padding to get there, the theme's is a sibling of the panel
   and already does. */
.location .loc-line { width: 1px; align-self: stretch; background: var(--border); flex: none; }
.location .loc-place { text-align: center; }
/* The flag rides in the line: flag and city are one block, and it is that
   block the chip centres — which is also the axis the stint below takes. */
.location .flag { margin-right: .4rem; font-size: 1.05rem; line-height: 1; }
/* The date is a button because it opens something; it must not look like the
   app's filled accent buttons, so it keeps the pill's own type. */
.loc-date {
  display: flex; align-items: center; justify-content: center; gap: .4rem; flex: none;
  min-width: var(--pill-end);
  height: var(--chip-row); margin: 0; padding: 0 calc(.2rem + 1px) 0 .2rem;
  font-family: inherit; font-size: .9rem; font-weight: 700; line-height: 1.2;
  background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 8px;
}
.loc-date:hover { color: var(--brand); }
.loc-date:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.cal-glyph { width: .95rem; height: .95rem; flex: none; color: var(--brand); }
/* The month at a glance: a look, not a control — nothing in it is clickable,
   so no cell carries a hover or a focus ring. */
.month-pop {
  position: absolute; top: calc(100% + .55rem); left: -1rem; z-index: 30;
  padding: .6rem .7rem .7rem;
  background: var(--pop-surface); color: var(--pop-text);
  border: 1px solid var(--pop-border); border-radius: 14px; box-shadow: var(--pop-shadow);
  text-align: center; cursor: default;
}
.month-pop .cal-head { display: flex; align-items: center; justify-content: space-between; gap: .3rem; margin-bottom: .35rem; }
.month-pop .cal-title { font-size: .82rem; font-weight: 700; white-space: nowrap; }
/* The two arrows are the only controls in here, so they stay quiet until
   they are hovered or focused. */
.month-pop .cal-step {
  margin: 0; padding: 0 .35rem; flex: none;
  font-family: inherit; font-size: 1rem; line-height: 1.3;
  background: transparent; color: var(--pop-muted); border: 1px solid transparent; border-radius: 7px;
}
.month-pop .cal-step:hover { color: var(--brand); border-color: var(--pop-border); }
.month-pop .cal-step:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.month-pop .cal-grid { display: grid; grid-template-columns: repeat(7, 1.55rem); gap: .1rem; }
.month-pop .cal-dow { font-size: .65rem; font-weight: 700; color: var(--pop-muted); line-height: 1.5rem; }
.month-pop .cal-day { font-size: .75rem; font-weight: 500; line-height: 1.55rem; border-radius: 7px; }
/* On a date cell the days are buttons: same grid, now a control. */
.month-pop.on-cell { left: .2rem; top: calc(100% - .2rem); }
.month-pop button.cal-day {
  margin: 0; padding: 0; width: 1.55rem; height: 1.55rem;
  font-family: inherit; background: transparent; color: var(--pop-text); border: 1px solid transparent; cursor: pointer;
}
.month-pop button.cal-day:hover { border-color: var(--brand); }
.month-pop button.cal-day:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.month-pop .cal-picked { background: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 800; }
.month-pop button.cal-today { box-shadow: inset 0 0 0 1px var(--brand); }
.month-pop .cal-today { background: var(--brand); color: var(--on-brand); font-weight: 800; }
/* The place line is a box of the shared row height, centred like the date and
   the theme glyph: their centres coincide exactly, whatever each font does.
   The stint hangs off the line, out of the flow — it is the one thing in the
   chip that is deliberately off the axis, and out of the flow it cannot push
   the line off it either. The cell keeps a minimum width because a short city
   name would otherwise leave the stint hanging over the seams. */
/* The floor covers the widest stint the app can write — "365 days since
   Dec 31, 2025" measures 8.2rem — plus this cell's own 2rem of padding,
   which the border-box min-width includes. Without it a short city name
   leaves the stint hanging over the seams. */
.location .loc-place { position: relative; min-width: 10.4rem; padding: 0 1rem; }
.location .place-line { position: relative; height: var(--chip-row); display: inline-flex; align-items: center; white-space: nowrap; }
/* Hung from the line's own right edge, which is why it lives inside it: the
   line is centred in the cell, so its right edge is not a distance CSS could
   have worked out from the cell. */
.location .stint { position: absolute; top: 100%; right: 0; white-space: nowrap; }
.location .stint { display: block; font-size: .7rem; font-weight: 500; line-height: 1.05; color: var(--text-muted); }

/* Tabs as a floating pill segmented control. */
.tabs {
  display: inline-flex;
  align-items: center;
  height: var(--chip-h);
  gap: .25rem;
  padding: 0 .3rem;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  margin: 0;
  padding: .45rem 1.2rem;
  font-weight: 700;
}
.tab.active { background: var(--brand-grad); color: var(--on-brand); }

.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-block: var(--gap);
  box-shadow: var(--shadow);
}

/* Dashboard: main column plus the glass side panel from the reference. */
.dash-grid { display: grid; grid-template-columns: 1fr 16.5rem; gap: var(--gap); align-items: start; }
.dash-main { min-width: 0; }
.side-panel {
  /* relative (never static): the absolute mountains anchor to the panel */
  position: relative;
  margin-top: var(--gap);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(165deg, #b9aef5 0%, #8b7ff0 55%, #6f63d6 100%);
  box-shadow: 0 12px 30px rgba(90, 70, 180, .28);
}
.side-panel h2 { color: #fff; position: relative; }
.side-panel .mountains { position: absolute; bottom: 0; left: 0; width: 100%; height: 38%; }
.chiplist { display: flex; flex-direction: column; gap: .45rem; position: relative; }
.chip.more { cursor: pointer; }
.chip.more:hover { background: rgba(255, 255, 255, .3); }
.chip {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  padding: .5rem .75rem;
  background: rgba(255, 255, 255, .2);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 14px;
  font-size: .82rem;
  font-weight: 600;
}
.chip small { font-weight: 500; opacity: .9; white-space: nowrap; }
.chip.quiet { justify-content: center; background: rgba(255, 255, 255, .1); font-weight: 500; }

/* The map: presence bubbles and the year's route on a soft panel. */
#map { border-radius: 14px; overflow: hidden; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
#map svg { display: block; width: 100%; height: auto; }
#map .land { fill: color-mix(in srgb, var(--accent) 11%, transparent); }
#map .grat { stroke: color-mix(in srgb, var(--accent) 10%, transparent); stroke-width: 1; }
#map .route { fill: none; stroke: var(--accent-soft); stroke-width: 2; }
#map .route.planned { stroke-dasharray: 5 5; opacity: .8; }
#map .bubble { fill: var(--accent); opacity: .72; }
#map .bubble.planned { fill: none; stroke: var(--accent); stroke-dasharray: 3 3; opacity: .8; }
#map .maplabel { font-size: 11px; font-weight: 700; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }

.headline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: var(--gap);
}
.headline-grid .card { margin-block: 0; }
.headline-grid { margin-block: var(--gap); }

.rule-terms { font-size: .75rem; font-weight: 400; color: var(--text-muted); margin-left: .5rem; }

.counter { font-size: 1.8rem; font-weight: 700; }
.counter small { font-size: .95rem; font-weight: 400; color: var(--text-muted); }

.bar {
  height: .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  overflow: hidden;
  margin-block: .5rem;
}
.bar-fill { height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }

.warnings { display: grid; gap: .5rem; margin-block: var(--gap); }
.warning {
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .9rem;
  border: 1px solid var(--warn);
  background: var(--warn-bg);
}
.warning.breach { border-color: var(--danger); background: var(--danger-bg); }

.errors { border-color: var(--danger); background: var(--danger-bg); }

/* Expandables: the WHOLE summary line is the click target, not just the
   disclosure icon. We draw our own marker so behavior is uniform. */
details > summary {
  cursor: pointer;
  display: block;
  width: 100%;
  padding: .2rem 0;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: .4rem;
  transition: transform .15s;
}
details[open] > summary::before { transform: rotate(90deg); }

.expiry { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .85rem; }

.projection { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; margin-top: .5rem; }

.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--gap); }
.country-toggle { display: flex; align-items: center; }
.country-toggle button { margin: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px; }
.country {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .85rem;
  display: flex;
  flex-direction: column;
}
/* The card's anchor: one big presence number, everything else supports it. */
.country-stat { display: flex; align-items: baseline; gap: .45rem; margin: .4rem 0 .5rem; }
.country-stat .stat-n { font-size: 1.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.country-stat .stat-cap { font-size: .72rem; color: var(--text-muted); }
.country h3 { margin: 0 0 .25rem; display: flex; align-items: center; gap: .5rem; }
.country h3 .flag { font-size: 1.15rem; line-height: 1; }
/* City cards: the generated postcard sits behind the content, anchored to
   the bottom edge like a horizon. Extra bottom room keeps the text and the
   illustration out of each other's way. */
.country { position: relative; overflow: hidden; }
.country > :not(.postcard) { position: relative; }
.citycard { padding-bottom: 4.8rem; }
.postcard {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto; /* the full drawing shows; no hard crop */
  pointer-events: none;
  /* fade the top of the scene out so it never fights the card's text */
  -webkit-mask-image: linear-gradient(to top, #000 52%, transparent 95%);
  mask-image: linear-gradient(to top, #000 52%, transparent 95%);
}
.recency-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
}
.recency-badge.here { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.country .recency { margin: 0; font-size: .75rem; color: var(--text-muted); }
.country .recency.here { color: var(--brand); font-weight: 600; }
.country ul {
  margin: 0;
  padding: .4rem 0 0;
  list-style: none;
  font-size: .8rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.country li { display: flex; justify-content: space-between; gap: .5rem; }
.country li .label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country .value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.country .value.warn { color: var(--warn); }
.country .value.danger { color: var(--danger); }

/* On narrow screens a log wider than the card scrolls inside it. Wide
   screens keep overflow visible: an overflow ancestor would break the
   sticky header below (sticky anchors to the nearest scroll container). */
@media (max-width: 1100px) {
  .card:has(#stays-table) { overflow-x: auto; }
  /* That card is now the scroll container its sticky children measure
     against, so their page offsets (the stack's height, ~200px on a phone)
     would push the column header down INSIDE the card, over the rows. Here
     it simply scrolls with the log; the title strip gets the same below,
     after its own sticky rule. */
  #stays-table thead th { position: static; }
}
.stays { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stays th, .stays td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
/* The whole header row sticks to the top while the log scrolls. Collapsed
   borders do not travel with sticky cells, so the divider is a shadow. */
.stays thead th {
  position: sticky;
  top: var(--topbar-h, 0px);
  z-index: 3;
  /* Generous room above the labels: while the head is stuck under the app's
     own bar, the two would otherwise read as one crowded strip. The padding
     (not a top offset) is what buys it, because the cell's own background is
     what covers the rows sliding underneath. */
  padding-top: 1.15rem;
  background: var(--surface);
  border-bottom: none;
  box-shadow: 0 1px 0 var(--border);
}
/* Future (planned) rows read dimmed and italic instead of repeating a
   "(planned)" label on every line: explicit user choice, the one place
   where lowered text contrast is wanted. Deadline colors still override. */
.stays tr.planned td, .stays tr.planned input.inline {
  font-style: italic;
  color: color-mix(in srgb, var(--text) 65%, var(--bg));
}
/* Row meaning uses ONE hue at three strengths, so the amber/coral numbers
   in the tracking column never fight the background: tracked country =
   faint lavender, today = stronger lavender with the side bar, draft =
   mid lavender with a dashed outline. */
.stays tr.tracked td {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.stays tr.today td {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
.stays tr.today td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
/* A planned stay that covers today is being lived, not merely planned:
   it keeps the italic (still unconfirmed) but not the lowered contrast. */
.stays tr.planned.today td, .stays tr.planned.today input.inline { color: var(--text); }
/* Date cells show a friendly label ("Nov 23") over the native input; focus
   swaps back to the real input for editing and the picker. */
.stays td.datecell { position: relative; }
.stays td.datecell .datelabel {
  position: absolute;
  left: calc(.5rem + 5px);
  top: calc(.3rem + 3px);
  pointer-events: none;
  white-space: nowrap;
}
/* At rest the input hugs its label (width set inline by render(), icon one
   space after the date): the generic 7.2rem min-width below must NOT apply
   here or it pushes the icon to a far column edge. */
.stays td.datecell input.inline[type="date"] { color: transparent; min-width: 0; }
/* The friendly label never gives way to the raw dd/mm/yyyy field: the cell
   opens the app's own calendar instead, by mouse or by keyboard (app.js).
   :focus-visible cannot express "keyboard only" here — a text input matches
   it on a plain click too, by design, which is exactly how the swap kept
   coming back. The field stays as the value holder, transparent under the
   label, and shows a ring when it holds focus. */
.stays td.datecell:focus-within { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 8px; }

/* Editable log: inputs look like plain text until focused. Dates stay
   narrow; the notes column takes the remaining width. */
.stays input.inline {
  /* appearance:none kills Safari's native bubble-and-arrow chrome on
     datalist inputs; the log cells must read as plain text until focused. */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: .1rem .25rem;
  width: 100%;
  min-width: 6rem;
}
.stays input.inline::-webkit-list-button { display: none; }
.stays input.inline[list]::-webkit-calendar-picker-indicator { display: none; }
.stays input.inline[type="date"] { min-width: 7.2rem; width: 7.2rem; padding-right: 0; }
.leaveby.danger { color: var(--danger); font-weight: 700; }
.leaveby.warn { color: var(--warn); font-weight: 700; }
/* Every date cell — the log's and the draft row's — anchors the app's own
   calendar, so each is a positioning context. */
.stays td.datepick { position: relative; }
/* The native picker icon is gone from the log's date cells: the whole cell
   opens the app's own calendar (R41), so the icon was a second,
   differently-styled way to the same place — and it reserved 26px in the
   narrowest columns of the table. The draft row keeps it: its field shows
   its own value rather than a label over it. */
.stays td.datecell input.inline[type="date"]::-webkit-calendar-picker-indicator { display: none; }
.stays th.days, .stays td.days { width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
/* Plain-text cells (days, track, deadline) sit next to cells whose text
   lives inside bordered+padded inputs; compensate so baselines align. */
.stays td.days, .stays td.track, .stays td.allowed { padding-top: calc(.3rem + 3px); }
/* Personal tracking columns (config.track): running window usage per row. */
.stays th.track { text-align: right; }
.stays td.track { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
/* The date columns (From, To, Days and each tracking window) never take
   more than their content needs. In an auto table the spare width is shared
   out among the columns, and these four were collecting a slice of it while
   City and Notes ran short. width: 1% is how that algorithm is told "shrink
   to fit"; the nowrap is on the cells only, because the header labels are
   allowed to wrap — "Brazil window" on two lines is narrower than on one,
   which is the whole point. */
.stays th[data-col="from"], .stays td[data-col="from"],
.stays th[data-col="to"], .stays td[data-col="to"],
.stays th.days, .stays td.days,
.stays th.track, .stays td.track { width: 1%; }
.stays td[data-col="from"], .stays td[data-col="to"], .stays td.days, .stays td.track { white-space: nowrap; }
/* The turn of the year is a band of its own (R42): a row with no data at
   all, holding sparkles, the year, and one soft wave that fades out to the
   right. The stay that straddles New Year is an ordinary row again — the
   dates carry no year, and this is where the reader finds it.
   The trail is a flex item, not an absolute box, so it always starts right
   after the year however wide that number renders. */
.stays tr.yearband td { padding: 0; border-top: 0; }
.stays tr.yearband + tr td { border-top: 0; }
.band-art {
  display: flex; align-items: center; gap: .7rem;
  height: 54px; padding-left: .5rem; overflow: hidden;
  color: var(--gold); background: color-mix(in srgb, var(--gold) 9%, transparent);
}
.band-art .band-shine { display: block; flex: none; }
/* A hole in the plan (days between two trips nobody decided yet): an empty
   dashed row in date order, the whole row one button that drafts the stay
   with the hole's dates. Muted like the Plan's decide card, so it reads as
   missing rather than as data. */
.stays tr.gapband td { padding: .35rem 0; }
.stays tr.gapband + tr td { border-top: 0; }
.fill-gap {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .5rem; width: 100%;
  padding: .7rem .9rem; border: 1px dashed var(--border); border-radius: 10px;
  background: transparent; color: var(--text-muted); font: inherit; text-align: left; cursor: pointer;
}
.fill-gap b { color: var(--text); font-weight: 700; }
.fill-gap .gap-plus { font-weight: 700; }
.fill-gap .gap-days { margin-left: auto; font-size: .85rem; }
.fill-gap:hover, .fill-gap:focus-visible { border-color: var(--brand); color: var(--text); }
.band-year {
  flex: none; font-weight: 800; font-size: 1.7rem; letter-spacing: .06em; line-height: 1;
  color: var(--gold-ink);
}
/* The wave stops before the end of the row, and stops by fading: a hard edge
   would read as a broken rule. */
.band-trail {
  flex: 1 1 auto; min-width: 0; height: 54px; margin-right: 18%;
  -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent);
  mask-image: linear-gradient(90deg, #000 55%, transparent);
}
.band-trail svg { display: block; width: 100%; height: 54px; }
.stays td.track.warn { color: var(--warn); font-weight: 600; }
.stays td.track.danger { color: var(--danger); font-weight: 700; }
/* Wide enough for "Dominican Republic" and "Campos do Jordão" unclipped. */
.stays input.inline[data-f="country"], .stays input.inline[data-d="country"] { width: 10rem; min-width: 10rem; }
.stays input.inline[data-f="city"], .stays input.inline[data-d="city"] { width: 8.5rem; min-width: 8.5rem; }
/* Keep the columns snug: the inputs define the width, notes absorb the slack. */
.stays th.country-col, .stays td.country-col { width: 11rem; }
/* The deadline column never wraps its label or its date. */
.stays th.allowed, .stays td.allowed { white-space: nowrap; }
/* 38% is the comfortable ask; the floor is low so notes are what give way
   (shrink, not bleed) when the optional columns are expanded. */
.stays td.notes-cell { width: 38%; min-width: 8.5rem; }
/* Collapsing hides the column's CONTENT but keeps the cells, so header and
   body columns stay aligned (a removed td would shift every row left). */
#stays-table.allowed-collapsed td.allowed .leaveby,
#stays-table.allowed-collapsed th.allowed .th-label { display: none; }
#stays-table.allowed-collapsed td.allowed { width: 2rem; padding-left: 0; padding-right: 0; }
#stays-table.notes-collapsed td.notes-cell > *,
#stays-table.notes-collapsed th.notes-col .th-label { display: none; }
#stays-table.notes-collapsed td.notes-cell { width: 2rem; min-width: 0; padding-left: 0; padding-right: 0; }
/* Column-visibility toggles: just the eye, no button chrome, whisper-faint
   until hovered (they are plumbing, not content). */
/* A hidden column keeps its place as a narrow strip: the header holds the
   eye that brings it back (a button inside the thing it hides has to outlive
   it) and the cells go blank. Both head and body keep the same column count,
   which a display:none on one side alone would break. */
.stays th.col-off, .stays td.col-off { width: 1.7rem; min-width: 0; padding-left: 0; padding-right: 0; }
.stays th.col-off .th-label { display: none; }
/* The cells must give the space BACK, so their content leaves the flow
   entirely: visibility:hidden kept the column as wide as the date input it
   was hiding. The cell itself stays (an empty one, 1.7rem wide) because the
   header and the body have to keep the same number of columns. font-size: 0
   catches the cells whose content is a bare text node, like Days. */
.stays td.col-off > * { display: none; }
/* And the strip that is left is inert. The cell is still `datepick`, and the
   click handler matches on that, so clicking where a hidden From/To used to
   be opened the calendar over an invisible cell and a chosen day saved the
   row — dragging the next row's "from" with it. The booking group is inert
   for the same reason, one rule up. The eye lives in the `th`, which keeps
   its clicks. */
.stays td.col-off { pointer-events: none; cursor: default; }
.stays td.col-off { font-size: 0; line-height: 0; }
/* Every header carries its eye, but only the one under the pointer shows it
   — fourteen eyes in a row would read as a toolbar. A hidden column keeps
   its eye visible, or there would be no way back. */
/* The eye is taken out of the flow: at opacity 0 it was still reserving its
   width in every header, which is ~25px the narrow columns cannot spare. It
   overlays the label's tail while hovered, which is the moment the reader is
   after the eye and not the word. */
/* No `position` here: the header cells are already sticky, which is a
   positioned state, so the eye anchors to them as they are. Setting
   `relative` overrode the sticky and turned its offset into a displacement —
   the header row slid down into the middle of the table. */
.stays thead th .col-eye { position: absolute; right: 1px; top: 50%; transform: translateY(-50%); opacity: 0; transition: opacity .12s; }
.stays th.col-off .col-eye { position: static; transform: none; }
/* A header with no `data-col` is never marked col-off, so it never reaches
   the escape below: at opacity 0 those five eyes (the booking group, Notes,
   Should-leave-before and the two via columns) could only be found by
   hovering a blank strip. They keep the resting opacity they always had. */
.stays thead th:not([data-col]) .col-eye { opacity: .3; }
.stays thead th:hover .col-eye,
.stays thead th .col-eye:focus-visible,
.stays th.col-off .col-eye { opacity: .55; }
.stays thead th:hover .col-eye:hover { opacity: 1; }
.col-eye {
  margin: 0;
  padding: 0;
  vertical-align: middle;
  background: transparent;
  color: var(--text-muted);
  opacity: .3;
  border: none;
  border-radius: 0;
  line-height: 1;
}
.col-eye:hover { color: var(--brand); opacity: 1; }
/* The info glyphs whisper next to the header words instead of shouting. */
.stays th .hint { font-size: .72em; font-weight: 500; color: var(--text-muted); vertical-align: .1em; }
.stays input.inline:hover { border-color: var(--border); }
.stays input.inline:focus { border-color: var(--brand); background: var(--bg); outline: none; }
.stays td.actions { width: 6.5rem; white-space: nowrap; }
/* Ghost insert affordance on the left edge of each row. */
.stays td.has-insert { position: relative; }
.insert-row {
  position: absolute;
  left: -1.5rem;
  top: 100%; /* sit on the divider below the row: the insert lands after it */
  transform: translateY(-50%);
  z-index: 1;
  margin: 0;
  padding: 0 .4rem;
  font-size: .85rem;
  line-height: 1.3;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: 0;
}
.stays tr:hover .insert-row { opacity: .5; }
.stays .insert-row:hover { opacity: 1; }
.stays tr.draft td {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-top: 1.5px dashed var(--accent-soft);
  border-bottom: 1.5px dashed var(--accent-soft);
}
.stays .save-draft { margin: 0 .25rem 0 0; padding: .2rem .6rem; font-size: .8rem; }
.stays .cancel-draft {
  margin: 0;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.hide-row, .delete-row, .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.7rem; /* match the inline date/text inputs so all row content shares one center line */
  margin: 0 .15rem 0 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  border: none;
  opacity: .3;
  vertical-align: middle;
}
.hide-row:hover { opacity: 1; }
.delete-row { font-size: 1rem; line-height: 1; }
.delete-row:hover { opacity: 1; color: var(--danger); }
.drag-handle {
  cursor: grab;
  font-size: .8rem;
  user-select: none;
}
.drag-handle:hover { opacity: 1; }
.stays td.grab { width: 1.4rem; padding-right: 0; }
.stays tr.drop-before td { box-shadow: inset 0 2px 0 var(--brand); }
.stays tr.drop-after td { box-shadow: inset 0 -2px 0 var(--brand); }
#show-hidden {
  margin: .5rem 0 0;
  padding: .2rem .7rem;
  border-radius: 999px;
  background: transparent;
  color: color-mix(in srgb, var(--text) 45%, var(--bg));
  border: 1px solid var(--border);
  font-size: .8rem;
}
#hidden-list { margin-top: .5rem; }
.hidden-stay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .3rem 0;
  border-top: 1px solid var(--border);
  font-size: .85rem;
}
.hidden-stay .restore-row {
  margin: 0;
  padding: .15rem .7rem;
  border-radius: 999px;
  font-size: .8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
/* Card header row: title on the left, controls tucked in the top-right.
   In the log card the whole strip sticks under the app's own sticky stack,
   and the table's column header sticks right under the strip (see the th
   offset). Both offsets are measured tokens, never fixed numbers: the stack
   grows when the location pill wraps, and the strip grows when the filter
   row does. */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.card:has(#stays-table) .card-head {
  position: sticky;
  top: var(--topbar-h, 0px);
  z-index: 5;
  background: var(--surface);
  /* stretch over the card's own padding so rows never peek at the edges */
  margin: -1.1rem -1.2rem 0;
  padding: 1.2rem 1.2rem .7rem;
  border-radius: var(--radius) var(--radius) 0 0;
}
/* Narrow screens: the card scrolls sideways itself, so the strip's page
   offset would land it mid-card, over the rows (see the 1100px rule above). */
@media (max-width: 1100px) {
  .card:has(#stays-table) .card-head { position: static; }
}
/* Slightly under the sticky strip (which covers the overlap): a gap here
   would let rows peek through while scrolling. The generous padding is the
   breathing room above the labels while the two bars are stuck together. */
#stays-table thead th {
  top: calc(var(--topbar-h, 0px) + var(--log-head-h, 3.8rem));
  padding-top: 1.15rem;
  padding-bottom: .55rem;
}
/* Data in these columns lives inside inputs (1px border + 4px padding), so
   their headers get the same 5px lead-in to line up with the text below. */
#stays-table thead th:not(.days):not(.track):not(.allowed):not(.grab):not(.bookvia) {
  padding-left: calc(.5rem + 5px);
}
.card-tools { display: flex; align-items: center; gap: .5rem; }
#log-filter {
  margin: 0;
  padding: .3rem .95rem;
  width: 13rem;
  font-size: .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
}
#log-filter:focus { outline: none; border-color: var(--brand); }
#older-controls { display: flex; gap: .5rem; }
#older-controls button {
  margin: 0;
  padding: .25rem .9rem;
  font-size: .85rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.stays .save-row { margin: 0; padding: .2rem .6rem; font-size: .8rem; }
/* Notes are a tiny list editor: Enter on a filled line opens the next one;
   clicking the empty cell starts the first line. No standing blank lines. */
.stays .notes-cell input.note-line { display: block; min-width: 6rem; width: 100%; }
.stays td.notes-cell { cursor: text; }
th[title] { cursor: help; }
input, button, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .35rem .5rem;
}
button {
  background: var(--brand);
  color: var(--on-brand);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  margin-top: .75rem;
  padding-inline: 1rem;
}
.form-status { margin-left: .5rem; font-size: .85rem; }
.form-status.error { color: var(--danger); }
.form-status.ok { color: var(--ok); }

/* The score stays pinned while the checklist scrolls under it. */
#ties-score {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  padding-top: .5rem;
}

.score {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: var(--gap);
}
.score-number { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.score.ok .score-number { color: var(--ok); }
.score.warn .score-number { color: var(--warn); }
.score.danger .score-number { color: var(--danger); }
.score.warn { border-color: var(--warn); background: var(--warn-bg); }
.score.danger { border-color: var(--danger); background: var(--danger-bg); }
.score-text { font-size: .85rem; }

.answer-group { display: inline-flex; flex-shrink: 0; }
.answer-btn {
  margin: 0;
  padding: .1rem .5rem;
  font-size: .75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.answer-btn:first-child { border-radius: 999px 0 0 999px; }
.answer-btn:last-child { border-radius: 0 999px 999px 0; border-left: none; }
.answer-btn.active.yes { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.answer-btn.active.no { background: var(--ok); color: #fff; border-color: var(--ok); }
.answer-btn.active.na { background: color-mix(in srgb, var(--text) 18%, var(--surface)); }
.answer-btn:not(:first-child) { border-left: none; border-radius: 0; }
.answer-btn:last-child { border-radius: 0 999px 999px 0; }

.tie { border-top: 1px solid var(--border); padding-block: .5rem; }
.tie summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.tie summary::-webkit-details-marker { display: none; }
.tie summary::before { content: none; }
.tie .risk {
  font-size: .7rem;
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.risk.red { background: var(--danger-bg); color: var(--danger); }
.risk.caution { background: var(--warn-bg); color: var(--warn); }
.risk.ok { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); color: var(--ok); }
.risk.ops { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--accent); }
.risk.fyi { background: color-mix(in srgb, var(--text) 10%, var(--surface)); color: var(--text); }
.tie .body { font-size: .85rem; color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0; }
.tie textarea { width: 100%; min-height: 2.2rem; }

@media (max-width: 1024px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* The phone log (app.js logCard): cards under month headings, shown below
   640px in place of the table (the switch is in the block right after).
   Sizes are the ones Tiago picked for reading on the road (2026-11-02):
   place 18px, every secondary line 15px, never smaller. Each card is a
   two-row grid with fixed row heights, so the day sits on the place's line
   and the weekday on the days' line. */
#log-cards { display: none; }
.log-month { margin: 1.4rem .25rem .5rem; font-size: 1rem; font-weight: 600; color: var(--gold); }
.log-month:first-child { margin-top: .25rem; }
.log-card {
  position: relative;
  overflow: hidden;
  margin-bottom: .5rem;
  padding: .55rem .75rem;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
}
.log-card > :not(.lc-sparkles) { position: relative; }
.lc-grid { display: grid; grid-template-columns: 2.1rem minmax(0, 1fr); grid-template-rows: 27px 23px; column-gap: .6rem; align-items: center; }
.lc-day { font-size: 23px; font-weight: 600; line-height: 1; text-align: center; }
.lc-weekday { font-size: 15px; line-height: 1; text-align: center; color: var(--text-faint); }
.lc-line { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.lc-place { min-width: 0; overflow: hidden; font-size: 18px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.lc-sub { font-size: 15px; color: var(--text-faint); white-space: nowrap; }
.lc-limit b { font-weight: inherit; }
.lc-limit b.warn { color: var(--warn); }
.lc-limit b.danger { color: var(--danger); }
.lc-book { display: flex; flex: none; gap: .55rem; }
.lc-book > span { display: inline-flex; align-items: center; }
.lc-book svg { width: 18px; height: 18px; }
.lc-book .done { color: var(--ok); }
.lc-book .done svg + svg { width: 12px; height: 12px; margin-left: 1px; }
.lc-book .open { color: var(--warn); }
.lc-book.all-set { font-size: 15px; color: var(--ok); }
.lc-notes { margin: .45rem 0 .1rem 2.75rem; padding-left: .55rem; border-left: 2px solid var(--accent-soft); font-size: 15px; line-height: 1.4; color: var(--text-muted); }
.lc-notes p { margin: 0; overflow-wrap: anywhere; }
.log-card.today { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
/* What is still undecided reads as a task, in the orange of an open
   booking mark. */
.log-card.task { box-shadow: inset 3px 0 0 var(--warn); }
.log-card.task .lc-place { color: var(--warn); }
.lc-decide {
  flex: none;
  margin: 0;
  padding: 1px 10px;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--warn);
  background: none;
  border: 1.5px solid var(--warn);
  border-radius: 999px;
  cursor: pointer;
}
/* The card that holds New Year (a stay, an Exterior row or a hole): a
   midnight card in either theme, its line marking where the year turns,
   sparkles in the bottom-left corner. The min-height keeps the sparkles
   under the weekday on a card with no notes. */
.log-card.new-year { min-height: 7rem; color: #edeaff; background: #100c26; border-color: #3a3270; }
.log-card.new-year .lc-weekday, .log-card.new-year .lc-sub { color: #8b86a8; }
.log-card.new-year .lc-notes { color: #b9b4d9; border-left-color: #5b519e; }
.lc-sparkles { position: absolute; left: 0; bottom: 0; width: 52px; height: 56px; color: #f2c14e; pointer-events: none; }
.lc-year { height: 16px; margin: .5rem 0 .1rem 2.75rem; }
.lc-year .track, .lc-year .done { position: absolute; left: 0; top: 7px; height: 2px; border-radius: 2px; }
.lc-year .track { right: 0; background: #383165; }
.lc-year .done { width: var(--at); background: #5b519e; }
.lc-year svg { position: absolute; left: var(--at); top: 0; width: 16px; height: 16px; margin-left: -8px; color: #f2c14e; }
.lc-year .label { position: absolute; left: var(--at); top: -3px; margin-left: 12px; font-size: 13px; color: #f2c14e; }
.lc-year.flip .label { margin-left: 0; transform: translateX(calc(-100% - 12px)); }

/* The "Where to?" form a card's "decide" opens: the whole screen, not a
   floating popup. Every field is the same box with its name inside, one
   gap between all of them; a placeholder is faint, a value full white. The
   dates open a calendar sheet from the bottom that a tap above it, a swipe
   down or Done closes. 18px inputs also keep iOS from zooming in. The
   bottom keeps at least 2.5rem: opened from the home screen the app runs to
   the iPhone's rounded corners, and without viewport-fit=cover the
   safe-area inset reads 0, so OK and Done were cut by the corners. */
.where-to {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: calc(.9rem + env(safe-area-inset-top)) 1rem max(2.5rem, calc(1rem + env(safe-area-inset-bottom)));
  background: var(--bg);
  color: var(--text);
}
.where-to[hidden] { display: none; }
body.where-to-open { overflow: hidden; }
.decide-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.decide-head h2 { margin: 0; font-size: 1.65rem; font-weight: 700; }
.decide-close { display: grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0; color: var(--text-muted); background: var(--surface); border: 0; border-radius: 50%; }
.decide-body { flex: 1; display: flex; flex-direction: column; gap: .75rem; overflow-y: auto; }
.df {
  display: block;
  margin: 0;
  padding: .45rem .9rem .55rem;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.df:focus-within, .df.on { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.df small { display: block; font-size: 13px; line-height: 1.3; color: var(--text-faint); }
.df input { width: 100%; margin: 0; padding: 0; font: inherit; font-size: 18px; color: var(--text); background: none; border: 0; outline: none; }
.df input::placeholder { color: var(--text-faint); opacity: .75; }
.df-dates { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.df-date b { display: block; font-size: 22px; font-weight: 600; line-height: 1.25; }
.df-date span { display: block; font-size: 15px; color: var(--text-muted); }
.df-suggest { margin: -.35rem 0 0; padding: 0; list-style: none; background: var(--pop-surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.df-suggest[hidden] { display: none; }
.df-suggest li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .9rem; font-size: 17px; border-top: 1px solid var(--border); cursor: pointer; }
.df-suggest li:first-child { border-top: 0; }
.df-suggest li em { font-style: normal; font-size: 13px; color: var(--text-faint); white-space: nowrap; }
.df-suggest li.warn { font-size: 13px; color: var(--warn); cursor: default; padding-bottom: .2rem; }
.df-suggest li.add { color: var(--link); }
.decide-error { margin: 0; font-size: 15px; color: var(--danger); }
.decide-ok { margin: .75rem 0 0; padding: .8rem; font: inherit; font-size: 18px; font-weight: 700; color: var(--on-brand); background: var(--brand); border: 0; border-radius: 16px; }
.decide-ok:disabled { color: var(--text-faint); background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }
.cal-backdrop { position: absolute; inset: 0; background: rgba(10, 8, 25, .55); }
.cal-backdrop[hidden], .cal-sheet[hidden] { display: none; }
.cal-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: .75rem 1rem max(2.5rem, calc(1rem + env(safe-area-inset-bottom)));
  background: var(--pop-surface);
  border-top: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  touch-action: none;
}
.cal-grab { width: 40px; height: 4px; margin: 0 auto .6rem; border-radius: 2px; background: var(--accent-soft); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; font-size: 17px; font-weight: 600; }
.cal-head button { display: grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0; color: var(--text-muted); background: none; border: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; text-align: center; }
.cal-grid .wd { font-size: 13px; color: var(--text-faint); }
.cal-grid button { position: relative; height: 38px; margin: 0; padding: 0; font: inherit; font-size: 16px; color: var(--text); background: none; border: 0; border-radius: 0; }
.cal-grid button.busy { color: var(--text-faint); }
.cal-grid button.busy::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent-soft); }
.cal-grid button.in { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.cal-grid button span { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; }
.cal-grid button.edge span { color: var(--on-brand); background: var(--brand); font-weight: 700; }
.cal-done { width: 100%; margin: .75rem 0 0; padding: .7rem; font: inherit; font-size: 17px; font-weight: 700; color: var(--on-brand); background: var(--brand); border: 0; border-radius: 14px; }

@media (max-width: 640px) {
  .location { text-align: left; }
  /* Three across needs room; below this the row becomes a stack again. */
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .topbar .tabs { margin-inline: 0; }
  .topbar-right { justify-self: start; }
  /* A long place ("Santa Cruz de la Sierra") made the chip wider than the
     phone, and the phone then zoomed the whole page out to fit it: every
     letter of the log shrank. Here the name gives way and ellipsizes. */
  .topbar-right { max-width: 100%; min-width: 0; }
  .location { flex: 1 1 auto; min-width: 0; }
  .location .loc-place { flex: 1 1 auto; min-width: 0; }
  .location .place-line { max-width: 100%; }
  .location .place-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  /* The phone log is the card list, read-only (Tiago, 2026-11-01: on the
     phone he only looks at the log, he does not work on it). The table and
     its column tools stay on wider screens. */
  #stays-table, #hidden-stays { display: none; }
  #log-cards { display: block; }
  /* On the Plan tab the phone shows the log's cards first and the to-do
     after them; wider screens keep the to-do on top (Tiago, 2026-11-02).
     :not([hidden]) so the flex display never overrides the tab's hidden. */
  #tab-trips:not([hidden]) { display: flex; flex-direction: column; gap: var(--gap); margin-block: var(--gap); }
  #trips-log-slot { order: -1; }
  /* Flex margins do not collapse: the gap above spaces the cards instead. */
  #tab-trips > .card, #trips-log-slot > .card { margin-block: 0; }
  /* The log's head: title, filter and (on the Trips tab) the older-entries
     button on one line squeezed the title onto two lines and pushed the
     button off the card. Here the title gets its line, the tools the next. */
  .card:has(#stays-table) .card-head { flex-wrap: wrap; row-gap: .6rem; }
  .card:has(#stays-table) .card-tools { flex: 1 1 100%; flex-wrap: wrap; }
  #log-filter { flex: 1 1 10rem; width: auto; min-width: 0; }
  #older-controls { flex: 1 1 100%; }
  #older-controls button { width: 100%; border-radius: .9rem; }
  /* Residency checklist: buttons, badge and title on one line left the
     title a one-word-wide column (three-button items worst). The title
     takes the first line, the answers and the badge the one below. The
     score box stops sticking: under the app's own sticky stack it covered
     over half the screen while scrolling, and it gets more compact. */
  .tie summary { flex-wrap: wrap; row-gap: .35rem; }
  .tie summary .title { order: -1; flex-basis: 100%; }
  #ties-score { position: static; }
  .score { gap: .75rem; padding: .6rem .8rem; }
  .score-number { font-size: 2rem; }
  .score-text { font-size: .78rem; }
}

/* The in-app chat (public/chat.js). A pill at the bottom right opens a
   panel floating over the right edge of the app, which stays visible beside
   it; on a phone the panel is the whole screen, closed by the chevron at the
   top. Every color is a theme token, so both themes follow on their own. */
.chat-fab {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: .7rem 1.25rem .7rem 1rem;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: var(--on-brand);
  background: var(--brand);
  box-shadow: var(--pop-shadow);
}
.chat-fab:hover { filter: brightness(1.05); }
.chat-fab svg { flex: none; }
.chat-fab[hidden], .chat-panel[hidden] { display: none; }

.chat-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  width: min(25rem, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  background: var(--pop-surface);
  color: var(--pop-text);
  border: 1px solid var(--pop-border);
  border-radius: var(--radius);
  box-shadow: var(--pop-shadow);
  overflow: hidden;
}
.chat-panel button { margin: 0; font: inherit; }
.chat-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem .8rem .7rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.chat-head h2 { margin: 0; flex: 1; font-size: 1.2rem; font-weight: 800; }
.chat-new {
  padding: .25rem .85rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--link);
  background: color-mix(in srgb, var(--brand) 14%, var(--pop-surface));
}
.chat-new:hover { color: var(--link-hover); }
.chat-icon {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  color: var(--pop-muted);
  background: transparent;
}
.chat-icon:hover { color: var(--pop-text); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.chat-back { display: none; }

.chat-thread {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1rem;
}
.chat-empty { margin: auto 0; text-align: center; color: var(--pop-muted); font-size: .92rem; }
.chat-empty p { margin: .3rem 0; }
.chat-example {
  display: inline-block;
  padding: .2rem .8rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--pop-surface));
  color: var(--pop-text);
}
.chat-msg {
  max-width: 85%;
  padding: .5rem .85rem;
  border-radius: 1.1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.chat-msg.user {
  align-self: flex-end;
  color: var(--on-brand);
  background: var(--brand);
  border-bottom-right-radius: .35rem;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: color-mix(in srgb, var(--accent) 13%, var(--pop-surface));
  border-bottom-left-radius: .35rem;
}
.chat-msg.error {
  align-self: stretch;
  max-width: none;
  font-size: .88rem;
  color: var(--danger);
  background: var(--danger-bg);
}
/* Three dots while the first words are on their way. */
.chat-msg.typing { min-width: 3.4rem; min-height: 2.2rem; }
.chat-msg.typing::after {
  content: "";
  display: block;
  width: 1.7rem;
  height: .5rem;
  background: radial-gradient(circle closest-side, var(--pop-muted) 90%, transparent) 0 50% / .5rem .5rem repeat-x;
  animation: chat-dots 1s steps(4) infinite;
}
@keyframes chat-dots { from { width: 0; } to { width: 2rem; } }

.chat-card {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .6rem .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: var(--surface);
  font-size: .92rem;
  font-weight: 600;
}
.chat-card-icon { display: inline-grid; flex: none; color: var(--ok); }
.chat-card-text { flex: 1; min-width: 0; }
.chat-pill {
  flex: none;
  padding: .2rem .8rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--link);
  background: transparent;
  border: 1px solid var(--brand-soft);
}
.chat-pill:hover:not(:disabled) { color: var(--link-hover); border-color: var(--brand); }
.chat-pill:disabled { cursor: default; opacity: .7; }
.chat-action.undone .chat-card-text { color: var(--text-faint); text-decoration: line-through; }
.chat-action.undone .chat-card-icon { color: var(--text-faint); }
.chat-card-error { flex-basis: 100%; font-size: .82rem; font-weight: 500; color: var(--danger); }
.chat-action { flex-wrap: wrap; }

.chat-confirm {
  flex-direction: column;
  align-items: stretch;
  border-color: color-mix(in srgb, var(--danger) 55%, var(--surface));
  background: var(--danger-bg);
}
.chat-confirm .chat-card-row { display: flex; align-items: center; gap: .55rem; }
.chat-confirm .chat-card-icon { color: var(--danger); }
.chat-confirm-buttons { display: flex; justify-content: flex-end; gap: .45rem; }
.chat-confirm .chat-pill { color: var(--text); border-color: var(--border); background: var(--surface); }
.chat-confirm .chat-pill.danger { color: var(--on-brand); border-color: var(--danger); background: var(--danger); }
.chat-confirm .chat-pill.danger:hover:not(:disabled) { color: var(--on-brand); filter: brightness(1.06); }
.chat-confirm.settled { background: var(--surface); border-color: var(--border); }
.chat-confirm.settled .chat-card-icon, .chat-card-state { color: var(--text-faint); }
.chat-card-state { font-size: .82rem; text-align: right; }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .7rem .8rem calc(.8rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 2.6rem;
  max-height: 10rem;
  padding: .55rem .95rem;
  font: inherit;
  line-height: 1.4;
  color: var(--pop-text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 1.3rem;
}
.chat-form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.chat-send {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  color: var(--on-brand);
  background: var(--brand);
}
.chat-send:disabled { cursor: default; opacity: .45; }

/* The row the chat just wrote, for a moment, wherever it is drawn. */
@keyframes chat-flash { from { background-color: color-mix(in srgb, var(--brand) 38%, var(--surface)); } }
#stays-table tr.chat-flash td,
#trip-todos .trip.chat-flash { animation: chat-flash 2.4s ease-out; }
#trip-todos .trip.chat-flash { box-shadow: 0 0 0 2px var(--brand); }
@media (prefers-reduced-motion: reduce) {
  #stays-table tr.chat-flash td, #trip-todos .trip.chat-flash { animation-duration: .01s; }
  .chat-msg.typing::after { animation: none; width: 2rem; }
}

@media (max-width: 640px) {
  .chat-fab { right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .chat-panel {
    inset: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
  }
  .chat-head { padding-left: .5rem; }
  .chat-back { display: inline-grid; }
  .chat-close { display: none; }
  /* 16px keeps iOS from zooming the page into the field. */
  .chat-form textarea { font-size: 16px; }
  body.chat-open { overflow: hidden; }
}
