/* Light retains the existing site palette. Theme controls are shared by both layouts. */
:root {
    --fsm-theme-surface: #fff;
    --fsm-theme-text: #1e293b;
    --fsm-theme-muted: #64748b;
    --fsm-theme-border: #e2e8f0;
    --fsm-theme-hover: #f1f5f9;
    --fsm-theme-selected: #e0f2fe;
    --fsm-theme-accent: #0369a1;
}
/* One icon button opens a compact three-position selector. */
.fsm-navbar-controls { display: flex; align-items: center; gap: 6px; order: 3; margin-left: 12px; }
.main-navbar .navbar-collapse, .fsm-legacy .navbar-collapse { order: 2; }
.fsm-theme-picker { position: relative; line-height: 1; }
.fsm-theme-picker summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--fsm-theme-border);
    border-radius: 50%;
    background: var(--fsm-theme-surface);
    color: var(--fsm-theme-accent);
    cursor: pointer;
    list-style: none;
    user-select: none;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .035);
    transition: background .15s ease, border-color .15s ease;
}
.fsm-theme-picker summary::-webkit-details-marker { display: none; }
.fsm-theme-picker summary:hover, .fsm-theme-picker[open] summary { background: var(--fsm-theme-hover); border-color: #38bdf8; }
.fsm-theme-picker summary:focus-visible { outline: 3px solid #38bdf8; outline-offset: 3px; }
.fsm-theme-picker svg { display: block; width: 19px; height: 19px; flex: 0 0 auto; }
.fsm-theme-current-icon > span { display: none; }
html[data-fsm-mode="light"] [data-fsm-theme-icon="light"],
html[data-fsm-mode="dark"] [data-fsm-theme-icon="dark"],
html[data-fsm-mode="auto"] [data-fsm-theme-icon="auto"] { display: block; }
.fsm-theme-menu {
    position: absolute;
    z-index: 1100;
    top: calc(100% + 8px);
    right: 0;
    width: max-content;
    margin: 0;
    padding: 7px;
    border: 1px solid var(--fsm-theme-border);
    border-radius: 14px;
    background: var(--fsm-theme-surface);
    color: var(--fsm-theme-text);
    box-shadow: 0 12px 32px rgba(2, 12, 27, .18);
}
.fsm-theme-menu fieldset { display: flex; gap: 4px; min-width: 0; padding: 0; margin: 0; border: 0; }
.fsm-theme-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.fsm-theme-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--fsm-theme-muted);
    background: transparent;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.fsm-theme-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fsm-theme-option:hover { background: var(--fsm-theme-hover); color: var(--fsm-theme-accent); }
.fsm-theme-option-icon { display: flex; align-items: center; justify-content: center; color: inherit; }
.fsm-theme-option-icon svg { stroke-width: 2; }
html[data-fsm-theme="dark"] .fsm-theme-option { color: #cbd5e1; }
html[data-fsm-theme="dark"] .fsm-theme-option:is([value="light"], :has(input[value="light"])) .fsm-theme-option-icon { color: #fcd34d; }
.fsm-theme-option:is([aria-pressed="true"], :has(input:checked)) { background: var(--fsm-theme-selected); border-color: var(--fsm-theme-accent); color: var(--fsm-theme-accent); }
.fsm-theme-option:is(:focus-visible, :has(input:focus-visible)) { outline: 2px solid #38bdf8; outline-offset: 1px; }
@media (max-width: 991.98px) {
    .fsm-navbar-controls { order: 2; margin-left: auto; gap: 6px; }
    .main-navbar .navbar-collapse, .fsm-legacy .navbar-collapse { order: 3; }
    .fsm-theme-picker summary { width: 44px; height: 44px; }
    .fsm-navbar-controls .navbar-toggler { width: 44px; height: 44px; padding: 8px; margin: 0; }
    .fsm-theme-menu { right: 0; left: auto; }
    .main-navbar .navbar-brand { margin-right: 8px; min-width: 0; }
    .main-navbar .navbar-logo { max-width: calc(100vw - 160px); height: auto; max-height: 44px; }
    .fsm-legacy .navbar { margin-left: 12px !important; margin-right: 12px !important; padding-left: 0; padding-right: 0; }
    .fsm-legacy .navbar .logo { width: auto; max-width: calc(100vw - 144px); max-height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
    .fsm-theme-picker *, .fsm-theme-picker *::after { transition: none !important; }
}

/* Navy surfaces, cyan accents, neutral readable text. Brand backgrounds stay navy. */
html[data-fsm-theme="dark"] {
    color-scheme: dark;
    --fsm-bg-light: #081321;
    --fsm-card-bg: #101f33;
    --fsm-text-main: #e2e8f0;
    --fsm-text-muted: #a5b4c8;
    --fsm-border: #283b52;
    --fsm-shadow-sm: 0 2px 8px rgba(0, 0, 0, .16);
    --fsm-shadow-md: 0 10px 30px rgba(0, 0, 0, .22);
    --fsm-shadow-lg: 0 20px 40px rgba(0, 0, 0, .3);
    --fsm-theme-surface: #101f33;
    --fsm-theme-text: #e2e8f0;
    --fsm-theme-muted: #a5b4c8;
    --fsm-theme-border: #283b52;
    --fsm-theme-hover: #192e48;
    --fsm-theme-selected: #14344f;
    --fsm-theme-accent: #7dd3fc;
    --bs-body-bg: #081321;
    --bs-body-color: #e2e8f0;
    --bs-secondary-color: #a5b4c8;
    --bs-border-color: #283b52;
    --bs-link-color: #7dd3fc;
    --bs-link-color-rgb: 125, 211, 252;
    --bs-link-hover-color: #bae6fd;
    --bs-link-hover-color-rgb: 186, 230, 253;
}
html[data-fsm-theme="dark"] body { background-color: #081321; color: #e2e8f0; }
html[data-fsm-theme="dark"] :is(h1,h2,h3,h4,h5,h6,.brand-font,.section-title,.stat-number,.team-name) { color: #f1f5f9; }
html[data-fsm-theme="dark"] .main-navbar { background: rgba(10, 25, 43, .96); box-shadow: 0 4px 20px rgba(0,0,0,.2); }
/* Keep the original logo legible without recoloring the brand artwork. */
html[data-fsm-theme="dark"] .navbar-brand { background: #f8fafc; padding-left: 10px; padding-right: 10px; border-radius: 10px; }
html[data-fsm-theme="dark"] .nav-link-custom { color: #e2e8f0 !important; }
html[data-fsm-theme="dark"] .nav-link-custom:is(:hover,.active) { color: #7dd3fc !important; background: rgba(56,189,248,.12); }
html[data-fsm-theme="dark"] .utc-badge { color: #cbd5e1; background: #15273d; }
html[data-fsm-theme="dark"] .navbar-light .navbar-toggler-icon {
    filter: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='%23cbd5e1' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}
html[data-fsm-theme="dark"] :is(.feature-card,.ceo-card,.team-card,.fleet-card,.live-badge-wrapper) { background: #101f33; }
html[data-fsm-theme="dark"] :is(.stat-icon-wrapper,.ceo-badge-tag,.team-role,.fleet-count-badge) { color: #7dd3fc; }
html[data-fsm-theme="dark"] .stat-card:hover .stat-icon-wrapper { color: #fff; }
html[data-fsm-theme="dark"] .team-callsign { background: #192e48; color: #cbd5e1; }
html[data-fsm-theme="dark"] .team-email:hover { color: #7dd3fc; }
html[data-fsm-theme="dark"] .custom-faq-accordion .accordion-item,
html[data-fsm-theme="dark"] .custom-faq-accordion .accordion-button { background: #101f33; color: #e2e8f0; }
html[data-fsm-theme="dark"] .custom-faq-accordion .accordion-button:not(.collapsed) { background: #14344f; color: #7dd3fc; }
html[data-fsm-theme="dark"] .custom-faq-accordion .accordion-body { background: #0c192b; color: #b9c7d8; }
html[data-fsm-theme="dark"] .fleet-table { --bs-table-bg: #101f33; --bs-table-color: #e2e8f0; --bs-table-border-color: #283b52; }
html[data-fsm-theme="dark"] .fleet-table tbody :is(td,th) { border-bottom-color: #283b52; }
html[data-fsm-theme="dark"] .fleet-table tbody tr.table-total-row { --bs-table-bg: #192e48; background: #192e48; }
html[data-fsm-theme="dark"] .fleet-table tbody tr:hover > * { --bs-table-bg: #192e48; }
html[data-fsm-theme="dark"] .fleet-notice-card { background: #10273a; border-color: #34657f; color: #cbd5e1; }
html[data-fsm-theme="dark"] :is(.text-dark,.text-body) { color: #e2e8f0 !important; }
html[data-fsm-theme="dark"] :is(.text-muted,.text-secondary) { color: #a5b4c8 !important; }
html[data-fsm-theme="dark"] .text-primary { color: #7dd3fc !important; }
html[data-fsm-theme="dark"] .text-success { color: #6ee7b7 !important; }
html[data-fsm-theme="dark"] .text-warning { color: #fcd34d !important; }
html[data-fsm-theme="dark"] :is(.bg-light,.bg-white) { background-color: #101f33 !important; }
html[data-fsm-theme="dark"] .text-white-50 { color: #a5b4c8 !important; }
html[data-fsm-theme="dark"] .boards-auto { background: #0c302c; border-color: #1a6452; color: #6ee7b7; }
html[data-fsm-theme="dark"] .boards-page .depboardtime { color: #e2e8f0; }
html[data-fsm-theme="dark"] .boards-info { background: #10273a; border-color: #283b52; color: #7dd3fc; }
html[data-fsm-theme="dark"] .boards-contact a { color: #7dd3fc; }
html[data-fsm-theme="dark"] #board-sound-control #muteButton { background: #101f33 !important; color: #7dd3fc !important; }
/* Preserve the original charcoal/yellow boards in every theme. */
html[data-fsm-theme="dark"] .boards-page .board-header h2 { color: #ffc320; }
html[data-fsm-theme="dark"] .fsm-legacy :is(.navbar,.navbar.bg-light,footer.bg-light) { background: #101f33 !important; }
html[data-fsm-theme="dark"] .fsm-legacy .navbar > a:first-child { background: #f8fafc; border-radius: 10px; }
html[data-fsm-theme="dark"] .fsm-legacy .navbar .nav-link { color: #cbd5e1; }
html[data-fsm-theme="dark"] .fsm-legacy :is(#utc-time,.profile-name,.summary,.counter-label) { color: #e2e8f0 !important; }
html[data-fsm-theme="dark"] .fsm-legacy a:not(.btn):not(.nav-link) { color: #7dd3fc; }
