/* 1st RM dashboard - regimental navy, gold and cream, matching 1stroyalmarines.com.
   Headings are set in Libre Caslon Display and everything else in Inter. Caslon Display has
   one weight, so headings are never bolded (font-synthesis stops browsers faking it). */

:root {
    --navy-950: #081122;
    --navy-900: #0b1629;
    --navy-800: #0f1d33;
    --navy-700: #162744;
    --navy-600: #1d3257;
    --navy-500: #27416d;
    --gold: #c9a84c;
    --gold-bright: #e0c36a;
    --gold-dim: #a08535;
    --cream: #e8e0d0;
    --white: #f5f2ed;
    --muted: rgba(232, 224, 208, 0.76);
    --faint: rgba(232, 224, 208, 0.58);
    --line: rgba(201, 168, 76, 0.18);
    --line-strong: rgba(201, 168, 76, 0.4);
    --scarlet: #b3261e;
    --scarlet-bright: #d8453b;
    --green: #7fae78;
    --amber: #e0b04f;
    --red: #e0736b;
    --on-gold: #0b1629;  /* text on a gold (accent) fill */
    --paper: #f5f2ed;    /* text on scarlet, in both themes */
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --serif: "Libre Caslon Display", "Big Caslon", Baskerville, Georgia, serif;
    --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
    background:
        radial-gradient(1200px 500px at 50% -200px, rgba(201, 168, 76, 0.08), transparent 70%),
        var(--navy-900);
    color: var(--cream);
    font-family: var(--sans);
    font-synthesis: none;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    /* Column so the footer sits at the bottom of short pages. */
    display: flex;
    flex-direction: column;
}

/* The page background, as on 1stroyalmarines.com: an 1885 Admiralty chart of the English Channel,
   a ship of the line under sail and the Great Sea Serpent, the old prints' ink turned to faint
   gold (static/sea/, sources in sea/sources.txt). A wash of navy over it keeps the panels
   readable. Behind everything (z-index -1, under the body's own flow), and it stays put while
   the page scrolls. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(11, 22, 41, 0.35), rgba(11, 22, 41, 0.35)),
        url("sea/ship.webp?v=1"),
        url("sea/serpent.webp?v=1"),
        url("sea/chart.webp?v=1");
    background-position: center, left -2vw top 9vh, right -2vw bottom 2vh, center;
    background-size: auto, min(34vw, 600px) auto, min(32vw, 580px) auto, cover;
    background-repeat: no-repeat;
}
@media (max-width: 900px) {
    body::before {
        background-position: center, left -10vw top 4vh, right -10vw bottom 0, center;
        background-size: auto, 90vw auto, 90vw auto, cover;
        opacity: 0.7;
    }
}

a { color: var(--gold-bright); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.icon { width: 22px; height: 22px; flex: none; }

/* ---------- header ---------- */

.site-header {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px 28px;
    background: rgba(15, 29, 51, 0.92);
    border-bottom: 1px solid var(--line-strong);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(6px);
}
.brand {
    display: flex; align-items: center; gap: 12px;
    color: var(--white); text-decoration: none; white-space: nowrap;
}
.brand img { filter: drop-shadow(0 0 6px rgba(201, 168, 76, 0.35)); }
.brand span { font-family: var(--serif); font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; font-size: 15px; }
.brand small { display: block; color: var(--gold); font-family: var(--sans); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; }

.site-nav { display: flex; gap: 6px; margin-left: auto; }
.site-nav a {
    color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px;
}
.site-nav a:hover { color: var(--white); background: rgba(201, 168, 76, 0.1); }
.site-nav a.current { color: var(--on-gold); background: var(--gold); }
.site-nav a svg { display: none; }

.live-pill {
    display: flex; align-items: center; gap: 6px; margin-right: -14px; padding: 4px 11px; white-space: nowrap; cursor: default;
    border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px;
}
.live-pill[hidden] { display: none; }
.live-count { color: var(--cream); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(127, 174, 120, 0.6); animation: live-pulse 2.4s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(127, 174, 120, 0.6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(127, 174, 120, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
@media (max-width: 600px) { .live-label { display: none; } .live-pill { padding: 4px 9px; } }
.account { position: relative; display: flex; align-items: center; }
.account-btn {
    display: flex; align-items: center; gap: 10px; background: none; border: 1px solid transparent;
    border-radius: 999px; padding: 3px 10px 3px 3px; cursor: pointer; text-align: left;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: var(--line-strong); background: rgba(201, 168, 76, 0.08); }
.account img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--gold); }
.account .name { color: var(--cream); font-size: 14px; }
.account .rank { display: block; color: var(--gold); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.account svg.chevron { width: 16px; height: 16px; color: var(--muted); }
.account-menu {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 210px; z-index: 40;
    background: var(--navy-700); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.menu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-who strong { display: block; color: var(--white); }
.menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; border-radius: var(--radius-sm);
    padding: 9px 10px; cursor: pointer; color: var(--cream); font-size: 14px;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(201, 168, 76, 0.12); color: var(--white); }
.menu-item svg { width: 18px; height: 18px; }

/* Floating "Plan an event" button - phones only. */
.fab { display: none; }

/* ---------- layout ---------- */

/* min-width 0: a wide child (a table, the heatmap) scrolls in its own box instead of widening the page. */
.app { max-width: 1180px; width: 100%; min-width: 0; flex: 1 0 auto; margin: 28px auto 72px; padding: 0 20px; }

/* Same footer as 1stroyalmarines.com. */
.site-footer { text-align: center; padding: 22px 16px 28px; border-top: 1px solid var(--line); }
.site-footer .legal-nav {
    display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 20px;
    font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase;
}
.site-footer .legal-nav a { color: rgba(201, 168, 76, 0.55); text-decoration: none; transition: color 0.25s ease; }
.site-footer .creator-credit { margin-top: 12px; font-size: 12px; color: rgba(232, 224, 208, 0.4); }
.site-footer .creator-credit a { color: rgba(201, 168, 76, 0.4); text-decoration: none; transition: color 0.25s ease; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--gold); }

.page-title { margin: 0 0 22px; }
.page-title .crumbs { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.page-title .crumbs a { color: var(--gold); text-decoration: none; }
.page-title .crumbs a:hover { color: var(--gold-bright); }
.page-title h1 {
    font-family: var(--serif); font-weight: 400; letter-spacing: 0; color: var(--white);
    margin: 6px 0 0; font-size: 32px;
}
.page-title p { margin: 6px 0 0; color: var(--muted); }
.page-title .rule { height: 1px; margin-top: 14px; background: linear-gradient(90deg, var(--gold), transparent 70%); opacity: 0.6; }

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)), var(--navy-800);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 18px; }
.panel-title {
    display: flex; align-items: center; gap: 10px; margin: 0 0 16px;
    font-family: var(--serif); font-size: 17px; letter-spacing: 0.01em; color: var(--gold);
}
.panel-title .count { margin-left: auto; font-family: var(--sans); color: var(--muted); font-size: 13px; letter-spacing: 0; }

.loading, .empty { color: var(--muted); text-align: center; padding: 36px 0; }
.empty.small { padding: 8px 0; text-align: left; font-size: 14px; }

/* ---------- home ---------- */

.home { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-areas: "main next"; gap: 22px; align-items: start; }
.home-main { grid-area: main; display: flex; flex-direction: column; gap: 18px; }
.next-panel { grid-area: next; }
.home-main .panel + .panel, .home .panel + .panel { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
    position: relative; display: flex; flex-direction: column; gap: 10px;
    padding: 20px; min-height: 150px;
    background: var(--navy-800); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--cream); text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.card:hover { border-color: var(--gold); background: var(--navy-700); transform: translateY(-2px); }
.card .badge-icon {
    width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
    color: var(--gold); border: 1px solid var(--line-strong);
    background: radial-gradient(circle at 30% 30%, rgba(201, 168, 76, 0.18), rgba(201, 168, 76, 0.04));
}
.card h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 18px; letter-spacing: 0; color: var(--white); font-weight: 400; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card.feature { border-color: rgba(179, 38, 30, 0.6); background: linear-gradient(135deg, rgba(179, 38, 30, 0.22), transparent 60%), var(--navy-800); }
.card.feature .badge-icon { color: var(--paper); background: var(--scarlet); border-color: var(--scarlet-bright); }

/* The home page's tiles: compact, since Set a Course is the way in. The icon beside the name
   and the line under it held to two lines; on phones two to a row, names only. */
.cards.nav-cards { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.nav-cards .card {
    display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; row-gap: 2px;
    align-items: center; align-content: center; min-height: 0; padding: 12px 14px;
}
.nav-cards .card .badge-icon { grid-row: 1 / span 2; width: 36px; height: 36px; }
.nav-cards .card .badge-icon svg.icon { width: 18px; height: 18px; }
.nav-cards .card h2 { margin: 0; font-size: 16px; line-height: 1.25; }
.nav-cards .card p {
    font-size: 12.5px; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
@media (max-width: 600px) {
    .cards.nav-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .nav-cards .card { grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; padding: 10px 11px; }
    .nav-cards .card .badge-icon { grid-row: auto; width: 30px; height: 30px; }
    .nav-cards .card .badge-icon svg.icon { width: 16px; height: 16px; }
    .nav-cards .card h2 { font-size: 14px; }
    .nav-cards .card p { display: none; }
}

.next-list { display: flex; flex-direction: column; gap: 8px; }
.next-item {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center;
    padding: 6px; border-radius: var(--radius-sm); border-left: 3px solid var(--row, transparent);
}
.next-item:hover { background: rgba(201, 168, 76, 0.07); }
.next-item.mine { background: rgba(201, 168, 76, 0.08); }
.next-link { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: center; text-decoration: none; color: var(--cream); }
.next-rsvp { display: flex; justify-content: flex-end; }
.rsvp-btn { padding: 6px 14px; }
.rsvp-done { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-size: 13px; font-weight: 600; white-space: nowrap; }
.rsvp-done svg { width: 16px; height: 16px; }
.date-stamp {
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); text-align: center; overflow: hidden;
}
.date-stamp .m { background: var(--scarlet); color: var(--paper); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding: 1px 0; }
.date-stamp .d { font-family: var(--serif); font-weight: 400; font-size: 20px; color: var(--white); padding: 2px 0; }
.next-item .t { font-weight: 600; color: var(--white); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.next-item .s { color: var(--muted); font-size: 13px; }

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

.editor { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.editor-preview { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; border-radius: var(--radius); }
.sticky-actions {
    position: sticky; bottom: 0; z-index: 15; margin: 0 -8px; padding: 12px 8px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(11, 22, 41, 0), rgba(11, 22, 41, 0.94) 22%, var(--navy-900));
}
.sticky-actions .actions { margin-top: 0; }
.sticky-actions .error-text { margin: 0 0 8px; }
.panel.section { margin: 0 0 18px; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label {
    display: block; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--gold); margin-bottom: 7px;
}
.field .req { color: var(--scarlet-bright); }
.hint { color: var(--faint); font-size: 13px; margin-top: 6px; }
.section > .hint { margin: -4px 0 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

input[type="text"], input[type="url"], input[type="number"], input[type="date"], input[type="time"],
input[type="search"], select, textarea {
    width: 100%;
    background: var(--navy-900);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 130px; }
input[type="date"], input[type="time"], select { color-scheme: dark; }
select option { background: var(--navy-800); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
    background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.swatch.selected { border-color: var(--white); box-shadow: 0 0 0 2px var(--gold); }
.swatches input[type="color"] {
    width: 28px; height: 28px; padding: 0; border: 1px dashed var(--line-strong); border-radius: 50%;
    background: none; cursor: pointer; overflow: hidden;
}
.swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.swatches input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatches input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
.swatches .custom-label { color: var(--faint); font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(201, 168, 76, 0.1); border: 1px solid var(--line-strong); color: var(--cream);
    border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 13px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip, var(--gold)); }
.chip button {
    background: rgba(0, 0, 0, 0.25); border: 0; color: var(--cream); cursor: pointer;
    width: 18px; height: 18px; border-radius: 50%; line-height: 1; padding: 0;
}
.chip button:hover { background: var(--scarlet); }

.suggest { position: relative; }
.suggest-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: var(--navy-700); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    max-height: 220px; overflow-y: auto; margin-top: 4px; box-shadow: var(--shadow);
}
.suggest-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; cursor: pointer; }
.suggest-list button:hover { background: rgba(201, 168, 76, 0.12); }

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

.btn {
    border: 1px solid var(--line-strong); border-radius: 999px; padding: 9px 20px; cursor: pointer;
    background: transparent; color: var(--cream);
    font-weight: 600; font-size: 14px; letter-spacing: 0.02em;
    text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--gold); color: var(--white); background: rgba(201, 168, 76, 0.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn.primary:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn.danger { border-color: rgba(216, 69, 59, 0.6); color: #f3b3ad; }
.btn.danger:hover { background: var(--scarlet); border-color: var(--scarlet); color: var(--paper); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--white); background: rgba(201, 168, 76, 0.08); }
.btn.large { padding: 12px 26px; font-size: 15px; }
.btn svg { width: 18px; height: 18px; }

.error-text { color: #f3a39b; }

/* ---------- announcement preview (Discord-style card, our colours) ---------- */

.preview-label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); margin: 0 0 10px; }
.preview {
    background: var(--navy-950); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.preview .mentions { color: #a9b8ff; font-size: 14px; margin-bottom: 8px; min-height: 1px; }
.preview .embed {
    border-left: 4px solid var(--embed, var(--scarlet)); background: var(--navy-800); border-radius: 4px; padding: 12px 14px;
}
.preview .embed h3 { margin: 0 0 6px; color: var(--white); font-size: 16px; overflow-wrap: anywhere; }
.preview .embed .desc { white-space: pre-wrap; color: var(--cream); font-size: 14px; margin-bottom: 10px; overflow-wrap: anywhere; }
.preview .embed .f { margin-bottom: 8px; font-size: 14px; }
.preview .embed .f b { display: block; color: var(--white); font-size: 13px; }
.preview .embed .f span { color: var(--muted); }
.preview .embed img:not(.emoji) { display: block; max-width: 100%; border-radius: 4px; margin-top: 8px; }
.preview-note { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.preview.muted { opacity: 0.45; }

/* ---------- event lists ---------- */

.event-list { display: flex; flex-direction: column; gap: 8px; }
.event-row {
    display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center;
    background: var(--navy-800); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 16px 12px 12px; color: var(--cream); text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.event-row:hover { border-color: var(--gold); background: var(--navy-700); }
.event-row.mine { border-left: 3px solid var(--gold); background: linear-gradient(90deg, rgba(201, 168, 76, 0.09), transparent 45%), var(--navy-800); }
.event-row .title { font-weight: 600; color: var(--white); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-row .title .marker { width: 9px; height: 9px; border-radius: 50%; background: var(--row, var(--scarlet)); flex: none; }
.event-row .when { color: var(--muted); font-size: 13px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill.ok { color: var(--green); border-color: rgba(127, 174, 120, 0.45); background: rgba(127, 174, 120, 0.08); }
.pill.late { color: var(--amber); border-color: rgba(224, 176, 79, 0.45); background: rgba(224, 176, 79, 0.08); }
.pill.no { color: var(--red); border-color: rgba(224, 115, 107, 0.45); background: rgba(224, 115, 107, 0.08); }

.tag {
    font-size: 11px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
    border: 1px solid var(--line-strong); color: var(--gold); font-weight: 600;
}
.tag.live { background: var(--scarlet); border-color: var(--scarlet); color: var(--paper); }
.tag.muted { color: var(--faint); border-color: var(--line); }
.tag.region { color: #cfd8ea; border-color: rgba(160, 180, 220, 0.45); background: rgba(120, 150, 210, 0.12); }
.tag.region.r-na { color: #f2c38a; border-color: rgba(242, 170, 90, 0.5); background: rgba(242, 170, 90, 0.12); }
.tag.mine { color: var(--green); border-color: rgba(127, 174, 120, 0.55); background: rgba(127, 174, 120, 0.12); }
.tag.mine.late { color: var(--amber); border-color: rgba(224, 176, 79, 0.55); background: rgba(224, 176, 79, 0.1); }
.tag.low { color: #ffd0a0; border-color: rgba(255, 150, 60, 0.6); background: rgba(255, 150, 60, 0.14); }
.day-heading {
    display: flex; align-items: center; gap: 12px; color: var(--gold);
    font-size: 12px; margin: 18px 0 2px; text-transform: uppercase; letter-spacing: 0.18em;
}
.day-heading::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- event detail ---------- */

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.detail-banner { display: block; max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid var(--line); }
.detail-desc { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.facts { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.facts > div { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.facts svg { width: 20px; height: 20px; color: var(--gold); margin-top: 1px; }
.facts dt { color: var(--gold); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.facts dd { margin: 0; color: var(--cream); }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.roster section { background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.roster h3 {
    margin: 0 0 8px; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold);
    display: flex; justify-content: space-between;
}
.roster h3 span { color: var(--muted); letter-spacing: 0; }
.roster ul { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.roster li { padding: 3px 0; border-bottom: 1px solid rgba(201, 168, 76, 0.06); }
.roster li:last-child { border-bottom: 0; }

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

.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.cal-head h2 { margin: 0 auto 0 0; font-family: var(--serif); font-size: 22px; letter-spacing: 0; color: var(--white); font-weight: 400; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { color: var(--gold); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; text-align: center; padding: 4px 0; }
.cal-day {
    position: relative; background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm);
    min-height: 118px; padding: 6px; font-size: 12px; overflow: hidden; min-width: 0;
}
.cal-day.has-events { cursor: pointer; }
.cal-day.has-events:hover { border-color: var(--line-strong); }
.cal-day.selected { border-color: var(--gold-bright); background: rgba(201, 168, 76, 0.07); }
.cal-day:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal-day.other { opacity: 0.35; }
.cal-day.weekend { background: rgba(22, 39, 68, 0.6); }
.cal-day.today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.cal-day .num { color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.cal-day.today .num { color: var(--gold); }
.cal-event {
    display: block; background: color-mix(in srgb, var(--row, var(--scarlet)) 16%, var(--navy-700));
    border-left: 3px solid var(--row, var(--scarlet)); border-radius: 3px;
    padding: 2px 5px 3px; margin-bottom: 3px; color: var(--cream); text-decoration: none; line-height: 1.25;
}
.cal-event:hover { background: color-mix(in srgb, var(--row, var(--scarlet)) 30%, var(--navy-700)); }
.cal-event.mine { box-shadow: inset 0 0 0 1px var(--gold); }
.cal-time { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cal-time b { font-size: 10px; font-weight: 700; color: #f2c38a; letter-spacing: 0.04em; }
.cal-title {
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere; font-weight: 600; color: var(--white); font-size: 12px;
}
.cal-more {
    background: none; border: 0; padding: 1px 4px; cursor: pointer; color: var(--gold-bright); font-size: 12px; font-weight: 600;
}
.cal-more:hover { text-decoration: underline; }
.cal-count { display: none; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--row); display: inline-block; }
.cal-legend i.mine-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--gold); }
.agenda { margin-top: 18px; }
.agenda:empty { display: none; }

/* ---------- attendance ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { max-width: 260px; }
.toolbar select { width: auto; }
.toolbar .hint { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: 4px; }
/* Long ship ranks ("(First Rate) - HMS Royal Sovereign") wrap instead of widening the table. */
table.data td.rank-cell { white-space: normal; min-width: 110px; max-width: 190px; font-size: 13px; line-height: 1.35; }
table.data th {
    color: var(--gold); font-weight: 600; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
    cursor: pointer; user-select: none;
}
table.data th.sortable::after { content: " ↕"; color: var(--faint); font-size: 11px; }
table.data th.sortable:hover { color: var(--gold-bright); }
table.data th.sorted::after { content: " ▾"; color: var(--gold-bright); }
table.data th.sorted.asc::after { content: " ▴"; }
table.data td.rank-cell { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; margin: -4px 0 14px; }
.sort-chips { display: none; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.range-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
    border: 1px solid var(--line-strong); background: transparent; color: var(--cream); border-radius: 999px;
    padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.chip-btn.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.member-cards { display: none; flex-direction: column; gap: 8px; }
.member-card { background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.member-card.left { opacity: 0.7; }
.mc-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mc-name { font-weight: 600; color: var(--white); }
.mc-rank { color: var(--gold); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.mc-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.mc-stats b { color: var(--white); font-variant-numeric: tabular-nums; }
.mc-last { color: var(--faint); font-size: 13px; margin-top: 4px; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: rgba(201, 168, 76, 0.05); }
table.data tr.left td { color: var(--faint); }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-card { background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.stat-card .value { font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--white); }
.stat-card .label { color: var(--gold); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.quick-stats .stat-cards { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.quick-stats .stat-card .value { font-size: 26px; }

/* ---------- login ---------- */

.login {
    max-width: 460px; margin: 70px auto; text-align: center;
    background: var(--navy-800); border: 1px solid var(--line-strong); border-radius: 14px;
    padding: 40px 32px; box-shadow: var(--shadow);
}
.login img { width: 132px; height: 132px; filter: drop-shadow(0 0 16px rgba(201, 168, 76, 0.35)); }
.login h1 { margin: 18px 0 4px; font-family: var(--serif); font-weight: 400; letter-spacing: 0.01em; color: var(--white); font-size: 26px; }
.login .motto { color: var(--gold); font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; margin: 0 0 16px; }
.login p { color: var(--muted); }

.toast {
    position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    background: var(--navy-700); border: 1px solid var(--gold); color: var(--white);
    padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.error { border-color: var(--scarlet-bright); background: #3a1414; }

/* Shown while a change is being saved (app.js savingStarted). */
.save-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; overflow: hidden;
    background: rgba(201, 168, 76, 0.18);
}
.save-progress::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
    background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
    animation: save-progress-slide 1.1s ease-in-out infinite;
}
@keyframes save-progress-slide { to { left: 100%; } }
.saving {
    position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px; white-space: nowrap;
    background: var(--navy-700); border: 1px solid var(--line-strong); color: var(--white);
    padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 49; max-width: calc(100vw - 32px);
}
.saving .spinner {
    width: 14px; height: 14px; flex: none; border-radius: 50%;
    border: 2px solid var(--line-strong); border-top-color: var(--gold-bright);
    animation: saving-spin 0.8s linear infinite;
}
@keyframes saving-spin { to { transform: rotate(360deg); } }
/* Shown while the bot restarts (app.js setStarting): a card under the header, full width on phones. */
.saving.starting {
    top: calc(76px + env(safe-area-inset-top)); bottom: auto; left: 16px; right: 16px; transform: none;
    width: auto; max-width: 420px; margin: 0 auto; white-space: normal; z-index: 51;
    align-items: flex-start; gap: 12px; padding: 14px 18px; border-radius: 12px; border-color: var(--gold-dim);
}
.saving.starting .spinner { margin-top: 3px; }
.starting-text strong { display: block; color: var(--white); font-weight: 600; font-size: 15px; }
.starting-text small { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; }
.save-progress[hidden], .saving[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
    .save-progress::before { animation: none; left: 0; width: 100%; opacity: 0.6; }
    .saving .spinner { animation: none; border-color: var(--gold-bright); }
}

/* ---------- detachments: training, recruitment, public office ---------- */

.page-body > .panel + .panel, .page-body > .panel + .two-col, .page-body > .two-col + .panel { margin-top: 18px; }
.panel-pair > .panel + .panel { margin-top: 0; }
.name-cell { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.sub-rank { flex-basis: 100%; color: var(--faint); font-size: 12px; white-space: normal; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 0 3px rgba(127, 174, 120, 0.2); }
.wait-mid { color: var(--amber); }
.wait-long { color: var(--red); font-weight: 600; }
.bump-line { margin: 0; }

.it-toolbar .hint { margin: 10px 0 0; }
.it-weeks { display: flex; align-items: center; gap: 12px; }
.it-week-label { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; text-align: center; }
.it-week-label > span:first-child { font-family: var(--serif); font-size: 20px; color: var(--white); }
.it-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.it-grid .panel + .panel { margin-top: 0; }
.it-head { display: flex; align-items: center; gap: 10px; }
.it-head .panel-title { margin: 0; }
.it-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 10px 0 4px; font-size: 13px; }
.it-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.it-status .hint { margin: 0; }
.it-channel { margin-left: auto; font-size: 13px; }
.it-week-note { background: rgba(201, 168, 76, 0.07); border-left: 3px solid var(--gold); border-radius: 4px; padding: 8px 12px; margin: 12px 0 0; white-space: pre-wrap; }
.it-day .day-heading { margin-top: 16px; }
.it-session { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.it-session:last-child { border-bottom: 0; }
.it-time { color: var(--gold-bright); font-size: 14px; font-variant-numeric: tabular-nums; }
.it-title { color: var(--white); font-weight: 600; overflow-wrap: anywhere; }
.it-title a { color: inherit; }
.it-meta { color: var(--muted); font-size: 13px; }
.it-note { color: var(--faint); font-size: 13px; }
.lapsed-search { max-width: 260px; }
.lapsed-compose { margin: 0 0 12px; }
.lapsed-compose .hint { margin: 6px 0 0; }
.lapsed-note { width: 100%; min-height: 70px; }
.it-tasks { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.it-tasks li { margin: 2px 0; }
.it-editor { margin-top: 12px; }
.it-edit-row { display: grid; grid-template-columns: 250px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.it-edit-when { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 6px; }
.it-edit-what { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.it-edit-row > .icon-btn { margin-top: 8px; }
.it-edit-tasks { display: flex; flex-direction: column; gap: 6px; padding-left: 12px; border-left: 2px solid var(--line); }
.it-edit-task { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px) auto; gap: 6px; align-items: center; }
.it-edit-tasks .link-btn { align-self: flex-start; }
.it-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.it-suggest .hint { margin: 0; }
.it-week-field { margin-top: 16px; }
.it-note-input { min-height: 60px; }

.po-quota-line { margin: 0 0 14px; color: var(--muted); }
.po-quota-line strong { color: var(--cream); }
.po-table tr.group-row td {
    background: rgba(201, 168, 76, 0.09); color: var(--gold); font-size: 12px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase; text-align: center; padding: 7px 10px;
}
.po-table .link-btn.add-slot { margin-left: 14px; letter-spacing: 0; text-transform: none; font-weight: 400; }
.po-table td.total { color: var(--white); font-weight: 600; }
.po-table tr.vacant td { color: var(--faint); }
.vacant-name { color: var(--faint); }
.po-position { color: var(--cream); }
.pill.trial { color: #9fc1f5; border-color: rgba(79, 143, 224, 0.5); background: rgba(79, 143, 224, 0.12); }
.pill.loa { color: #c6aef2; border-color: rgba(150, 110, 220, 0.5); background: rgba(150, 110, 220, 0.14); }
.pill.muted, .pill.vacant { color: var(--faint); border-color: var(--line); background: rgba(0, 0, 0, 0.2); }
.pill.strikes.s0 { color: var(--green); border-color: rgba(127, 174, 120, 0.45); background: rgba(127, 174, 120, 0.08); }
.pill.strikes.s1 { color: var(--amber); border-color: rgba(224, 176, 79, 0.5); background: rgba(224, 176, 79, 0.1); }
.pill.strikes.s2 { color: #f2a15a; border-color: rgba(242, 140, 60, 0.55); background: rgba(242, 140, 60, 0.12); }
.pill.strikes.s3 { color: #f3b3ad; border-color: rgba(216, 69, 59, 0.6); background: rgba(216, 69, 59, 0.18); }
.quota { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.quota-track { flex: 1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.quota-fill { display: block; height: 100%; background: var(--amber); border-radius: 999px; }
.quota.met .quota-fill { background: var(--green); }
.quota-num { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.quota.met .quota-num { color: var(--green); }
.icon-btn.edit:hover { background: rgba(201, 168, 76, 0.25); }
.po-unassigned { margin-top: 14px; }
.po-card { display: flex; flex-direction: column; gap: 6px; }
.po-card.vacant { opacity: 0.7; }
.po-card .mc-head .spacer { flex: 1; }
.po-card-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.po-card-team { margin: 10px 0 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.po-card-team .add-slot { font-family: var(--sans); font-size: 13px; }
.po-entry-form { display: grid; grid-template-columns: minmax(0, 1.4fr) 84px minmax(0, 1fr) 150px minmax(0, 1.4fr) auto; gap: 8px; align-items: center; margin-bottom: 14px; }
.quota-row { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
/* Mentioned in Despatches, on the Public Office page */
.despatch-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 14px; }
.despatch-form textarea { grid-column: 1 / -1; width: 100%; resize: vertical; font: inherit; }
.despatch-list { list-style: none; margin: 0; padding: 0; }
.despatch-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.despatch-list li > button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.despatch-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-width: 0; }
.despatch-head .meta { color: var(--muted); font-size: 0.85em; }
.despatch-list blockquote { margin: 0; font-family: var(--serif); font-style: italic; overflow-wrap: anywhere; }
@media (max-width: 640px) { .despatch-form { grid-template-columns: minmax(0, 1fr); } }
dialog.picker.po-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: visible; }
dialog.picker.po-dialog.reminder-dialog { width: min(560px, calc(100vw - 32px)); overflow-y: auto; }
.event-row.reminder-row { grid-template-columns: minmax(0, 1fr) auto; }
.event-row.reminder-row .pills { align-items: center; }
@media (max-width: 640px) { .event-row.reminder-row { grid-template-columns: minmax(0, 1fr); } .event-row.reminder-row .pills { justify-content: flex-start; } }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
    .it-grid { grid-template-columns: minmax(0, 1fr); }
    .po-entry-form { grid-template-columns: minmax(0, 1fr) 84px; }
    .po-entry-form > :nth-child(3), .po-entry-form > :nth-child(4) { grid-column: auto; }
    .po-entry-form > :nth-child(5) { grid-column: 1 / -1; }
    .home, .editor, .detail { grid-template-columns: minmax(0, 1fr); }
    .home { grid-template-areas: "next" "main"; }
    .editor-preview { position: static; max-height: none; }
    .site-header { flex-wrap: wrap; row-gap: 8px; }
    .site-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
    .account { margin-left: auto; }
    table.data .hide-md { display: none; }
    table.data { font-size: 13px; }
    table.data th, table.data td { padding: 8px 7px; }
    table.data th { letter-spacing: 0.06em; }
    table.data td.rank-cell { min-width: 90px; max-width: 130px; font-size: 12.5px; }
}
/* Below this the member table doesn't fit: members show as cards (with sort buttons). */
@media (max-width: 760px) {
    .members-table { display: none; }
    .member-cards, .sort-chips { display: flex; }
}
@media (max-width: 600px) {
    /* One slim sticky row up top; the sections move to a tab bar at the bottom. */
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    /* No blur here: a backdrop-filter would pin the fixed tab bar to the header instead of the screen. */
    .site-header { padding: 8px 14px; gap: 10px; flex-wrap: nowrap; backdrop-filter: none; background: rgba(15, 29, 51, 0.98); }
    .brand img { width: 32px; height: 32px; }
    .brand span { font-size: 13px; letter-spacing: 0.1em; }
    .brand small, .account .name, .account svg.chevron { display: none; }
    .account { margin-left: auto; }
    .account-btn { padding: 2px; }
    .account img { width: 32px; height: 32px; }
    .site-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; order: initial; width: auto; margin: 0;
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; overflow: visible;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(11, 22, 41, 0.97); border-top: 1px solid var(--line-strong); backdrop-filter: blur(8px);
    }
    .site-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 10px; font-size: 12px; }
    .site-nav a svg { display: block; width: 22px; height: 22px; }
    .site-nav a.current { background: rgba(201, 168, 76, 0.16); color: var(--gold-bright); }
    .fab {
        display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 29;
        width: 56px; height: 56px; border-radius: 50%; background: var(--gold); color: var(--on-gold);
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5); text-decoration: none;
    }
    .fab svg { width: 26px; height: 26px; stroke-width: 2.2; }
    .fab[hidden] { display: none; }
    .toast, .saving { bottom: calc(80px + env(safe-area-inset-bottom)); }
    .sticky-actions { bottom: calc(64px + env(safe-area-inset-bottom)); padding-bottom: 12px; }
    .site-footer { padding-bottom: 20px; }

    .app { padding: 0 16px; margin-top: 18px; margin-bottom: 40px; }
    .page-title h1 { font-size: 24px; }
    .panel { padding: 16px; }
    .event-row { grid-template-columns: 48px minmax(0, 1fr); }
    .event-row .pills { grid-column: 1 / -1; justify-content: flex-start; }
    .next-item { grid-template-columns: minmax(0, 1fr); }
    .next-rsvp { justify-content: flex-start; padding-left: 64px; }

    /* Calendar: coloured bars in the grid, the day's events listed underneath. */
    .cal-head { flex-wrap: wrap; }
    .cal-head h2 { flex: 1 0 100%; font-size: 19px; }
    .cal-plan { display: none; }
    .cal-grid { gap: 3px; }
    .cal-dow { font-size: 11px; letter-spacing: 0.06em; }
    .cal-day { min-height: 62px; padding: 3px; }
    .cal-event { height: 5px; padding: 0; margin: 0 0 2px; border-left: 0; border-radius: 3px; background: var(--row, var(--scarlet)); pointer-events: none; }
    .cal-event.mine { box-shadow: 0 0 0 1px var(--gold-bright); }
    .cal-time, .cal-title { display: none; }
    .cal-more { display: none; }
    .cal-count { display: block; position: absolute; right: 4px; top: 3px; font-size: 11px; color: var(--muted); }

    /* Attendance: cards with sort chips instead of the wide table. */
    .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; }
    .legend .wide-only { display: none; }
}

/* ---------- discord emoji in titles ---------- */

img.emoji { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: 0.25em; object-fit: contain; }
.page-title h1 img.emoji { width: 0.9em; height: 0.9em; }

/* ---------- role picker ---------- */

.chip.role { border-color: color-mix(in srgb, var(--chip, var(--gold)) 55%, transparent); color: var(--chip, var(--cream)); }
.chip.role .dot { background: var(--chip, var(--gold)); }
.role-list { max-height: 280px; }
.role-list .role-option { display: flex; align-items: center; gap: 8px; color: var(--chip, var(--cream)); }
.role-list .role-option .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip, var(--faint)); flex: none; }

/* ---------- banner picker ---------- */

.banners { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.banner-choice {
    padding: 0; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--navy-900);
    cursor: pointer; overflow: hidden; min-height: 44px; color: var(--muted); font-size: 13px;
}
.banner-choice img { display: block; width: 100%; height: 44px; object-fit: cover; }
.banner-choice.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.25); }
.banner-choice:hover { border-color: var(--line-strong); }
input:disabled { opacity: 0.45; }

/* ---------- discord preview extras ---------- */

.preview .embed .line { font-size: 14px; color: var(--cream); margin-bottom: 4px; }
.preview .embed .muted-line { color: var(--muted); margin-top: 8px; }
.preview-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preview-buttons .pb {
    font-size: 12.5px; padding: 5px 10px; border-radius: 4px; background: #4e5058; color: #fff; font-weight: 600;
}
.preview-buttons .pb.ok { background: #248046; }
.preview-buttons .pb.no { background: #da373c; }
.preview-buttons .pb.info { background: #5865f2; }

/* ---------- roster & assignment boards ---------- */

.drop-zone { transition: border-color 0.15s, background 0.15s; min-height: 90px; }
.drop-zone.over { border-color: var(--gold); background: rgba(201, 168, 76, 0.08); }
.drop { list-style: none; padding: 0; margin: 0; min-height: 24px; }
.drop li.draggable {
    display: flex; align-items: center; gap: 6px; padding: 5px 4px; border-radius: 4px; cursor: grab;
    border-bottom: 1px solid rgba(201, 168, 76, 0.06);
}
.drop li.draggable:hover { background: rgba(201, 168, 76, 0.07); }
.drop li.dragging { opacity: 0.4; }
.drop li .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.grip { width: 14px; height: 14px; color: var(--faint); }
select.mini { width: auto; max-width: 118px; padding: 2px 6px; font-size: 12px; border-radius: 4px; }
.icon-btn { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 2px; border-radius: 4px; display: grid; place-items: center; }
.icon-btn:hover { color: var(--paper); background: var(--scarlet); }
.icon-btn svg { width: 16px; height: 16px; }
.roster-tools { margin-top: 14px; margin-bottom: 0; }
.roster-tools .grow { flex: 1 1 260px; max-width: 360px; }
.round-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.roster h3.group-name { text-transform: none; letter-spacing: 0.02em; font-size: 13px; }

/* ---------- template cards ---------- */

.template-card .card-banner { width: 100%; height: 56px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.template-card .meta { color: var(--faint); font-size: 13px; }

/* ---------- composition preview ---------- */

.composition-link { margin-top: 12px; width: 100%; justify-content: center; }
.live-status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 0 3px rgba(127, 174, 120, 0.2); }
.comp-embed { border-left: 4px solid var(--gold); background: var(--navy-900); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 12px; }
.comp-embed h3 { margin: 0 0 8px; color: var(--white); font-size: 16px; }
.comp-desc { color: var(--cream); font-size: 14px; margin-bottom: 10px; }
.comp-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.comp-field { background: var(--navy-800); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.comp-field.wide { grid-column: 1 / -1; }
.comp-field-name { color: var(--gold); font-weight: 600; font-size: 13.5px; margin-bottom: 6px; overflow-wrap: anywhere; }
.comp-field-value { font-size: 14px; color: var(--cream); overflow-wrap: anywhere; }
.comp-field-value strong, .comp-desc strong { color: var(--white); }
.md-line { min-height: 1.2em; }
.comp-message { margin: 0; }

/* ---------- your own signup (event page) ---------- */

.rsvp { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.rsvp:empty { display: none; }
.rsvp-label { color: var(--white); font-weight: 600; margin-bottom: 8px; }
.rsvp-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rsvp-opt {
    border: 1px solid var(--line-strong); background: transparent; color: var(--cream); border-radius: var(--radius-sm);
    padding: 9px 4px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.rsvp-opt.ok:hover, .rsvp-opt.ok.on { background: rgba(127, 174, 120, 0.2); border-color: var(--green); color: #cfe8ca; }
.rsvp-opt.late:hover, .rsvp-opt.late.on { background: rgba(224, 176, 79, 0.18); border-color: var(--amber); color: #f5deb0; }
.rsvp-opt.no:hover, .rsvp-opt.no.on { background: rgba(224, 115, 107, 0.18); border-color: var(--red); color: #f6c4bf; }
.rsvp-opt:disabled { opacity: 0.6; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; margin-top: 8px; color: var(--gold-bright); cursor: pointer; font-size: 13px; text-decoration: underline; }
.link-btn.inline { margin: 0; font-size: inherit; font-family: inherit; }
dialog.picker select { width: 100%; }

dialog.picker {
    background: var(--navy-800); color: var(--cream); border: 1px solid var(--line-strong); border-radius: 14px;
    padding: 22px; width: min(360px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog.picker::backdrop { background: rgba(4, 9, 18, 0.7); }
dialog.picker h2 { margin: 0 0 4px; font-family: var(--serif); font-weight: 400; color: var(--white); font-size: 19px; letter-spacing: 0; }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice-list .btn { justify-content: center; }

/* ---------- editor extras ---------- */

.template-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip {
    display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--navy-900);
    color: var(--cream); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 14px;
}
.tchip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip, var(--gold)); }
.tchip:hover { border-color: var(--gold); }
.tchip.selected { border-color: var(--gold); background: rgba(201, 168, 76, 0.16); color: var(--white); font-weight: 600; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.label-row label { display: block; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.emoji-toggle { white-space: nowrap; }
.emoji-panel {
    margin: 8px 0; background: var(--navy-900); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px;
}
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-height: 210px; overflow-y: auto; margin-top: 8px; }
.emoji-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px; cursor: pointer; display: grid; place-items: center; }
.emoji-btn:hover, .emoji-btn:focus-visible { background: rgba(201, 168, 76, 0.14); border-color: var(--line-strong); }
.emoji-btn img { width: 26px; height: 26px; object-fit: contain; }
.title-render { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--navy-950); color: var(--white); font-weight: 600; }

/* ---------- streaks ---------- */

.streak {
    display: inline-block; font-size: 12px; font-weight: 700; color: #ffb35c; padding: 0 6px; border-radius: 999px;
    background: rgba(255, 140, 40, 0.12); border: 1px solid rgba(255, 140, 40, 0.35); white-space: nowrap; vertical-align: 1px;
}

/* ---------- time zones in the editor ---------- */

.zone-echo {
    margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--navy-950);
    border: 1px solid var(--line); color: var(--cream); font-size: 14px;
}
.zone-echo:empty { display: none; }

/* ---------- delete dialog ---------- */

dialog.picker { width: min(420px, calc(100vw - 32px)); }
.choice-list .btn.choice {
    flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: 2px; padding: 12px 14px;
    border-radius: var(--radius);
}
.choice-list .btn.choice strong { color: var(--white); font-size: 15px; }
.choice-list .btn.choice span { color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.4; }
.choice-list .btn.choice.danger:hover span, .choice-list .btn.choice.danger:hover strong { color: var(--white); }

/* ---------- attendance chart ---------- */

.trend-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.trend-head .panel-title { margin-bottom: 0; }
.trend-head .range-chips { margin-left: auto; }
.trend-head .btn { margin-left: 4px; }
.trend-sub { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.trend-body { transition: opacity 0.2s; }
.trend-body.refreshing { opacity: 0.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.line-key { display: inline-block; width: 16px; border-top: 2px solid var(--key); vertical-align: middle; }
.line-key.dashed { border-top-style: dashed; }
.chart, .chart-plot { min-width: 0; max-width: 100%; }
.chart-plot { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
.chart-svg .grid { stroke: rgba(232, 224, 208, 0.08); stroke-width: 1; }
.chart-svg .axis { stroke: rgba(232, 224, 208, 0.28); stroke-width: 1; }
.chart-svg .tick { fill: var(--faint); font-size: 11px; font-family: var(--sans); }
.chart-svg .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dashed { stroke-dasharray: 5 4; }
.chart-svg .marker { stroke: var(--navy-800); stroke-width: 2; }
.chart-svg .end-key { stroke-width: 2; }
.chart-svg .end-label { fill: var(--muted); font-size: 12px; font-family: var(--sans); }
.chart-svg .crosshair { stroke: rgba(232, 224, 208, 0.45); stroke-width: 1; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
    position: absolute; pointer-events: none; min-width: 150px; background: var(--navy-950); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); padding: 8px 10px; box-shadow: var(--shadow); font-size: 13px; z-index: 2;
}
.chart-tip .tip-head { color: var(--muted); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row strong { color: var(--white); font-size: 15px; min-width: 22px; }
.chart-tip .tip-row span:last-child { color: var(--muted); }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--gold-bright); width: fit-content; }
.chart-table .table-wrap { margin-top: 8px; max-height: 280px; overflow-y: auto; }
.name-btn {
    background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left;
    text-decoration: underline; text-decoration-color: rgba(201, 168, 76, 0.4); text-underline-offset: 3px;
}
.name-btn:hover, .name-btn:focus-visible { color: var(--gold-bright); text-decoration-color: var(--gold-bright); }

/* A checkbox inside a form field reads as a sentence, not another field label. */
.field label.check {
    display: flex; align-items: flex-start; gap: 10px; text-transform: none; letter-spacing: 0;
    color: var(--cream); font-size: 14.5px; line-height: 1.4; margin: 0;
}
.field label.check input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--gold); }

/* Repeats that don't exist yet (made once the one before starts): shown, but quieter. */
.cal-event.projected { opacity: 0.7; background: transparent; border-left-style: dashed; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--row, var(--scarlet)) 30%, transparent); }
.event-row.projected { opacity: 0.75; border-left-style: dashed; }
.repeat-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px dashed var(--muted); }

/* ---------------- analytics ---------------- */
.sub-head { font-family: var(--serif); font-weight: 400; color: var(--gold); font-size: 18px; letter-spacing: 0; margin: 22px 0 10px; }
.chip-gap { width: 10px; }
.game-name { display: inline-flex; align-items: center; gap: 8px; }
.bar-rows { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-label { color: var(--cream); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: var(--navy-900); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--gold); }
.bar-value { color: var(--white); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.heatmap-wrap { overflow-x: auto; }
.heatmap { display: grid; grid-template-columns: 38px repeat(24, minmax(14px, 1fr)); gap: 3px; min-width: 460px; }
.hm-hour { font-size: 11px; color: var(--faint); text-align: left; }
.hm-day { font-size: 12px; color: var(--muted); align-self: center; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--line);
    background: color-mix(in srgb, var(--gold) calc(var(--heat, 0) * 100%), var(--navy-900)); }
.top-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.top-box { background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.top-box h3 { font-family: var(--serif); font-weight: 400; color: var(--gold); font-size: 17px; margin: 0 0 8px; }
.top-box ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.top-box li span { color: var(--cream); }
.top-box li b { float: right; color: var(--white); font-variant-numeric: tabular-nums; }
.two-col > div { min-width: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 18px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-top: 10px; }
.report-box { background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.report-box h3 { font-family: var(--serif); font-weight: 400; color: var(--gold); font-size: 17px; margin: 0 0 8px; }
.md-list { margin: 0 0 6px; padding-left: 18px; display: grid; gap: 3px; }
.md-line { margin: 4px 0; }
.report-box strong, .md-line strong { color: var(--white); }
.stat-cards.compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
@media (max-width: 600px) {
    .stat-cards.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .stat-cards.compact .stat-card { padding: 12px; }
    .stat-cards.compact .stat-card .value { font-size: 24px; }
    .bar-row { grid-template-columns: 96px 1fr auto; }
}

/* ---------- the Naval Chronicle ---------- */

.chronicle-preview { display: block; max-width: 100%; max-height: 420px; margin-top: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.chronicle-issues { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.chronicle-card { min-height: 0; padding: 14px; }
.chronicle-card:hover { transform: none; }
.chronicle-card img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--cream); }
.chronicle-card h2 { display: flex; align-items: center; gap: 8px; }
.chronicle-card .meta { color: var(--faint); font-size: 13px; }
.chronicle-card .actions { margin-top: auto; }
.chronicle-card .tag { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-gold); background: var(--gold); border-radius: 999px; padding: 2px 8px; }
input[type="file"] { display: block; width: 100%; color: var(--muted); font: inherit; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--navy-700); color: var(--cream); font: inherit; cursor: pointer; }
input[type="file"]::file-selector-button:hover { border-color: var(--gold); }

/* ---------- chain of command ---------- */

.hierarchy { --stem: 26px; display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; }
.hier-crown { display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }
.hier-key {
    min-width: 260px; text-align: center; padding: 14px 22px;
    background: linear-gradient(180deg, rgba(201, 168, 76, 0.12), rgba(201, 168, 76, 0.03)), var(--navy-800);
    border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
}
.hier-key.top { border-color: var(--gold); min-width: 300px; }
.hier-role { font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.hier-name { font-family: var(--serif); font-size: 22px; font-weight: 400; color: var(--white); margin-top: 2px; }
.hier-key.top .hier-name { font-size: 26px; }
.hier-name.you { color: var(--gold-bright); }
.hier-name.vacant { color: var(--faint); font-style: italic; font-weight: 400; }
/* Majors and above, under the Colonel and over both companies. */
.hier-command { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; position: relative; margin-top: calc(var(--stem) - 12px); }
.hier-command::before {
    content: ""; position: absolute; left: 50%; top: calc(var(--stem) * -1); height: var(--stem);
    border-left: 1px solid var(--gold-dim);
}
.hier-key.command { border-color: var(--gold-dim); }
.hier-sub { color: var(--muted); font-size: 13px; display: flex; gap: 6px; justify-content: center; align-items: center; }

/* The gold stem from the Colonel, and the bracket out to both companies. */
.hier-split {
    position: relative; width: 100%; margin-top: calc(var(--stem) * 2);
    display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
    column-gap: 28px; row-gap: var(--stem); align-items: stretch;
}
.hier-split::before {
    content: ""; position: absolute; left: 50%; top: calc(var(--stem) * -2); height: var(--stem);
    border-left: 1px solid var(--gold-dim);
}
.hier-split::after {
    content: ""; position: absolute; left: 25%; right: 25%; top: calc(var(--stem) * -1); height: var(--stem);
    border: 1px solid var(--gold-dim); border-bottom: 0;
}
/* One cell per company per row; paired cards stretch to the same height. */
.hier-cell {
    grid-column: var(--col); grid-row: var(--row); position: relative; min-width: 0;
    display: flex; flex-direction: column; justify-content: center;
}
.hier-cell > * { flex: 1 1 auto; }
.hier-cell-head > *, .hier-cell-oc > * { flex: 0 0 auto; }
.hier-cell:not(.hier-cell-head):not(.hier-span)::before {
    content: ""; position: absolute; left: 50%; top: calc(var(--stem) * -1); height: var(--stem);
    border-left: 1px solid var(--gold-dim);
}
/* A company with nothing at this level: the line carries straight on down. */
.hier-cell.empty::after {
    content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--gold-dim);
}
/* The OC card is centred; its line runs on past it to the next row. */
.hier-cell-oc { align-items: center; }
.hier-cell-oc::after {
    content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--gold-dim);
}
.hier-key.oc { width: min(100%, 340px); position: relative; z-index: 1; }

/* Serjeants Major: one card across both companies, tied into both columns' lines. */
.hier-majors { border-color: var(--gold-dim); background: linear-gradient(180deg, rgba(201, 168, 76, 0.08), rgba(201, 168, 76, 0.02)), var(--navy-800); }
.hier-majors .hier-people { justify-content: center; }
.hier-majors-note { margin: -4px 0 8px; text-align: center; color: var(--muted); font-size: 12.5px; }
.hier-span { grid-column: 1 / -1; align-items: center; }
.hier-span > .hier-majors { flex: 0 0 auto; width: min(46%, 520px); position: relative; z-index: 1; }
.hier-span::before {
    /* across from one column's line to the other, behind the card */
    content: ""; position: absolute; top: 50%; left: calc((100% - 28px) / 4); right: calc((100% - 28px) / 4);
    border-top: 1px solid var(--gold-dim);
}
.hier-span::after, .hier-span-line.right {
    content: ""; position: absolute; top: calc(var(--stem) * -1); bottom: 0; left: calc((100% - 28px) / 4); border-left: 1px solid var(--gold-dim);
}
/* Placed from the left like the other lines, so it doesn't sit a pixel off theirs. */
.hier-span-line.right { left: calc(100% - (100% - 28px) / 4); }
.hier-majors-regions { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px 16px; }
.hier-majors-region { grid-column: var(--col); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hier-majors-region .hier-region { margin-left: 0; vertical-align: 0; }
.hier-cell.phone-only { display: none; }
.hier-company-head { text-align: center; padding: 10px 0 2px; border-bottom: 2px solid var(--scarlet); }
.hier-company-head h2 { font-family: var(--serif); font-weight: 400; margin: 0; font-size: 24px; color: var(--white); display: inline; }
.hier-region {
    margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 7px;
    border-radius: 999px; border: 1px solid var(--line-strong); color: var(--gold); vertical-align: 4px;
}

.hier-tier {
    background: var(--navy-800); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 16px 14px;
}
.hier-tier-label {
    margin: 0 0 8px; text-align: center; font-family: var(--sans); font-size: 11.5px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
}
.hier-group {
    display: grid; grid-template-columns: minmax(118px, 34%) 1fr; gap: 6px 14px; align-items: baseline;
    padding: 7px 0; border-top: 1px solid var(--line);
}
.hier-group:first-of-type { border-top: 0; }
.hier-rank { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
/* Cpl/LS rows with the equivalent unique appointments off to the side. */
.hier-equiv {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: 0 22px; align-items: center;
    border-top: 1px solid var(--line);
}
.hier-equiv-main .hier-group { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.hier-equiv-main .hier-group:first-child { border-top: 0; }
.hier-equiv-side {
    position: relative; margin: 8px 0; padding: 8px 10px; border: 1px dashed var(--gold-dim); border-radius: var(--radius-sm);
    background: rgba(201, 168, 76, 0.05);
}
.hier-equiv-side::before {
    content: ""; position: absolute; left: -23px; top: 50%; width: 22px; border-top: 1px dashed var(--gold-dim);
}
.hier-equiv-label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
.hier-appointment { padding: 4px 0; }
.hier-appointment + .hier-appointment { border-top: 1px solid var(--line); }
.hier-appointment .hier-rank { font-style: italic; margin-bottom: 3px; }
.hier-equiv + .hier-group { border-top: 1px solid var(--line); }
.hier-people { display: flex; flex-wrap: wrap; gap: 6px; }
.hier-person {
    max-width: 100%; overflow-wrap: anywhere;
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--white); font-size: 14px; font-weight: 600;
}
.hier-person.you { border-color: var(--gold); color: var(--gold-bright); background: rgba(201, 168, 76, 0.12); }
.hier-person.away { color: var(--muted); font-weight: 400; }
.hier-person.sample { font-size: 12px; padding: 1px 8px; }
.hier-status {
    font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 1px 5px; border-radius: 4px;
    background: rgba(224, 176, 79, 0.18); color: var(--amber);
}
.hier-branch { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 1px 5px; border-radius: 4px; font-style: normal; }
.hier-branch.rm { background: rgba(179, 38, 30, 0.28); color: #f0a49e; }
.hier-branch.rn { background: rgba(80, 130, 210, 0.25); color: #a9c6f2; }
.hier-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.hier-count { text-align: center; padding: 6px 4px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.04); }
.hier-count strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 20px; color: var(--white); }
.hier-count span { font-size: 12px; color: var(--muted); }
.hier-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 22px; }

/* Senior NCO blocks, each with its NCOs hanging beneath. */
.hier-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px 14px; align-items: start; }
.hier-section { display: flex; flex-direction: column; min-width: 0; }
.hier-sec-head {
    position: relative; text-align: center; padding: 8px 10px; border: 1px solid var(--gold-dim); border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(201, 168, 76, 0.1), rgba(201, 168, 76, 0.03)), var(--navy-800);
}
.hier-sec-rank { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); display: flex; gap: 6px; justify-content: center; align-items: center; }
.hier-sec-name { font-weight: 700; color: var(--white); font-size: 15px; margin-top: 2px; display: flex; gap: 6px; justify-content: center; align-items: center; overflow-wrap: anywhere; }
.hier-sec-name.you { color: var(--gold-bright); }
.hier-sec-head.away .hier-sec-name { color: var(--muted); font-weight: 400; }
.hier-sec-body {
    position: relative; margin-top: 14px; padding: 4px 10px 6px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}
.hier-sec-body::before {
    content: ""; position: absolute; left: 50%; top: -15px; height: 14px; border-left: 1px solid var(--gold-dim);
}
.hier-sec-body .hier-group { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.hier-sec-body .hier-group.appointment .hier-rank { font-style: italic; }
.hier-sec-empty { margin: 6px 0; text-align: center; color: var(--faint); font-style: italic; font-size: 13px; }
.hier-unassigned { margin-top: 16px; padding: 8px 12px 4px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.hier-unassigned > .hier-equiv-label { text-align: center; margin-bottom: 2px; }
.hier-equiv-side.hier-appointments { margin: 16px 0 0; }
.hier-equiv-side.hier-appointments::before { display: none; }
.hier-appointments > .hier-equiv-label { text-align: center; }
/* The Colonel's appointments: in the first company's NCO box (else bottom left), joined to the
   Colonel by a line up the left gutter. */
.hierarchy:has(.hier-colonels) { position: relative; padding-left: 28px; }
.hier-equiv-side.hier-colonels { align-self: flex-start; margin: calc(var(--stem) * 1.5) 0 0; min-width: 260px; max-width: 420px; }
.hier-equiv-side.hier-colonels::before { display: none; }
.hier-colonels > .hier-equiv-label { text-align: left; }
.hier-tier .hier-equiv-side.hier-colonels { align-self: stretch; max-width: none; min-width: 0; margin: 16px 0 0; }
.hier-colonels-line { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 2; }
.hier-colonels-line path { fill: none; stroke: var(--gold-dim); stroke-width: 1; stroke-dasharray: 4 3; }

dialog.picker.hier-assign { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.hier-assign-company { margin-top: 16px; }
.hier-assign-company h3 { margin: 0 0 6px; font-family: var(--serif); font-weight: 400; font-size: 16px; color: var(--white); }
.hier-assign-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.hier-assign-row > span { display: flex; flex-direction: column; min-width: 0; }
.hier-assign-row small { color: var(--muted); font-size: 12px; }
.hier-assign-row select { width: auto; max-width: 55%; }

@media (max-width: 860px) {
    .hier-split { grid-template-columns: minmax(0, 1fr); margin-top: var(--stem); }
    .hier-cell { grid-column: 1; grid-row: auto; order: var(--order); }
    .hier-cell.empty, .hier-cell.desktop-only { display: none; }
    .hier-cell.phone-only { display: flex; }
    .hier-cell-head:not(:first-child) { margin-top: calc(var(--stem) * 0.6); }
    .hier-split::after { display: none; }
    .hier-split::before { top: calc(var(--stem) * -1); }
    .hier-key, .hier-key.top { min-width: 0; width: 100%; }
    .hier-crown, .hier-command { width: 100%; }
    .hier-group { grid-template-columns: 1fr; }
    .hier-equiv { grid-template-columns: minmax(0, 1fr); }
    .hier-equiv-side::before { left: 50%; top: -9px; width: 0; height: 8px; border-top: 0; border-left: 1px dashed var(--gold-dim); }
    .hierarchy:has(.hier-colonels) { padding-left: 0; }
    .hier-equiv-side.hier-colonels { align-self: stretch; max-width: none; }
}

/* Phones: the detachment pages and the restart card under the slim header. */
@media (max-width: 600px) {
    .saving.starting { top: calc(60px + env(safe-area-inset-top)); }
    .it-weeks { gap: 8px; }
    .it-weeks .wide-label { display: none; }
    .it-week-label > span:first-child { font-size: 17px; }
    .it-session { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .it-edit-row { grid-template-columns: minmax(0, 1fr) auto; }
    .it-edit-when { grid-column: 1 / -1; grid-row: 1; }
    .it-edit-what { grid-column: 1; grid-row: 2; }
    .it-edit-row > .icon-btn { grid-column: 2; grid-row: 2; }
    .it-edit-task { grid-template-columns: minmax(0, 1fr) auto; }
    .it-edit-task select { grid-column: 1; }
    .it-channel { margin-left: 0; }
    .po-entry-form { grid-template-columns: minmax(0, 1fr) 76px; }
    .po-entry-form > .btn { grid-column: 1 / -1; justify-content: center; }
}

/* ---------------- FINN ---------------- */
.po-finn-link { margin: 0 0 16px; }
.finn-compose { margin-bottom: 18px; }
.finn-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.finn-pick { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; color: var(--cream); margin: 0; }
.finn-pick .icon { width: 16px; height: 16px; }
.finn-media { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.finn-media:empty { display: none; }
.finn-thumb {
    position: relative; width: 104px; height: 104px; border-radius: var(--radius-sm); overflow: hidden; flex: none;
    border: 1px solid var(--line-strong); background: var(--navy-900); display: grid; place-items: center;
    color: var(--muted); text-decoration: none;
}
.finn-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.finn-thumb.video { align-content: center; gap: 4px; padding: 8px; text-align: center; font-size: 12px; }
.finn-thumb.video span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finn-thumb .icon { width: 26px; height: 26px; color: var(--gold); }
.finn-remove {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(8, 17, 34, 0.85); color: var(--cream); font-size: 16px; line-height: 1;
}
.finn-remove:hover { background: var(--scarlet); color: var(--paper); }
.finn-platforms { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.finn-when { display: grid; gap: 8px; }
.finn-custom-when { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 8px; }
.finn-custom-when[hidden] { display: none; }
.finn-cards { display: grid; gap: 14px; }
.finn-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: rgba(0, 0, 0, 0.15); }
.finn-card .actions { margin-top: 12px; }
.finn-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.finn-card-head .tag .icon { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
.finn-text { margin-top: 10px; }
.finn-caption { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.finn-hashtags { margin: 6px 0 0; color: var(--gold-bright); font-size: 14px; overflow-wrap: anywhere; }
.finn-fits { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.finn-fit.over { color: var(--gold-bright); }
.finn-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.finn-chips a.pill { text-decoration: none; }
.finn-items { display: grid; gap: 12px; margin-top: 12px; }
.finn-item { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 14px; align-items: start; }
.finn-item .finn-media { margin-top: 0; }
.finn-item .finn-chips { margin-top: 6px; }
.finn-due { display: flex; align-items: center; gap: 6px; color: var(--cream); font-size: 14px; }
.finn-due .icon { width: 15px; height: 15px; color: var(--gold); }
.finn-error { margin: 6px 0 0; color: #f3b3ad; }

@media (max-width: 600px) {
    .finn-thumb { width: 84px; height: 84px; }
    .finn-item { grid-template-columns: 84px minmax(0, 1fr); gap: 10px; }
    .finn-custom-when { grid-template-columns: minmax(0, 1fr); }
}

/* Lapsed members */
.lapsed-pills { display: inline-flex; flex-wrap: wrap; gap: 4px; }
table.data td.lapsed-last { white-space: normal; min-width: 180px; max-width: 280px; font-size: 13px; }
.lapsed-table input[type="checkbox"], .member-card input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }

/* The live pill takes over the account button's push to the right when the nav wraps or moves to the bottom. */
@media (max-width: 900px) {
    .live-pill { margin-left: auto; margin-right: 0; }
    .live-pill:not([hidden]) + .account { margin-left: 0; }
}

/* DM Manager */
.dm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); gap: 16px; align-items: start; }
.dm-side { position: sticky; top: 16px; }
.dm-body { width: 100%; min-height: 180px; }
.dm-link-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; margin-bottom: 8px; }
.dm-audience-count { margin: 12px 0 4px; }
.dm-embed { background: rgba(0, 0, 0, 0.28); border-left: 4px solid var(--dm-accent, #E01515); border-radius: var(--radius-sm);
    padding: 12px 14px; display: grid; gap: 8px; overflow-wrap: anywhere; }
.dm-author { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--white); }
.dm-author img { width: 22px; height: 22px; border-radius: 50%; }
.dm-title { font-weight: 700; color: var(--white); font-size: 15.5px; }
.dm-text { white-space: pre-wrap; font-size: 14px; line-height: 1.45; color: var(--cream); }
.dm-text a { color: #7ab7ff; }
.dm-image { max-width: 100%; border-radius: var(--radius-sm); }
.dm-footer { font-size: 12px; color: var(--faint); }
.dm-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dm-button { font-size: 13px; padding: 6px 12px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.08); color: var(--white); }
.dm-history { display: grid; gap: 12px; }
.dm-campaign { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 8px; }
.dm-campaign-head, .dm-campaign-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dm-progress { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.dm-progress span { display: block; height: 100%; background: var(--gold); }
@media (max-width: 860px) {
    .dm-grid { grid-template-columns: 1fr; }
    .dm-side { position: static; }
    .dm-link-row { grid-template-columns: 1fr; }
}
.dm-image-field { display: grid; gap: 8px; }
.dm-thumb { max-width: 220px; max-height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--line); object-fit: cover; }

/* Phones: six tabs fit a 360px screen (labels shrink or trim instead of pushing the last tab
   off the edge), and form fields are 16px so iPhones don't zoom in when one is tapped. */
@media (max-width: 600px) {
    .site-nav { grid-auto-columns: minmax(0, 1fr); }
    .site-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 600px) {
    .site-nav a { font-size: 11px; letter-spacing: -0.01em; padding-inline: 0; }
}
@media (max-width: 380px) {
    .site-nav a { font-size: 10px; }
}
@media (max-width: 760px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
    select, textarea { font-size: 16px !important; }
}
/* A long breadcrumb trail wraps instead of widening the page, and the hidden file picker
   behind "Add pictures or videos" stays 1px (input[type="file"] above made it full width). */
.page-title .crumbs { flex-wrap: wrap; row-gap: 2px; }
input[type="file"].finn-file { width: 1px; height: 1px; left: 0; top: 0; }

/* A private event's specials: a tick and "most men" box each. */
.specials { display: grid; gap: 8px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line, rgba(201, 168, 76, 0.25)); border-radius: 8px; }
.specials[hidden] { display: none; }
.special-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.special-row .check { min-width: 120px; }
.field .special-row label.special-max { display: inline-flex; align-items: center; gap: 8px; margin: 0; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 13px; }
.special-row input[type="number"] { width: 72px; }
.special-row .hint { flex-basis: 100%; margin: 0; }
/* The private-event tag carries its specials, so it may wrap on a phone. */
.tag.hosted { white-space: normal; max-width: 100%; min-width: 0; }
.special-row[hidden] { display: none; }

/* ================= The theme menu, More and All pages (26 November 2026) ================= */

/* theme.js + theme.css draw the menu; these are its colours here. */
:root {
    --tm-bg: var(--navy-700); --tm-ink: var(--white); --tm-muted: var(--muted); --tm-line: var(--line-strong);
    --tm-accent: var(--gold); --tm-on-accent: var(--on-gold); --tm-hover: rgba(201, 168, 76, 0.1); --tm-font: var(--sans);
}
.theme-slot { display: flex; align-items: center; }
.theme-slot:empty { display: none; }
@media (max-width: 900px) {
    .live-pill:not([hidden]) + .theme-slot { margin-left: 0; }
    .theme-slot { margin-left: auto; }
    .theme-slot + .account { margin-left: 0; }
}
@media (max-width: 600px) {
    .theme-slot .theme-menu > summary { border-color: transparent; min-height: 34px; padding: 6px; }
    .theme-slot .tm-panel { top: calc(56px + env(safe-area-inset-top)); position: fixed; }
}

/* More: every page, grouped, in a panel under the bar (a page of its own on phones). */
.site-nav a.nav-more { display: inline-flex; align-items: center; gap: 6px; }
.site-header { position: sticky; }
.more-menu {
    position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 6px); z-index: 45;
    width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 110px); overflow-y: auto;
    padding: 18px 20px 12px; border-radius: var(--radius);
    background: var(--navy-700); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 22px; }
.more-group h2 {
    margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
    font: 600 11px/1.2 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold);
}
.more-group ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.more-link {
    display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: center;
    padding: 7px 8px; border-radius: var(--radius-sm); color: var(--cream); text-decoration: none;
}
.more-link:hover, .more-link:focus-visible { background: rgba(201, 168, 76, 0.1); color: var(--white); outline: none; }
.more-link:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); }
.more-icon {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--gold);
    border: 1px solid var(--line-strong); background: radial-gradient(circle at 30% 30%, rgba(201, 168, 76, 0.16), rgba(201, 168, 76, 0.03));
}
.more-icon svg.icon { width: 16px; height: 16px; }
.more-text { display: flex; flex-direction: column; min-width: 0; }
.more-text strong { font-weight: 600; font-size: 14px; color: var(--white); }
.more-text small { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more-menu .more-text small { -webkit-line-clamp: 1; }
.more-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.more-foot a { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); text-decoration: none; font-size: 13px; font-weight: 600; }
.more-foot a svg { width: 16px; height: 16px; }
@media (max-width: 1100px) { .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* #/pages */
.pages-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.pages-list .more-group { background: var(--navy-800); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 6px; }
.pages-theme { margin-top: 18px; }
.pages-theme .theme-menu > summary { display: none; }
.pages-theme .tm-panel { position: static; width: auto; max-width: 420px; box-shadow: none; padding: 0; border: 0; background: transparent; }
@media (max-width: 1000px) { .pages-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .pages-list { grid-template-columns: minmax(0, 1fr); gap: 12px; } }

/* Phones: five tabs. Profile and Analytics move into More (the All pages page). */
@media (max-width: 600px) {
    .site-nav a[data-nav="profile"], .site-nav a[data-nav="analytics"] { display: none !important; }
    .site-nav a.nav-more { display: flex; }
}

/* ================= Light theme ================= */
/* Parchment and navy ink. The prints behind the page stay; the wash over them goes pale. */
:root[data-theme="light"] {
    color-scheme: light;
    --navy-950: #e7decb;
    --navy-900: #f3eee3;
    --navy-800: #fbf8f2;
    --navy-700: #f3ecdd;
    --navy-600: #e8dfcc;
    --navy-500: #d9cbaa;
    --gold: #8a6a1c;
    --gold-bright: #6f540f;
    --gold-dim: #a3832f;
    --cream: #26324a;
    --white: #0f1d33;
    --muted: rgba(15, 29, 51, 0.74);
    --faint: rgba(15, 29, 51, 0.58);
    --line: rgba(138, 106, 28, 0.22);
    --line-strong: rgba(138, 106, 28, 0.45);
    --scarlet: #b3261e;
    --scarlet-bright: #c8352c;
    --green: #2f7a43;
    --amber: #94650a;
    --red: #b3261e;
    --shadow: 0 6px 20px rgba(15, 29, 51, 0.1);
    --on-gold: #fffaf0;
    --tm-hover: rgba(138, 106, 28, 0.1);
}
:root[data-theme="light"] body {
    background: radial-gradient(1200px 500px at 50% -200px, rgba(138, 106, 28, 0.08), transparent 70%), var(--navy-900);
}
:root[data-theme="light"] body::before {
    background-image:
        linear-gradient(rgba(243, 238, 227, 0.55), rgba(243, 238, 227, 0.55)),
        url("sea/ship.webp?v=1"),
        url("sea/serpent.webp?v=1"),
        url("sea/chart.webp?v=1");
}
:root[data-theme="light"] .site-header { background: rgba(251, 248, 242, 0.94); }
:root[data-theme="light"] .brand img { filter: none; }
:root[data-theme="light"] .panel { background: var(--navy-800); }
:root[data-theme="light"] .site-footer .legal-nav a, :root[data-theme="light"] .site-footer .creator-credit a { color: rgba(138, 106, 28, 0.8); }
:root[data-theme="light"] .site-footer .creator-credit { color: rgba(15, 29, 51, 0.5); }
:root[data-theme="light"] .sticky-actions { background: linear-gradient(180deg, rgba(243, 238, 227, 0), rgba(243, 238, 227, 0.94) 22%, var(--navy-900)); }
:root[data-theme="light"] .chip button { background: rgba(15, 29, 51, 0.06); }
:root[data-theme="light"] .btn.danger { color: #941a0f; }
:root[data-theme="light"] .error-text { color: #98180b; }
:root[data-theme="light"] .tag.region { color: #2e4675; }
:root[data-theme="light"] .tag.region.r-na { color: #99590a; }
:root[data-theme="light"] .tag.low { color: #a35200; }
:root[data-theme="light"] .cal-time b { color: #99590a; }
:root[data-theme="light"] .pill.trial { color: #09429a; }
:root[data-theme="light"] .pill.loa { color: #3f1193; }
:root[data-theme="light"] .pill.muted, :root[data-theme="light"] .pill.vacant { background: rgba(15, 29, 51, 0.05); }
:root[data-theme="light"] .pill.strikes.s2 { color: #9e4d05; }
:root[data-theme="light"] .pill.strikes.s3 { color: #941a0f; }
:root[data-theme="light"] .rsvp-opt.ok:hover, :root[data-theme="light"] .rsvp-opt.ok.on { color: #2f6b25; }
:root[data-theme="light"] .rsvp-opt.late:hover, :root[data-theme="light"] .rsvp-opt.late.on { color: #8a5f08; }
:root[data-theme="light"] .rsvp-opt.no:hover, :root[data-theme="light"] .rsvp-opt.no.on { color: #951a0e; }
:root[data-theme="light"] .streak { color: #a35700; }
:root[data-theme="light"] .chart-svg .grid { stroke: rgba(15, 29, 51, 0.09); }
:root[data-theme="light"] .chart-svg .axis { stroke: rgba(15, 29, 51, 0.32); }
:root[data-theme="light"] .chart-svg .crosshair { stroke: rgba(15, 29, 51, 0.52); }
:root[data-theme="light"] .hier-branch.rm { color: #931a10; }
:root[data-theme="light"] .hier-branch.rn { color: #0f4494; }
:root[data-theme="light"] .finn-remove { background: rgba(251, 248, 242, 0.9); }
:root[data-theme="light"] .finn-card { background: rgba(15, 29, 51, 0.04); }
:root[data-theme="light"] .finn-error { color: #941a0f; }
:root[data-theme="light"] .finn-hashtags { color: #6f540f; }
:root[data-theme="light"] .fame-src.kofi { color: #08449b; }
:root[data-theme="light"] .fame-src.mee6 { color: #4d1093; }
:root[data-theme="light"] .pf-bar { background: rgba(15, 29, 51, 0.09); }
:root[data-theme="light"] .pf-pill.ok { color: #2f6b25; }
:root[data-theme="light"] .pf-hero > .pf-banner::after { background: linear-gradient(180deg, rgba(251, 248, 242, 0) 35%, rgba(251, 248, 242, 0.7) 75%, var(--navy-800)); }
:root[data-theme="light"] .pf-chips li { background: rgba(251, 248, 242, 0.75); }
:root[data-theme="light"] .pf-clock { background: rgba(251, 248, 242, 0.75); }
:root[data-theme="light"] .pf-pin-cat { color: rgba(15, 29, 51, 0.71); }
:root[data-theme="light"] .pf-hex.t6 { color: #a37900; }
:root[data-theme="light"] .pf-chart .grid { stroke: rgba(15, 29, 51, 0.09); }
:root[data-theme="light"] .pf-chart .grid.base { stroke: rgba(15, 29, 51, 0.29); }
:root[data-theme="light"] .pf-ladder .state.done, :root[data-theme="light"] .pf-cat-bar.complete .n, :root[data-theme="light"] .pf-status.yes { color: #2f6b25; }
:root[data-theme="light"] .pf-ring .track, :root[data-theme="light"] .pf-big-ring .track { stroke: rgba(15, 29, 51, 0.1); }
:root[data-theme="light"] .pf-status.no { background: rgba(15, 29, 51, 0.07); }
:root[data-theme="light"] .more-link:hover, :root[data-theme="light"] .more-link:focus-visible { background: rgba(138, 106, 28, 0.1); }
@media (max-width: 600px) {
    :root[data-theme="light"] .site-header { background: rgba(251, 248, 242, 0.98); }
    :root[data-theme="light"] .site-nav { background: rgba(251, 248, 242, 0.97); }
    :root[data-theme="light"] .site-nav a.current { background: rgba(138, 106, 28, 0.14); }
}

/* Things that stay dark in the light theme: the Discord previews (they show Discord), the
   Muster Chart and the profile's collectible card. */
:root[data-theme="light"] :is(.preview, .dm-preview, .mc-panel, .pf-face, .pf-showcase) {
    --navy-950: #081122; --navy-900: #0b1629; --navy-800: #0f1d33; --navy-700: #162744; --navy-600: #1d3257; --navy-500: #27416d;
    --gold: #c9a84c; --gold-bright: #e0c36a; --gold-dim: #a08535; --cream: #e8e0d0; --white: #f5f2ed;
    --muted: rgba(232, 224, 208, 0.76); --faint: rgba(232, 224, 208, 0.58);
    --line: rgba(201, 168, 76, 0.18); --line-strong: rgba(201, 168, 76, 0.4); --on-gold: #0b1629;
    color: var(--cream);
}
:root[data-theme="light"] .dm-preview { background: #0f1d33; border-radius: var(--radius); padding: 12px; }

/* ================= Accent colours (the theme menu) ================= */
/* The gold family follows the accent; the regiment's scarlet and the crest stay. */
:root[data-accent="scarlet"] { --gold: #d0574c; --gold-bright: #ec8a7f; --gold-dim: #a8382f; --on-gold: #fffaf0; }
:root[data-accent="sea"] { --gold: #3aa08a; --gold-bright: #7fd0bd; --gold-dim: #2a7a69; --on-gold: #06201a; }
:root[data-accent="royal"] { --gold: #5b8ae0; --gold-bright: #9dbcf3; --gold-dim: #3b6fd1; --on-gold: #071833; }
:root[data-accent="plum"] { --gold: #9d70c6; --gold-bright: #caabe6; --gold-dim: #7a4fa3; --on-gold: #fffaf0; }
:root[data-accent="silver"] { --gold: #a3adbb; --gold-bright: #d3d9e2; --gold-dim: #7e8898; --on-gold: #0b1629; }
:root[data-theme="light"][data-accent="scarlet"] { --gold: #a8322a; --gold-bright: #8c241d; --gold-dim: #c0453c; --on-gold: #fffaf0; }
:root[data-theme="light"][data-accent="sea"] { --gold: #1d6e5d; --gold-bright: #14564a; --gold-dim: #2f8f7a; --on-gold: #fffaf0; }
:root[data-theme="light"][data-accent="royal"] { --gold: #2a58b0; --gold-bright: #1f4690; --gold-dim: #3b6fd1; --on-gold: #fffaf0; }
:root[data-theme="light"][data-accent="plum"] { --gold: #6e4596; --gold-bright: #57347a; --gold-dim: #8a5bb5; --on-gold: #fffaf0; }
:root[data-theme="light"][data-accent="silver"] { --gold: #556273; --gold-bright: #3f4a59; --gold-dim: #6f7c8e; --on-gold: #fffaf0; }
:root[data-accent] { --line: color-mix(in srgb, var(--gold) 22%, transparent); --line-strong: color-mix(in srgb, var(--gold) 45%, transparent); --tm-hover: color-mix(in srgb, var(--gold) 12%, transparent); }

/* The bar fits: the theme button is just the palette here, and between phones and wide
   screens the account shows only its picture (the name is in its menu). */
.theme-slot .tm-label { display: none; }
.theme-slot .theme-menu > summary { padding: 7px; border-color: transparent; }
@media (min-width: 601px) and (max-width: 1380px) {
    .account .name, .account svg.chevron { display: none; }
    .account-btn { padding: 2px; }
}
@media (min-width: 901px) and (max-width: 1120px) {
    .site-header { gap: 16px; padding-inline: 18px; }
    .site-nav a { padding: 6px 9px; }
    .brand small, .live-label { display: none; }
    .live-pill { padding: 4px 9px; }
}
:root[data-theme="light"] .course-face { fill: rgba(251, 248, 242, 0.9); }
:root[data-theme="light"] .cal-day.weekend { background: rgba(138, 106, 28, 0.07); }
:root[data-theme="light"] .course-arrow, :root[data-theme="light"] .course-set { background: rgba(251, 248, 242, 0.7); }
/* Too narrow for seven links in one row: Profile and Analytics are under More, as on phones. */
@media (min-width: 901px) and (max-width: 1040px) {
    .site-nav a[data-nav="profile"], .site-nav a[data-nav="analytics"] { display: none !important; }
}
