/* ==========================================================================
   Alien Life Engine — Modern Glassmorphic Cyber-Biological UI / UX
   Ultra-wide Desktop to Mobile Responsive System
   ========================================================================== */


.tab-label-short { display: none; }
.tab-label-full { display: inline; }
.hotkey-hint {
    opacity: 0.65;
    font-weight: normal;
    font-size: 11px;
    margin-left: 4px;
    color: var(--text-muted);
}

:root {
    --bg-universe: #0E1318;
    --drawer-bg: rgba(18, 24, 33, 0.94);
    --card-bg: rgba(28, 36, 48, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(255, 255, 255, 0.16);
    
    --accent-life: #15DE59;
    --accent-life-glow: rgba(21, 222, 89, 0.35);
    --accent-cyan: #2F7AB7;
    --accent-magenta: #F82380;
    --accent-amber: #DEB14D;
    --accent-purple: #7230DB;
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --dock-bg: rgba(14, 19, 24, 0.88);
    --hud-glass: rgba(14, 19, 24, 0.78);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Base Reset & Full-Screen Canvas */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-universe);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    user-select: none;
}

#env {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    text-align: center;
    background-color: var(--bg-universe);
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}

#env-canvas {
    position: relative;
    top: 0px;
    left: 0px;
    display: inline-block;
    image-rendering: pixelated;
    cursor: crosshair;
}

/* ==========================================================================
   TOP GLASS HUD: Header, Live Telemetry & Actions
   ========================================================================== */
#top-hud {
    position: fixed;
    top: 12px;
    left: 16px;
    right: 16px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    gap: 12px;
}

#top-hud > * {
    pointer-events: auto;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hud-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--hud-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.hud-brand-symbol {
    font-size: 16px;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
}

.wordmark {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ffffff;
    display: inline-flex;
}

.wordmark-accent {
    color: var(--accent-life);
    text-shadow: 0 0 8px var(--accent-life-glow);
}

.hud-telemetry {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-pill {
    background: var(--hud-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    padding: 5px 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.hud-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot-pop {
    background-color: var(--accent-life);
    box-shadow: 0 0 8px var(--accent-life);
}

.dot-species {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

.hud-lbl {
    font-weight: 700;
    color: var(--text-dim);
    font-size: 10px;
}

.hud-val {
    color: var(--text-primary);
    font-weight: 700;
}

/* Center Toast: Hive Hint */
@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Right HUD Buttons */
.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-btn {
    background: var(--hud-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}

.hud-btn.active {
    background: rgba(21, 222, 89, 0.15);
    border-color: var(--accent-life);
    color: var(--accent-life);
    box-shadow: 0 0 12px var(--accent-life-glow);
}

.hud-btn-primary {
    background: linear-gradient(135deg, #15DE59 0%, #10b981 100%);
    color: #06240d;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 16px rgba(21, 222, 89, 0.35);
}

.hud-btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(21, 222, 89, 0.45);
}

/* ==========================================================================
   FLOATING ACTION DOCK (Centered Bottom Action Bar)
   ========================================================================== */
#floating-dock {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    will-change: auto;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--dock-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-full);
    padding: 6px 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6), 0 0 1px rgba(255,255,255,0.2);
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    scrollbar-width: none;
}

#floating-dock::-webkit-scrollbar {
    display: none;
}

.dock-section {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dock-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 3px;
    flex-shrink: 0;
}

.dock-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.dock-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: translateY(-2px);
}

.dock-btn:active {
    transform: translateY(0);
}

.dock-btn.selected, .dock-btn.active {
    background: rgba(21, 222, 89, 0.2);
    border-color: var(--accent-life);
    color: var(--accent-life);
    box-shadow: 0 0 12px var(--accent-life-glow);
}

.dock-btn-drawer {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.dock-btn-drawer.active {
    background: var(--accent-life);
    color: #06240d;
    box-shadow: 0 0 16px var(--accent-life-glow);
}

.dock-speed {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.dock-speed-val {
    /* Fixed width + tabular figures: "Actual FPS: 7" -> "MAX" -> "Actual FPS: 122"
       changes digit count every frame, and without a reserved box the whole dock
       re-centres on each change, which reads as a shiver. */
    width: 106px;
    min-width: 106px;
    flex: 0 0 106px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    color: var(--text-primary);
    font-weight: 600;
}

.dock-icon {
    font-size: 12px;
    color: var(--text-dim);
}

.dock-brush {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
}

.dock-brush label {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
}

/* Styled Range Sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.12);
    height: 4px;
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-life);
    box-shadow: 0 0 8px var(--accent-life-glow);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

#brush-slider::-webkit-slider-thumb {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(47, 122, 183, 0.5);
}

/* ==========================================================================
   THE STUDIO DRAWER / SLIDE-OVER SHEET (Control Panel)
   ========================================================================== */
.control-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: 84px;
    width: 600px;
    max-width: calc(100vw - 32px);
    z-index: 60;
    background: var(--drawer-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: -8px 12px 48px rgba(0,0,0,0.65), 0 0 1px rgba(255,255,255,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: drawerSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sheet-handle {
    display: none;
}

.drawer-header {
    background: rgba(14, 19, 24, 0.6);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
}

.drawer-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px 8px 18px;
}

.drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-title h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.drawer-badge {
    background: rgba(21, 222, 89, 0.15);
    border: 1px solid rgba(21, 222, 89, 0.3);
    color: var(--accent-life);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    letter-spacing: 0.08em;
}

.drawer-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.drawer-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Horizontal Tab Navigation */
.tabnav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabnav::-webkit-scrollbar {
    display: none;
}

.tabnav-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.tabnav-item i {
    font-size: 12px;
}

.tabnav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.tabnav-item.open-tab {
    background: rgba(21, 222, 89, 0.15);
    border-color: rgba(21, 222, 89, 0.35);
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(21, 222, 89, 0.15);
}

.tabnav-item.open-tab i {
    color: var(--accent-life);
}

/* Drawer Body & Tab Content */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.drawer-body::-webkit-scrollbar {
    width: 6px;
}

.drawer-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
}

.tab {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

.tab#about {
    display: block;
}

.tab.open-tab, .tab[style*="display: grid"], .tab[style*="display: flex"], .tab[style*="display: block"] {
    display: block !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-card-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Modern Glass Card */
.ui-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: border-color 0.2s ease;
}

.ui-card:hover {
    border-color: var(--card-hover-border);
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.card-title i {
    color: var(--accent-life);
    font-size: 13px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 10px;
}

.card-subtext {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 14px 0 8px 0;
}

/* Form Rows & Inputs */
.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    color: var(--text-secondary);
}

.form-row:last-child {
    border-bottom: none;
}

.form-row label {
    cursor: pointer;
    flex: 1;
}

.ui-input, .ui-input-num {
    background: rgba(14, 19, 24, 0.85);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 5px 8px;
    font-size: 13px;
    font-family: var(--font-mono);
    outline: none;
    transition: all 0.15s ease;
}

.ui-input-num {
    width: 80px;
    text-align: right;
}

.ui-input-num:focus, .ui-input:focus, .ui-select:focus {
    border-color: var(--accent-life);
    box-shadow: 0 0 10px var(--accent-life-glow);
}

.ui-select {
    background: rgba(14, 19, 24, 0.85);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 5px 10px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.ui-select option {
    background: #18202c;
    color: #fff;
}

/* Switches & Checkboxes */
input[type="checkbox"].ui-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    position: relative;
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

input[type="checkbox"].ui-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input[type="checkbox"].ui-switch:checked {
    background: var(--accent-life);
}

input[type="checkbox"].ui-switch:checked::after {
    transform: translateX(16px);
    background: #06240d;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #15DE59 0%, #10b981 100%);
    color: #06240d;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(21, 222, 89, 0.25);
}

.btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--card-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(248, 35, 128, 0.15);
    border-color: rgba(248, 35, 128, 0.3);
    color: #ff6b9d;
}

.btn-danger:hover {
    background: rgba(248, 35, 128, 0.25);
    color: #fff;
}

.btn-chip {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--card-border);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: var(--radius-full);
}

.btn-chip:hover, .btn-chip.selected {
    background: rgba(21, 222, 89, 0.2);
    border-color: var(--accent-life);
    color: var(--accent-life);
}

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

.button-group {
    display: flex;
    gap: 8px;
}

/* Cell Legend Palette */
#cell-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: rgba(14, 19, 24, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    margin: 8px 0 12px 0;
}

.cell-legend-type {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(0,0,0,0.4);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.cell-legend-type:hover {
    transform: scale(1.15);
    border-color: #ffffff;
}

.hive-about-hint {
    background: rgba(21, 222, 89, 0.1);
    border-left: 3px solid var(--accent-life);
    padding: 8px 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 12px;
    color: #e5e7eb;
    margin-top: 10px;
}

.about-detail {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 10px;
}

.credits-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
}

.credit-link {
    color: var(--accent-cyan);
    text-decoration: none;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.credit-link:hover {
    text-decoration: underline;
    color: #60a5fa;
}

/* Editor Workbench */
.editor-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.workbench-viewport {
    background: rgba(10, 14, 18, 0.95);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    margin-bottom: 12px;
}

#editor-env {
    width: 195px;
    height: 195px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0E1318;
    border-radius: 4px;
}

#editor-canvas {
    width: 195px;
    height: 195px;
    display: block;
    image-rendering: pixelated;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    cursor: pointer;
}

.cell-palette-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.palette-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.cell-type {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(0,0,0,0.4);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.cell-type:hover {
    transform: scale(1.15);
    border-color: #ffffff;
}

.workbench-actions {
    display: flex;
    gap: 8px;
}

/* Organism Details & MindViewer Host */
.inspector-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.badge-pill {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    padding: 2px 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--accent-life);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#mind-host {
    margin-top: 10px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #18202c;
    border: 1px solid rgba(255,255,255,0.08);
}

/* Chronicle Events & Lineage Cards */
.chronicle-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

#chronicle-log {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.chronicle-card {
    background: rgba(14, 19, 24, 0.7);
    border: 1px solid var(--card-border);
    border-left: 3px solid var(--accent-cyan);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

#lineage-tree, #dynasty-list {
    background: rgba(14, 19, 24, 0.7);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 10px;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
}

/* Statistics Census Grid */
.census-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.census-stat {
    background: rgba(14, 19, 24, 0.7);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.col-span-2 {
    grid-column: span 2;
}

.census-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.census-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.chart-box {
    width: 100%;
    height: 260px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Community Modal — centered glass dialog */
.load-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: min(1100px, calc(100vw - 48px));
    max-height: min(760px, calc(100vh - 96px));
    background: var(--drawer-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 72px rgba(0,0,0,0.7), 0 0 1px rgba(255,255,255,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    text-align: left;
}

.load-panel.open {
    display: flex !important;
}

.load-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(14, 19, 24, 0.6);
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
}

.load-panel-title h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.load-panel-title h2 i {
    color: var(--accent-life);
    font-size: 14px;
}

.modal-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.community-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.community-body::-webkit-scrollbar {
    width: 6px;
}

.community-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
}

.community-lineage {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(14, 19, 24, 0.7);
    border: 1px solid var(--card-border);
    border-left: 2px solid var(--accent-life);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 0;
}

.community-lineage a {
    color: var(--accent-life);
    text-decoration: none;
    font-weight: 600;
}

.community-lineage a:hover {
    text-decoration: underline;
}

.community-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.community-link {
    display: grid;
    grid-template-columns: 22px 1fr;
    grid-template-rows: auto auto;
    gap: 2px 10px;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    text-decoration: none;
    transition: all 0.15s ease;
}

.community-link:hover {
    background: rgba(21, 222, 89, 0.12);
    border-color: rgba(21, 222, 89, 0.35);
    transform: translateY(-1px);
}

.community-link i {
    grid-row: 1 / span 2;
    font-size: 16px;
    color: var(--accent-life);
    text-align: center;
}

.community-link-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.community-link-blurb {
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text-muted);
}

.community-heading {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0 0 0;
}

.community-note {
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: -10px 0 0 0;
}

.similar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.similar-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(14, 19, 24, 0.75);
    border: 1px solid var(--card-border);
    text-decoration: none;
    transition: all 0.15s ease;
}

.similar-card:hover {
    background: rgba(21, 222, 89, 0.1);
    border-color: rgba(21, 222, 89, 0.3);
    transform: translateY(-1px);
}

.similar-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.similar-demo {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-life);
    background: rgba(21, 222, 89, 0.14);
    border: 1px solid rgba(21, 222, 89, 0.3);
    border-radius: var(--radius-full);
    padding: 1px 7px;
}

.similar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: var(--accent-life);
    opacity: 0.85;
}

/* Keeps the status text on one line so the badge can hold the opposite end,
   rather than the two competing for the same run of space. */
.similar-meta > .similar-meta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.similar-why {
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Headless Icon Overlay */
#headless-notification {
    position: fixed;
    top: 70px;
    left: 20px;
    z-index: 40;
    background: rgba(248, 35, 128, 0.2);
    border: 1px solid var(--accent-magenta);
    color: var(--accent-magenta);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    font-size: 14px;
    display: none;
    box-shadow: 0 0 16px rgba(248, 35, 128, 0.4);
}

/* Utilities */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.font-bold { font-weight: 700; }

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (Ultra-wide to Mobile)
   ========================================================================== */
@media (min-width: 1440px) {
    .control-panel {
        width: 660px;
    }
}

@media (max-width: 1024px) {
    }

@media (max-width: 768px) {
    .hotkey-hint {
        display: none !important;
    }

    .tab-label-full {
        display: none !important;
    }

    .tab-label-short {
        display: inline !important;
    }

    #top-hud {
        top: 8px;
        left: 8px;
        right: 8px;
        gap: 6px;
    }

    .hud-brand {
        padding: 4px 8px;
    }

    .wordmark {
        font-size: 11px;
    }

    .hud-telemetry .hud-pill:nth-child(2) {
        display: none;
    }

    .hud-right {
        gap: 5px;
    }

    .hud-btn span {
        display: none;
    }

    .hud-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    #floating-dock {
        bottom: 10px;
        padding: 4px 8px;
        gap: 4px;
    }

    .dock-speed {
        display: none;
    }

    .dock-brush {
        display: none;
    }

    .dock-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    /* Mobile Bottom Sheet */
    .control-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 85vh;
        border-radius: 24px 24px 0 0;
        border-bottom: none;
        border-left: none;
        border-right: none;
        animation: sheetSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sheet-handle {
        display: block;
        width: 44px;
        height: 5px;
        background: rgba(255, 255, 255, 0.28);
        border-radius: var(--radius-full);
        margin: 12px auto 6px auto;
    }

    .tabnav {
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
        padding: 6px 14px;
    }

    .tabnav-item {
        padding: 6px 10px;
        font-size: 12px;
    }

    .ui-input-num {
        min-height: 38px;
        min-width: 72px;
        font-size: 14px;
        padding: 6px 8px;
    }

    .form-row {
        padding: 9px 0;
    }

    .load-panel {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 40px);
    }

    .community-link-grid,
    .similar-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes sheetSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ---- Chronicle rows (dark theme) --------------------------------------- */
/* The chronicle is a log, so it reads as one continuous list rather than a stack
   of separate cards: no gap, no per-row outline, hairline separators between
   entries, and the coloured left border running unbroken down the whole column.
   Vertical padding is halved (8px -> 4px) and the inter-row margin removed, which
   roughly doubles how much history fits without the rows touching. */
.chron-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(14, 19, 24, 0.55);
    border-left: 3px solid var(--accent-cyan);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.chron-icon {
    flex: 0 0 auto;
    font-size: 11.5px;
    /* The icon and the tick number were sitting flush against each other. */
    margin-right: 7px;
}

.chron-tick {
    flex: 0 0 auto;
    min-width: 56px;
    text-align: right;
    margin-right: 8px;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.chron-row:first-child { border-top-right-radius: var(--radius-sm); }
.chron-row:last-child  { border-bottom-right-radius: var(--radius-sm); border-bottom: none; }
.chron-row:hover { background: rgba(21, 222, 89, 0.06); }

.chron-text { color: var(--text-primary); font-weight: 500; }

.chron-genesis    { border-left-color: #16a34a; } .chron-genesis    .chron-icon { color: #4ade80; }
.chron-first      { border-left-color: #d97706; } .chron-first      .chron-icon { color: #fbbf24; }
.chron-mind       { border-left-color: #2563eb; } .chron-mind       .chron-icon { color: #60a5fa; }
.chron-culture    { border-left-color: #7c3aed; } .chron-culture    .chron-icon { color: #a78bfa; }
.chron-boom       { border-left-color: #059669; } .chron-boom       .chron-icon { color: #34d399; }
.chron-famine     { border-left-color: #ea580c; } .chron-famine     .chron-icon { color: #fb923c; }
.chron-bottleneck { border-left-color: #ca8a04; } .chron-bottleneck .chron-icon { color: #facc15; }
.chron-dynasty    { border-left-color: #64748b; } .chron-dynasty    .chron-icon { color: #cbd5e1; }
.chron-record     { border-left-color: #0284c7; } .chron-record     .chron-icon { color: #38bdf8; }
.chron-apocalypse { border-left-color: #dc2626; background: rgba(127, 29, 29, 0.25); }
.chron-apocalypse .chron-icon { color: #f87171; }

.chronicle-empty { color: var(--text-dim); font-style: italic; font-size: 12.5px; }

.lin-row { padding: 3px 0; color: var(--text-secondary); white-space: nowrap; }
.lin-alive .lin-name { color: var(--accent-life); font-weight: 700; }
.lin-branch { color: var(--text-dim); margin-right: 4px; }
.lin-name { color: var(--text-primary); font-weight: 600; margin-right: 4px; }
.lin-gen { color: var(--text-dim); font-size: 11px; font-weight: 600; }

.dyn-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.dyn-row:last-child { border-bottom: none; }
.dyn-name { color: var(--text-primary); font-weight: 600; }
.dyn-stat { color: var(--text-dim); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }


/* ---- Hive shape readout & clamp notice --------------------------------- */
.shape-readout {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent-life);
    background: rgba(21, 222, 89, 0.08);
    border: 1px solid rgba(21, 222, 89, 0.2);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Shown only when the engine had to change what was asked for. Staying silent
   about a clamped value is how a user ends up believing N=1 was accepted. */
.hive-notice {
    display: none;
    font-size: 12px;
    color: #fde68a;
    background: rgba(217, 119, 6, 0.12);
    border-left: 3px solid #d97706;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 8px 11px;
    margin-bottom: 10px;
    line-height: 1.45;
}

.hive-notice.visible { display: block; }
