/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
}

.app-container {
    height: 100vh;
    overflow: hidden;
}

/* Dashboard layout */
.dashboard {
    display: flex;
    height: 100vh;
    outline: none;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: #16213e;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 40px;
}

.sidebar-toggle {
    background: #0f3460;
    border: none;
    color: #e0e0e0;
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
}

.sidebar-toggle:hover {
    background: #1a4a7a;
}

.sidebar-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar-header {
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 18px;
    color: #4cc9f0;
    margin-bottom: 8px;
}

.scenario-badge {
    background: #0f3460;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: #4cc9f0;
}

.help-btn {
    background: #0f3460;
    border: 1px solid #4cc9f0;
    color: #4cc9f0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    vertical-align: middle;
}

.help-btn:hover {
    background: #4cc9f0;
    color: #1a1a2e;
}

/* Tab bar */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: #1a1a2e;
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #7b8fb8;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.tab-btn:hover {
    background: #16213e;
    color: #e0e0e0;
}

.tab-btn.active {
    background: #0f3460;
    color: #4cc9f0;
}

/* Panels */
.panel {
    background: #1a2744;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.panel h3 {
    font-size: 14px;
    color: #7b8fb8;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-primary {
    background: #4cc9f0;
    color: #1a1a2e;
}

.btn-primary:hover {
    background: #3ab8df;
}

.btn-secondary {
    background: #0f3460;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #1a4a7a;
}

.btn-success {
    background: #06d6a0;
    color: #1a1a2e;
}

.btn-success:hover {
    background: #05c090;
}

.btn-danger {
    background: #ef233c;
    color: white;
}

.btn-danger:hover {
    background: #d91e36;
}

.btn-warning {
    background: #ffd166;
    color: #1a1a2e;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scenario controls */
.scenario-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.scenario-select {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
}

/* Grid size select */
.grid-select {
    width: 70px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
}

.server-action-row {
    margin-bottom: 12px;
}

.server-action-row .btn {
    width: 100%;
}

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(26, 26, 46, 0.3);
    border-top-color: #1a1a2e;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    background: rgba(239, 35, 60, 0.15);
    border: 1px solid #ef233c;
    color: #ef233c;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.info-message {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid #3b82f6;
    color: #93c5fd;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 12px;
}

.server-state-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.state-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-idle { background: #0f3460; color: #7b8fb8; }
.state-starting { background: rgba(255, 209, 102, 0.2); color: #ffd166; }
.state-connected { background: rgba(6, 214, 160, 0.2); color: #06d6a0; }
.state-error { background: rgba(239, 35, 60, 0.2); color: #ef233c; }

.server-info-text {
    font-size: 12px;
    color: #7b8fb8;
}

/* Server list */
.server-list {
    margin-top: 12px;
}

.server-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: #16213e;
    border-radius: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.server-metrics-row {
    display: flex;
    gap: 4px;
    width: 100%;
    padding-left: 20px;
    margin-top: 2px;
}

.server-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.server-name {
    flex: 1;
    font-size: 13px;
    cursor: pointer;
}

.server-coord {
    font-size: 11px;
    color: #7b8fb8;
}

.no-servers {
    color: #7b8fb8;
    font-size: 13px;
    font-style: italic;
}

.tab-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
    font-size: 12px;
}

.status-connected {
    color: #06d6a0;
}

.status-disconnected {
    color: #ef233c;
}

.play-panel-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* Survivor panel */
.survivor-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.survivor-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-dead {
    background: #ef233c;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}

.status-infected {
    background: #ffd166;
    color: #1a1a2e;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.health-bar {
    position: relative;
    height: 24px;
    background: #0f3460;
    border-radius: 4px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef233c, #06d6a0);
    transition: width 0.3s;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
}

.weapon-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #16213e;
    border-radius: 6px;
}

.weapon-type {
    font-weight: bold;
}

.ammo {
    color: #ffd166;
}

.control-hints {
    font-size: 12px;
    color: #7b8fb8;
}

.control-hints p {
    margin: 4px 0;
}

.hint {
    color: #7b8fb8;
    font-size: 12px;
    margin-top: 8px;
}

/* Player stats */
.player-stats {
    background: #16213e;
    border-radius: 6px;
    padding: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.stat-label {
    color: #7b8fb8;
    font-size: 12px;
}

.stat-value {
    font-weight: bold;
    font-size: 14px;
}

.stat-value.kills {
    color: #06d6a0;
}

.stat-value.deaths {
    color: #ef233c;
}

/* Kill feedback */
.kill-feedback-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.kill-score-popup {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ffd166;
    text-shadow: 0 0 10px rgba(255, 209, 102, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: score-float 1s ease-out forwards;
    pointer-events: none;
}

@keyframes score-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* Visualization panel */
.viz-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.control-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.color-mode {
    flex-wrap: wrap;
}

.renderer-3d-settings {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.renderer-3d-settings .control-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 6px;
}

.renderer-3d-settings .control-row label {
    font-size: 12px;
    color: #7b8fb8;
}

.renderer-3d-settings input[type="range"] {
    width: 100%;
}

/* === LOD Zones Multi-Thumb Range Bar === */
.lod-zones-bar {
    margin-top: 6px;
}

.lod-zones-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #7b8fb8;
    margin-bottom: 4px;
}

.lod-zones-values {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
    letter-spacing: -0.3px;
}

.lod-zones-radii {
    display: flex;
    gap: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
    color: #6b7a96;
    margin-bottom: 3px;
}

.lod-zones-track {
    position: relative;
    display: flex;
    height: 22px;
    border-radius: 4px;
    overflow: visible;
}

.lod-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.6);
    overflow: hidden;
    white-space: nowrap;
}

.lod-zone:first-child {
    border-radius: 4px 0 0 4px;
}

.lod-zone:last-of-type {
    border-radius: 0 4px 4px 0;
}

.lod-zone-0 { background: #06d6a0; }
.lod-zone-1 { background: #4895ef; }
.lod-zone-2 { background: #ff8800; }

/* Overlaid transparent range inputs — only thumbs visible */
.lod-thumb {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 26px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

/* Lower thumb above upper so it stays reachable when close */
.lod-thumb-lower { z-index: 3; }
.lod-thumb-upper { z-index: 2; }

.lod-thumb:focus {
    outline: none;
}

.lod-thumb::-webkit-slider-runnable-track {
    background: transparent;
    height: 26px;
}

.lod-thumb::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 26px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 3px;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.lod-thumb::-webkit-slider-thumb:hover {
    background: #e0e0e0;
    border-color: #111;
}

.lod-thumb::-moz-range-track {
    background: transparent;
    height: 26px;
}

.lod-thumb::-moz-range-thumb {
    width: 10px;
    height: 26px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 3px;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.lod-thumb::-moz-range-thumb:hover {
    background: #e0e0e0;
    border-color: #111;
}

/* ── Dual Range Bar (fog start/end) ─────────────────────────── */

.dual-range-bar {
    margin-bottom: 8px;
}

.dual-range-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 2px;
}

.dual-range-values {
    color: #8ecae6;
    font-variant-numeric: tabular-nums;
}

.dual-range-track {
    position: relative;
    height: 22px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: visible;
}

.dual-range-gradient {
    position: absolute;
    top: 0;
    bottom: 0;
    background: linear-gradient(to right, rgba(168, 216, 234, 0.1), rgba(168, 216, 234, 0.5));
    pointer-events: none;
}

.dual-range-solid {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    background: rgba(168, 216, 234, 0.5);
    border-radius: 0 4px 4px 0;
    pointer-events: none;
}

.dual-range-thumb {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 26px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.dual-range-lower { z-index: 3; }
.dual-range-upper { z-index: 2; }

.dual-range-thumb:focus { outline: none; }

.dual-range-thumb::-webkit-slider-runnable-track {
    background: transparent;
    height: 26px;
}

.dual-range-thumb::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 26px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 3px;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.dual-range-thumb::-webkit-slider-thumb:hover {
    background: #e0e0e0;
    border-color: #111;
}

.dual-range-thumb::-moz-range-track {
    background: transparent;
    height: 26px;
}

.dual-range-thumb::-moz-range-thumb {
    width: 10px;
    height: 26px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 3px;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.dual-range-thumb::-moz-range-thumb:hover {
    background: #e0e0e0;
    border-color: #111;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.zoom-controls .btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #7b8fb8;
}

.zoom-controls .btn:hover {
    border-color: #4cc9f0;
    color: #e0e0e0;
}

.zoom-value {
    min-width: 50px;
    text-align: center;
    font-size: 12px;
    color: #e0e0e0;
}

.zoom-divider {
    color: #0f3460;
}

/* TOD (Time of Day) controls */
.tod-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.tod-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

.tod-icon {
    font-size: 14px;
}

.tod-slider {
    margin-bottom: 8px;
}

.tod-slider input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #0f3460;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.tod-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4cc9f0;
    cursor: pointer;
}

.tod-slider input[type="range"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tod-speed-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tod-speed-buttons .btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #7b8fb8;
}

.tod-speed-buttons .btn:hover:not(:disabled) {
    border-color: #4cc9f0;
    color: #e0e0e0;
}

.tod-speed-buttons .btn.active {
    background: #4cc9f0;
    border-color: #4cc9f0;
    color: #0a1628;
}

/* Log panel */
.log-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.log-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #0f3460;
    word-break: break-all;
}

.log-empty {
    color: #7b8fb8;
    font-style: italic;
}

/* Canvas container */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.canvas-container canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Weapon HUD overlay */
.weapon-hud {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(22, 33, 62, 0.9);
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #0f3460;
}

.weapon-icon {
    font-size: 24px;
}

.weapon-name {
    font-weight: bold;
    font-size: 14px;
}

.weapon-ammo {
    background: #ffd166;
    color: #1a1a2e;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
}

.cooldown-bar {
    width: 60px;
    height: 6px;
    background: #0f3460;
    border-radius: 3px;
    overflow: hidden;
}

.cooldown-fill {
    height: 100%;
    background: #4cc9f0;
    animation: cooldown 1s linear;
}

@keyframes cooldown {
    from { width: 100%; }
    to { width: 0%; }
}

/* Dynamic HUD overlay */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.hud-overlay > div {
    position: absolute;
    pointer-events: auto;
}

.hud-top-left {
    top: 12px;
    left: 12px;
}

.hud-top-right {
    top: 12px;
    right: 12px;
}

.hud-bottom-left {
    bottom: 20px;
    left: 12px;
}

.hud-bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.hud-bottom-right {
    bottom: 20px;
    right: 12px;
}

.hud-widget {
    background: rgba(22, 33, 62, 0.9);
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    margin-bottom: 6px;
    font-size: 13px;
}

.hud-widget-label {
    color: #7b8fb8;
    font-size: 11px;
    margin-right: 6px;
}

.hud-widget-value {
    font-weight: bold;
    color: #e0e0e0;
}

/* Hotbar inventory HUD */
.hud-hotbar {
    padding: 4px 6px;
}

.inventory-hud {
    display: flex;
    gap: 4px;
}

.inventory-slot {
    width: 48px;
    height: 48px;
    background: rgba(10, 20, 40, 0.85);
    border: 2px solid #334;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    color: #ccc;
    transition: border-color 0.15s;
}

.inventory-slot:hover {
    border-color: #4cc9f0;
}

.inventory-slot.selected {
    border-color: #f0c040;
    background: rgba(240, 192, 64, 0.15);
}

.inventory-slot .item-name {
    font-size: 10px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44px;
    text-align: center;
}

.inventory-slot .item-count {
    font-size: 12px;
    font-weight: bold;
    color: #e0e0e0;
}

/* Health bar */
.health-bar {
    position: relative;
    width: 120px;
    height: 18px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    transition: width 0.3s;
    border-radius: 3px;
}

.health-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* Canvas context menu */
.canvas-context-menu {
    position: fixed;
    z-index: 1000;
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.context-menu-item:hover {
    background: #16213e;
    color: #4cc9f0;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #ef233c;
    color: white;
    padding: 12px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* Loading */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #0f3460;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #4cc9f0;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: #4cc9f0;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1a4a7a;
}

/* === Server Panels === */
.entity-count-badge {
    background: #0f3460;
    color: #4cc9f0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.grid-miniview {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.grid-miniview-grid {
    display: grid;
    gap: 4px;
    max-width: 200px;
}

.grid-slot {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 10px;
    border: 2px solid transparent;
}

.grid-slot.connected {
    background: rgba(6, 214, 160, 0.15);
}

.grid-slot.disconnected {
    background: rgba(100, 100, 100, 0.15);
    border: 2px dashed #333;
    color: #555;
}

.btn-zoom {
    background: transparent;
    color: #4cc9f0;
    border: 1px solid #0f3460;
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
}

.btn-zoom:hover {
    background: #0f3460;
}

/* === Server Metrics === */
.metric-badge {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    white-space: nowrap;
}

.fps-badge {
    background: #06d6a0;
    color: #1a1a2e;
}

.latency-badge {
    background: #ffd166;
    color: #1a1a2e;
}

.memory-badge {
    background: #4cc9f0;
    color: #1a1a2e;
}

.server-metrics-detail {
    background: #111a30;
    padding: 8px 12px;
    border-radius: 0 0 6px 6px;
    margin-top: -4px;
    margin-bottom: 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 12px;
    color: #7b8fb8;
}

/* === Connection Status === */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-connected {
    background: #06d6a0;
}

.dot-reconnecting {
    background: #ffd166;
    animation: pulse 1s ease-in-out infinite;
}

.dot-disconnected {
    background: #ef233c;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === Log Panel Filters === */
.log-filters {
    margin-bottom: 8px;
}

.log-search {
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 12px;
    margin-bottom: 6px;
}

.log-search::placeholder {
    color: #7b8fb8;
}

.log-filter-buttons {
    display: flex;
    gap: 4px;
}

.log-time {
    color: #7b8fb8;
    margin-right: 4px;
}

.log-category {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.log-cat-server { background: rgba(76, 201, 240, 0.2); color: #4cc9f0; }
.log-cat-entity { background: rgba(6, 214, 160, 0.2); color: #06d6a0; }
.log-cat-system { background: rgba(123, 143, 184, 0.2); color: #7b8fb8; }

/* === Help Overlay === */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.help-content {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.help-header h2 {
    color: #4cc9f0;
    font-size: 18px;
}

.help-section {
    margin-bottom: 16px;
}

.help-section h3 {
    color: #7b8fb8;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #0f3460;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.shortcut-row kbd {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: #4cc9f0;
    min-width: 28px;
    text-align: center;
}

.shortcut-row span {
    color: #e0e0e0;
}

/* === Canvas Overlay (shared) === */
.canvas-overlay {
    position: absolute;
    background: rgba(22, 33, 62, 0.85);
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 12px;
    z-index: 50;
    color: #e0e0e0;
}

.canvas-overlay h3 {
    font-size: 13px;
    color: #7b8fb8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Grid Minimap Overlay === */
.grid-minimap-overlay {
    bottom: 20px;
    left: 20px;
}

.grid-minimap-overlay .grid-miniview-grid {
    max-width: none;
}

.grid-minimap-overlay .grid-slot {
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: transform 0.15s;
}

.grid-minimap-overlay .grid-slot:hover {
    transform: scale(1.1);
}

/* === VP Settings (sidebar) === */
.vp-settings {
    border-bottom: 1px solid #0f3460;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.vp-settings input[type="range"] {
    width: 100%;
    accent-color: #4cc9f0;
}

/* === Entity Legend === */
.entity-type-list {
    margin-bottom: 12px;
}

.entity-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.entity-type-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* === Voxel Rendering Section === */
.voxel-viz-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.voxel-viz-section h4 {
    font-size: 13px;
    color: #4cc9f0;
    margin-bottom: 8px;
}

/* === No Connection Hint === */
.no-connection-hint {
    color: #7b8fb8;
    font-size: 13px;
    font-style: italic;
    padding: 8px 0;
}

/* === Sidebar Header === */
.sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sidebar-title-row h2 {
    margin-bottom: 0;
}

/* === Status Bar World Indicator === */
.current-world {
    color: #4cc9f0;
    font-size: 11px;
    background: rgba(76, 201, 240, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* === Worlds Panel === */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-header h3 {
    margin-bottom: 0;
}

.world-save-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(76, 201, 240, 0.08);
    border: 1px solid rgba(76, 201, 240, 0.25);
    border-radius: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.current-world-label {
    flex: 1;
    font-size: 13px;
    color: #7b8fb8;
    min-width: 0;
}

.current-world-label strong {
    color: #4cc9f0;
}

.save-message {
    font-size: 12px;
}

.text-ok { color: #06d6a0; }
.text-error { color: #ef233c; }
.text-muted { color: #4a5570; }

/* Create form */
.create-world-form {
    background: #111a30;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #0f3460;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-row label {
    width: 58px;
    font-size: 12px;
    color: #7b8fb8;
    flex-shrink: 0;
}

.form-input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 13px;
    min-width: 0;
}

.form-input:focus {
    outline: none;
    border-color: #4cc9f0;
}

/* === 2-column worlds layout === */
.worlds-layout {
    display: flex;
    gap: 24px;
    height: 100%;
}

.worlds-left-col {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

.worlds-right-col {
    width: 420px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #0d1525;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 16px;
}

.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #556680;
    text-align: center;
    gap: 12px;
}

.detail-placeholder-icon {
    font-size: 48px;
    opacity: 0.4;
}

.detail-placeholder p {
    font-size: 13px;
    max-width: 240px;
    line-height: 1.5;
}

/* === Search / Filter bar === */
.worlds-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.worlds-search-input {
    flex: 1;
    background: #0a1020;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.2s;
}

.worlds-search-input::placeholder {
    color: #556680;
}

.worlds-search-input:focus {
    border-color: #4cc9f0;
}

.worlds-filter-select {
    background: #0a1020;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    color: #e0e0e0;
    cursor: pointer;
    min-width: 130px;
}

/* === Card grid === */
.world-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.world-card {
    background: #111a30;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #0f3460;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.world-card:hover {
    border-color: #1a4a7a;
    background: #131e36;
}

.world-card.selected {
    border-color: #4cc9f0;
    background: rgba(76, 201, 240, 0.06);
}

.world-card.active-world {
    border-color: rgba(76, 201, 240, 0.35);
    background: rgba(76, 201, 240, 0.04);
}

.world-card.deleting {
    border-color: rgba(239, 35, 60, 0.4);
    background: rgba(239, 35, 60, 0.04);
}

.world-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.world-card-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 4px;
}

.running-worlds-section {
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(76, 201, 240, 0.05);
    border: 1px solid rgba(76, 201, 240, 0.15);
    border-radius: 6px;
}

.running-worlds-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #8899aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.running-world-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.running-world-item.active {
    background: rgba(76, 201, 240, 0.1);
}

.running-world-item + .running-world-item {
    margin-top: 4px;
}

.running-world-info {
    flex: 1;
    color: #aabbcc;
}

.active-badge {
    font-size: 0.7rem;
    color: #4cc9f0;
    font-weight: 600;
}

.world-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
}

.world-name {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
}

.world-meta {
    font-size: 11px;
    color: #7b8fb8;
}

.world-saved {
    font-size: 11px;
    color: #7b8fb8;
}

.world-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 35, 60, 0.4);
    color: #ef233c;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger-outline:hover {
    background: rgba(239, 35, 60, 0.12);
}

.btn-danger-outline:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* States */
.empty-state {
    color: #7b8fb8;
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 24px 16px;
    line-height: 1.6;
}

.loading-indicator {
    color: #7b8fb8;
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

/* === Script UI === */

.script-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(76, 201, 240, 0.12);
    color: #4cc9f0;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 6px;
}

.terrain-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 6px;
}

.running-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
    vertical-align: middle;
    margin-left: 6px;
}

.running-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ecc71;
}

.worlds-sort-select {
    background: #0a1020;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    color: #e0e0e0;
    cursor: pointer;
    min-width: 130px;
}

.world-meta-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    padding: 8px 0;
    font-size: 12px;
}

.meta-label {
    color: #7b8fb8;
    font-weight: 500;
}

.meta-value {
    color: #e0e0e0;
}

.world-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.world-info-clickable {
    cursor: pointer;
}

.world-info-clickable:hover .world-name {
    color: #4cc9f0;
}

/* Detail view */
.detail-back-row {
    margin-bottom: 8px;
}

.btn-back {
    background: transparent;
    border: none;
    color: #7b8fb8;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 0;
    transition: color 0.2s;
}

.btn-back:hover {
    color: #4cc9f0;
}

.detail-header {
    margin-bottom: 12px;
}

.detail-header .world-name {
    font-size: 16px;
    font-weight: 700;
    color: #e0e0e0;
    display: block;
    margin-bottom: 2px;
}

.detail-meta {
    font-size: 12px;
    color: #7b8fb8;
}

/* Script summary card */
.script-summary {
    background: #111a30;
    border: 1px solid rgba(76, 201, 240, 0.2);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.script-summary-row {
    font-size: 12px;
    color: #c0c8dc;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.script-summary-name {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 13px;
}

.summary-label {
    color: #7b8fb8;
    flex-shrink: 0;
}

.script-summary-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Source badges */
.source-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.source-ai {
    background: rgba(179, 136, 255, 0.15);
    color: #b388ff;
}

.source-imported {
    background: rgba(255, 209, 102, 0.15);
    color: #ffd166;
}

.source-manual {
    background: rgba(123, 143, 184, 0.15);
    color: #7b8fb8;
}

/* Tab bar */
.script-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.script-tab-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #7b8fb8;
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.script-tab-btn:hover {
    border-color: #1a4a7a;
    color: #c0c8dc;
}

.script-tab-btn.active {
    background: rgba(76, 201, 240, 0.1);
    border-color: rgba(76, 201, 240, 0.35);
    color: #4cc9f0;
}

/* AI generation form */
.ai-generation-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-model-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-model-label {
    font-size: 12px;
    color: #aaa;
    white-space: nowrap;
}

.ai-model-select {
    flex: 1;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #2a2a3a;
    color: #e0e0e0;
    font-size: 12px;
}

.ai-prompt-textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    min-height: 60px;
    box-sizing: border-box;
}

.ai-prompt-textarea:focus {
    outline: none;
    border-color: #b388ff;
}

.ai-prompt-hint {
    font-size: 11px;
    color: #4a5570;
}

.btn-ai {
    background: rgba(179, 136, 255, 0.15);
    border: 1px solid rgba(179, 136, 255, 0.35);
    color: #b388ff;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-start;
}

.btn-ai:hover:not(:disabled) {
    background: rgba(179, 136, 255, 0.25);
}

.btn-ai:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Generating spinner */
.generating-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #b388ff;
    padding: 8px 0;
}

.spinner-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b388ff;
    animation: pulse-dot 1.2s infinite ease-in-out;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Script preview card */
.script-preview {
    background: rgba(179, 136, 255, 0.04);
    border: 1px solid rgba(179, 136, 255, 0.3);
    border-radius: 6px;
    padding: 10px 12px;
}

.script-preview-title {
    font-size: 11px;
    font-weight: 700;
    color: #b388ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.script-preview-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Script tab */
.script-tab-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.script-textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 12px;
    font-family: 'Cascadia Code', 'Fira Code', 'SF Mono', monospace;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
    tab-size: 2;
}

.script-textarea:focus {
    outline: none;
    border-color: #4cc9f0;
}

.script-actions {
    display: flex;
    gap: 6px;
}

/* Validation */
.validation-errors {
    background: rgba(239, 35, 60, 0.06);
    border: 1px solid rgba(239, 35, 60, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: #ef233c;
}

.validation-errors div {
    margin-bottom: 2px;
}

.validation-errors div:last-child {
    margin-bottom: 0;
}

/* Detail bottom action bar */
.detail-actions {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #0f3460;
}

.detail-actions .btn {
    width: 100%;
    padding: 8px 16px;
    font-size: 14px;
}

/* Continent Grid Panel */
.continent-grid-panel {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #0f3460;
}

.continent-grid-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.continent-grid-title {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.continent-grid {
    display: grid;
    gap: 4px;
}

.continent-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    border: 1px solid transparent;
    min-height: 40px;
}

.continent-cell:hover {
    border-color: #4cc9f0;
}

.cell-coord {
    font-size: 10px;
    color: #94a3b8;
    font-family: monospace;
}

.cell-status {
    font-size: 10px;
    font-weight: 600;
}

.cell-running {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.cell-running .cell-status { color: #22c55e; }

.cell-starting {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.cell-starting .cell-status { color: #3b82f6; }

.cell-idle {
    background: rgba(234, 179, 8, 0.15);
    border-color: rgba(234, 179, 8, 0.3);
}

.cell-idle .cell-status { color: #eab308; }

.cell-saving {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
}

.cell-saving .cell-status { color: #a855f7; }

.cell-stopping {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.cell-stopping .cell-status { color: #ef4444; }

.cell-dormant {
    background: rgba(100, 116, 139, 0.1);
    border-color: rgba(100, 116, 139, 0.2);
}

.cell-dormant .cell-status { color: #64748b; }

.continent-grid-empty {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    padding: 8px;
}

/* === Worlds Page (Lobby) === */
.worlds-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 32px;
    overflow: hidden;
}

.worlds-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.worlds-page-header h1 {
    font-size: 22px;
    color: #4cc9f0;
}

.worlds-page-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.worlds-page-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* === Sidebar Lobby Link === */
.lobby-link {
    margin-bottom: 12px;
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid #7b8fb8;
    color: #7b8fb8;
    text-decoration: none;
    display: inline-block;
}

.btn-outline-secondary:hover {
    background: rgba(123, 143, 184, 0.15);
    color: #e0e0e0;
    border-color: #e0e0e0;
}

/* === AI Chat Panel === */

.ai-chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
}

.chat-msg-user {
    background: #0f3460;
    align-self: flex-end;
    max-width: 85%;
}

.chat-msg-ai {
    background: #1a2744;
    border: 1px solid #0f3460;
}

.chat-msg-system {
    text-align: center;
    color: #7b8fb8;
    font-size: 12px;
}

.chat-msg-error {
    text-align: center;
}

.chat-msg-error-text {
    color: #ff6b6b;
    font-size: 12px;
}

.chat-msg-system-text {
    color: #7b8fb8;
}

.chat-msg-label {
    font-size: 11px;
    color: #4cc9f0;
    margin-bottom: 2px;
    font-weight: 600;
}

.chat-msg-text {
    word-break: break-word;
}

.chat-msg-meta {
    font-size: 11px;
    color: #7b8fb8;
    margin-top: 4px;
}

.chat-msg-applied {
    color: #06d6a0;
    font-weight: 600;
}

.structure-preview-container {
    width: 100%;
    height: 160px;
    margin: 8px 0;
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a2e;
}

.chat-msg-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: #1a2744;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 8px 12px;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
}

.chat-input:focus {
    border-color: #4cc9f0;
}

.chat-input:disabled {
    opacity: 0.5;
}

/* === Structure Library === */

.structure-library {
    border-bottom: 1px solid #0f3460;
    padding: 8px 0;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

.structure-library-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 12px;
}

.structure-library-name {
    flex: 1;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.structure-library-meta {
    color: #7b8fb8;
    font-size: 11px;
    flex-shrink: 0;
}

.structure-library-loading,
.structure-library-empty {
    text-align: center;
    color: #7b8fb8;
    font-size: 12px;
    padding: 8px;
}

.structure-library-toggle {
    flex-shrink: 0;
    font-size: 11px !important;
    padding: 4px 8px !important;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
