:root {
    color-scheme: dark;
    --font-ui: "Figtree", system-ui, sans-serif;
    --font-label: "Syne", system-ui, sans-serif;
    --font-display: "Fraunces", serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
    --bg-deep: #050910;
    --bg-panel: rgba(10, 16, 28, 0.96);
    --bg-elevated: rgba(16, 24, 40, 0.94);
    --bg-glass: rgba(12, 18, 32, 0.82);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #eef3ff;
    --text-secondary: #c0cbe0;
    --muted: #8a9aba;
    --accent: #8b9cff;
    --accent-2: #58d7c4;
    --accent-3: #f5b87a;
    --danger: #ff7a7a;
    --success: #6ef0a8;
    --viewport-bg: #040710;
    --shadow-sm: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 40px rgba(88, 215, 196, 0.06);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    overflow-x: hidden;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-ui);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(88, 215, 196, 0.05), transparent 55%),
        radial-gradient(ellipse 50% 50% at 100% 40%, rgba(139, 156, 255, 0.04), transparent 50%),
        radial-gradient(ellipse 40% 60% at 0% 70%, rgba(245, 184, 122, 0.03), transparent 50%),
        linear-gradient(180deg, #050910 0%, #0a1020 100%);
}

body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ——— App shell ——— */
.atlas-app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

html[data-atlas-embedded="habitat-city"],
html[data-atlas-embedded="habitat-city"] body {
    height: 100%;
    overflow: hidden;
    background: transparent;
    background-image: none;
}

html[data-atlas-embedded="habitat-city"] .atlas-app {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
}

html[data-atlas-embedded="habitat-city"] .atlas-header,
html[data-atlas-embedded="habitat-city"] .atlas-inspector {
    display: none;
}

html[data-atlas-embedded="habitat-city"] .atlas-workspace {
    grid-template-columns: minmax(0, 1fr);
    height: 100%;
}

html[data-atlas-embedded="habitat-city"] .atlas-viewport {
    padding: 0;
    background: transparent;
}

html[data-atlas-embedded="habitat-city"] .viewport-chrome {
    margin-bottom: 8px;
    padding: 12px 16px 0;
}

html[data-atlas-embedded="habitat-city"] .viewport-chrome__hint {
    display: none;
}

/* Locked viewport height on wide screens so the inspector column scrolls inside the shell */
@media (min-width: 1101px) {
    .atlas-app {
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
    }
}

/* ——— Header ——— */
.atlas-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    backdrop-filter: blur(24px) saturate(1.3);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.atlas-header__brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.atlas-header__brand--home {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
}

.atlas-header__brand--home:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.atlas-header__kicker {
    font-family: var(--font-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-3);
}

.atlas-header__title {
    margin: 2px 0 0;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.atlas-header__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.atlas-header__mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
}

.atlas-header__mode .btn {
    white-space: nowrap;
}

.atlas-header__mode-current[aria-current="page"] {
    pointer-events: none;
}

.city-select,
.btn {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 10px 16px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s var(--ease-out-expo), border-color 0.2s ease, transform 0.15s var(--ease-out-expo), box-shadow 0.2s ease;
}

.city-select {
    min-width: 200px;
    max-width: 42vw;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.btn--primary {
    background: linear-gradient(135deg, #7a84ff 0%, #4ecfb8 100%);
    color: #050810;
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 2px 12px rgba(78, 207, 184, 0.2);
}

.btn--primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 20px rgba(78, 207, 184, 0.3);
    transform: translateY(-1px);
}

.btn--primary:active {
    transform: translateY(0);
    filter: brightness(0.96);
}

.btn--ghost {
    background: rgba(8, 14, 26, 0.6);
    border-color: rgba(88, 215, 196, 0.35);
    color: var(--accent-2);
    font-weight: 600;
}

.btn--ghost:hover {
    background: rgba(88, 215, 196, 0.1);
}

/* ——— Workspace: viewport | inspector ——— */
.atlas-workspace {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, min(32vw, 420px));
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    border-top: none;
    align-items: stretch;
}

.atlas-viewport {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 12px 12px 12px 16px;
    background: linear-gradient(180deg, rgba(5, 8, 15, 0.5) 0%, rgba(5, 8, 15, 0.85) 100%);
}

.viewport-chrome {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.viewport-chrome__left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.viewport-chrome__right {
    flex-shrink: 0;
}

.viewport-chrome__hint {
    font-size: 11px;
    color: var(--muted);
    opacity: 0.85;
}

.viewport-badge {
    font-family: var(--font-label);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(110, 240, 170, 0.12);
    color: var(--success);
    border: 1px solid rgba(110, 240, 170, 0.35);
}

.viewport-chrome__divider {
    width: 1px;
    height: 14px;
    background: var(--line);
}

.viewport-chrome__meta {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.viewport-chrome__dot {
    color: var(--muted);
    opacity: 0.6;
}

.viewport-chrome__label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.viewport-canvas-host {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Resizable preview: corner drag (CSS resize) */
.viewport-frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 280px;
    min-width: 240px;
    height: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    resize: both;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--viewport-bg);
    box-shadow: var(--shadow-lg), var(--shadow-glow), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

/* cinematic vignette overlay */
.viewport-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse 85% 80% at 50% 45%, transparent 50%, rgba(0, 0, 0, 0.18) 100%);
}

#stageFrame:fullscreen {
    border-radius: 0;
    resize: none;
}

.world-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    background:
        radial-gradient(circle at 50% 10%, rgba(100, 140, 220, 0.04), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(245, 184, 122, 0.02), transparent 40%),
        linear-gradient(180deg, rgba(8, 12, 22, 0.4), rgba(3, 5, 10, 0.96));
}

.world-stage--fallback2d {
    overflow: hidden;
}

.atlas-fallback-canvas,
.atlas-reference-capture-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.atlas-fallback-badge {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: min(360px, calc(100% - 36px));
    padding: 10px 12px;
    border: 1px solid rgba(88, 215, 196, 0.26);
    border-radius: var(--radius-md);
    color: #dbeafe;
    background: rgba(5, 10, 18, 0.78);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.atlas-fallback-badge strong {
    font-size: 12px;
    line-height: 1.1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.atlas-fallback-badge span {
    font-size: 12px;
    line-height: 1.35;
    color: rgba(219, 234, 254, 0.78);
}

/* D-pad */
.map-dpad {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 4px;
    padding: 9px;
    pointer-events: auto;
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(16, 22, 38, 0.95), rgba(8, 12, 22, 0.92));
    border: 1px solid rgba(88, 215, 196, 0.22);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.dpad-btn {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-label);
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    color: rgba(230, 238, 255, 0.92);
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(38, 48, 72, 0.95), rgba(16, 22, 38, 0.98));
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    transition: transform 90ms ease, background 90ms ease;
}

.dpad-btn:hover {
    border-color: rgba(88, 215, 196, 0.45);
}

.dpad-btn:active,
.dpad-btn.is-pressed {
    transform: translateY(1px) scale(0.97);
}

.dpad-up {
    grid-column: 2;
    grid-row: 1;
}
.dpad-left {
    grid-column: 1;
    grid-row: 2;
}
.dpad-right {
    grid-column: 3;
    grid-row: 2;
}
.dpad-down {
    grid-column: 2;
    grid-row: 3;
}

.viewport-fullscreen-exit {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 30;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(88, 215, 196, 0.42);
    background: linear-gradient(180deg, rgba(16, 22, 38, 0.96), rgba(8, 12, 22, 0.98));
    color: var(--accent-2);
    font-family: var(--font-label);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
}

#stageFrame:fullscreen .viewport-fullscreen-exit,
#stageFrame:-webkit-full-screen .viewport-fullscreen-exit {
    display: inline-flex;
}

/* Minimap + landmark search */
.viewport-map-tools {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    max-width: min(320px, calc(100% - 24px));
}

.viewport-map-tools > * {
    pointer-events: auto;
}

.landmark-search {
    width: 100%;
    max-width: 280px;
    border-radius: var(--radius-md);
    background: rgba(8, 12, 22, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-sm);
}

.landmark-search.is-collapsed {
    max-width: 220px;
}

.landmark-search.is-collapsed .landmark-search__bar {
    padding: 6px 7px;
}

.landmark-search.is-expanded .landmark-search__bar {
    padding: 8px 9px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.landmark-search.is-expanded {
    padding-bottom: 2px;
}

.landmark-search__bar {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.landmark-search__toggle {
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(18, 24, 40, 0.88);
    color: rgba(200, 210, 230, 0.95);
    cursor: pointer;
    transition: background 90ms ease, border-color 90ms ease;
}

.landmark-search__toggle:hover {
    border-color: rgba(88, 215, 196, 0.35);
    background: rgba(24, 32, 48, 0.95);
}

.landmark-search__chevron {
    display: block;
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-top: -4px;
    transition: transform 0.15s ease;
}

.landmark-search.is-expanded .landmark-search__chevron {
    transform: rotate(225deg);
    margin-top: 2px;
}

.landmark-search__drawer {
    padding: 0 9px 9px;
}

.landmark-search__drawer[hidden] {
    display: none !important;
}

.landmark-search__label {
    display: block;
    font-family: var(--font-label);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(136, 196, 255, 0.85);
    margin-bottom: 6px;
    padding-top: 4px;
}

.landmark-search__input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(18, 24, 40, 0.95);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
}

.landmark-search__input:focus {
    border-color: rgba(88, 215, 196, 0.45);
    box-shadow: 0 0 0 1px rgba(88, 215, 196, 0.25);
}

.landmark-search__results {
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(6, 10, 18, 0.96);
}

.landmark-search__results[hidden] {
    display: none !important;
}

.landmark-search__empty {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--muted);
}

.landmark-search__row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 8px 10px;
    margin: 0;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.35;
}

.landmark-search__row:last-child {
    border-bottom: none;
}

.landmark-search__row:hover,
.landmark-search__row.is-active {
    background: rgba(88, 215, 196, 0.12);
}

.landmark-search__name {
    font-weight: 600;
    color: #eef3ff;
}

.landmark-search__meta {
    font-size: 11px;
    color: var(--muted);
}

.atlas-minimap {
    padding: 7px 7px 9px;
    border-radius: var(--radius-md);
    background: rgba(6, 10, 18, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    cursor: crosshair;
    transition: border-color 0.2s ease;
}

.atlas-minimap:hover {
    border-color: rgba(88, 215, 196, 0.25);
}

.atlas-minimap__tag {
    display: block;
    font-family: var(--font-label);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(244, 91, 105, 0.9);
    margin-bottom: 5px;
    text-align: center;
}

#atlasMinimapCanvas {
    display: block;
    width: 168px;
    height: 168px;
    min-width: 120px;
    min-height: 120px;
    border-radius: 10px;
    vertical-align: middle;
    background: #243044;
}

/* ——— Inspector ——— */
.atlas-inspector {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    border-left: 1px solid var(--line);
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    backdrop-filter: blur(20px) saturate(1.2);
}

/* First block inside the scroll column: cancel parent padding so the band still spans edge-to-edge */
.inspector-top {
    flex-shrink: 0;
    margin-top: -14px;
    margin-bottom: 12px;
    margin-inline-start: -16px;
    margin-inline-end: calc(-1 * max(16px, env(safe-area-inset-right)));
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.inspector-title {
    margin: 0 0 6px;
    font-family: var(--font-label);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-3);
}

.inspector-lede {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.mission-visual-repair {
    color: #ffb347;
}

.inspector-mission-title,
.mission-title {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
}

.inspector-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.meta-tile {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.meta-tile--wide {
    grid-column: 1 / -1;
}

.meta-tile__label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}

.meta-tile__value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.inspector-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding: 14px 16px 28px;
    padding-inline-end: max(16px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.inspector-scroll::-webkit-scrollbar {
    width: 8px;
}

.inspector-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    margin: 4px 0;
}

.inspector-scroll::-webkit-scrollbar-thumb {
    background: rgba(139, 156, 255, 0.22);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.inspector-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 156, 255, 0.38);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.inspector-card {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.inspector-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.eyebrow {
    font-family: var(--font-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-3);
    margin-bottom: 8px;
}

.card-title,
.overlay-title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

.card-copy,
.overlay-copy {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--muted);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.landmark-policy-line {
    font-size: 11px;
    color: var(--muted);
    margin: 6px 0 4px;
    line-height: 1.45;
}

.landmark-policy-line__stats[data-warning="true"] {
    color: #ffb4a8;
}

.landmark-policy-line__div {
    opacity: 0.75;
    margin-left: 4px;
}

.landmark-legend {
    font-size: 11px;
    max-height: 8rem;
    overflow-y: auto;
    margin-top: 4px;
}

.landmark-legend__row {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    padding: 0 0 6px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    border-radius: 4px;
    transition: background 0.12s ease;
}

.landmark-legend__row:hover,
.landmark-legend__row:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.landmark-legend__row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.landmark-legend__name {
    font-weight: 600;
    color: #e8eefc;
}

.landmark-legend__meta {
    font-size: 10px;
    opacity: 0.78;
    margin-top: 2px;
}

.landmark-legend__sum {
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.35;
    opacity: 0.85;
}

.landmark-legend .landmark-line {
    margin: 0.15em 0;
}

.landmark-legend .landmark-xy {
    opacity: 0.7;
    font-size: 10px;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.stat-card {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* VAL-METRIC-005: Realism Gate styles */
.gate-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.gate-status--pass {
    background: rgba(110, 240, 168, 0.15);
    color: var(--success);
    border: 1px solid rgba(110, 240, 168, 0.3);
}
.gate-status--fail {
    background: rgba(255, 122, 122, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 122, 122, 0.3);
}
.gate-status--pending {
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.gate-metrics-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.gate-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.gate-metric-label {
    font-size: 11px;
    color: var(--text-secondary);
}
.gate-metric-value {
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.gate-metric-value--pass {
    color: var(--success);
}
.gate-metric-value--fail {
    color: var(--danger);
}
.gate-metric-value--pending {
    color: var(--muted);
}
.gate-profile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.gate-profile-label {
    font-size: 11px;
    color: var(--muted);
}
.gate-profile-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* VAL-CROSS-005: Corridor/topology summary section within realism gate */
.gate-corridor-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.gate-corridor-kicker {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.gate-connectivity-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
}
.gate-connectivity-tag--reachable {
    background: rgba(110, 240, 168, 0.12);
    color: var(--success);
    border: 1px solid rgba(110, 240, 168, 0.25);
}
.gate-connectivity-tag--blocked {
    background: rgba(255, 122, 122, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 122, 122, 0.25);
}
.gate-corridor-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}
.gate-corridor-meta-label {
    font-size: 10px;
    color: var(--muted);
}
.gate-corridor-meta-value {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: var(--mono, 'JetBrains Mono', monospace);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* VAL-REG-004: Regression Alert styles */
.regression-alert-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 122, 122, 0.1);
    border: 1px solid rgba(255, 122, 122, 0.25);
    cursor: pointer;
    transition: background 0.15s ease;
}
.regression-alert-row:hover {
    background: rgba(255, 122, 122, 0.18);
}
.regression-alert-row--stable {
    background: rgba(110, 240, 168, 0.08);
    border-color: rgba(110, 240, 168, 0.2);
    cursor: default;
}
.regression-alert-row--stable:hover {
    background: rgba(110, 240, 168, 0.12);
}
.regression-alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.regression-alert-city {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}
.regression-alert-status {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.regression-alert-status--regressing {
    color: var(--danger);
}
.regression-alert-status--stable {
    color: var(--success);
}
.regression-alert-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}
.regression-metric-chip {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-secondary);
}
.regression-metric-chip--fail {
    background: rgba(255, 122, 122, 0.2);
    color: var(--danger);
}
.regression-alert-empty {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    padding: 12px;
}
.regression-drilldown {
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.drilldown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.drilldown-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}
.drilldown-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.drilldown-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
.drilldown-content {
    font-size: 11px;
    color: var(--text-secondary);
}
.drilldown-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.drilldown-metric-row:last-child {
    border-bottom: none;
}
.drilldown-metric-name {
    color: var(--text-secondary);
}
.drilldown-metric-values {
    display: flex;
    gap: 8px;
    align-items: center;
    font-variant-numeric: tabular-nums;
}
.drilldown-baseline {
    color: var(--muted);
}
.drilldown-current {
    color: var(--text-primary);
    font-weight: 600;
}
.drilldown-current--fail {
    color: var(--danger);
}
.drilldown-arrow {
    color: var(--muted);
    font-size: 10px;
}
.drilldown-delta {
    font-size: 10px;
    font-weight: 600;
}
.drilldown-delta--negative {
    color: var(--danger);
}
.drilldown-delta--positive {
    color: var(--success);
}
.drilldown-snapshot-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 10px;
    color: var(--muted);
}

.worker-ribbon {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.15);
}

.worker-pill {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    flex: 1 1 auto;
    min-width: min(140px, 100%);
}

.worker-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: capitalize;
}

.worker-status {
    margin-top: 3px;
    font-size: 11px;
    color: var(--muted);
}

.worker-pill[data-status="started"] {
    border-color: rgba(138, 164, 255, 0.45);
}
.worker-pill[data-status="completed"] {
    border-color: rgba(118, 240, 165, 0.42);
}
.worker-pill[data-status="fallback"] {
    border-color: rgba(245, 193, 109, 0.42);
}
.worker-pill[data-status="rejected"] {
    border-color: rgba(255, 117, 117, 0.42);
}

.district-list,
.patch-feed {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.district-card,
.patch-card {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    min-width: 0;
    overflow-wrap: anywhere;
}

.district-card h3,
.patch-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.district-card p,
.patch-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.patch-meta {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    color: var(--accent-2);
    font-size: 11px;
    gap: 8px;
    flex-wrap: wrap;
}

/* Patch card states — terminal state must be visually unambiguous */
.patch-card.patch-applied {
    border-color: rgba(118, 240, 165, 0.3);
}

.patch-card.patch-rejected {
    border-color: rgba(255, 117, 117, 0.35);
}

.patch-card.patch-pending {
    border-color: rgba(255, 184, 122, 0.25);
}

/* Rejection rationale — VAL-LOOP-004: rationale preserved across refresh */
.patch-rationale {
    margin-top: 6px !important;
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 117, 117, 0.08);
    border: 1px solid rgba(255, 117, 117, 0.2);
    color: #ffd4d4 !important;
    font-size: 11px !important;
}

.rationale-label {
    color: var(--danger);
    font-weight: 600;
}

.control-feedback {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.control-feedback[data-state="success"] {
    border-color: rgba(118, 240, 165, 0.42);
    color: var(--success);
    background: rgba(118, 240, 165, 0.08);
}

.control-feedback[data-state="error"] {
    border-color: rgba(255, 117, 117, 0.42);
    color: #ffd4d4;
    background: rgba(255, 117, 117, 0.12);
}

/* VAL-CROSS-010: Global control error feedback — sits inline in header actions.
   Shows full semantic error text from API responses without truncation so
   validators can read the same error details the API returned. */
.world-control-feedback {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 4px 10px;
    font-size: 11px;
    max-width: 520px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    vertical-align: middle;
    line-height: 1.4;
}

.world-control-feedback:not([hidden]) {
    display: inline-flex;
}

.world-control-feedback[data-state="error"] {
    border-color: rgba(255, 117, 117, 0.5);
    color: #ffd4d4;
    background: rgba(255, 117, 117, 0.15);
    font-weight: 500;
}

/* VAL-CROSS-010: Persistent control error log — surfaces semantic API error
   details in a scrollable list so validators can read error text after any
   failed control action (focus/hydrate/pause/start). Entries survive refreshes. */
.control-error-log {
    margin-top: 8px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid rgba(255, 117, 117, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(255, 117, 117, 0.06);
    padding: 4px 0;
}

.control-error-log-entry {
    padding: 4px 10px;
    font-size: 11px;
    line-height: 1.4;
    color: #ffd4d4;
    word-break: break-word;
    overflow-wrap: break-word;
    border-bottom: 1px solid rgba(255, 117, 117, 0.1);
}

.control-error-log-entry:last-child {
    border-bottom: none;
}

.region-list,
.review-panel {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.region-card,
.review-card {
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.region-card[data-active="true"] {
    border-color: rgba(138, 164, 255, 0.42);
}

.region-card h3,
.review-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.region-copy,
.review-copy {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.region-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.region-pill {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    font-size: 11px;
    color: var(--muted);
}

.region-actions,
.review-mode-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.mini-action,
.mode-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 6px 10px;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.mini-action:hover,
.mode-pill:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mini-action--warn {
    border-color: rgba(255, 117, 117, 0.28);
    color: #ffd4d4;
}

.mode-pill[data-active="true"] {
    border-color: rgba(88, 215, 196, 0.42);
    background: rgba(88, 215, 196, 0.12);
    color: var(--accent-2);
}

.replay-row {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.replay-select {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    font-size: 12px;
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.review-stat {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.review-stat strong {
    display: block;
    font-size: 16px;
}

.review-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.review-line {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.review-line strong {
    color: var(--text);
}

.review-line[data-severity="high"],
.review-line[data-severity="critical"] {
    border: 1px solid rgba(255, 117, 117, 0.28);
}

.review-line[data-severity="medium"] {
    border: 1px solid rgba(245, 193, 109, 0.22);
}

.city-select[disabled] {
    opacity: 0.55;
    pointer-events: none;
}

.ws-status {
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ws-status[data-state="live"] {
    border-color: rgba(118, 240, 165, 0.42);
    color: var(--success);
    background: rgba(118, 240, 165, 0.08);
    animation: live-pulse 3s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(118, 240, 165, 0); }
    50% { box-shadow: 0 0 0 3px rgba(118, 240, 165, 0.1); }
}

.ws-status[data-state="connecting"],
.ws-status[data-state="reconnecting"] {
    border-color: rgba(245, 193, 109, 0.42);
    color: var(--accent-3);
    background: rgba(245, 193, 109, 0.08);
}

.ws-status[data-state="error"] {
    border-color: rgba(255, 117, 117, 0.42);
    color: var(--danger);
    background: rgba(255, 117, 117, 0.08);
}

.ws-status[data-state="degraded"] {
    border-color: rgba(167, 179, 208, 0.42);
    color: var(--muted);
    background: rgba(167, 179, 208, 0.08);
}

/* Firebase Auth Section (VAL-AUTH-001, VAL-AUTH-006, VAL-AUTH-007, VAL-AUTH-008) */
.auth-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-signed-out {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-signed-in {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-providers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.auth-provider-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.auth-provider-btn img {
    width: 16px;
    height: 16px;
}

.auth-user-photo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.auth-user-email {
    font-size: 12px;
    color: var(--muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

canvas {
    display: block;
}

@media (prefers-contrast: more) {
    :root {
        --text: #ffffff;
        --muted: #e2e8f5;
        --line: rgba(255, 255, 255, 0.22);
    }
}

/* ——— Responsive ——— */
@media (max-width: 1100px) {
    /* Let the document scroll; stacked panels are not height-capped */
    .atlas-app {
        height: auto;
        max-height: none;
        min-height: 100dvh;
    }

    .atlas-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        flex: none;
        min-height: auto;
    }

    .atlas-viewport {
        min-height: min(52vh, 560px);
        flex: none;
    }

    .atlas-inspector {
        border-left: none;
        border-top: 1px solid var(--line);
        max-height: none;
        overflow: visible;
    }

    .inspector-top {
        margin-top: 0;
        margin-inline: 0;
    }

    .inspector-scroll {
        flex: none;
        min-height: auto;
        overflow: visible;
        overscroll-behavior: auto;
        scrollbar-gutter: auto;
    }

    .viewport-chrome__hint {
        display: none;
    }
}

@media (max-width: 720px) {
    .atlas-header {
        flex-direction: column;
        align-items: stretch;
    }

    .atlas-header__actions {
        justify-content: stretch;
    }

    .city-select {
        max-width: none;
        width: 100%;
    }

    .map-dpad {
        grid-template-columns: repeat(3, 38px);
        grid-template-rows: repeat(3, 38px);
        bottom: 10px;
        padding: 7px;
    }

    .atlas-minimap {
        right: 8px;
        bottom: 8px;
        transform: scale(0.92);
        transform-origin: bottom right;
    }

    .review-grid {
        grid-template-columns: 1fr;
    }

    .inspector-mission-title,
    .mission-title {
        font-size: 1.15rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   ONBOARD OVERLAY — cinematic city-creation flow
   ═══════════════════════════════════════════════════════════════════ */

.onboard-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.onboard-overlay[hidden] {
    display: none;
}

.onboard-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 5, 12, 0.88);
    -webkit-backdrop-filter: blur(32px) saturate(0.6);
    backdrop-filter: blur(32px) saturate(0.6);
    animation: onboard-fade-in 0.35s var(--ease-out-expo) both;
}

@keyframes onboard-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.onboard-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius-xl);
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(139, 156, 255, 0.06), transparent 60%),
        radial-gradient(ellipse 60% 50% at 50% 100%, rgba(88, 215, 196, 0.04), transparent 50%),
        linear-gradient(180deg, rgba(14, 20, 36, 0.97), rgba(8, 12, 24, 0.99));
    border: 1px solid rgba(139, 156, 255, 0.15);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.5),
        0 32px 80px rgba(0, 0, 0, 0.6),
        0 0 120px rgba(88, 215, 196, 0.04);
    padding: 48px 40px 40px;
    animation: onboard-panel-in 0.45s 0.1s var(--ease-out-expo) both;
    overflow: hidden;
}

@keyframes onboard-panel-in {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.onboard-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    z-index: 2;
}

.onboard-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* --- Phase containers --- */
.onboard-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    animation: onboard-phase-in 0.4s var(--ease-out-expo) both;
}

.onboard-phase[hidden] {
    display: none;
}

@keyframes onboard-phase-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Input phase --- */
.onboard-glyph {
    width: 56px;
    height: 56px;
    color: var(--accent);
    margin-bottom: 4px;
    animation: onboard-glyph-float 3s ease-in-out infinite;
}

@keyframes onboard-glyph-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.onboard-glyph svg {
    width: 100%;
    height: 100%;
}

.onboard-headline {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    background: linear-gradient(135deg, var(--text) 40%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.onboard-sub {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.55;
    max-width: 400px;
    margin: 0;
}

.onboard-form {
    width: 100%;
    margin-top: 8px;
}

.onboard-input-wrap {
    display: flex;
    gap: 0;
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(139, 156, 255, 0.25);
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.onboard-input-wrap:focus-within {
    border-color: rgba(139, 156, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 156, 255, 0.08), 0 0 40px rgba(88, 215, 196, 0.06);
}

.onboard-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 16px 18px;
    font: inherit;
    font-size: 16px;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.onboard-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.onboard-go {
    flex-shrink: 0;
    border: none;
    background: linear-gradient(135deg, #7a84ff 0%, #4ecfb8 100%);
    color: #050810;
    font-family: var(--font-label);
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.04em;
    padding: 0 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: filter 0.2s ease, transform 0.15s var(--ease-out-expo);
}

.onboard-go:hover {
    filter: brightness(1.1);
}

.onboard-go:active {
    transform: scale(0.97);
}

.onboard-go__arrow {
    font-size: 18px;
    transition: transform 0.2s var(--ease-out-expo);
}

.onboard-go:hover .onboard-go__arrow {
    transform: translateX(3px);
}

.onboard-go:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: saturate(0.4);
}

.onboard-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.onboard-chip {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    padding: 7px 16px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s var(--ease-out-expo);
}

.onboard-chip:hover {
    background: rgba(139, 156, 255, 0.1);
    border-color: rgba(139, 156, 255, 0.3);
    color: var(--text);
    transform: translateY(-1px);
}

/* --- Progress phase --- */
.onboard-progress-ring {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 4px;
}

.onboard-progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.onboard-arc {
    transition: stroke-dashoffset 0.8s var(--ease-out-expo);
}

.onboard-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-2);
}

.onboard-log {
    width: 100%;
    max-height: 160px;
    overflow-y: auto;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--muted);
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.onboard-log-line {
    animation: onboard-log-line-in 0.3s var(--ease-out-expo) both;
}

@keyframes onboard-log-line-in {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

.onboard-log-line--phase {
    color: var(--accent-2);
    font-weight: 500;
}

.onboard-log-line--error {
    color: var(--danger);
}

/* Scanning animation on the progress ring */
@keyframes onboard-ring-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(88, 215, 196, 0.2)); }
    50% { filter: drop-shadow(0 0 14px rgba(88, 215, 196, 0.45)); }
}

.onboard-progress-ring svg {
    animation: onboard-ring-pulse 2s ease-in-out infinite;
}

/* --- Done phase --- */
.onboard-done-check {
    width: 72px;
    height: 72px;
    margin-bottom: 4px;
}

.onboard-done-check svg {
    width: 100%;
    height: 100%;
}

.onboard-check-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: onboard-check-draw 0.6s 0.2s var(--ease-out-expo) forwards;
}

@keyframes onboard-check-draw {
    to { stroke-dashoffset: 0; }
}

.onboard-dismiss {
    margin-top: 8px;
    padding: 14px 36px;
    font-size: 15px;
}

/* --- Error phase --- */
.onboard-error-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--danger);
    border: 2px solid rgba(255, 122, 122, 0.3);
    background: rgba(255, 122, 122, 0.06);
}

.onboard-retry {
    margin-top: 8px;
}

/* --- Responsive --- */
@media (max-width: 560px) {
    .onboard-panel {
        padding: 36px 24px 28px;
        max-width: 100%;
    }

    .onboard-headline {
        font-size: 1.25rem;
    }

    .onboard-input {
        padding: 14px 14px;
        font-size: 15px;
    }

    .onboard-go {
        padding: 0 20px;
    }
}

/* --- Mask Effects Controls --- */
.mask-effects-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.mask-control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.mask-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.mask-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-1);
    cursor: pointer;
}

.mask-checkbox-text {
    user-select: none;
}

.mask-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.mask-color-input {
    width: 32px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

.mask-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.mask-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.mask-slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    appearance: none;
    cursor: pointer;
}

.mask-slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-1);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mask-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-1);
    cursor: pointer;
    border: none;
}

.mask-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.mask-presets-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}

.mask-preset-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.mask-preset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text);
}

.mask-preset-btn.active {
    background: var(--accent-1);
    border-color: var(--accent-1);
    color: #000;
}

/* ═══════════ Time-of-day control (P0-1) ═══════════ */

.tod-control {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tod-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.tod-kicker {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.tod-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.82);
    letter-spacing: 0.04em;
}

.tod-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: linear-gradient(
        90deg,
        #182848 0%,
        #1c2840 8%,
        #2c3e60 20%,
        #7896c9 35%,
        #ffd8a8 55%,
        #f0b177 73%,
        #2e4478 82%,
        #080818 100%
    );
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.tod-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

.tod-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.tod-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border: none;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.tod-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tod-preset-btn {
    flex: 1 1 auto;
    min-width: 52px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 10px;
    font-family: "Figtree", sans-serif;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tod-preset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.92);
}

.tod-preset-btn.is-active {
    background: rgba(255, 216, 168, 0.16);
    border-color: rgba(255, 216, 168, 0.5);
    color: #ffd8a8;
}

.tod-cycle-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    user-select: none;
}

.tod-cycle-toggle input[type="checkbox"] {
    accent-color: #ffd8a8;
    cursor: pointer;
}

.weather-control {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.weather-btn {
    flex: 1 1 auto;
    min-width: 52px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 10px;
    font-family: "Figtree", sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.weather-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.92);
}

.weather-btn.is-active {
    background: rgba(168, 196, 224, 0.16);
    border-color: rgba(168, 196, 224, 0.5);
    color: #a8c4e0;
}

/* ═══════════ P1-12: Guidebook card ═══════════ */

.guidebook-card {
    background: linear-gradient(165deg, rgba(255, 216, 168, 0.05), rgba(138, 120, 96, 0.03));
    border: 1px solid rgba(255, 216, 168, 0.18);
}

.guidebook-title {
    font-family: "Fraunces", serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.15;
    color: #f2e7d4;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.guidebook-lede {
    font-family: "Fraunces", serif;
    font-size: 13.5px;
    font-style: italic;
    line-height: 1.5;
    color: rgba(242, 231, 212, 0.78);
    margin: 0 0 14px 0;
}

.guidebook-palette {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    height: 18px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.guidebook-palette-swatch {
    flex: 1 1 auto;
    min-width: 8px;
}

.guidebook-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.guidebook-section-kicker {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
}

.guidebook-districts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.78);
}

.guidebook-district-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guidebook-district-chip {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.4);
}

.guidebook-district-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.guidebook-district-theme {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-style: italic;
}

.guidebook-landmarks {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.guidebook-landmark-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.82);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
    font-family: "Figtree", sans-serif;
}

.guidebook-landmark-row:hover {
    background: rgba(255, 216, 168, 0.1);
    border-color: rgba(255, 216, 168, 0.28);
    color: #ffd8a8;
}

.guidebook-landmark-row__name {
    font-weight: 600;
}

.guidebook-landmark-row__meta {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ═══════════ Truth context display in Guidebook ═══════════ */
.guidebook-truth-context {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 6px;
}
.truth-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.truth-stat--wide {
    flex-basis: 100%;
}
.truth-stat__label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}
.truth-stat__value {
    font-family: "JetBrains Mono", monospace;
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}
.truth-stat__value--warning {
    color: #ffb347;
}
.truth-stat__value--alert {
    color: #ff7b7b;
}
.truth-stat__value--provenance {
    font-size: 11px;
    white-space: normal;
    line-height: 1.35;
}

/* ═══════════ P0-4: Lab vs Explore mode ═══════════ */

.atlas-app[data-mode="explore"] .lab-only {
    display: none !important;
}

.atlas-app[data-mode="explore"] .lab-only-inline {
    display: none !important;
}

.atlas-app[data-mode="lab"] #modeToggleBtn .mode-label::before {
    content: "Lab · ";
    color: rgba(255, 216, 168, 0.95);
    font-weight: 600;
}

#modeToggleBtn[aria-pressed="true"] {
    background: rgba(255, 216, 168, 0.12);
    border-color: rgba(255, 216, 168, 0.4);
    color: #ffd8a8;
}
