/* Family Trips v3. All styling lives in this file: the CSP has no 'unsafe-inline'.
   Per-trip geometry is set from JS through CSSOM, never as attribute markup.
   Visual language follows v2.5 (colours, 8 px/day stream, label gutter, NOW line). */

:root {
    --bg: #eef2f5;
    --surface: #ffffff;
    --text: #333333;
    --text-muted: #666666;
    --line: #e1e4e8;
    --ok: #28a745;
    --bad: #c0392b;
    --now: #e74c3c;
    --blue: #007bff;
    --blue-rgb: 0, 123, 255;
    --green-rgb: 40, 167, 69;
    --purple-rgb: 155, 89, 182;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ---- Buttons ---- */
.btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #f0f2f5;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #0056b3; }
.btn-logout { color: var(--now); border-color: rgba(231, 76, 60, 0.3); background: rgba(231, 76, 60, 0.05); }

/* ---- Top bar ---- */
.topbar { padding: 5px 16px; border-bottom: 1px solid rgba(0, 0, 0, 0.05); }
.topbar-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 15px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.topbar-user:hover .topbar-name { color: var(--blue); }
.topbar-text { display: flex; flex-direction: column; min-width: 0; }
.topbar-name { font-size: 14px; font-weight: 700; }
.topbar-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Timeline ---- */
.timeline-section { flex: 1; min-height: 0; padding: 5px 16px 10px; display: flex; flex-direction: column; }
.status { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: #fceae9; color: var(--bad); font-size: 14px; }
.scroller {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}
.loading { margin: 0; padding: 40px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }
.stream {
    position: relative;
    width: 100%;
    background: repeating-linear-gradient(0deg, transparent, transparent 55px, #f4f6f8 56px);
}

.month-row {
    position: absolute;
    left: 0;
    width: 100%;
    border-bottom: 1px solid var(--line);
    pointer-events: none;
}
.month-row.current { background-color: rgba(var(--blue-rgb), 0.03); }
.month-label {
    position: absolute;
    left: 0;
    top: 0;
    width: 15%;
    height: 100%;
    margin: 0;
    padding: 10px 12px 0 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    border: 0;
    border-right: 1px solid #f0f2f5;
    background: none;
    color: #aab7b8;
    font: inherit;
    pointer-events: auto;
    cursor: pointer;
}
.month-label:hover .month-name, .month-label:focus-visible .month-name { color: var(--blue); }
.month-label:hover .month-add, .month-label:focus-visible .month-add { background: var(--blue); transform: scale(1.1); }
.month-name { text-transform: uppercase; letter-spacing: 1.5px; font-size: 12px; font-weight: 800; color: #34495e; }
.month-year { margin-top: 2px; font-size: 10px; font-weight: 600; letter-spacing: 0.5px; color: #95a5a6; }
.month-add {
    margin-top: 8px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--line);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* Trip blocks: colour from color-*, opacity from clarity-* (v2.5: 1 / 0.8 / 0.4). */
.trip {
    --rgb: var(--blue-rgb);
    --alpha: 1;
    position: absolute;
    /* A <button> centres its content vertically; v2.5 trips read from the top. */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    margin: 0;
    padding: 4px 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background-color: rgba(var(--rgb), var(--alpha));
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    container: trip / inline-size; /* lets the narrow-block rules below react to the block's own width */
}
.trip:hover, .trip:focus-visible { transform: scale(1.02); z-index: 100 !important; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); }
.trip:focus-visible { outline: 2px solid #34495e; outline-offset: 1px; }
.color-blue   { --rgb: var(--blue-rgb); }
.color-green  { --rgb: var(--green-rgb); }
.color-purple { --rgb: var(--purple-rgb); }
.clarity-booked      { --alpha: 1; }
.clarity-committed   { --alpha: 0.8; }
.clarity-placeholder { --alpha: 0.4; }

.trip-text {
    display: block;
    font-size: 11px;
    line-height: 1.25;
    font-weight: 600;
    word-wrap: break-word;
}
.trip-people {
    position: absolute;
    right: 4px;
    bottom: 4px;
    display: flex;
    flex-direction: row-reverse;
}
/* Keep label text clear of the avatar stack (v2.5 let avatars cover it). */
.trip.people-1 .trip-text { padding-right: 18px; }
.trip.people-2 .trip-text { padding-right: 30px; }
.trip.people-3 .trip-text { padding-right: 42px; }
.trip.people-4 .trip-text { padding-right: 54px; }

/* Anomaly: no one travelling. Hatched, outlined in red, flagged. */
.trip.anomaly .trip-text { padding-right: 20px; }
.trip.anomaly {
    border: 2px dashed var(--now);
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0 6px, transparent 6px 12px);
    color: #7b1d12; /* hatching is pale; white text would vanish */
}
.trip-flag {
    position: absolute;
    top: 3px;
    right: 3px;
    padding: 0 4px;
    border-radius: 3px;
    background: var(--now);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
}

/* Layout B: stacked cards get a lifted edge so the indent reads as layering. */
.trip.variant-stacked { box-shadow: -3px 0 6px rgba(0, 0, 0, 0.18); }
/* Layout C: the same person on two trips at once. */
.trip.variant-conflict { outline: 2px solid var(--now); outline-offset: -2px; }
.trip.variant-conflict::after {
    content: 'double-booked';
    position: absolute;
    right: 3px;
    bottom: 2px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--now);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
}

/* Narrow blocks (phones, busy clusters): the title gets the full width and the
   avatars move below it, smaller, instead of reserving a strip on the right that
   left one word per line. The dates go too (they show in the tooltip and detail);
   very narrow blocks also drop the avatars. */
@container trip (max-width: 120px) {
    .trip-range { display: none; }
    .trip-text { padding-right: 0 !important; font-size: 10.5px; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
    .trip-people { position: static; margin-top: 1px; padding-left: 4px; flex-direction: row; }
    .trip-people .avatar { width: 12px; height: 12px; margin-left: -4px; font-size: 7px; }
    .trip-flag { position: static; align-self: flex-start; margin-bottom: 2px; line-height: 14px; }
}
@container trip (max-width: 56px) {
    .trip-people { display: none; }
}
@container trip (max-width: 90px) {
    .trip.variant-conflict::after { content: '2×'; }
}

/* Layout C: a side trip inside a longer trip of the same person. */
.trip.variant-nested { border-left: 4px solid rgba(0, 0, 0, 0.35); }

/* Layout C lanes */
.lane-bar {
    position: sticky;
    top: 0;
    height: 26px;
    z-index: 150;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--line);
}
.lane-head {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid #ccc;
    font-size: 12px;
    font-weight: 700;
    color: #34495e;
    overflow: hidden;
    white-space: nowrap;
}
.lane-head.lane-none { color: var(--now); border-bottom-color: var(--now); }
.lane-guide {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px dashed #edf0f3;
    pointer-events: none;
}
.lane-guide.lane-none { background: rgba(231, 76, 60, 0.03); }

/* ---- Horizontal view (family lanes, assets/lanes-view.js) ----
   The scroller scrolls both ways; the names column and the month header are
   sticky, so they stay put while the track moves under them. */
.scroller.is-horizontal { flex: 0 1 auto; overflow: auto; overscroll-behavior-x: contain; }
.hview {
    --name-w: 96px;
    display: grid;
    grid-template-columns: var(--name-w) max-content;
    width: max-content;
}
.h-corner, .h-away-label, .h-names {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.h-corner { top: 0; z-index: 4; border-bottom: 1px solid var(--line); }
.h-away-label {
    padding-right: 8px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    letter-spacing: 0.5px;
    text-align: right;
    text-transform: uppercase;
}
.h-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.h-month {
    position: absolute;
    top: 0;
    height: 20px;
    margin: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.h-month-name {
    position: sticky;
    left: calc(var(--name-w) + 6px);
    display: inline-block;
    padding: 4px 6px 0;
    color: #34495e;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}
.h-month-year { color: #95a5a6; font-weight: 600; letter-spacing: 0.5px; }
.h-month.current .h-month-name { color: var(--blue); }
.h-month:hover .h-month-name, .h-month:focus-visible .h-month-name { color: var(--blue); text-decoration: underline; }
.h-tick {
    position: absolute;
    top: 21px;
    transform: translateX(-50%);
    color: #95a5a6;
    font-size: 9px;
    font-weight: 600;
    pointer-events: none;
}
.h-tick.weekend { color: #c4cdd3; }
.h-today {
    position: absolute;
    bottom: 1px;
    transform: translateX(-50%);
    padding: 0 4px;
    border-radius: 3px;
    background: var(--now);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 13px;
    pointer-events: none;
    z-index: 1;
}
.h-away { position: relative; }
.away-run { position: absolute; top: 4px; height: 6px; }
.away-1   { background: #dde2e7; }
.away-2   { background: #b9c2cb; }
.away-3   { background: #8f9ba7; }
.away-all { background: #f0ad4e; }

.h-names { padding-top: 0; }
.h-name {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    border-left: 3px solid #ccc;
    overflow: hidden;
}
.h-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; color: #34495e; }
.h-name.lane-none { border-left-color: var(--now); }
.h-name.lane-none .h-name-text { color: var(--now); }
.avatar-lane { width: 26px; height: 26px; margin: 0; font-size: 12px; }
.avatar-none { background: var(--now); }

/* z-index 0 makes the body a stacking context: trips (z 10 and up) stay under the sticky names. */
.h-body { position: relative; z-index: 0; }
.h-body.show-weekends {
    background-image: repeating-linear-gradient(90deg,
        rgba(52, 73, 94, 0.035) 0 calc(var(--ppd) * 2),
        transparent calc(var(--ppd) * 2) calc(var(--ppd) * 7));
    background-position: var(--wk-x) 0;
}
.h-lane { position: absolute; left: 0; right: 0; border-bottom: 1px dashed #edf0f3; pointer-events: none; }
.h-lane.odd { background: rgba(52, 73, 94, 0.025); }
.h-lane.lane-none { background: rgba(231, 76, 60, 0.04); }
.h-mline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); pointer-events: none; }
.h-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--now); z-index: 5000; pointer-events: none; }

/* Trips: same colours, clarity and flags as the vertical view (.trip); the title
   stays in view while a long trip scrolls past (sticky needs overflow: clip, not hidden). */
.trip.hbar {
    padding: 3px 5px;
    overflow: clip;
    container: hbar / size;
}
.trip.hbar:hover, .trip.hbar:focus-visible { transform: none; }
.hbar .trip-text {
    position: sticky;
    left: calc(var(--name-w) + 6px);
    align-self: flex-start;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.hbar .trip-range { display: block; font-size: 10px; font-weight: 400; opacity: 0.9; white-space: nowrap; }
.hbar.title-outside .trip-text, .hbar.title-hidden .trip-text { visibility: hidden; }
.hbar.variant-conflict::after { content: '2×'; }
.hbar.variant-nested { border-left-width: 3px; }
@container hbar (max-height: 38px) {
    .hbar .trip-range { display: none; }
    .hbar .trip-text { white-space: nowrap; }
}
@container hbar (max-width: 100px) {
    .hbar .trip-range { display: none; }
}
.h-outlabel {
    position: absolute;
    display: flex;
    align-items: center;
    width: max-content;
    overflow: hidden;
    color: #34495e;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
}

/* Trips in view: the list under the lanes. It gives up height before the lanes do. */
.inview {
    flex: 0 100 auto;
    min-height: 0;
    margin-top: 8px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}
.inview-title {
    position: sticky;
    top: 0;
    margin: 0;
    padding: 8px 12px 6px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}
.inview-list { list-style: none; margin: 0; padding: 0; }
.inview-list > li + li { border-top: 1px solid #f0f2f5; }
.inview-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.inview-item:hover, .inview-item:focus-visible { background: rgba(var(--blue-rgb), 0.05); }
:where(.inview-swatch) { --rgb: var(--blue-rgb); --alpha: 1; }
.inview-swatch {
    align-self: stretch;
    flex: none;
    width: 5px;
    border-radius: 3px;
    background: rgba(var(--rgb), var(--alpha));
}
.inview-swatch.anomaly { background: var(--now); }
.inview-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.inview-name { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.inview-when { margin-top: 1px; color: var(--text-muted); font-size: 12px; }
.inview-people { display: flex; flex: none; padding-left: 6px; }
.inview-people .avatar { width: 22px; height: 22px; margin-left: -6px; font-size: 11px; }
.inview-none { color: var(--bad); font-size: 12px; font-weight: 600; }
.inview-empty { padding: 12px; color: var(--text-muted); font-size: 13px; }
/* Landscape phones: the lanes need all the height. */
@media (max-height: 480px) { .inview { display: none; } }

/* View picker: direction toggle + the selects for the current direction */
.view-toggle {
    display: inline-flex;
    flex: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 0;
    padding: 5px 8px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid #ddd; }
.view-toggle-btn[aria-pressed="true"] { background: rgba(var(--blue-rgb), 0.1); color: var(--blue); }
.view-toggle-btn svg { width: 16px; height: 16px; flex: none; }

/* View picker */
.view-picker { display: flex; gap: 6px; }
.view-select {
    padding: 5px 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font: inherit;
    font-size: 12px;
}

.avatar {
    width: 18px;
    height: 18px;
    margin-left: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    border: 1px solid #fff;
    border-radius: 50%;
    background: #ccc;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    object-fit: cover;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}
.avatar-md { width: 36px; height: 36px; margin: 0; font-size: 16px; border-width: 2px; }
.avatar-lg { width: 44px; height: 44px; margin: 0; font-size: 18px; }
.avatar-xl { width: 100%; height: 100%; margin: 0; border-radius: 12px; border: 0; font-size: 40px; }
.topbar-avatar { display: inline-flex; }

.now-line {
    position: absolute;
    left: 15%;
    right: 0;
    height: 2px;
    background: var(--now);
    z-index: 50;
    pointer-events: none;
}
.now-line::before {
    content: 'NOW';
    position: absolute;
    left: -45px;
    top: -7px;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--now);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

/* ---- Detail dialog ---- */
.modal {
    width: min(90vw, 500px);
    max-height: 90vh;
    padding: 25px;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    color: var(--text);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.modal[open] { animation: slide-up 0.25s ease-out; }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.detail-title { margin: 0; font-size: 20px; line-height: 1.25; }
.btn-close { border: 0; background: none; font-size: 26px; line-height: 1; color: #999; cursor: pointer; padding: 0 4px; }
.btn-close:hover { color: var(--text); }
.detail-meta { margin: 0 0 12px; display: grid; gap: 8px; font-size: 14px; }
.detail-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; }
.detail-row dt { font-weight: 700; color: var(--text-muted); }
.detail-row dd { margin: 0; }
.detail-who { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-person { display: inline-flex; align-items: center; gap: 6px; }
.detail-person .avatar { margin: 0; width: 22px; height: 22px; font-size: 11px; }
/* Defaults at zero specificity, so the color-* / clarity-* classes win. */
:where(.chip) { --rgb: var(--blue-rgb); --alpha: 1; }
.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(var(--rgb), var(--alpha));
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
.detail-desc {
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-danger { color: #fff; background: var(--now); border-color: var(--now); }
.detail-anomaly { margin: 0 0 12px; }
.detail-message { margin: 12px 0 0; }
.detail-none { color: var(--bad); font-weight: 600; }

/* ---- Editor ---- */
.editor-form { display: flex; flex-direction: column; gap: 12px; }
.editor-banner { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text-muted); padding: 0; }
.field-hint { font-weight: 400; font-size: 12px; color: #999; }
.field-input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
    font: inherit;
    font-size: 16px; /* no iOS zoom */
    background: #fff;
}
textarea.field-input { resize: vertical; min-height: 80px; }
.field-input[aria-invalid="true"] { border-color: var(--bad); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-error { color: var(--bad); font-size: 13px; margin: 0; }
.check-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.check-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
}
.check-pill:has(input:checked) { border-color: var(--blue); background: rgba(var(--blue-rgb), 0.08); }
.check-pill input { margin: 0; accent-color: var(--blue); }
.swatch { --alpha: 1; width: 14px; height: 14px; border-radius: 3px; background: rgba(var(--rgb), 1); }

/* ---- Profile & family ---- */
.profile-grid { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
.profile-photo {
    width: 120px;
    height: 150px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #eee;
    overflow: hidden;
    cursor: pointer;
}
.profile-photo:hover { opacity: 0.85; }
.profile-name { margin: 0; font-size: 22px; font-weight: 700; }
.profile-email { margin: 2px 0 10px; font-size: 13px; color: #888; word-break: break-all; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-label input { width: 16px; height: 16px; accent-color: var(--blue); }
.profile-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dialog-message { margin: 12px 0 0; }
.ranking-title { margin: 18px 0 8px; font-size: 15px; }
.ranking-list { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid #eee; max-height: 240px; overflow-y: auto; }
.ranking-item { margin-bottom: 10px; font-size: 13px; }
.ranking-year { font-weight: 700; color: var(--blue); margin-right: 6px; font-size: 14px; }
.ranking-details { color: #555; }
.ranking-empty { color: #999; font-style: italic; font-size: 13px; }
.family-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.family-item { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; }
.family-name { font-weight: 700; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    margin: 0;
    padding: 10px 16px;
    border-radius: 8px;
    background: #2c3e50;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    z-index: 3000;
}

.version-watermark {
    position: fixed;
    bottom: 10px;
    left: 10px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
}

/* ---- Login ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    padding: 32px 24px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.login-title { margin: 0 0 20px; font-size: 22px; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-label { font-size: 14px; color: var(--text-muted); }
.login-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
    font-size: 16px; /* 16px stops iOS zooming into the field */
}
.login-code { font-size: 24px; letter-spacing: 6px; text-align: center; }
.login-button {
    padding: 14px;
    border: 0;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.login-button:hover { background: #0056b3; }
.login-secondary { display: flex; justify-content: space-between; margin-top: 16px; }
.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}
.flash {
    margin: 0 0 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
}
.flash-info { background: #e8f4fd; color: #1b4f72; border-left: 4px solid var(--blue); }
.flash-error { background: #fceae9; color: var(--bad); border-left: 4px solid var(--bad); }

/* ---- Phones ---- */
/* Narrow screens: the top bar becomes two rows.
     row 1  [photo  name ................  + Trip  Go to Now]
     row 2  [Waterfall ▾          ][Even ▾                 ]
   .topbar-actions is unwrapped (display: contents) so its children join the
   card's flex row and the view picker can take a full row of its own. */
@media (max-width: 720px) {
    .topbar-card { flex-wrap: wrap; row-gap: 8px; }
    .topbar-user { flex: 1 1 0; }
    .topbar-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-actions { display: contents; }
    .view-picker { order: 3; flex: 1 0 100%; }
    .view-select {
        flex: 1 1 0;
        min-width: 0;
        min-height: 40px;
        padding: 6px 8px;
        font-size: 16px; /* below 16px iOS Safari zooms the page when a select is tapped */
    }
    .topbar-actions .btn { min-height: 40px; }
    .view-toggle-btn { min-width: 40px; min-height: 40px; }
}

@media (max-width: 600px) {
    .topbar, .timeline-section { padding-left: 8px; padding-right: 8px; }
    .topbar-card { padding: 8px 10px; }
    .btn { padding: 8px 10px; font-size: 13px; }
    .month-label { width: 12%; padding-right: 4px; } /* gutter: PHONE_CTX.gutterPct in layout/geometry.js */
    .month-name { letter-spacing: 0.3px; font-size: 11px; }
    .month-year { font-size: 9px; letter-spacing: 0; }
    .trip { padding: 3px 4px; }
    .trip-text { font-weight: 500; -webkit-font-smoothing: antialiased; }
    .view-toggle-text { display: none; } /* icons only; the buttons carry aria-labels */
    .hview { --name-w: 52px; }
    .h-name { flex-direction: column; justify-content: center; gap: 2px; padding: 0 2px; }
    .h-name-text { max-width: 100%; font-size: 10px; }
    .avatar-lane { width: 24px; height: 24px; font-size: 11px; }
    .h-away-label { padding-right: 4px; font-size: 8px; letter-spacing: 0; }
    .topbar-email { display: none; }
    .profile-grid { grid-template-columns: 90px 1fr; gap: 12px; }
    .profile-photo { width: 90px; height: 112px; }
    .field-pair { grid-template-columns: 1fr; }
}
