:root {
    --bg: #0f1c24;
    --panel: #15293a;
    --panel-2: #1c374d;
    --ink: #e8f0f4;
    --ink-dim: #a5b8c3;
    --accent: #3fb1c5;
    --accent-strong: #5fd1e5;
    --good: #4ec57d;
    --warn: #e9b343;
    --bad: #e23a3a;
    --border: #27445e;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

main.container { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
    background: linear-gradient(180deg, #0a1620, #122433);
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 600; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.3rem; }
nav a { margin-left: 1.1rem; color: var(--ink-dim); font-size: 0.95rem; }
nav a:first-child { margin-left: 0; }
nav a.active { color: var(--accent-strong); }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 0;
    color: var(--ink-dim);
    font-size: 0.85rem;
    text-align: center;
}

/* Hero */
.hero { margin: 1rem 0 2rem; }
.hero h1 { font-size: 1.85rem; margin: 0 0 0.4rem; }
.hero p { color: var(--ink-dim); margin: 0; }

/* Unified panel */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.panel-form { margin: 0; }
.panel-section { margin-top: 1.5rem; }
.panel-section.hidden { display: none; }
.panel-section-bordered {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.empty-state {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--panel-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--ink-dim);
    text-align: center;
    font-size: 0.95rem;
}

/* Cold-load shimmer placeholders. Shown when a city is picked but no cached
   payload exists, so users see structure forming before the data lands. */
.result-skeleton {
    margin-top: 1.5rem;
}
.result-skeleton.hidden { display: none; }
.skeleton {
    background: linear-gradient(90deg, var(--panel-2) 0%, #2e4c66 50%, var(--panel-2) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; opacity: 0.6; }
}
.skeleton-score-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.skeleton-dial { width: 130px; height: 130px; border-radius: 50%; flex-shrink: 0; }
.skeleton-verdict {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.skeleton-line-lg { height: 28px; width: 55%; }
.skeleton-line    { height: 16px; width: 80%; }
.skeleton-line-sm { height: 12px; width: 38%; }
.skeleton-factor-grid {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}
.skeleton-factor { height: 110px; }
.skeleton-chart  { margin-top: 1.5rem; height: 280px; }

/* Live "what's loading" indicator. One tag per data source; each flips from a
   spinner to a ✓ (or ✗) as its fetch resolves. */
.fetch-status {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--ink-dim);
}
.fetch-status.hidden { display: none; }
.fetch-status-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}
.fetch-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem 0.2rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-2);
    font-size: 0.78rem;
    color: var(--ink);
    line-height: 1.2;
}
.fetch-spin {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--ink-dim);
    border-top-color: transparent;
    border-radius: 50%;
    animation: fetch-spin 0.8s linear infinite;
    flex-shrink: 0;
}
.fetch-mark {
    width: 12px;
    text-align: center;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}
.fetch-mark.ok   { color: var(--good); }
.fetch-mark.fail { color: var(--bad); }
.fetch-tag.done   { border-color: rgba(78, 197, 125, 0.4); }
.fetch-tag.failed { border-color: rgba(226, 58, 58, 0.4); }
@keyframes fetch-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .fetch-spin { animation: none; }
}
.empty-state.hidden { display: none; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); }
.field select, .field input {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}
.field select:focus, .field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field select:disabled { opacity: 0.7; cursor: progress; }

/* Result */
.score-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.score-dial {
    width: 130px; height: 130px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: conic-gradient(var(--score-color, var(--accent)) calc(var(--score, 0) * 1%), #233a4f 0);
    flex-shrink: 0;
    position: relative;
}
.score-dial::before {
    content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--panel);
}
.score-dial-inner { position: relative; text-align: center; }
.score-dial-inner .num { font-size: 2rem; font-weight: 700; line-height: 1; }
.score-dial-inner .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }

.verdict h2 { margin: 0; font-size: 1.6rem; }
.verdict p { margin: 0; color: var(--ink-dim); }
.verdict-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

/* "LIVE" badge — pulsing red dot, streaming-style */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffd8d8;
    background: rgba(226, 58, 58, 0.16);
    border: 1px solid rgba(226, 58, 58, 0.5);
    padding: 0.18rem 0.55rem 0.18rem 0.5rem;
    border-radius: 999px;
    line-height: 1;
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bad);
    box-shadow: 0 0 0 0 rgba(226, 58, 58, 0.7);
    animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(226, 58, 58, 0.7); }
    70%  { box-shadow: 0 0 0 8px rgba(226, 58, 58, 0); }
    100% { box-shadow: 0 0 0 0 rgba(226, 58, 58, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
}

/* "CACHED" badge — shown in place of LIVE when we're painting from
   localStorage while a fresh fetch is in flight. Amber/static so users can
   tell at a glance that the reading isn't current. */
.cached-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffe9b0;
    background: rgba(233, 179, 67, 0.16);
    border: 1px solid rgba(233, 179, 67, 0.5);
    padding: 0.18rem 0.55rem 0.18rem 0.5rem;
    border-radius: 999px;
    line-height: 1;
}
.cached-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warn);
}

.species-filter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.species-filter label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
}
.species-filter select {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}
.species-filter select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-color: var(--accent);
}

.factor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.factor {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.factor .name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.3rem; }
.factor .name { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.factor .score-pts {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.factor .score-pts .max { color: var(--ink-dim); font-weight: 400; }
.factor .score-pts-bonus { margin-left: 0.25rem; font-size: 0.75rem; font-weight: 700; }
.factor .score-pts-bonus.pos { color: var(--good); }
.factor .score-pts-bonus.neg { color: var(--bad); }
.factor .value { font-size: 1.15rem; font-weight: 600; }
.factor .detail { font-size: 0.8rem; color: var(--ink-dim); margin-top: 0.15rem; }

.factor-bar { height: 5px; background: #4a6e8c; border-radius: 2px; margin-top: 0.5rem; overflow: hidden; }
.factor-bar > span { display: block; height: 100%; background: var(--accent); }

/* Modifier chips: visibly thinner/dashed treatment so users read these as
   bonuses on top of the 0-100 base, not as additional 25-point factors. */
.modifier-row {
    margin-top: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.modifier-row-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    margin-right: 0.25rem;
}
.modifier {
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.2;
}
.modifier-val {
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    min-width: 1.6rem;
    text-align: center;
}
.modifier-val.pos  { color: var(--good); }
.modifier-val.neg  { color: var(--bad); }
.modifier-val.zero { color: var(--ink-dim); }
.modifier-label {
    color: var(--ink);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
/* Inline SVG icon used in modifier chips and breakdown rows (e.g. sun/horizon
   marker for the dawn/dusk bonus). Warm yellow to read as "solar". */
.modifier-icon {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: #ecc949;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-right: 0.35rem;
    vertical-align: -2px;
}
.modifier-detail {
    color: var(--ink-dim);
    font-size: 0.82rem;
}

/* Notable Michigan state records caught in the selected city's waters.
   Sits above the nearby-waters list as flavor/context. */
.state-records {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    background: var(--panel-2);
    border: 1px solid rgba(233, 179, 67, 0.45);
    border-radius: 8px;
}
.state-records.hidden { display: none; }
.state-records-title {
    margin: 0 0 0.55rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ecc949;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.trophy-mark {
    font-size: 0.95rem;
    line-height: 1;
}
.state-records-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.state-record {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
}
.state-record-species {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.95rem;
}
.state-record-stats {
    font-variant-numeric: tabular-nums;
    color: #ecc949;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}
.state-record-meta {
    grid-column: 1 / -1;
    color: var(--ink-dim);
    font-size: 0.78rem;
}

.waters-list {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.waters-list h3 {
    margin: 0 0 0.6rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 600;
}
.waters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}
.water-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.water-icon {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}
.water-icon.t-superior { background: var(--accent-strong); }
.water-icon.t-inland   { background: var(--good); }
.water-icon.t-river    { background: #7bb1d6; }
.water-icon.t-channel  { background: var(--ink-dim); }
.water-body { min-width: 0; }
.water-name { font-weight: 600; font-size: 0.95rem; }
.water-meta { font-size: 0.78rem; color: var(--ink-dim); margin-top: 0.1rem; }

.fish-list {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.fish-list h3 {
    margin: 0 0 0.6rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 600;
}
.fish-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.fish-chip {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.2;
}

.notes {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--ink-dim);
    font-size: 0.9rem;
}
.notes ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.notes li { margin: 0.2rem 0; }

.hidden { display: none !important; }

.error {
    background: rgba(226, 58, 58, 0.12);
    border: 1px solid var(--bad);
    color: #ffd8d8;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

/* About page */
.prose h2 { margin-top: 2rem; }
.prose table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.prose th, .prose td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.95rem; }
.prose th { color: var(--ink-dim); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* "How we got to N" breakdown — itemized contributions summing to the dial. */
.score-breakdown {
    margin-top: 0.75rem;
    padding: 0.55rem 0.85rem 0.6rem;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.score-breakdown.hidden { display: none; }
.breakdown-title {
    margin: 0 0 0.3rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 600;
}
.breakdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.breakdown-list li,
.breakdown-total-row {
    display: grid;
    grid-template-columns: 2.2rem 1fr;
    gap: 0.55rem;
    align-items: baseline;
    padding: 0.1rem 0;
    font-size: 0.82rem;
    line-height: 1.35;
}
.breakdown-total-row {
    border-top: 1px solid var(--border);
    margin-top: 0.2rem;
    padding-top: 0.3rem;
    font-weight: 700;
    font-size: 0.88rem;
}
.breakdown-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--ink);
}
.breakdown-val.pos  { color: var(--good); }
.breakdown-val.neg  { color: var(--bad); }
.breakdown-val.zero { color: var(--ink-dim); }
.breakdown-line { color: var(--ink); }
.breakdown-line .breakdown-detail {
    color: var(--ink-dim);
    font-size: 0.78rem;
    margin-left: 0.25rem;
}
.breakdown-tag {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dim);
    border: 1px dashed var(--border);
    padding: 0 0.3rem;
    border-radius: 999px;
    margin-left: 0.3rem;
    vertical-align: 1px;
}
.breakdown-cap {
    font-style: italic;
    font-size: 0.75rem;
    color: var(--ink-dim);
    margin-left: 0.3rem;
}

/* 7-day forecast chart (nested inside the result block) */
.forecast-inline {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.forecast-inline .section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    text-transform: none;
    letter-spacing: normal;
}

.buoy-badge {
    font-size: 0.72rem;
    font-weight: 500;
    background: #1a2d40;
    color: #7a9ab8;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #1e3a52;
}

.chart-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #7a9ab8;
    cursor: pointer;
    user-select: none;
}
.chart-toggle input { accent-color: #7a9ab8; cursor: pointer; }

.forecast-meta-text {
    margin: 0 0 1rem;
    color: var(--ink-dim);
    font-size: 0.85rem;
}

.chart-card {
    background: #132030;
    border: 1px solid #1e3a52;
    border-radius: 10px;
    padding: 1.25rem 1rem 1rem;
    position: relative;
    height: 280px;
}
.chart-card canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--ink-dim);
}
.chart-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}
.chart-legend .dot-good { background: var(--good); }
.chart-legend .dot-fair { background: #ecc949; }
.chart-legend .dot-slow { background: #dd6f33; }
.chart-legend .dot-bad  { background: var(--bad); }
