/* =====================================================================
   PinJunket design system. Mobile-first; light and dark.
   Tokens on :root; components below. No framework.
   ===================================================================== */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #18202b;
    --muted: #5f6b7a;
    --faint: #8a95a3;
    --border: #e1e5ea;
    --accent: #0f766e;          /* deep teal */
    --accent-strong: #0b5e58;
    --accent-soft: #e3f3f1;
    --accent-text: #ffffff;
    --pin: #f97316;             /* default pin color (coral) */
    --danger: #c0352b;
    --danger-soft: #fdecea;
    --ok: #1a7f37;
    --warn: #a15c00;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
    --radius: 12px;
    --radius-sm: 8px;
    --gutter: 16px;
    --topbar-h: 56px;
    --tabbar-h: 62px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1318;
        --surface: #171c23;
        --surface-2: #1f262f;
        --text: #e8ecf1;
        --muted: #9aa5b3;
        --faint: #6f7a88;
        --border: #2a323d;
        --accent: #2dd4bf;
        --accent-strong: #5eead4;
        --accent-soft: #123532;
        --accent-text: #06201d;
        --pin: #fb923c;
        --danger: #f87171;
        --danger-soft: #3a1d1b;
        --ok: #4ade80;
        --warn: #fbbf24;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { color: inherit; font-size: .9em; }

/* ---------------------------------------------------------------- shell */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--gutter);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.topbar .brand svg { width: 22px; height: 22px; fill: var(--pin); }
.topbar .crumb {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-weight: 600;
}
.topbar .who { color: var(--muted); font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.spacer { flex: 1; }

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--gutter);
    padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}
.page.narrow { max-width: 640px; }

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0; flex: 1; min-width: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; width: 100%; margin-top: -8px; }

/* Trip tabs: a row on wide screens, a bottom bar on phones. */
.trip-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 0 var(--gutter);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--topbar-h);
    z-index: 19;
    scrollbar-width: none;
}
.trip-tabs::-webkit-scrollbar { display: none; }
.trip-tabs a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 12px;
    color: var(--muted);
    font-weight: 600;
    font-size: .925rem;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}
.trip-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.trip-tabs svg, .tabbar svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

.tabbar { display: none; }

@media (max-width: 720px) {
    .trip-tabs { display: none; }
    .tabbar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 30;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface);
        border-top: 1px solid var(--border);
    }
    .tabbar a, .tabbar button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: .7rem;
        font-weight: 600;
        color: var(--muted);
        background: none;
        border: none;
        text-decoration: none;
        cursor: pointer;
        font-family: inherit;
    }
    .tabbar a.active, .tabbar button.active { color: var(--accent); }
    .topbar .who { display: none; }
}

/* Bottom sheet ("More" on phones, menus). */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
.sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 41;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-lg);
    padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
}
.sheet a, .sheet button.item {
    display: block;
    width: 100%;
    padding: 14px 16px;
    color: var(--text);
    font-size: 1rem;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.sheet a:hover, .sheet button.item:hover { background: var(--surface-2); }
.sheet .sheet-note { padding: 10px 16px; color: var(--muted); font-size: .875rem; }

/* ---------------------------------------------------------------- surfaces */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }

.grid { display: grid; gap: 12px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Trip cards on the home screen. */
.trip-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
    transition: transform .08s ease, box-shadow .12s ease;
}
.trip-card:hover { text-decoration: none; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.trip-card .band {
    height: 72px;
    background: linear-gradient(135deg, var(--accent) 0%, #14b8a6 55%, var(--pin) 130%);
    position: relative;
}
.trip-card .band svg { position: absolute; right: 14px; bottom: -14px; width: 40px; height: 40px; fill: var(--surface); filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }
.trip-card .body { padding: 14px 16px 16px; }
.trip-card .name { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.trip-card .meta { color: var(--muted); font-size: .875rem; display: flex; gap: 10px; flex-wrap: wrap; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); }
.list > li:first-child { border-top: none; }
.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    color: var(--text);
    text-decoration: none;
    min-height: 52px;
}
a.row:hover { text-decoration: none; background: var(--surface-2); border-radius: var(--radius-sm); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .detail { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.dim { opacity: .6; }

/* Pin marker dot */
.dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex: none;
    background: var(--pin);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
}
.pin-glyph { width: 28px; height: 28px; flex: none; }
.pin-glyph path { fill: var(--pin); }

/* Chips / badges */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: .825rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.chip.static { cursor: default; }
.chip button { background: none; border: none; padding: 0; margin-left: 2px; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .725rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    background: var(--surface-2);
    color: var(--muted);
}
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.warn { background: #fff4e0; color: var(--warn); }
@media (prefers-color-scheme: dark) { .badge.warn { background: #3a2a0c; } }

/* ---------------------------------------------------------------- toolbar, search */

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.search svg { width: 18px; height: 18px; stroke: var(--faint); fill: none; stroke-width: 2; flex: none; }
.search input { border: none; background: none; padding: 10px 0; flex: 1; min-width: 0; font: inherit; color: var(--text); outline: none; }

/* ---------------------------------------------------------------- forms */

.form { display: grid; gap: 14px; }
.form .two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .form .two { grid-template-columns: 1fr; } }

label.field { display: grid; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url],
input[type=date], input:not([type]), select, textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.actions .spacer { flex: 1; }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

button.link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* Floating add button (phones) */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
    z-index: 25;
    width: 56px; height: 56px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: var(--shadow-lg);
    border: none;
    cursor: pointer;
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }
@media (max-width: 720px) { .fab { display: flex; } .wide-only { display: none !important; } }

/* Selection bar for bulk actions */
.selbar {
    position: sticky;
    top: calc(var(--topbar-h) + 46px);
    z-index: 18;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}
@media (max-width: 720px) { .selbar { top: var(--topbar-h); } }

/* ---------------------------------------------------------------- feedback */

.error { color: var(--danger); }
.ok { color: var(--ok); }
.muted { color: var(--muted); }
.error-banner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--danger);
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    color: var(--danger);
}
.error-banner button { background: none; border: none; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
}
.empty svg { width: 48px; height: 48px; fill: var(--border); margin-bottom: 8px; }
.empty h2 { color: var(--text); }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.readonly-note { display: flex; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: .875rem; }

/* ---------------------------------------------------------------- sign-in */

.signin {
    max-width: 400px;
    margin: 8vh auto 0;
    padding: 28px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.signin .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.4rem; margin-bottom: 4px; }
.signin .brand svg { width: 30px; height: 30px; fill: var(--pin); }
.signin form { display: grid; gap: 14px; margin-top: 16px; }

.gate-error { max-width: 560px; margin: 10vh auto; padding: 0 var(--gutter); }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gutter);
    z-index: 100;
}
.overlay-box { background: var(--surface); border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.overlay-box .signin { margin: 0; border: none; padding: 0; box-shadow: none; }

/* Dialog (confirmations, small forms) */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--gutter); }
.dialog { background: var(--surface); border-radius: 16px; padding: 20px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.dialog h2 { margin-bottom: 8px; }

/* Notes */
.note { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .when { display: block; color: var(--faint); font-size: .75rem; margin-top: 4px; white-space: normal; }

/* Labels editor */
.label-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.label-row:first-child { border-top: none; }
.label-row input[type=text], .label-row input:not([type]) { flex: 1; min-width: 0; }

/* Utilities */
.stack > * + * { margin-top: 12px; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app-footer { text-align: center; color: var(--faint); font-size: .8rem; padding: 24px 0 8px; }

/* ---------------------------------------------------------------- plan / calendar */

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: none; background: none; padding: 6px 14px; border-radius: 999px; font: inherit; font-weight: 600; font-size: .875rem; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.card.day { border-left: 5px solid var(--day, var(--border)); }

.cal h2 { margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--faint); text-align: center; padding: 2px 0; }
.cal-cell {
    min-height: 84px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: stretch;
    text-align: left;
    padding: 4px 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--faint);
    font: inherit;
    overflow: hidden;
}
.cal-cell.in { background: var(--surface); color: var(--text); cursor: pointer; border-top: 4px solid var(--day, var(--border)); }
.cal-cell.in:hover { border-color: var(--accent); }
.cal-cell.out { background: transparent; border-color: transparent; }
.cal-num { font-weight: 700; font-size: .8rem; }
.cal-pin { display: flex; align-items: center; gap: 4px; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pin .dot { width: 8px; height: 8px; box-shadow: none; }
.cal-pin span:last-child { overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: .7rem; color: var(--muted); }
@media (max-width: 520px) {
    .cal-cell { min-height: 56px; padding: 3px; }
    .cal-pin span:last-child { display: none; }
    .cal-pin { display: inline-flex; }
}

/* ---------------------------------------------------------------- tables (money) */

.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--faint); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table th.num, .table td.num { text-align: right; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.table tr.link-row { cursor: pointer; }
.table tr.link-row:hover td { background: var(--surface-2); }
.neg { color: var(--danger); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }

.owes { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.owes .owe { color: var(--danger); }

/* Stops editor */
.stop { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--border); }
.stop:first-child { border-top: none; }
.stop .num-badge { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .85rem; }
.stop .moves { display: flex; flex-direction: column; gap: 4px; }
.stop .fields { display: grid; gap: 8px; }
.stop .fields .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* People */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .85rem; }

/* ---------------------------------------------------------------- map */

.page-full { position: relative; }
.map-screen { position: relative; height: calc(100dvh - var(--topbar-h) - 47px); min-height: 360px; }
@media (max-width: 720px) {
    .map-screen { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom)); }
}
.map-canvas { position: relative; background: var(--surface-2); }
.map-canvas.fill { position: absolute; inset: 0; }
.map-canvas.mini { height: 240px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); margin-top: 12px; }
.map-el { position: absolute; inset: 0; }
.map-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); }
.map-msg p { max-width: 420px; background: var(--surface); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }

.map-top { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5; display: grid; gap: 8px; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.map-chips::-webkit-scrollbar { display: none; }
.map-chips .chip, .map-controls .chip, .map-controls select { box-shadow: var(--shadow); }
.map-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.map-controls select { min-height: 32px; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.map-controls .chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.map-note { background: var(--surface); padding: 6px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .85rem; justify-self: start; }

.map-card {
    position: absolute;
    left: 10px; right: 10px; bottom: 12px;
    z-index: 6;
    max-width: 520px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
}
.map-card h2 { font-size: 1.05rem; margin: 0; }
.nearby { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 4px; font-size: .85rem; }

/* Google's place search element inherits our look where it allows. */
.place-search gmp-place-autocomplete { width: 100%; color-scheme: light dark; }

/* Map screen v2: search bar, filter panel, cards */
.map-searchbar { display: flex; gap: 8px; align-items: center; }
.map-searchbar .search { box-shadow: var(--shadow); }
.map-btn { box-shadow: var(--shadow); border-radius: 999px; }
.map-panel {
    position: absolute; z-index: 7; top: 64px; right: 10px; bottom: 10px;
    width: min(340px, calc(100% - 20px));
    overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.map-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin: 14px 0 6px; }
.check-list { display: grid; gap: 4px; }
.check-list.scroll { max-height: 180px; overflow-y: auto; }
.check-list label.check, .route-row label.check { font-weight: 500; font-size: .925rem; }
.check-list .swatch, .route-row .swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.route-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 4px 0; }
.route-row label { flex: 1; min-width: 0; }
.route-row .route-sum { width: 100%; padding-left: 28px; margin-top: -2px; }

.map-card .card-scroll { max-height: 46vh; overflow-y: auto; }
.place-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: .9rem; }
.create-pin, .quick-edit { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.quick-edit summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.photo-strip figure { margin: 0; }
.photo-strip img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.photo-strip figcaption { font-size: .7rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .swatch + * { margin-left: 0; }
.chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
/* Route editor: stops beside a map (stacked on phones) */
.route-layout { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; height: calc(100dvh - var(--topbar-h) - 47px); }
.route-side { overflow-y: auto; padding: 14px 16px 40px; border-right: 1px solid var(--border); background: var(--bg); }
.route-map { position: relative; min-height: 320px; }
@media (max-width: 720px) {
    .route-layout { display: flex; flex-direction: column-reverse; height: auto; }
    .route-map { height: 45vh; position: sticky; top: var(--topbar-h); z-index: 5; }
    .route-side { border-right: none; padding-bottom: calc(var(--tabbar-h) + 32px); }
}
.route-total { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
ol.stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stop-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.stop-row.dragging { opacity: .5; }
.stop-row .grip { cursor: grab; color: var(--faint); padding: 6px 0; user-select: none; letter-spacing: -2px; }
.stop-row .num-badge { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; margin-top: 6px; }
.stop-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.stop-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stop-sub select { width: auto; min-height: 34px; padding: 4px 8px; }
.stop-sub .hint { display: inline-flex; align-items: center; gap: 4px; }
.stop-sub .pin-glyph { width: 18px; height: 18px; }
.stop-row .moves { display: flex; flex-direction: column; gap: 2px; }
/* Plan drag-and-drop */
.cal-cell.drop, .card.day.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.cal-pin[draggable=true], li[draggable=true] { cursor: grab; }
.cal-cell { cursor: default; }
.cal-cell.in { cursor: pointer; }
/* Pin cards (old Detail view) */
.totals { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.totals > div { flex: 1; min-width: 140px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: grid; }
.totals strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.totals .muted { font-size: .8rem; }
.pin-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pin-card { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--pin-c); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; align-content: start; box-shadow: var(--shadow); }
.pin-card h3 { margin: 0; font-size: 1.05rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pin-card .desc { white-space: pre-wrap; margin: 2px 0 0; font-size: .925rem; }
.detail.contact { display: flex; gap: 12px; flex-wrap: wrap; white-space: normal; }

/* Cost percentage split */
.split-rows { display: grid; gap: 6px; }
.split-row { display: grid; grid-template-columns: 1fr 96px auto 90px; gap: 8px; align-items: center; }
.split-row input { min-height: 38px; padding: 6px 8px; text-align: right; }
.split-name { font-weight: 600; color: var(--text); font-size: .925rem; }
.split-amt { color: var(--muted); }
/* Brand (original PinJunket artwork) */
.topbar .brand-logo { height: 40px; width: auto; display: block; }
@media (max-width: 400px) { .topbar .brand-logo { height: 32px; } }
/* The wordmark is dark blue on transparent: give it a light chip in dark mode so it stays readable. */
@media (prefers-color-scheme: dark) { .topbar .brand-logo { background: #f5f7fa; border-radius: 8px; padding: 2px 6px; } }
.signin-logo { display: block; width: 200px; height: auto; margin: 0 auto 4px; }

/* Trip cards: cover image (default PinJunket image until cover photos arrive) */
.trip-card .cover { aspect-ratio: 415 / 270; background: #3a9be8; overflow: hidden; }
.trip-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.trip-card:hover .cover img { transform: scale(1.03); }
/* Calendar days outside the trip's dates (when it has both) */
.cal-cell.outside { opacity: .45; background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, transparent 6px, transparent 12px); }

/* Invites */
.invite-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; }
.invite-box input { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.topbar a.who { color: var(--muted); text-decoration: none; }
.topbar a.who:hover { color: var(--accent); }
/* Plan: Daily list with full pin details (old Daily view) */
.list.daily > li.daily-pin { display: flex; gap: 10px; padding: 12px 0; align-items: stretch; }
.daily-pin .color-bar { width: 6px; border-radius: 3px; flex: none; }
.daily-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.daily-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 1.05rem; }
.daily-title .btn { margin-left: auto; }
.pin-facts { display: grid; gap: 4px; font-size: .925rem; }
.pin-facts .desc { white-space: pre-wrap; margin: 2px 0 0; }
.day-link { font-size: inherit; font-weight: inherit; color: inherit; }
.day-link:hover { color: var(--accent); }
.pin-dialog { max-width: 520px; max-height: 85vh; overflow-y: auto; }
.pin-card h3 .link { font-size: inherit; font-weight: 700; text-align: left; }
/* ---------------------------------------------------------------- snow check (route editor + map) */
.snow { margin-top: 10px; display: grid; gap: 8px; }
.map-card .snow { margin-top: 0; }
.snow-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.snow-head .btn svg { width: 16px; height: 16px; }
.snow-line { margin: 0; font-size: .9rem; }
.snow-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--muted); }
.snow-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.snow-legend .dot { width: 10px; height: 10px; }
.snow .num-badge { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex: none; }
.snow .num-badge.small { width: 14px; height: 14px; margin: 0 6px; }
.snow-detail { padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.snow-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.snow-table th, .snow-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.snow-table td:last-child { white-space: normal; min-width: 120px; }
.snow-table th { font-weight: 600; color: var(--muted); }
ol.snow-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.snow-row { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.snow-row.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.snow-row .main { flex: 1; min-width: 0; display: grid; }
.snow-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snow-row .detail { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snow-num { display: grid; justify-items: end; font-size: .85rem; }
.snow-credit { margin: 0; }
.route-sum .btn { margin-left: 6px; }