* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; color: #fff; }
#canvas { display: block; }

/* ─── Top navigation bar ─── */
#topNav {
    position: fixed; top: 0; left: 0; right: 0;
    height: 40px; z-index: 60;
    background: rgba(8,8,28,0.92); backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center;
    padding: 0 16px; gap: 4px;
}
.nav-tab {
    display: inline-flex; align-items: center;
    padding: 6px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 500;
    color: #889; text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.nav-tab:hover { color: #bcd; background: rgba(255,255,255,0.06); }
.nav-tab.active {
    color: #8bf; background: rgba(68,136,255,0.15);
}
#topNav { overflow-x: auto; scrollbar-width: none; }
#topNav::-webkit-scrollbar { display: none; }
.nav-tab { flex: none; white-space: nowrap; }

#ui {
    position: absolute; top: 56px; left: 16px;
    background: rgba(8,8,28,0.88); backdrop-filter: blur(12px);
    padding: 20px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    min-width: 270px; user-select: none;
    transition: min-width 0.25s ease, padding 0.25s ease;
    overflow: visible;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 72px);
}
#sidebarContent {
    overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0;
}
#sidebarContent::-webkit-scrollbar { width: 10px; }
#sidebarContent::-webkit-scrollbar-track { background: transparent; margin: 2px 0; }
#sidebarContent::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15); border-radius: 5px;
    border-left: 5px solid transparent; border-right: 2px solid transparent; background-clip: padding-box;
}
#ui h2 { margin-bottom: 4px; font-size: 20px; font-weight: 600; }
#ui .sub { font-size: 13px; color: #889; margin-bottom: 0; }
#sidebarHeader {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 8px; margin-bottom: 16px;
}
#sidebarToggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    color: #9ab; width: 28px; height: 28px;
    font-size: 16px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; padding: 0;
    transition: background 0.2s, color 0.2s;
}
#sidebarToggle:hover { background: rgba(255,255,255,0.12); color: #fff; }
#ui.collapsed { min-width: 0; padding: 12px; }
#ui.collapsed #sidebarHeader > div { display: none; }
#ui.collapsed #sidebarContent { display: none; }
#ui.collapsed #sidebarHeader { margin-bottom: 0; }
.section { margin-bottom: 6px; }
.section summary {
    font-size: 13px; font-weight: 600; color: #9ac;
    text-transform: uppercase; letter-spacing: 0.06em;
    cursor: pointer; padding: 6px 0; list-style: none;
    display: flex; align-items: center; gap: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.section summary::-webkit-details-marker { display: none; }
.section summary::before {
    content: '\25B6'; font-size: 9px; color: #78a;
    transition: transform 0.2s ease;
    display: inline-block;
}
.section[open] > summary::before { transform: rotate(90deg); }
.section-body { padding: 8px 0 2px; }
.climate-live-badge {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 1px 5px; border-radius: 4px;
    background: rgba(100,200,255,0.15); color: #6cf;
    vertical-align: middle; margin-left: 2px;
}
.climate-hint {
    font-size: 11px; color: #678; line-height: 1.4;
    margin-bottom: 8px;
}
.import-expect {
    font-size: 11px; color: #8ab; line-height: 1.5;
    background: rgba(68,136,255,0.08);
    border: 1px solid rgba(68,136,255,0.15);
    border-radius: 6px; padding: 8px 10px;
    margin-bottom: 10px;
    max-width: 250px;
}
.section[open] > summary { border-bottom-color: rgba(255,255,255,0.06); margin-bottom: 2px; }
.cg { margin-bottom: 10px; }
.cg label { display: block; font-size: 14px; color: #aab; margin-bottom: 3px; }
.cg .v { float: right; color: #6af; font-variant-numeric: tabular-nums; }
.tip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; font-size: 11px; line-height: 1;
    border-radius: 50%; background: rgba(255,255,255,0.18); color: #bcd;
    cursor: help; position: relative; vertical-align: text-top;
    margin-left: 3px; flex-shrink: 0; transform: translateY(1px);
}
.tip:hover { background: rgba(255,255,255,0.25); color: #def; }
.tip:hover::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
    background: rgba(8,8,28,0.96); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    padding: 6px 10px; font-size: 13px; color: #cde;
    width: 220px; white-space: normal; line-height: 1.4;
    z-index: 200; pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
input[type="range"] { width: 100%; accent-color: #48f; cursor: pointer; }

/* Slider thumb tooltip */
.slider-tooltip {
    position: absolute; top: -30px;
    background: rgba(8,8,28,0.94);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 11px; color: #6af;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
    transform: translateX(-50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.slider-tooltip.visible { opacity: 1; }
select {
    width: 100%; padding: 7px 10px; font-size: 14px; font-family: inherit;
    background: rgba(255,255,255,0.06); color: #cde;
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23667'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
select:hover { border-color: rgba(255,255,255,0.18); }
select:focus { outline: none; border-color: #48f; }
select option { background: #12122a; color: #cde; }
select optgroup { font-style: normal; font-weight: 600; color: #78a; background: #12122a; }
button#generate {
    width: 100%; padding: 10px; margin-top: 10px; margin-bottom: 12px;
    background: linear-gradient(135deg, #2255cc, #3366ee);
    color: white; border: none; border-radius: 8px;
    font-size: 15px; font-weight: 500; cursor: pointer;
    transition: background 0.3s ease, opacity 0.3s ease;
}
button#generate:hover { filter: brightness(1.15); }
button#generate.stale {
    background: linear-gradient(135deg, #b87a1a, #d4922a);
}
button#generate.stale:hover { filter: brightness(1.15); }
button#generate.regen {
    background: linear-gradient(135deg, #993322, #bb4433);
}
button#generate.regen:hover { filter: brightness(1.15); }
button#generate.generating {
    background: linear-gradient(135deg, #333, #444);
    cursor: wait; opacity: 0.8;
}
#reapplyBtn {
    width: 100%; padding: 8px; margin-top: 4px;
    background: rgba(255,255,255,0.06); color: #556;
    border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
    font-size: 14px; font-weight: 500; font-family: inherit; cursor: default;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
#reapplyBtn:disabled { opacity: 0.4; }
#reapplyBtn.spinning .reapply-icon { display: inline-block; animation: spin 0.8s linear infinite; }
#reapplyBtn.ready {
    background: linear-gradient(135deg, #1a7a4a, #22aa5a);
    color: #fff; border-color: transparent;
    cursor: pointer; opacity: 1;
}
#reapplyBtn.ready:hover { filter: brightness(1.15); }
#seedRow {
    display: flex; gap: 4px; margin-bottom: 12px;
}
#seedCode {
    flex: 1; min-width: 0;
    background: rgba(255,255,255,0.06); color: #6af;
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    padding: 5px 8px; font-size: 13px; font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 0.05em; outline: none;
}
#seedCode:focus { border-color: #48f; }
#seedCode.flash { animation: seedFlash 0.6s ease; }
@keyframes seedFlash {
    0%   { background: rgba(68,136,255,0.25); border-color: #48f; }
    100% { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
}
#seedRow button {
    background: rgba(255,255,255,0.06); color: #9ab;
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    padding: 4px 8px; font-size: 13px; cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s; white-space: nowrap;
}
#seedRow button:hover { background: rgba(255,255,255,0.12); color: #fff; }
#loadBtn.ready {
    background: linear-gradient(135deg, #2255cc, #3366ee);
    color: #fff; border-color: transparent;
}
#loadBtn.ready:hover { filter: brightness(1.15); }
#seedError {
    font-size: 11px; color: #c44; margin: -8px 0 8px 2px;
    display: none;
}
#seedError.visible { display: block; }

/* Map type tabs */
.map-tabs {
    display: flex; gap: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 8px; padding: 3px;
    margin-bottom: 10px;
}
.map-tab {
    flex: 1; padding: 8px 0; border: none;
    background: transparent; color: #889;
    font-size: 12px; font-weight: 500; font-family: inherit;
    border-radius: 6px; cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.map-tab:hover { color: #bcd; }
.map-tab.active {
    background: rgba(68,136,255,0.18); color: #8bf;
}

/* Legend container */
.viz-legend {
    font-size: 11px; color: #9ab; line-height: 1.5;
    margin-bottom: 8px;
}
.viz-legend:empty { display: none; }

.legend-gradient {
    height: 10px; border-radius: 4px;
    margin-bottom: 4px;
}
.legend-labels {
    display: flex; justify-content: space-between;
    font-size: 10px; color: #667;
}
/* the climate layers' legends (js/climate-layers.js): classes as swatches, and a line on what the layer shows */
.legend-classes { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 11px; color: #aab; }
.legend-classes span { white-space: nowrap; }
.legend-classes i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend-note { font-size: 11px; color: #889; line-height: 1.4; margin-top: 4px; }
/* (they wrap within the panel instead of widening it: the panel is as wide as its widest content) */
.legend-note, .legend-classes { contain: inline-size; }

.legend-koppen {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 3px 6px;
    position: relative;
}
.legend-koppen-item {
    display: flex; align-items: center; gap: 4px;
    font-size: 10px; color: #9ab; white-space: nowrap;
    position: relative; cursor: help;
}
.legend-koppen-item:hover { color: #def; }
.legend-koppen-header {
    font-size: 11px; margin-bottom: 4px;
}
.legend-koppen-header a {
    color: #8ab8ff; text-decoration: none;
}
.legend-koppen-header a:hover { text-decoration: underline; color: #aad0ff; }
.legend-koppen-tooltip {
    position: absolute;
    background: rgba(8,8,28,0.96); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    padding: 6px 10px; font-size: 12px; color: #cde;
    width: 240px; white-space: normal; line-height: 1.4;
    z-index: 200; pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: none;
}
.legend-koppen-tooltip.visible { display: block; }
.legend-koppen-swatch {
    width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
}

.tg { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.tg label { font-size: 13px; color: #99b; display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Custom toggle switches */
.toggle-label { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.toggle-label input[type="checkbox"] {
    position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.toggle-track {
    position: relative; display: inline-block;
    width: 32px; height: 18px; flex-shrink: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 9px;
    transition: background 0.2s ease;
}
.toggle-thumb {
    position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: #667; border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
}
.toggle-label input:checked + .toggle-track {
    background: rgba(68,136,255,0.35);
}
.toggle-label input:checked + .toggle-track .toggle-thumb {
    transform: translateX(14px);
    background: #48f;
}
.toggle-label:hover .toggle-track { background: rgba(255,255,255,0.15); }
.toggle-label input:checked:hover + .toggle-track { background: rgba(68,136,255,0.45); }
.stats-toggle {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.stats-toggle summary {
    font-size: 11px; color: #556; cursor: pointer;
    list-style: none; display: flex; align-items: center; gap: 4px;
}
.stats-toggle summary::-webkit-details-marker { display: none; }
.stats-toggle summary::before {
    content: '\25B6'; font-size: 7px; color: #445;
    transition: transform 0.2s ease; display: inline-block;
}
.stats-toggle[open] > summary::before { transform: rotate(90deg); }
.stats-toggle summary:hover { color: #889; }
#stats {
    font-size: 11px;
    color: #556;
    line-height: 1.6;
    margin-top: 4px;
}
#repoLink {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: #556;
    text-decoration: none;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
    transition: color 0.2s;
}
#repoLink:hover { color: #9ab; }
#repoLink svg { flex-shrink: 0; }
.slider-hint {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #667;
    margin-top: 2px;
    margin-bottom: 4px;
    pointer-events: none;
}
/* Detail slider warning levels */
.cg.detail-orange input[type=range] { accent-color: #e8a020; }
.cg.detail-red input[type=range] { accent-color: #d04030; }
.detail-warn { font-size: 11px; margin-top: -2px; margin-bottom: 4px; }
.detail-warn:empty { display: none; }
.detail-warn.orange { color: #e8a020; }
.detail-warn.red { color: #d04030; }
#topInfo {
    position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
    font-size: 13px; color: #889;
    background: rgba(8,8,28,0.85); backdrop-filter: blur(8px);
    padding: 6px 14px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap; pointer-events: none;
}
#info {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    font-size: 13px; color: #667; transition: color 0.4s ease;
    pointer-events: none;
}
#info.nudge { animation: infoNudge 2.5s ease; }
@keyframes infoNudge {
    0%   { color: #667; }
    15%  { color: #acd; }
    85%  { color: #acd; }
    100% { color: #667; }
}
#hoverInfo {
    position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
    font-size: 14px; color: #cde; background: rgba(8,8,28,0.85);
    backdrop-filter: blur(8px); padding: 8px 16px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    pointer-events: none; display: none; line-height: 1.6;
    max-width: 360px; text-align: left;
}
.hi-label {
    display: inline-block; width: 52px; font-size: 11px;
    color: #889; text-transform: uppercase;
}

/* Help button */
#helpBtn {
    position: absolute; top: 52px; right: 16px;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(40,60,120,0.7); backdrop-filter: blur(12px);
    border: 1px solid rgba(100,160,255,0.25);
    color: #8bf; font-size: 18px; font-weight: 700;
    cursor: pointer; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    padding: 0; line-height: 1;
}
#helpBtn:hover { background: rgba(60,90,180,0.8); border-color: rgba(100,160,255,0.5); color: #fff; }

/* Tutorial overlay */
#tutorialOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}
#tutorialOverlay.hidden {
    opacity: 0; pointer-events: none;
}

/* Tutorial card */
#tutorialCard {
    position: relative;
    max-width: 420px; width: 90%;
    background: rgba(8,8,28,0.94); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 32px 28px 24px;
    color: #cde;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
#tutorialOverlay.hidden #tutorialCard {
    opacity: 0; transform: translateY(-16px);
}

/* Close button */
#tutorialClose {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none;
    color: #667; font-size: 22px; cursor: pointer;
    line-height: 1; padding: 4px;
    transition: color 0.2s;
}
#tutorialClose:hover { color: #fff; }

/* Steps */
.tutorial-step {
    display: none;
}
.tutorial-step.active {
    display: block;
}
.tutorial-step h3 {
    font-size: 18px; font-weight: 600; color: #fff;
    margin-bottom: 10px;
}
.tutorial-step p {
    font-size: 14px; line-height: 1.6; color: #9ab;
    margin-bottom: 8px;
}
.tutorial-step p:last-of-type {
    margin-bottom: 0;
}
.tutorial-step p strong {
    color: #cde;
}

/* Dots */
.tutorial-dots {
    display: flex; justify-content: center; gap: 8px;
    margin: 20px 0 16px;
}
.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: background 0.2s;
}
.dot.active {
    background: #48f;
}

/* Nav buttons */
.tutorial-nav {
    display: flex; justify-content: space-between;
}
.btn-ghost {
    background: none; border: 1px solid rgba(255,255,255,0.12);
    color: #9ab; padding: 8px 20px; border-radius: 8px;
    font-size: 14px; font-family: inherit; cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover:not(:disabled) { border-color: rgba(255,255,255,0.25); color: #cde; }
.btn-ghost:disabled { opacity: 0.35; cursor: default; }
.btn-primary {
    background: linear-gradient(135deg, #2255cc, #3366ee);
    border: none; color: #fff; padding: 8px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
    transition: filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.15); }

/* Build overlay — unified loading / generation screen */
.build-overlay {
    position: fixed; inset: 0;
    background: rgba(3,3,8,0.75);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}
.build-overlay.hidden {
    opacity: 0; pointer-events: none;
}
.build-overlay.initial {
    background: #030308;
    z-index: 1000;
}
.build-overlay-inner {
    display: flex; flex-direction: column; align-items: center;
}
.build-overlay-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #48f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.build-overlay-title {
    margin-top: 16px; color: #667;
    font-size: 14px;
}
/* A browser that cannot run the app, or app code that could not load (js/support-check.js) */
#cantRun {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: #030308;
}
.cant-run-card { max-width: 440px; text-align: center; }
.cant-run-card h2 { margin: 0 0 10px; color: #dde; font-size: 18px; font-weight: 600; }
.cant-run-card p { margin: 0; color: #99a; font-size: 14px; line-height: 1.6; }

/* A failed build, import or export: the overlay shows a message and a Close button (js/build-error.js) */
.build-error { display: none; }
.build-overlay.failed .build-overlay-spinner,
.build-overlay.failed .progress-bar-container,
.build-overlay.failed .progress-label { display: none; }
.build-overlay.failed .build-error {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    max-width: min(360px, calc(100vw - 48px)); margin-top: 18px; text-align: center;
}
.build-error-text { margin: 0; color: #dde; font-size: 14px; line-height: 1.5; }
.build-error-detail { margin: 0; color: #778; font-size: 12px; overflow-wrap: anywhere; }
.build-error-detail:empty { display: none; }
.build-error-close {
    min-height: 44px; padding: 0 24px; margin-top: 4px;
    background: transparent; color: #abc; font: inherit; font-size: 14px;
    border: 1px solid rgba(255,255,255,0.18); border-radius: 8px; cursor: pointer;
}
.build-error-close:hover, .build-error-close:focus-visible { border-color: #48f; color: #cde; outline: none; }

/* Progress bar */
.progress-bar-container {
    width: 240px; height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 20px;
}
.progress-bar-fill {
    height: 100%; width: 100%;
    background: #48f;
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
    will-change: transform;
}
.progress-label {
    font-size: 13px; color: #9ab;
    margin-top: 8px;
    text-align: center;
}

/* Export button */
#exportBtn {
    width: 100%; padding: 9px; margin-bottom: 12px;
    background: none;
    color: #9ab; border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
    font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
#exportBtn:hover { border-color: rgba(255,255,255,0.25); color: #cde; background: rgba(255,255,255,0.04); }

/* Export overlay */
#exportOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.3s ease;
}
#exportOverlay.hidden {
    opacity: 0; pointer-events: none;
}
#exportCard {
    position: relative;
    max-width: 380px; width: 90%;
    background: rgba(8,8,28,0.94); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 28px 24px 20px;
    color: #cde;
}
#exportCard h3 {
    font-size: 18px; font-weight: 600; color: #fff;
    margin-bottom: 16px;
}
#exportClose {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none;
    color: #667; font-size: 22px; cursor: pointer;
    line-height: 1; padding: 4px;
    transition: color 0.2s;
}
#exportClose:hover { color: #fff; }
.export-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 18px;
}

/* Survey overlay */
#surveyOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}
#surveyOverlay.hidden {
    opacity: 0; pointer-events: none;
}
#surveyCard {
    position: relative;
    max-width: 380px; width: 90%;
    background: rgba(8,8,28,0.94); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 28px 24px 20px;
    color: #cde;
}
#surveyCard h3 {
    font-size: 18px; font-weight: 600; color: #fff;
    margin-bottom: 10px;
}
#surveyCard p {
    font-size: 14px; line-height: 1.6; color: #9ab;
    margin-bottom: 0;
}
#surveyClose {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none;
    color: #667; font-size: 22px; cursor: pointer;
    line-height: 1; padding: 4px;
    transition: color 0.2s;
}
#surveyClose:hover { color: #fff; }
.survey-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 18px;
}
.survey-actions .btn-primary {
    text-decoration: none;
    display: inline-flex; align-items: center;
}

/* What's New overlay */
#whatsNewOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}
#whatsNewOverlay.hidden {
    opacity: 0; pointer-events: none;
}
#whatsNewCard {
    position: relative;
    max-width: 440px; width: 90%;
    background: rgba(8,8,28,0.94); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 32px 28px 24px;
    color: #cde;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
#whatsNewOverlay.hidden #whatsNewCard {
    opacity: 0; transform: translateY(-16px);
}
#whatsNewClose {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none;
    color: #667; font-size: 22px; cursor: pointer;
    line-height: 1; padding: 4px;
    transition: color 0.2s;
}
#whatsNewClose:hover { color: #fff; }
.whatsnew-step {
    display: none;
}
.whatsnew-step.active {
    display: block;
}
.whatsnew-step h3 {
    font-size: 18px; font-weight: 600; color: #fff;
    margin-bottom: 10px;
}
.whatsnew-step p {
    font-size: 14px; line-height: 1.6; color: #9ab;
    margin-bottom: 8px;
}
.whatsnew-step p:last-of-type {
    margin-bottom: 0;
}
.whatsnew-step p strong {
    color: #cde;
}
.whatsnew-warn {
    background: rgba(232,160,32,0.10);
    border: 1px solid rgba(232,160,32,0.25);
    border-radius: 8px;
    padding: 10px 12px;
    color: #c9a44e;
    font-size: 13px;
    line-height: 1.5;
}
.whatsnew-warn strong {
    color: #e8a020;
}
.whatsnew-list {
    list-style: none; padding: 0; margin: 0;
}
.whatsnew-beta {
    display: inline-block; vertical-align: 2px; margin-left: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 2px 7px; border-radius: 5px; background: rgba(255,180,60,0.16); color: #fc8;
}
.whatsnew-step p.whatsnew-beta-note { margin-top: 8px; font-size: 13px; color: #a98; }
.whatsnew-step p.whatsnew-beta-note strong { color: #fc8; }
.whatsnew-list li {
    font-size: 14px; line-height: 1.6; color: #9ab;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.whatsnew-list li:last-child {
    border-bottom: none;
}
.whatsnew-list li strong {
    color: #cde;
}

/* Mobile view switcher — hidden on desktop */
.mobile-view-switch { display: none; }

/* Sheet handle — hidden on desktop */
.sheet-handle { display: none; }

/* Edit toggle — hidden on desktop */
.edit-toggle { display: none; }

/* Refresh FAB — hidden on desktop */
.refresh-fab { display: none; }

/* Rebuild FAB — appears when pending plate edits exist */
.rebuild-fab {
    position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(135deg, #1a7a4a, #22aa5a);
    color: #fff; border: none; border-radius: 24px;
    padding: 10px 22px;
    font-size: 15px; font-weight: 500; font-family: inherit;
    cursor: pointer; z-index: 25;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 16px rgba(34,170,90,0.35);
    transition: filter 0.2s, box-shadow 0.2s;
    animation: rebuildPulse 2s ease-in-out infinite;
}
.rebuild-fab:hover { filter: brightness(1.15); box-shadow: 0 4px 20px rgba(34,170,90,0.5); }
@keyframes rebuildPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(34,170,90,0.35); }
    50% { box-shadow: 0 4px 24px rgba(34,170,90,0.55); }
}

/* ─── Import page ─── */
.import-upload-area {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px;
}
.import-file-label {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #9ab; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.import-file-label:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.20);
    color: #cde;
}
.import-file-label svg { flex-shrink: 0; width: 16px; height: 16px; }
.import-file-name {
    font-size: 12px; color: #667;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0; flex: 1;
}
.import-preview {
    width: 100%; max-height: 120px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 6px;
    background: #0a0a1a;
}
.import-dims {
    font-size: 11px; color: #667;
    text-align: center; margin-bottom: 8px;
}
.import-hint {
    font-size: 11px; color: #556;
    line-height: 1.4; margin-bottom: 10px;
}
.import-btn {
    width: 100%; padding: 10px; margin-top: 6px;
    background: linear-gradient(135deg, #2255cc, #3366ee);
    color: white; border: none; border-radius: 8px;
    font-size: 15px; font-weight: 500; font-family: inherit; cursor: pointer;
    transition: background 0.3s ease, opacity 0.3s ease;
}
.import-btn:hover:not(:disabled) { filter: brightness(1.15); }
.import-btn:disabled {
    background: linear-gradient(135deg, #333, #444);
    cursor: default; opacity: 0.5;
}

/* ───── Mobile: tablets + phones ───── */
@media (max-width: 768px) {
    #topNav { height: 36px; padding: 0 8px; }
    .nav-tab { padding: 4px 12px; font-size: 12px; min-height: 32px; }
    #topInfo { display: none; }

    /* Bottom sheet */
    #ui {
        position: fixed; bottom: 0; left: 0; right: 0;
        top: auto;
        display: flex; flex-direction: column;
        max-height: 70vh;
        overflow: visible;
        border-radius: 16px 16px 0 0;
        padding: 10px 20px 20px;
        min-width: 0;
        z-index: 30;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        will-change: transform;
    }
    #ui.collapsed {
        transform: translateY(calc(100% - 60px));
        padding: 10px 20px 20px;
    }
    /* Override desktop display:none — content stays rendered (for full-height drag) but invisible */
    #ui.collapsed #sidebarContent { display: block; visibility: hidden; }
    #ui.collapsed #sidebarHeader > div { display: block; visibility: hidden; }
    #ui.collapsed #sidebarHeader { margin-bottom: 0; }
    /* Reveal content as soon as a drag begins */
    #ui.collapsed.dragging #sidebarContent,
    #ui.collapsed.dragging #sidebarHeader > div { visibility: visible; }

    /* Mobile sidebarContent becomes the scroll container */
    #sidebarContent {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        flex: 1;
        min-height: 0;
        padding-right: 0; padding-left: 0;
    }

    /* Disable content scroll during handle drag */
    #ui.dragging #sidebarContent {
        overflow-y: hidden;
        pointer-events: none;
    }

    /* Show drag handle */
    .sheet-handle {
        display: flex;
        justify-content: center;
        padding: 12px 0 8px;
        cursor: grab;
        touch-action: none;
        flex-shrink: 0;
    }
    .sheet-handle span {
        display: block;
        width: 36px; height: 4px;
        background: rgba(255,255,255,0.25);
        border-radius: 2px;
    }

    /* Hide desktop sidebar toggle */
    #sidebarToggle { display: none; }

    /* Mobile view switcher — to the left of the help button */
    .mobile-view-switch {
        display: block;
        position: fixed; top: 40px; left: 16px;
        width: calc(100vw - 16px - 44px - 16px - 12px);
        background: rgba(40,60,120,0.7); backdrop-filter: blur(12px);
        border: 1px solid rgba(100,160,255,0.25);
        color: #8bf; font-size: 13px; font-family: inherit; font-weight: 500;
        padding: 8px 28px 8px 12px; border-radius: 18px;
        min-height: 44px;
        appearance: none; cursor: pointer;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2388bbff'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-position: right 10px center;
        z-index: 50;
    }
    .mobile-view-switch:focus { outline: none; border-color: #48f; }
    .mobile-view-switch option { background: #12122a; color: #cde; }

    /* Edit toggle button */
    .edit-toggle {
        display: flex;
        align-items: center; justify-content: center;
        position: fixed; bottom: 70px; right: 16px;
        width: 48px; height: 48px;
        border-radius: 50%;
        background: rgba(40,60,120,0.8);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(100,160,255,0.25);
        color: #8bf;
        cursor: pointer;
        z-index: 25;
        transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    }
    .edit-toggle.active {
        background: rgba(34,170,90,0.85);
        border-color: rgba(34,170,90,0.5);
        color: #fff;
        box-shadow: 0 0 12px rgba(34,170,90,0.4);
    }

    /* Refresh FAB — mirrors edit toggle on the left */
    .refresh-fab {
        display: flex;
        align-items: center; justify-content: center;
        position: fixed; bottom: 70px; left: 16px;
        width: 48px; height: 48px;
        border-radius: 50%;
        background: rgba(40,60,120,0.8);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(100,160,255,0.25);
        color: #8bf;
        cursor: pointer;
        z-index: 25;
        transition: background 0.3s, box-shadow 0.3s, color 0.3s, border-color 0.3s;
    }
    .refresh-fab:hover { background: rgba(60,90,180,0.9); color: #fff; }
    .refresh-fab.armed {
        background: rgba(34,170,90,0.85);
        border-color: rgba(34,170,90,0.5);
        color: #fff;
        box-shadow: 0 0 12px rgba(34,170,90,0.4);
    }

    /* Rebuild FAB — above bottom sheet */
    .rebuild-fab {
        bottom: 130px;
        min-height: 48px;
        padding: 12px 24px;
        font-size: 16px;
    }

    /* Import page touch targets */
    .import-file-label { padding: 12px 18px; font-size: 14px; min-height: 44px; }
    .import-btn { padding: 14px; font-size: 16px; min-height: 48px; }
    .import-hint { font-size: 12px; }

    /* Touch targets */
    .map-tab { padding: 12px 0; font-size: 13px; min-height: 44px; }
    #debugLayer, #climateSeason { min-height: 44px; }
    #helpBtn { width: 44px; height: 44px; font-size: 20px; top: 40px; right: 12px; }
    .toggle-track { width: 38px; height: 22px; border-radius: 11px; }
    .toggle-thumb { width: 18px; height: 18px; }
    .toggle-label input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
    button#generate { padding: 14px; font-size: 16px; }
    select { padding: 10px 12px; }
    #seedRow button { padding: 8px 12px; }

    /* Font sizes */
    .cg label { font-size: 15px; }
    .section summary { font-size: 14px; }
    #stats { font-size: 12px; }
    .slider-hint { font-size: 12px; }
    #seedCode { font-size: 14px; }

    /* Tooltips: reposition above */
    .tip:hover::after {
        left: 50%; top: auto;
        bottom: calc(100% + 8px);
        transform: translateX(-50%);
    }

    /* Info bars: shift up above collapsed sheet */
    #info { bottom: 68px; }
    #hoverInfo { bottom: 92px; max-width: calc(100vw - 32px); font-size: 13px; }

    /* Tutorial card — tighter padding */
    #tutorialCard { padding: 24px 20px 18px; }
    #whatsNewCard { padding: 24px 20px 18px; }
}

/* ───── Mobile landscape ───── */
@media (max-width: 768px) and (orientation: landscape) {
    #ui { max-height: 50vh; }
}

/* ───── Small phones ───── */
@media (max-width: 480px) {
    .nav-tab { padding: 4px 10px; }
    .nav-long { display: none; }
    #ui { padding: 8px 14px 14px; }
    #tutorialCard { padding: 20px 16px 14px; }
    #whatsNewCard { padding: 20px 16px 14px; }
    button#generate { padding: 12px; font-size: 15px; }
    .cg label { font-size: 14px; }
    .section summary { font-size: 13px; }
}
