/* ===========================================================================
   Velmigo design system
   ---------------------------------------------------------------------------
   One file, layered top to bottom: tokens, base, primitives, shell, controls,
   surfaces, overlays, then one section per app surface. Every rule reads its
   colours from the token block, so the whole app re-themes from `[data-theme]`
   alone -- there is no second dark stylesheet and no `!important` in here.

   Class names are the contract with the templates: component classes (.stop,
   .row, .btn-*) are what templates should use, and the older names are kept
   styled so a page that has not been migrated still looks deliberate.
   =========================================================================== */

/* ---------- 1. Tokens ---------- */

:root {
    --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Radii */
    --r-xs: 6px;
    --r-sm: 9px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 999px;

    /* Spacing scale */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.25rem;
    --s-6: 1.5rem;
    --s-8: 2rem;
    --s-10: 2.5rem;
    --s-12: 3rem;

    /* Type scale */
    --t-micro: 0.72rem;
    --t-xs: 0.78rem;
    --t-sm: 0.84rem;
    --t-base: 0.94rem;
    --t-md: 1.05rem;
    --t-lg: 1.2rem;
    --t-xl: 1.5rem;
    --t-2xl: 1.9rem;
    --t-display: clamp(1.85rem, 1.2rem + 2.4vw, 2.9rem);

    /* Motion */
    --dur-instant: 90ms;
    --dur-fast: 150ms;
    --dur: 240ms;
    --dur-slow: 420ms;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --spring: cubic-bezier(0.34, 1.4, 0.64, 1);

    --bar-h: 3.6rem;
    --page-max: 1320px;
}

:root,
[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5fa;
    --bg-tint-1: rgba(79, 70, 229, 0.07);
    --bg-tint-2: rgba(6, 182, 212, 0.06);
    --surface: #ffffff;
    --surface-2: #fafbfe;
    --surface-3: #f1f3f9;
    --surface-glass: rgba(255, 255, 255, 0.82);
    --bar: rgba(255, 255, 255, 0.78);
    --line: #e4e7f0;
    --line-strong: #b0b9cd;
    --ink: #0d1424;
    --ink-2: #2a3348;
    --muted: #5f6880;
    /* Measured against every surface this lands on (white, --surface-2/3, the
       tinted cards, --accent-soft): the old #76829a sat at 3.4-3.9, under the
       4.5 the small text it dresses needs. #606a83 clears it everywhere and is
       still the quieter of the two greys -- though by less than it was, which is
       the price of the hint and placeholder text being readable at all. */
    --faint: #606a83;
    --accent: #4f46e5;
    --accent-ink: #ffffff;
    --accent-soft: #eef0ff;
    --accent-line: #c9cdfb;
    --accent-2: #0891b2;
    --ok: #0f9d63;
    --ok-soft: #e7f7ef;
    --warn: #b45309;
    --warn-soft: #fdf3e3;
    --danger: #d81b47;
    --danger-soft: #fdeef1;
    --grad-accent: linear-gradient(135deg, #5b52ea 0%, #7c5cf0 48%, #12a5c9 100%);
    --grad-brand: linear-gradient(140deg, #6366f1, #8b5cf6 55%, #06b6d4);
    --shadow-1: 0 1px 2px rgba(13, 20, 36, 0.05), 0 1px 1px rgba(13, 20, 36, 0.04);
    --shadow-2: 0 2px 4px rgba(13, 20, 36, 0.05), 0 8px 20px rgba(13, 20, 36, 0.07);
    --shadow-3: 0 10px 24px rgba(13, 20, 36, 0.1), 0 28px 60px rgba(13, 20, 36, 0.12);
    --shadow-accent: 0 6px 18px rgba(79, 70, 229, 0.28);
    --inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);
    --ring-danger: 0 0 0 3px rgba(216, 27, 71, 0.16);
    --map-filter: none;
    --scrim: rgba(13, 20, 36, 0.4);
    /* Route and pin colour: a hue is picked per day in JS, these decide how
       strongly it reads against the basemap (lighter on the dark tiles). */
    --route-s: 72%;
    --route-l: 50%;
    /* Neutral on purpose: a connector between days belongs to no single day. */
    --route-connector: #6f7a91;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #080b14;
    --bg-tint-1: rgba(99, 102, 241, 0.14);
    --bg-tint-2: rgba(6, 182, 212, 0.1);
    --surface: #111726;
    --surface-2: #151c2e;
    --surface-3: #1c2437;
    --surface-glass: rgba(17, 23, 38, 0.78);
    --bar: rgba(11, 15, 26, 0.72);
    --line: #3a4762;
    --line-strong: #54658a;
    --ink: #eef1f9;
    --ink-2: #d3d9ea;
    --muted: #9fa9bf;
    --faint: #98a2b8;
    --accent: #8b8cf9;
    --accent-ink: #0b1020;
    --accent-soft: #1d2246;
    --accent-line: #3b3f7a;
    --accent-2: #35c2d8;
    --ok: #3ecf8e;
    --ok-soft: #10291f;
    --warn: #f0b357;
    --warn-soft: #2a2113;
    --danger: #ff6b8a;
    --danger-soft: #2d1620;
    --grad-accent: linear-gradient(135deg, #6d6ef5 0%, #9a6cf3 48%, #22b8d4 100%);
    --grad-brand: linear-gradient(140deg, #7c7ff7, #a177f5 55%, #22c1de);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.45), 0 10px 24px rgba(0, 0, 0, 0.35);
    --shadow-3: 0 12px 30px rgba(0, 0, 0, 0.55), 0 40px 80px rgba(0, 0, 0, 0.45);
    --shadow-accent: 0 6px 20px rgba(124, 127, 247, 0.35);
    --inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --ring: 0 0 0 3px rgba(139, 140, 249, 0.28);
    --ring-danger: 0 0 0 3px rgba(255, 107, 138, 0.22);
    /* Raster tiles are light-only; inverting them is the standard way to keep a
       dark UI from being blinded by its own map. Labels invert back to legible. */
    --map-filter: invert(1) hue-rotate(185deg) brightness(0.95) contrast(0.92) saturate(0.8);
    --scrim: rgba(3, 6, 14, 0.6);
    --route-s: 76%;
    --route-l: 66%;
    --route-connector: #c2ccdf;
}

/* ---------- 2. Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--t-base);
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 520px at 12% -8%, var(--bg-tint-1), transparent 62%),
        radial-gradient(900px 460px at 92% 4%, var(--bg-tint-2), transparent 58%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.55rem, 1.25rem + 1.1vw, 1.95rem); }
h2 { font-size: var(--t-md); }
h3 { font-size: var(--t-base); letter-spacing: -0.01em; }
h4 { font-size: var(--t-sm); letter-spacing: 0; }

p { margin: 0 0 var(--s-2); }

a { color: var(--accent); text-decoration-color: color-mix(in oklab, var(--accent) 40%, transparent); }
a:hover { text-decoration-color: currentColor; }

img, svg { max-width: 100%; }

/* A long place name or unbroken title must not blow a column sideways.
   `break-word` (not `anywhere`): anywhere also shrinks the box's min-content
   width, which let a flex item collapse and break words mid-syllable. */
.activity-title,
.activity-location,
.activity-notes,
.booking-title,
.booking-notes,
.expense-title,
.trip-card-title,
.member-name,
.transport-route,
.shared-export a { overflow-wrap: break-word; }
.share-url { overflow-wrap: anywhere; }

/* Themed scrollbars: the default track is a bright seam across a dark surface. */
* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border: 3px solid transparent;
    border-radius: var(--r-full);
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }

::selection { background: color-mix(in oklab, var(--accent) 28%, transparent); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 50%;
    top: -3rem;
    transform: translateX(-50%);
    z-index: 3000;
    padding: 0.6rem 1rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: 0.6rem; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--t-sm); }
.micro {
    font-size: var(--t-micro);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--faint);
}
.figure { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 3. Layout ---------- */

.container {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--s-8) var(--s-6) var(--s-12);
}

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.spacer { flex: 1 1 auto; }

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--s-4);
    align-items: start;
}

.section-label {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--t-micro);
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--faint);
}

.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-4) 0; }

/* ---------- 4. App shell ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    height: var(--bar-h);
    padding: 0 var(--s-6);
    background: var(--bar);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid var(--line);
    view-transition-name: app-bar;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: var(--t-md);
    font-weight: 750;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: var(--r-sm);
    background: var(--grad-brand);
    color: #fff;
    font-size: 0.95rem;
    box-shadow: var(--shadow-accent);
}

.tagline {
    color: var(--muted);
    font-size: var(--t-sm);
    padding-left: var(--s-3);
    border-left: 1px solid var(--line);
}

.nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.header-user { display: flex; align-items: center; gap: var(--s-2); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.28rem 0.7rem 0.28rem 0.3rem;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--t-sm);
    font-weight: 500;
    box-shadow: var(--shadow-1);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: var(--r-full);
    background: var(--grad-brand);
    color: #fff;
    font-size: var(--t-xs);
    font-weight: 700;
    text-transform: uppercase;
    flex: 0 0 auto;
}

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -0.45rem; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.logout-form { margin: 0; }

.logout-btn {
    padding: 0.32rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    background: transparent;
    color: var(--muted);
    font-size: var(--t-sm);
    font-weight: 500;
    box-shadow: none;
}
.logout-btn:hover { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 45%, var(--line)); background: var(--danger-soft); }

/* ---------- 5. Buttons ---------- */

button,
input,
select,
textarea { font: inherit; color: inherit; }

input,
select,
textarea,
button {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                background-color var(--dur-fast) var(--ease),
                transform var(--dur-instant) var(--ease);
}

input::placeholder,
textarea::placeholder { color: var(--faint); }

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) { border-color: var(--line-strong); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled { opacity: 0.55; cursor: not-allowed; }

input[aria-invalid="true"],
input:user-invalid { border-color: var(--danger); }
input:user-invalid:focus-visible { box-shadow: var(--ring-danger); }

/* Date fields render a native picker; the colour-scheme token above is what
   makes that picker match the theme, so only its affordance needs styling. */
input[type="date"] { min-width: 9.5rem; }
input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.72;
    cursor: pointer;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator { opacity: 0.9; }

select {
    appearance: none;
    padding-right: 1.9rem;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right 0.85rem center, right 0.55rem center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

button { cursor: pointer; }

.btn,
button.primary,
button.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--r-sm);
    font-size: var(--t-sm);
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    box-shadow: var(--shadow-1);
}

button.primary,
.btn-primary {
    background-image: var(--grad-accent);
    background-color: var(--accent);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-accent);
}
button.primary:hover,
.btn-primary:hover { transform: translateY(-1px); filter: saturate(112%) brightness(1.04); }
button.primary:active,
.btn-primary:active { transform: translateY(0) scale(0.985); }

button.secondary,
.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
}
button.secondary:hover,
.btn-secondary:hover {
    border-color: var(--accent-line);
    color: var(--accent);
    background: var(--surface);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-danger {
    background: var(--danger-soft);
    border-color: color-mix(in oklab, var(--danger) 30%, transparent);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: transparent; }

.btn-sm { padding: 0.34rem 0.65rem; font-size: var(--t-xs); border-radius: var(--r-xs); }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: 1.9rem;
    height: 1.9rem;
    padding: 0.15rem 0.4rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    color: var(--muted);
    font-size: var(--t-sm);
    line-height: 1;
    box-shadow: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Icons: one stroke weight, sized in em so they track the text they sit with. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
    width: 1.05em;
    height: 1.05em;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.14em;
}
.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-btn > .icon { width: 1.15em; height: 1.15em; }
.logout-btn { display: inline-flex; align-items: center; gap: 0.35rem; }
.brand-word { letter-spacing: -0.03em; }

.kbd {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--t-micro);
    font-weight: 600;
}

/* ---------- 6. Fields ---------- */

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > .field-label,
.field-row label { color: var(--muted); font-size: var(--t-xs); font-weight: 600; }

.field-label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-hint { color: var(--faint); font-size: var(--t-xs); }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); }
.field-row label { display: flex; flex-direction: column; gap: 0.3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.form-error { color: var(--danger); font-size: var(--t-sm); font-weight: 500; }

.currency-input { width: 4.5rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.field-row input[name="num_people"] { width: 4.5rem; }
.field-row input[name="budget"] { width: 7rem; }

/* htmx in-flight affordance: dim the element that owns the request. */
.htmx-indicator { opacity: 0; transition: opacity var(--dur) var(--ease); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

button.htmx-request,
.btn.htmx-request { opacity: 0.7; pointer-events: none; }

/* ---------- 7. Surfaces ---------- */

.card,
.surface {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.card::after,
.surface::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: var(--inner-top);
    pointer-events: none;
}

.surface-pad { padding: var(--s-5); }
.surface-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--line);
}
.surface-head h2,
.surface-head h3 { display: flex; align-items: center; gap: 0.5rem; }
.surface-body { padding: var(--s-5); }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}
.section-head h2 { display: flex; align-items: center; gap: 0.5rem; }

.chip,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.24rem 0.62rem;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: var(--t-xs);
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
}

.pill-soft { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-outline { background: transparent; border-color: var(--line); color: var(--muted); }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.12rem 0.45rem;
    border-radius: var(--r-xs);
    background: var(--surface-3);
    color: var(--muted);
    font-size: var(--t-micro);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ---------- 8. Figures ---------- */

.stat { display: flex; flex-direction: column; gap: 0.1rem; }
.stat-figure {
    font-size: var(--t-lg);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: var(--t-micro);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--faint);
}
.stat-ok .stat-figure { color: var(--ok); }
.stat-danger .stat-figure { color: var(--danger); }

/* ---------- 9. Empty states & skeletons ---------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: var(--s-8) var(--s-5);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    background: color-mix(in oklab, var(--surface-2) 70%, transparent);
    color: var(--muted);
    text-align: center;
}
.empty-icon {
    display: grid;
    place-items: center;
    width: 2.9rem;
    height: 2.9rem;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.35rem;
}
.empty-icon .icon { width: 1.4rem; height: 1.4rem; stroke-width: 1.6; }
.activity-add-toggle .icon { width: 1.1em; height: 1.1em; }
.empty-state h3 { color: var(--ink); font-size: var(--t-base); }
.empty-state p { color: var(--muted); font-size: var(--t-sm); max-width: 34ch; }

/* An empty state stands in for a whole collection, so it spans the container
   it lands in rather than taking one grid column or one flex slot. */
.trip-grid > .empty-state,
.days-board > .empty-state,
.activity-list > .empty-state,
.expense-list > .empty-state,
.transport-list > .empty-state,
.booking-list > .empty-state,
.member-list > .empty-state { grid-column: 1 / -1; flex: 1 1 100%; }
.days-board > .empty-state { padding: var(--s-10) var(--s-6); }

.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    min-height: 0.8rem;
}
.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface) 65%, transparent), transparent);
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton-stack .skeleton:nth-child(2) { width: 82%; }
.skeleton-stack .skeleton:nth-child(3) { width: 64%; }

/* ---------- 10. Overlays ---------- */

#progress {
    position: fixed;
    inset: 0 0 auto;
    height: 2px;
    z-index: 4000;
    background: var(--grad-accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
    opacity: 0;
    transition: transform var(--dur) var(--ease), opacity var(--dur-fast) linear;
}
#progress.is-active { opacity: 1; }
#progress.is-done { opacity: 0; transform: scaleX(1); }

.toast-region {
    position: fixed;
    left: 50%;
    bottom: var(--s-5);
    transform: translateX(-50%);
    z-index: 3600;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.5rem;
    width: min(92vw, 26rem);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.65rem 0.75rem 0.65rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-glass);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    box-shadow: var(--shadow-3);
    color: var(--ink);
    font-size: var(--t-sm);
    pointer-events: auto;
    animation: toast-in var(--dur) var(--spring);
}
.toast-icon {
    display: grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    flex: 0 0 auto;
    border-radius: var(--r-full);
    background: var(--ok-soft);
    color: var(--ok);
    font-size: var(--t-xs);
}
.toast-danger .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-warn .toast-icon { background: var(--warn-soft); color: var(--warn); }
.toast-text { flex: 1 1 auto; min-width: 0; }
.toast.is-leaving { animation: toast-out var(--dur-fast) var(--ease) forwards; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.9rem) scale(0.97); }
    to { opacity: 1; transform: none; }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
}

dialog.sheet {
    width: min(92vw, 30rem);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-3);
}
dialog.sheet::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(3px);
}
dialog.sheet[open] { animation: sheet-in var(--dur) var(--ease-out); }
@keyframes sheet-in {
    from { opacity: 0; transform: translateY(-0.6rem) scale(0.97); }
    to { opacity: 1; transform: none; }
}
.sheet-body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); }
.sheet-head { display: flex; align-items: center; gap: 0.6rem; font-weight: 650; }
.sheet-actions { display: flex; justify-content: flex-end; gap: var(--s-2); }
.sheet-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--r-full);
    background: var(--danger-soft);
    color: var(--danger);
}

/* Command palette */
.palette {
    width: min(94vw, 40rem);
    margin: 8vh auto auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--ink);
    box-shadow: var(--shadow-3);
    overflow: hidden;
}
.palette::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.palette[open] { animation: sheet-in var(--dur) var(--ease-out); }
.palette-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--line);
}
.palette-input-row input {
    flex: 1 1 auto;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: var(--t-md);
    box-shadow: none;
}
/* The field is borderless inside the dialog, so its own outline was switched
   off: the row's rule lights up instead, which says where the focus is without
   drawing a box around a line that has no box. */
.palette-input-row:focus-within { border-bottom-color: var(--accent); }
.palette-input-row input:focus-visible { outline: none; box-shadow: none; }
.palette-results { max-height: 52vh; overflow-y: auto; padding: var(--s-2); }
.palette-group { padding: var(--s-2) var(--s-3) 0.25rem; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink);
    font-size: var(--t-base);
    font-weight: 500;
    text-align: left;
    box-shadow: none;
}
.palette-item:hover,
.palette-item.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}
.palette-item .palette-item-title { flex: 1 1 auto; min-width: 0; }
.palette-item .palette-hint { color: var(--faint); font-size: var(--t-xs); }
.palette-empty { padding: var(--s-6) var(--s-5); text-align: center; color: var(--muted); }
.palette-foot {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 0.6rem var(--s-5);
    border-top: 1px solid var(--line);
    color: var(--faint);
    font-size: var(--t-xs);
}

/* Appearance menu and shortcut sheet: both are `dialog.sheet`, so they inherit
   the backdrop, the entrance and the focus trap. */
.menu-sheet { width: min(92vw, 24rem); }
.menu-options { display: flex; flex-direction: column; gap: 0.3rem; }
.menu-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--ink);
    text-align: left;
    box-shadow: none;
}
.menu-option:hover { background: var(--surface-2); border-color: var(--line); }
.menu-option-text { display: flex; flex-direction: column; gap: 0.05rem; flex: 1 1 auto; min-width: 0; }
.menu-option-text strong { font-weight: 600; font-size: var(--t-base); }
.menu-option .menu-check { color: var(--accent); opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.menu-option.is-selected { background: var(--accent-soft); border-color: var(--accent-line); }
.menu-option.is-selected .menu-check { opacity: 1; }

.shortcut-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.shortcut-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: 0.45rem 0.2rem;
    border-bottom: 1px solid var(--line);
    font-size: var(--t-sm);
}
.shortcut-list li:last-child { border-bottom: 0; }
.shortcut-keys { display: inline-flex; gap: 0.2rem; flex: 0 0 auto; }

/* ---------- 11. Trip list ---------- */

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-5);
    flex-wrap: wrap;
    margin-bottom: var(--s-6);
    view-transition-name: hero;
}
.hero h1 {
    font-size: var(--t-display);
    letter-spacing: -0.035em;
    line-height: 1.02;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding-bottom: 0.08em;
}
.hero p { color: var(--muted); margin: var(--s-2) 0 0; max-width: 46ch; }

.trip-create { padding: var(--s-5); margin-bottom: var(--s-6); }
.trip-create .name-input {
    width: 100%;
    margin-bottom: var(--s-4);
    padding: 0.8rem 1rem;
    font-size: var(--t-md);
    font-weight: 550;
    border-radius: var(--r-md);
    background: var(--surface-2);
}
.trip-create .name-input:focus-visible { background: var(--surface); }
.trip-create .field-row button { margin-left: auto; }

/* The row spans the card instead of huddling left: five narrow controls in a
   wide card leave a void between the last field and the primary button. */
.trip-create .field-row label { flex: 1 1 7rem; min-width: 0; }
.trip-create .field-row input { width: 100%; }
.trip-create .name-input { max-width: none; }

.trip-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
    gap: var(--s-4);
}

/* Card accents rotate by position instead of by name hash: the grid reads as a
   spectrum, and a trip keeps its colour as long as it keeps its rank. */
.trip-grid > .trip-card:nth-child(8n + 1) { --card-hue: 243; }
.trip-grid > .trip-card:nth-child(8n + 2) { --card-hue: 190; }
.trip-grid > .trip-card:nth-child(8n + 3) { --card-hue: 288; }
.trip-grid > .trip-card:nth-child(8n + 4) { --card-hue: 32; }
.trip-grid > .trip-card:nth-child(8n + 5) { --card-hue: 158; }
.trip-grid > .trip-card:nth-child(8n + 6) { --card-hue: 348; }
.trip-grid > .trip-card:nth-child(8n + 7) { --card-hue: 214; }
.trip-grid > .trip-card:nth-child(8n + 8) { --card-hue: 268; }

.trip-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-lg);
    background:
        linear-gradient(180deg,
            color-mix(in oklab, hsl(var(--card-hue, 245) 70% 60%) 10%, var(--surface)),
            var(--surface) 42%);
}
.trip-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg,
        hsl(var(--card-hue, 245) 78% 62%),
        hsl(calc(var(--card-hue, 245) + 40) 74% 60%));
}
.trip-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--accent) 35%, var(--line));
    box-shadow: var(--shadow-2);
}
.trip-card:hover .trip-card-delete { opacity: 1; }

.trip-card-link {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: var(--s-5) var(--s-5) var(--s-4);
    min-height: 8.5rem;
    color: inherit;
    text-decoration: none;
}
.trip-card-title {
    font-size: var(--t-md);
    font-weight: 650;
    letter-spacing: -0.02em;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}
.trip-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
}
.trip-card-count {
    align-self: flex-start;
    padding: 0.15rem 0.5rem;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--muted);
    font-size: var(--t-micro);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.trip-card-delete {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease);
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
}
.trip-card-delete:focus-visible { opacity: 1; }

.trip-more { display: flex; justify-content: center; margin-top: var(--s-5); }
.load-more {
    padding: 0.55rem 1.4rem;
    border-radius: var(--r-full);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-weight: 600;
    font-size: var(--t-sm);
    box-shadow: var(--shadow-1);
}
.load-more:hover { border-color: var(--accent-line); color: var(--accent); }
.load-more.htmx-request { opacity: 0.6; }

/* ---------- 12. Trip header, budget, map ---------- */

.breadcrumb { margin-bottom: var(--s-4); font-size: var(--t-sm); }
.breadcrumb a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 550;
}
.breadcrumb a:hover { color: var(--accent); }

.trip-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-5);
    padding: var(--s-5) var(--s-6);
    margin-bottom: var(--s-4);
}
.trip-header-main { min-width: 0; }
.trip-header h1 { font-size: var(--t-2xl); }
.trip-header-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--s-3);
    min-width: min(100%, 260px);
}
.trip-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: var(--s-3); }

.budget-track { width: 100%; }
.budget-numbers {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-2);
    font-size: var(--t-xs);
    color: var(--muted);
    margin-bottom: 0.4rem;
}
.budget-numbers strong {
    color: var(--ink);
    font-size: var(--t-base);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.budget-bar {
    height: 8px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(13, 20, 36, 0.08);
}
.budget-fill {
    height: 100%;
    width: 0;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--ok), #34d399);
    transition: width var(--dur-slow) var(--ease-out), background var(--dur) var(--ease);
}
.budget-fill.over { background: linear-gradient(90deg, var(--danger), #fb7185); }

.map-panel {
    height: 380px;
    margin-bottom: var(--s-5);
    overflow: hidden;
    z-index: 1;
    border-radius: var(--r-lg);
}
.map-panel .leaflet-tile-pane { filter: var(--map-filter); }
.map-panel .leaflet-container,
.map-panel.leaflet-container { background: var(--surface-3); font-family: var(--font-sans); }
.map-panel .leaflet-bar,
.map-panel .leaflet-popup-content-wrapper,
.map-panel .leaflet-popup-tip {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: var(--shadow-2);
}
.map-panel .leaflet-popup-content-wrapper { border-radius: var(--r-md); }
.map-panel .leaflet-control-zoom a { color: var(--ink); background: var(--surface); border-color: var(--line); }
.map-panel .leaflet-control-zoom a:hover { background: var(--surface-3); }
.map-panel .leaflet-control-attribution {
    background: var(--surface-glass);
    color: var(--muted);
    border-radius: var(--r-xs) 0 0 0;
    border: 1px solid var(--line);
    border-right: 0;
    border-bottom: 0;
}
.map-panel .leaflet-control-attribution a { color: var(--accent); }
[data-theme="dark"] .map-panel .leaflet-control-attribution { background: var(--surface); }

/* Day-coloured thumbtack pins, one per stop, numbered like the board. */
.map-pin {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: var(--r-full) var(--r-full) var(--r-full) 2px;
    transform: rotate(-45deg);
    background: hsl(var(--pin-hue, 245) var(--route-s) var(--route-l));
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(13, 20, 36, 0.35);
    transition: transform var(--dur-fast) var(--spring), box-shadow var(--dur-fast) var(--ease);
}
.map-pin > span {
    transform: rotate(45deg);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.map-pin.placeholder { visibility: hidden; }
.leaflet-marker-icon.is-linked .map-pin {
    transform: rotate(-45deg) scale(1.34);
    box-shadow: 0 6px 16px rgba(13, 20, 36, 0.45);
}

/* Day legend: the map and the board share one hue per day, and this is what
   says which is which. */
.map-legend {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-glass);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    box-shadow: var(--shadow-1);
    color: var(--ink-2);
    font-size: var(--t-xs);
    font-weight: 600;
}
.map-legend-title {
    font-size: var(--t-micro);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--faint);
    font-weight: 700;
}
.map-legend-item { display: flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.map-legend-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: var(--r-full);
    background: hsl(var(--legend-hue, 245) var(--route-s) var(--route-l));
    flex: 0 0 auto;
}
/* The between-day leg, drawn solid and cased while a day's own route is dashed:
   the legend has to explain the second kind of line on the map. */
.map-legend-dash {
    width: 1.15rem;
    height: 3px;
    flex: 0 0 auto;
    border-radius: var(--r-full);
    background: var(--route-connector);
    box-shadow: 0 0 0 1.5px var(--surface);
}

.board-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-5);
    padding: var(--s-3);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-glass);
    backdrop-filter: blur(10px);
}
.board-actions .inline-form { margin: 0; }
.board-actions .spacer { flex: 1 1 auto; }

/* ---------- 13. Board ---------- */

/* Day tabs: built by app.js only when the board is a carousel, so the board
   itself never depends on them. Sticky under the app bar. */
.day-tabs {
    position: sticky;
    top: calc(var(--bar-h) - 1px);
    z-index: 800;
    display: flex;
    gap: 0.35rem;
    margin: 0 calc(-1 * var(--s-4)) var(--s-3);
    padding: 0.5rem var(--s-4);
    overflow-x: auto;
    background: var(--bar);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    background: var(--surface);
    color: var(--muted);
    font-size: var(--t-xs);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: none;
}
.day-tab:hover { color: var(--ink); border-color: var(--line-strong); }
.day-tab.is-active {
    color: var(--ink);
    border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
    background: var(--accent-soft);
}
.day-tab-count {
    padding: 0 0.3rem;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--faint);
    font-size: var(--t-micro);
    font-variant-numeric: tabular-nums;
}
.day-tab.is-active .day-tab-count { background: color-mix(in oklab, var(--accent) 18%, transparent); color: var(--accent); }

.days-board {
    display: flex;
    gap: var(--s-4);
    align-items: stretch;
    overflow-x: auto;
    padding-bottom: var(--s-5);
    scroll-snap-type: x proximity;
}

.day-column {
    /* Grows to fill a wide screen, stops at a readable measure, and refuses to
       shrink below a usable column -- past that the board scrolls. */
    flex: 1 1 320px;
    min-width: 300px;
    max-width: 460px;
    padding: var(--s-4);
    scroll-snap-align: start;
    scroll-margin-top: calc(var(--bar-h) + 3.25rem);
    /* --day-color mirrors --day-hue for color-mix, which needs a colour rather
       than the bare number the hue-driven rules use. */
    --day-color: hsl(var(--day-hue, 245) 68% 60%);
    background: color-mix(in oklab, var(--surface) 82%, var(--day-color) 18%);
}
.day-column.is-drop-target,
.activity-list.sortable-drag-over {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
    padding-bottom: var(--s-3);
    border-bottom: 2px solid color-mix(in oklab, hsl(var(--day-hue, 245) 68% 60%) 40%, var(--line));
}
.day-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 650; }
.day-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: var(--r-full);
    background: hsl(var(--day-hue, 245) 72% 58%);
    box-shadow: 0 0 0 3px color-mix(in oklab, hsl(var(--day-hue, 245) 72% 58%) 22%, transparent);
    flex: 0 0 auto;
}
.day-date { color: var(--muted); font-weight: 500; font-size: var(--t-xs); }
.day-actions { display: flex; gap: 0.1rem; opacity: 0.6; transition: opacity var(--dur-fast) var(--ease); }
.day-column:hover .day-actions,
.day-column:focus-within .day-actions { opacity: 1; }
.day-weather {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--t-xs);
    font-weight: 600;
    color: var(--accent-2);
    white-space: nowrap;
}
.day-count { font-size: var(--t-micro); color: var(--faint); font-weight: 600; }

.activity-list {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: var(--s-3);
    min-height: 2.5rem;
    border: 1px dashed transparent;
    border-radius: var(--r-md);
    counter-reset: stop;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

/* Stops are numbered the way the map pins are, so a pin and its card can be
   matched by eye instead of by colour alone. */
.activity-card::before {
    counter-increment: stop;
    content: counter(stop);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 1.2rem;
    height: 1.2rem;
    margin-top: 0.05rem;
    border-radius: var(--r-full);
    background: color-mix(in oklab, hsl(var(--day-hue, 245) 68% 60%) 16%, transparent);
    color: color-mix(in oklab, hsl(var(--day-hue, 245) 68% 60%) 72%, var(--ink));
    font-size: var(--t-micro);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Stop cards: a quiet rail on the left carries the day colour and the order. */
.activity-card {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    padding: 0.7rem 0.75rem 0.7rem 0.6rem;
    border: 1px solid var(--line);
    border-left: 3px solid hsl(var(--day-hue, 245) 68% 60%);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    animation: stop-in var(--dur) var(--ease-out) both;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}
.activity-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in oklab, hsl(var(--day-hue, 245) 68% 60%) 45%, var(--line));
    box-shadow: var(--shadow-2);
}
.activity-card.is-linked {
    border-color: var(--accent);
    box-shadow: var(--shadow-2), var(--ring);
}
.activity-card.is-flash { animation: flash-stop 1.1s var(--ease-out); }

@keyframes stop-in {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to { opacity: 1; transform: none; }
}
@keyframes flash-stop {
    0% { background: var(--accent-soft); }
    100% { background: var(--surface); }
}

.drag-handle {
    cursor: grab;
    padding: 0.1rem 0.15rem;
    color: var(--faint);
    user-select: none;
    touch-action: none;
    opacity: 0.55;
    transition: color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.activity-card:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost {
    opacity: 0.45;
    border-style: dashed;
    background: var(--accent-soft);
}
.sortable-chosen { cursor: grabbing; box-shadow: var(--shadow-3); }
.sortable-drag { transform: rotate(1.5deg); }

.activity-body { flex: 1 1 auto; min-width: 0; }
.activity-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.45rem; }
.activity-title { font-weight: 600; letter-spacing: -0.01em; }
.activity-time {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.05rem 0.4rem;
    border-radius: var(--r-xs);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--t-micro);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.cost-chip {
    margin-left: auto;
    padding: 0.1rem 0.45rem;
    border-radius: var(--r-full);
    background: var(--ok-soft);
    color: var(--ok);
    font-size: var(--t-micro);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.activity-location {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.2rem;
    color: var(--accent-2);
    font-size: var(--t-xs);
    font-weight: 600;
}
.activity-notes { margin-top: 0.25rem; color: var(--muted); font-size: var(--t-xs); }
.activity-actions { display: flex; gap: 0.05rem; opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.activity-card:hover .activity-actions,
.activity-card:focus-within .activity-actions { opacity: 1; }
.activity-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    margin-top: 0.4rem;
}
.activity-card.editing {
    flex-direction: column;
    align-items: stretch;
    background: var(--surface-2);
    border-left-color: var(--accent);
    gap: var(--s-2);
    animation: none;
}
.activity-card.editing .form-actions { display: flex; gap: var(--s-2); }

.activity-add-form { display: flex; flex-direction: column; gap: var(--s-2); }
/* Collapsing is opt-in from JS: without it the form stays visible, so a script
   failure degrades to the plain form rather than to nothing at all. Any add-form
   can opt in with data-collapsible, not just the board's. */
form[data-collapsible].is-collapsed { display: none; }
.activity-add-form.is-collapsed { display: none; }
.activity-add-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.55rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--muted);
    font-size: var(--t-sm);
    font-weight: 600;
    box-shadow: none;
}
.activity-add-toggle:hover {
    border-style: solid;
    border-color: var(--accent-line);
    color: var(--accent);
    background: var(--accent-soft);
}
.geo-row { display: flex; gap: 0.35rem; }
.geo-row .geo-input { flex: 1 1 auto; }
.geo-find { flex: 0 0 auto; }
.geo-find.found { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, var(--line)); }

/* ---------- 14. Logistics: expenses, transport, bookings, members ---------- */

.logistics-grid {
    display: grid;
    /* Two panels per row on a laptop: with four panels a three-column grid left
       one orphaned on a second row, and every panel was too narrow for a row of
       figures to sit beside its label. */
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: var(--s-4);
    align-items: start;
    margin-top: var(--s-5);
}
.logistics-grid > * { min-width: 0; }

.expenses-card,
.transport-card,
.bookings-card,
.members-card { padding: var(--s-4) var(--s-5) var(--s-5); }
.expenses-card { margin-top: 0; }

/* Panel heading: a quiet label over a hairline rule, so each panel reads as a
   section rather than as loose content inside a box. */
.logistics-grid .section-head {
    align-items: baseline;
    padding-bottom: var(--s-3);
    margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--line);
}
.logistics-grid .section-head h2 { font-size: var(--t-md); }
.logistics-grid .section-head > .muted,
.logistics-grid .section-head > span:not(.pill):not(.chip) {
    font-size: var(--t-xs);
    color: var(--faint);
}

.expense-row,
.booking-row,
.transport-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    margin-bottom: 0.4rem;
    transition: background-color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}
.expense-row:hover,
.booking-row:hover,
.transport-row:hover {
    background: var(--surface);
    border-color: var(--line-strong);
    transform: translateX(2px);
}
.booking-row,
.transport-row { align-items: flex-start; }

/* A flex child with no minimum collapses to one character per line once its
   siblings stop shrinking, which is what a title next to a date, a payer, an
   amount and two buttons does. */
.expense-row .expense-title { flex: 1 1 11rem; min-width: 8rem; font-weight: 550; }
.expense-figures,
.transport-figures { margin-left: auto; }
.expense-figures,
.booking-figures,
.transport-figures {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
}
.expense-add-form { margin-top: var(--s-3); }

.row-actions { display: flex; gap: 0.05rem; opacity: 0.5; transition: opacity var(--dur-fast) var(--ease); }
.expense-row:hover .row-actions,
.booking-row:hover .row-actions,
.transport-row:hover .row-actions,
.expense-row:focus-within .row-actions,
.booking-row:focus-within .row-actions,
.transport-row:focus-within .row-actions { opacity: 1; }

.expense-list,
.booking-list,
.transport-list { display: flex; flex-direction: column; }

.transport-card .transport-list { display: flex; flex-direction: column; gap: 0.3rem; }
.transport-group {
    margin: var(--s-3) 0 0.35rem;
    font-size: var(--t-micro);
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--faint);
}
.transport-route {
    flex: 1 1 12rem;
    min-width: 9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.transport-add-form { margin-top: var(--s-3); }
.transport-form .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-3); }

.estimate-buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.estimate-buttons .btn { flex: 1 1 11rem; justify-content: flex-start; }
.day-estimate .estimate-panel {
    margin-top: var(--s-2);
    padding: 0.7rem 0.85rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: var(--t-sm);
}
.day-estimate .estimate-legs { margin: var(--s-2) 0; padding-left: 1.15rem; color: var(--muted); }

.booking-main { flex: 1 1 14rem; min-width: 11rem; }
.booking-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; }
.booking-conf {
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface-3);
    font-family: var(--font-mono);
    font-size: var(--t-xs);
    letter-spacing: 0.04em;
}
.booking-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.8rem;
    margin-top: 0.35rem;
    font-size: var(--t-xs);
    color: var(--muted);
}
.booking-meta .icon { width: 0.95em; height: 0.95em; opacity: 0.8; }
.booking-provider { font-weight: 600; }
.booking-link { color: var(--muted); text-decoration: none; }
.booking-link:hover { color: var(--accent); }
.booking-notes { margin-top: 0.3rem; font-size: var(--t-xs); }
.booking-actions { display: flex; gap: 0.3rem; }
.booking-form { display: grid; gap: var(--s-3); margin-top: var(--s-3); }
.booking-form.editing { display: grid; }
.booking-form .form-actions { display: flex; gap: var(--s-2); }

.members-card .member-list,
.balances-inner ul,
.balance-list { list-style: none; margin: 0; padding: 0; }

.member-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--r-md);
    transition: background-color var(--dur-fast) var(--ease);
}
.member-item:hover { background: var(--surface-2); }
.member-item .member-name { flex: 1 1 auto; min-width: 0; font-weight: 550; }
.member-role { font-size: var(--t-xs); color: var(--muted); }
.member-role-form select { padding: 0.25rem 1.7rem 0.25rem 0.5rem; font-size: var(--t-xs); }
.invite-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: var(--s-3);
    align-items: end;
    margin-top: var(--s-3);
}
.invite-form .field { min-width: 0; }
@media (max-width: 640px) {
    .invite-form { grid-template-columns: 1fr; }
}

.vote-buttons { display: inline-flex; gap: 0.2rem; }
.vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-full);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: var(--t-xs);
    font-weight: 600;
    box-shadow: none;
}
.vote-btn:hover { border-color: var(--accent-line); color: var(--accent); }
.vote-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}
.vote-count { font-variant-numeric: tabular-nums; }

#balances { margin-top: var(--s-3); }
.balances-head { margin: var(--s-4) 0 var(--s-2); font-size: var(--t-xs); }
.balance-list { display: flex; flex-direction: column; gap: 0.15rem; }
.balance-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem var(--s-3);
    padding: 0.45rem 0.5rem;
    border-radius: var(--r-sm);
}
.balance-row .member-name { flex: 0 0 auto; font-weight: 600; }
.balance-row .balance-meta { flex: 1 1 auto; min-width: 8rem; font-variant-numeric: tabular-nums; }
.balance-row .balance-net { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.balance-verb {
    font-size: var(--t-micro);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.balance-up { color: var(--ok); }
.balance-down { color: var(--danger); }

.balance-expenses { margin-top: var(--s-2); }
.balance-expense { padding: 0.35rem 0.5rem; border-radius: var(--r-sm); }
.balance-expense:hover { background: var(--surface-2); }
.balance-expense-row { display: flex; align-items: center; gap: 0.5rem; }
.balance-expense-row .expense-title { flex: 1 1 auto; }

.share-list { list-style: none; margin: var(--s-2) 0 0; padding: 0; }
.share-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--r-sm);
    font-size: var(--t-sm);
}
.share-item:hover { background: var(--surface-2); }
.share-item.settled > span:first-child { text-decoration: line-through; color: var(--muted); }

.share-link-row { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.share-url {
    width: min(300px, 52vw);
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--t-xs);
}
.share-on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.small-btn {
    padding: 0.28rem 0.6rem;
    border-radius: var(--r-xs);
    font-size: var(--t-xs);
}

/* Anchors acting as buttons: `button.secondary` cannot style an <a>, so the
   button look is repeated here for link-shaped actions. */
.export-link,
a.secondary,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--t-sm);
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
                transform var(--dur-instant) var(--ease);
}
.export-link:hover,
a.secondary:hover,
a.btn:hover { border-color: var(--accent-line); color: var(--accent); transform: translateY(-1px); }

.shared-export { margin: var(--s-2) 0 var(--s-5); }
.shared-export a { font-size: var(--t-sm); font-weight: 600; }

.leave-trip { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 28%, var(--line)); }
.leave-trip:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.ai-plan-form { margin: 0; }
.booking-add-form { margin-top: var(--s-3); }
.transport-edit-form { width: 100%; margin-top: var(--s-2); }
.booking-title { font-weight: 650; letter-spacing: -0.01em; }
.rejected { color: var(--warn); }
.estimate-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-2);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.empty { color: var(--muted); font-size: var(--t-sm); }

/* ---------- 15. AI panel ---------- */

.assistant-panel {
    margin-top: var(--s-4);
    padding: var(--s-4) var(--s-5);
}
.assistant-panel .inline-form { margin-bottom: var(--s-2); }
.assistant-summary {
    margin-top: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--accent-line);
    border-radius: var(--r-md);
    background: var(--accent-soft);
    color: var(--ink-2);
    font-size: var(--t-sm);
}
.assistant-reply {
    margin-top: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: var(--t-sm);
    line-height: 1.55;
}
.assistant-pending {
    margin-top: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
    border-radius: var(--r-md);
    background: var(--warn-soft);
    font-size: var(--t-sm);
}
.assistant-pending .form-actions { margin-top: var(--s-2); }

/* The assistant's own replies; `.ai-result` scopes the applied (ok) and
   rejected (warn) result lines. The itinerary-looking classes in print.html
   are that document's own, and it styles itself. */
.ai-result { margin-top: var(--s-4); }
.ai-result .applied { color: var(--ok); font-size: var(--t-xs); font-weight: 600; }
.ai-result .pending { color: var(--warn); font-size: var(--t-xs); font-weight: 600; }

/* The share panel's warning, in the same clothes as the assistant's confirm
   block: both tell the traveller what they are about to make public or apply. */
.share-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin: var(--s-3) 0;
    padding: var(--s-3) var(--s-4);
    border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
    border-radius: var(--r-md);
    background: var(--warn-soft);
    color: var(--ink);
    font-size: var(--t-sm);
}
.share-warning .icon { color: var(--warn); flex: 0 0 auto; margin-top: 0.1rem; }

/* ---------- 16. Auth ---------- */

.login-wrap {
    display: grid;
    place-items: center;
    min-height: 62vh;
    padding: var(--s-5);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: var(--s-8);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}
.login-card h1 { font-size: var(--t-xl); letter-spacing: -0.03em; }
.login-card p { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.login-card input { padding: 0.65rem 0.8rem; }
.login-wrap .auth-alt { text-align: center; font-size: var(--t-sm); color: var(--muted); }

/* ---------- 17. PWA + error banner ---------- */

.offline-badge {
    position: fixed;
    left: 50%;
    bottom: var(--s-4);
    transform: translateX(-50%);
    z-index: 3500;
    padding: 0.45rem 0.9rem;
    border-radius: var(--r-full);
    background: var(--ink);
    color: var(--bg);
    font-size: var(--t-xs);
    font-weight: 600;
    box-shadow: var(--shadow-3);
    animation: toast-in var(--dur) var(--ease-out);
}
.offline-badge.is-offline { background: var(--warn); color: #fff; }

/* Filled by app.js for htmx responses that carry a failure status, which htmx
   itself never swaps into the page. */
.flash-banner {
    position: fixed;
    top: calc(var(--bar-h) + 0.75rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 3700;
    max-width: min(92vw, 32rem);
    padding: 0.6rem 1rem;
    border: 1px solid color-mix(in oklab, var(--danger) 35%, transparent);
    border-radius: var(--r-md);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: var(--t-sm);
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    box-shadow: var(--shadow-3);
    animation: toast-in var(--dur) var(--ease-out);
}

/* ---------- 18. Print ---------- */

@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        background-image: none !important;
    }
    .site-header,
    .board-actions,
    .nav-actions,
    .toast-region,
    #progress,
    form,
    button,
    .icon-btn,
    .map-panel { display: none !important; }
    .card,
    .surface,
    .activity-card,
    .day-column {
        box-shadow: none !important;
        background: #fff !important;
        border: 1px solid #999;
        break-inside: avoid;
    }
    .container { max-width: none; padding: 0; }
    a { color: #000; text-decoration: none; }
}

/* ---------- 19. Motion, view transitions, responsive ---------- */

@view-transition { navigation: auto; }

::view-transition-old(root) { animation: vt-out 160ms var(--ease) both; }
::view-transition-new(root) { animation: vt-in 260ms var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-0.25rem); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(0.5rem); } }

/* Theme flip: the whole page cross-fades instead of snapping. */
[data-theme-transition] ::view-transition-old(root) { animation: none; }
[data-theme-transition] ::view-transition-new(root) { animation: vt-in 220ms var(--ease-out) both; }

@media (max-width: 1200px) {
    :root { --page-max: 100%; }
    .container { padding: var(--s-6) var(--s-5) var(--s-10); }
    .day-column { flex: 1 1 300px; }
}

/* Tablet and below: the board becomes a snap carousel and gains day tabs (built
   in app.js, so a script-free page still scrolls the raw board). */
@media (max-width: 1024px) {
    .container { padding: var(--s-5) var(--s-5) var(--s-10); }
    .days-board {
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--s-4);
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    .day-column {
        flex: 0 0 min(74vw, 360px);
        scroll-snap-align: start;
    }
    .map-panel { height: 300px; }
    .trip-header-side { align-items: stretch; min-width: 100%; }
    .budget-track { max-width: none; }
}

@media (max-width: 860px) {
    .site-header { padding: 0 var(--s-4); }
    .tagline { display: none; }
    .trip-header { padding: var(--s-4); }
    .grid-two,
    .logistics-grid { grid-template-columns: 1fr; }
    .map-panel { height: 280px; }
    .hero { margin-bottom: var(--s-5); }
    .surface-head,
    .surface-body { padding: var(--s-4); }
    .expenses-card,
    .transport-card,
    .bookings-card,
    .members-card { border-radius: var(--r-md); }
}

/* Phone: stacked layout, comfortable rows, and controls that survive a thumb. */
@media (max-width: 640px) {
    .container { padding: var(--s-4) var(--s-4) var(--s-10); }
    .trip-grid { grid-template-columns: 1fr; }
    .toast-region { width: calc(100vw - 2 * var(--s-4)); }
    .nav-actions .nav-label { display: none; }
    .day-column { flex: 0 0 86vw; padding: var(--s-3); }
    /* The header is the map to the trip, not the trip itself: compress it so the
       itinerary reaches the first screen. */
    .trip-header { padding: var(--s-3) var(--s-4); gap: var(--s-3); }
    .trip-header h1 { font-size: var(--t-xl); }
    .trip-chips { margin-top: var(--s-2); gap: 0.3rem; }
    .trip-chips .chip { padding: 0.18rem 0.5rem; font-size: var(--t-micro); }
    /* The budget stats below say this already; two of them is clutter. */
    .trip-chips .chip:has(use[href="#i-wallet"]) { display: none; }
    .trip-header-side { flex-direction: row; flex-wrap: wrap; gap: var(--s-2); }
    .trip-header-side > * { flex: 1 1 auto; }
    .budget-track { min-width: 0; }
    .budget-numbers { font-size: var(--t-micro); gap: var(--s-2); }
    .stat-figure { font-size: var(--t-base); }
    /* Toolbar: two controls per row instead of four stacked ones. */
    .board-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: var(--s-2);
        gap: 0.4rem;
    }
    .board-actions > .inline-form,
    .board-actions > #assistant-panel { grid-column: 1 / -1; }
    .board-actions .inline-form { margin: 0; }
    .board-actions .btn,
    .board-actions button { width: 100%; }
    /* Day navigation sits above the toolbar on a phone, so the tabs and the
       stops are what the first screen shows. Ordering only works because the
       container is a flex column here. */
    main.container:has(#days) { display: flex; flex-direction: column; }
    main.container:has(#days) > .breadcrumb { order: 0; }
    main.container:has(#days) > .trip-header { order: 1; }
    main.container:has(#days) > .day-tabs { order: 2; }
    /* Content first: the stops are what a phone user opens this page for, so the
       toolbar follows the board rather than leading it. */
    main.container:has(#days) > #days { order: 3; }
    main.container:has(#days) > .board-actions { order: 4; }
    main.container:has(#days) > #map { order: 5; margin: var(--s-5) 0 0; }
    main.container:has(#days) > .logistics-grid { order: 6; }
    .map-panel { height: 240px; }
    .hero h1 { font-size: var(--t-xl); }
    .hero p { font-size: var(--t-sm); }
    /* 16px keeps iOS from zooming the layout when a field takes focus. */
    input,
    select,
    textarea { font-size: 16px; }
    .trip-create .field-row label { flex: 1 1 100%; }
    .activity-title { font-size: 0.98rem; }
    /* Votes and row actions drop under the stop instead of squeezing its text
       into a one-word-per-line column. */
    .activity-card { flex-wrap: wrap; }
    .activity-footer { flex: 1 1 100%; }
    /* The date field needs the whole row next to its button, or the native
       placeholder is wider than the control. */
    .board-actions input[type="date"] { flex: 1 1 auto; min-width: 0; }
    /* The legend shrinks to bare swatches: as a stacked list it covered the pins
       on a 240px-tall map. */
    .map-legend {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        padding: 0.3rem 0.45rem;
        font-size: var(--t-micro);
    }
    .map-legend-title { display: none; }
}

@media (max-width: 420px) {
    .brand-word { display: none; }
    .user-chip { padding-right: 0.3rem; }
    .day-column { flex: 0 0 90vw; }
    .trip-card-link { min-height: 0; }
    .day-tabs { top: calc(var(--bar-h) - 1px); }
}

/* Landscape phones: vertical space is the scarce one. */
@media (max-height: 560px) and (orientation: landscape) {
    .map-panel { height: 200px; }
    .hero { margin-bottom: var(--s-4); }
    .hero h1 { font-size: var(--t-xl); }
}

/* Touch: nothing may depend on hover. Row and card actions are always visible,
   every icon control gets a thumb-sized box, and keyboard-only affordances are
   dropped rather than crowding the bar. */
@media (pointer: coarse) {
    .icon-btn { min-width: 2.5rem; height: 2.5rem; font-size: 1rem; }
    .drag-handle { padding: 0.4rem 0.35rem; opacity: 1; }
    .activity-actions,
    .row-actions,
    .day-actions,
    .trip-card-delete { opacity: 1; }
    .activity-card:hover { transform: none; }
    .days-board { scroll-snap-type: x mandatory; }
    #shortcuts-open { display: none; }
    #palette-open .kbd { display: none; }
    .map-panel .leaflet-control-zoom a {
        width: 2.6rem;
        height: 2.6rem;
        line-height: 2.6rem;
        font-size: 1.3rem;
    }
}

/* PWA installed on a notched device: keep the chrome out of the cutouts. */
@supports (padding: max(0px)) {
    .site-header {
        padding-left: max(var(--s-5), env(safe-area-inset-left));
        padding-right: max(var(--s-5), env(safe-area-inset-right));
    }
    .container {
        padding-left: max(var(--s-4), env(safe-area-inset-left));
        padding-right: max(var(--s-4), env(safe-area-inset-right));
        padding-bottom: max(var(--s-10), env(safe-area-inset-bottom));
    }
    .toast-region { bottom: max(var(--s-5), env(safe-area-inset-bottom)); }
}

/* Requested contrast and transparency preferences, honoured rather than ignored. */
@media (prefers-contrast: more) {
    :root,
    [data-theme="light"] { --line: #b6bece; --line-strong: #8d97ab; --muted: #4b5563; --faint: #4b5563; }
    [data-theme="dark"] { --line: #47536f; --line-strong: #64708d; --muted: #c2cadb; --faint: #c2cadb; }
    .card,
    .surface,
    .activity-card,
    .day-column { border-width: 2px; }
    .btn { text-decoration: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .site-header,
    .board-actions,
    .palette,
    .toast,
    .map-legend { backdrop-filter: none; -webkit-backdrop-filter: none; }
    .site-header { background: var(--surface); }
    .palette,
    .toast,
    .map-legend { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    @view-transition { navigation: none; }
}
