:root {
    --bg: #1a1206;
    --surface: #261c0a;
    --surface-2: #352810;
    --text: #fef3c7;
    --muted: #d4a84b;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-200: #fde68a;
    --amber-300: #fcd34d;
    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;
    --amber-800: #92400e;
    --amber-900: #78350f;
    --success: #fbbf24;
    --warning: #f59e0b;
    --danger: #d97706;
    --border: #6b4f1d;
    --border-light: #8b6914;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--amber-300);
    text-decoration: none;
}

a:hover {
    color: var(--amber-200);
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
}

.logo a {
    color: var(--amber-200);
}

.main-nav a {
    margin-left: 1.25rem;
    color: var(--muted);
}

.main-nav a:hover {
    color: var(--amber-100);
}

.site-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer-note code {
    background: var(--surface-2);
    color: var(--amber-200);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.hero {
    text-align: center;
    padding: 2rem 1rem 3rem;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--amber-100);
}

.hero p {
    color: var(--muted);
    max-width: 640px;
    margin: 0 auto 2rem;
}

.zip-form {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.zip-form input[type="text"] {
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--amber-100);
    width: 160px;
    text-align: center;
    letter-spacing: 0.15em;
}

.zip-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.zip-form button,
.btn {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: var(--amber-900);
    font-weight: 600;
    cursor: pointer;
}

.zip-form button:hover,
.btn:hover {
    background: var(--accent-hover);
    color: var(--amber-900);
}

.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--amber-100);
}

.btn-secondary:hover {
    background: var(--amber-800);
    border-color: var(--amber-600);
    color: var(--amber-50);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.feature-card h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--amber-200);
}

.feature-card p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.map-page-header h2 {
    color: var(--amber-100);
}

.map-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.map-location {
    color: var(--muted);
}

.map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.map-container,
#mylar-map-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#mylar-map {
    z-index: 1;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

/* Panel mode: server-rendered map image */
.map-live-img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Fullscreen mode: canvas fills the map area */
.map-live-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: var(--bg);
}

.radar-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.radar-legend-bar {
    display: flex;
    height: 12px;
    width: 180px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.radar-legend-bar span {
    flex: 1;
}

.radar-legend-light { background: #fde68a; }
.radar-legend-mid { background: #f59e0b; }
.radar-legend-dark { background: #582f0a; }

.map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.layer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--amber-200);
    font-size: 0.9rem;
    padding: 0.35rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.layer-toggle input {
    accent-color: var(--accent);
}

.map-weather-overlay {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(38, 28, 10, 0.9);
    color: var(--amber-100);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    pointer-events: none;
}

.map-emf-bar {
    display: none;
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(38, 28, 10, 0.9);
    color: var(--amber-300);
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: monospace;
    pointer-events: none;
}

.map-fallback {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
}

.data-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.data-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.data-card h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--amber-200);
}

.data-value.low { color: var(--amber-300); }
.data-value.moderate { color: var(--amber-500); }
.data-value.elevated { color: var(--amber-600); }

.export-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.status-msg {
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border-radius: 6px;
    color: var(--amber-200);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.status-msg.success { border-left: 3px solid var(--amber-400); }
.status-msg.error { border-left: 3px solid var(--amber-700); }

.info-section hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.info-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-section h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    color: var(--amber-100);
}

.info-section h3 {
    margin-top: 1.5rem;
    color: var(--amber-200);
}

.info-section blockquote {
    border-left: 3px solid var(--accent);
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    color: var(--muted);
    background: var(--surface-2);
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.info-table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    color: var(--amber-100);
}

.info-table tr:first-child td {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--amber-200);
}

.fullscreen-body {
    margin: 0;
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.fullscreen-header {
    flex: 0 0 auto;
    z-index: 100;
    background: rgba(26, 18, 6, 0.94);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--amber-100);
}

.fullscreen-map {
    flex: 1 1 auto;
    position: relative;
    min-height: 240px;
    overflow: hidden;
    z-index: 1;
}

.fullscreen-map #mylar-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 240px;
    z-index: 1;
    background: var(--bg);
    min-height: 0;
}

.radar-legend-map {
    display: none;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1200;
    margin: 0;
    padding: 0.4rem 0.65rem;
    background: rgba(38, 28, 10, 0.92);
    border: 1px solid var(--border);
    border-radius: 6px;
    pointer-events: none;
}

.fullscreen-map .radar-legend-map .radar-legend-bar {
    width: 140px;
    height: 10px;
}

/* Amber outline on the fullscreen canvas while animating */
.fullscreen-map canvas.map-live-canvas[data-playing="1"] {
    outline: 2px solid var(--amber-500);
    outline-offset: -2px;
}

.fullscreen-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.fullscreen-status {
    flex: 0 0 auto;
    background: rgba(26, 18, 6, 0.94);
    color: var(--muted);
    font-size: 0.8rem;
    padding: 0.35rem 1rem;
    border-top: 1px solid var(--border);
    z-index: 200;
}

.animation-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.animation-panel h3 {
    margin-top: 0;
    color: var(--amber-100);
}

.animation-help {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0;
}

.share-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.share-panel h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.share-title {
    color: var(--amber-100);
    font-weight: 600;
    margin: 0.35rem 0;
}

.share-description {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
    margin: 0.5rem 0 0.75rem;
}

.share-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.share-url-input {
    flex: 1 1 280px;
    min-width: 200px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--amber-100);
    font-family: monospace;
    font-size: 0.85rem;
}

.share-note {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0.75rem 0 0;
    line-height: 1.4;
}

.share-note a {
    color: var(--amber-400);
}

.capture-interval-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--amber-200);
    font-size: 0.85rem;
}

.capture-interval-label input[type="number"] {
    width: 4rem;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--amber-100);
}

.animation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin: 1rem 0;
}

.animation-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.animation-controls input[type="number"] {
    width: 110px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--amber-100);
}

.animation-preview-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
    min-height: 200px;
}

/* Canvas-based video memory animation (panel mode) */
.animation-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: var(--bg);
    border-radius: 6px;
}

/* Amber outline while animating */
.animation-preview-wrap:has(.animation-canvas[data-playing="1"]) {
    outline: 2px solid var(--amber-500);
    outline-offset: -2px;
}

/* Legacy img double-buffer — kept for fallback only */
.animation-preview {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    background: var(--bg);
}

.animation-preview-front,
.animation-preview-buffer {
    opacity: 0;
    transition: opacity 0.08s ease;
}

.animation-preview-buffer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    pointer-events: none;
}

.animation-preview.is-visible {
    opacity: 1;
}

.animation-preview.is-playing {
    outline: 2px solid var(--amber-500);
    outline-offset: -2px;
}

.animation-meta {
    color: var(--muted);
    font-size: 0.85rem;
    font-family: monospace;
}

button:disabled,
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


@media (max-width: 640px) {
    .hero h2 { font-size: 1.5rem; }
    .map-controls { justify-content: center; }
}