/* ======================================================
   RS Platform — Premium Dual-Theme v3
   大厂级 · 双主题 · 全面对齐 · 大气布局
   ====================================================== */

/* ── Shared Design Tokens ─────────────── */
:root {
    --accent:     #0ea5e9;
    --accent-dim: rgba(14, 165, 233, 0.12);
    --accent-glow:rgba(14, 165, 233, 0.25);
    --accent-alt: #8b5cf6;
    --accent-alt-dim: rgba(139, 92, 246, 0.12);

    --danger:     #ef4444;
    --warning:    #f59e0b;
    --success:    #10b981;

    --radius-xs:  6px;
    --radius-sm:  8px;
    --radius:     12px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    --font-heading: 'Inter', 'SF Pro Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body:    'Inter', 'SF Pro Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    --ease:       cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.2s var(--ease);
    --transition-slow: 0.35s var(--ease);

    --nav-h:      56px;
    --page-px:    clamp(16px, 3vw, 40px);
    --content-max: 1400px;
}

/* ── Dark Theme (default) ─────────────── */
[data-theme="dark"], :root {
    --bg:         #09090b;
    --bg-elevated:#18181b;
    --bg-subtle:  #27272a;
    --panel:      rgba(24, 24, 27, 0.80);
    --panel-solid:#1c1c22;
    --card:       rgba(24, 24, 27, 0.70);
    --card-hover: rgba(39, 39, 42, 0.85);

    --text:       #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --border:     rgba(255, 255, 255, 0.08);
    --border-accent: rgba(14, 165, 233, 0.30);

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
    --shadow:     0 4px 24px rgba(0,0,0,0.5);
    --shadow-lg:  0 12px 48px rgba(0,0,0,0.6);

    --nav-bg:     rgba(9, 9, 11, 0.85);
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --code-bg:    #1e1e2e;
    --input-bg:   rgba(255,255,255,0.05);

    color-scheme: dark;
}

/* ── Light Theme ──────────────────────── */
[data-theme="light"] {
    --bg:         #f8fafc;
    --bg-elevated:#ffffff;
    --bg-subtle:  #f1f5f9;
    --panel:      rgba(255, 255, 255, 0.85);
    --panel-solid:#ffffff;
    --card:       rgba(255, 255, 255, 0.80);
    --card-hover: rgba(241, 245, 249, 0.95);

    --text:       #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border:     rgba(0, 0, 0, 0.08);
    --border-accent: rgba(14, 165, 233, 0.35);

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:     0 4px 24px rgba(0,0,0,0.08);
    --shadow-lg:  0 12px 48px rgba(0,0,0,0.12);

    --nav-bg:     rgba(255, 255, 255, 0.88);
    --overlay-bg: rgba(15, 23, 42, 0.4);
    --code-bg:    #f1f5f9;
    --input-bg:   rgba(0,0,0,0.03);

    --accent-dim: rgba(14, 165, 233, 0.08);
    --accent-glow:rgba(14, 165, 233, 0.15);
    --accent-alt-dim: rgba(139, 92, 246, 0.08);

    color-scheme: light;
}

/* ── Login Screen ────────────────────── */
.login-screen {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-bg {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-dim), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,0.08), transparent);
}
.login-card {
    position: relative; z-index: 1;
    width: 380px; max-width: 90vw;
    padding: 40px 36px 32px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo { margin-bottom: 16px; display: flex; justify-content: center; }
.login-title {
    font-family: var(--font-heading); font-size: 1.6rem; font-weight: 800;
    color: var(--text); margin: 0 0 4px;
}
.login-subtitle {
    font-size: 0.82rem; color: var(--text-muted); margin: 0 0 28px;
    font-family: var(--font-mono);
}
.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 16px; }
.login-form .form-label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}
.login-form .form-input {
    width: 100%; padding: 10px 14px;
    background: var(--input-bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: var(--font-body);
    outline: none; transition: border-color var(--transition);
    box-sizing: border-box;
}
.login-form .form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.login-error {
    background: rgba(239,68,68,0.1); color: var(--danger);
    font-size: 0.8rem; padding: 8px 12px; border-radius: var(--radius-xs);
    margin-bottom: 8px; text-align: center;
}
.login-footer {
    margin-top: 24px; font-size: 0.7rem; color: var(--text-muted);
    font-family: var(--font-mono);
}
[x-cloak] { display: none !important; }

/* ── Reset & Base ─────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Subtle dot grid */
body::before {
    content: '';
    position: fixed; inset: 0;
    background-image: radial-gradient(circle at 1px 1px, var(--border) 0.5px, transparent 0);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

/* ── Global Scrollbar ─────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
    opacity: 0.5;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }

/* ── Hide Number Spinners ─────────────── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ── Layout Shell ─────────────────────── */
.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Navigation ───────────────────── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 var(--page-px);
    height: var(--nav-h);
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
    margin-right: 8px;
}

.nav-brand .brand-icon {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: #fff;
    letter-spacing: 0.02em;
}

.nav-brand .brand-text {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.nav-brand .brand-tag {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-dim);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}

.nav-tabs {
    display: flex;
    gap: 1px;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.nav-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font-body);
}

.nav-tab svg, .nav-tab [data-lucide] { width: 15px; height: 15px; stroke-width: 1.8; }

.nav-tab:hover {
    color: var(--text);
    background: var(--input-bg);
}

.nav-tab.active {
    color: var(--accent);
    background: var(--accent-dim);
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.health-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239,68,68,0.5);
    transition: var(--transition);
}

.health-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16,185,129,0.5);
    animation: pulse-dot 2.5s ease infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 6px rgba(16,185,129,0.4); }
    50%      { box-shadow: 0 0 14px rgba(16,185,129,0.7); }
}

.nav-user {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── Theme Toggle Button ──────────────── */
.theme-toggle {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--border-accent);
}
.theme-toggle svg { width: 16px; height: 16px; }

/* ── Main Content ─────────────────────── */
.page-content {
    flex: 1;
    padding: 20px var(--page-px) 12px;
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
    min-height: calc(100vh - var(--nav-h));
}

/* Tab panels */
.tab-panel { display: none; animation: fadeUp 0.3s var(--ease); }
.tab-panel.active { display: block; }

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

/* ── Card System ─────────────────────── */
.glass {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.glass:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-accent);
}

.glass-static {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ── Typography ───────────────────────── */
h1 {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.15;
}
h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.25;
}
h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.4;
}
h4 {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 600;
}

.text-gradient {
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mono { font-family: var(--font-mono) !important; }
.text-muted { color: var(--text-secondary); }
.text-dim { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.subtitle { font-family: var(--font-body); }

/* ── Buttons ──────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-body);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    color: var(--text-secondary);
    background: var(--input-bg);
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(14,165,233,0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 16px rgba(14,165,233,0.35);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--input-bg);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--border-accent);
}

.btn-outline:hover {
    background: var(--accent-dim);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-danger {
    background: rgba(239,68,68,0.08);
    color: var(--danger);
    border-color: rgba(239,68,68,0.2);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.15);
    transform: translateY(-1px);
}

/* ── Form Controls ────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
    padding: 8px 12px;
    font-size: 0.82rem;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    outline: none;
    transition: var(--transition);
    line-height: 1.5;
    height: 36px;
    width: 100%;
    min-width: 0;
}

.form-textarea {
    height: auto;
    min-height: 80px;
    resize: vertical;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    cursor: pointer;
}

.form-select option { background: var(--panel-solid); color: var(--text); }

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-subtle);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 5px var(--accent-dim);
}

input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* ── Pills & Tags ─────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    font-family: var(--font-mono);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.pill-accent  { background: var(--accent-dim); color: var(--accent); }
.pill-ghost   { background: var(--input-bg); color: var(--text-secondary); border: 1px solid var(--border); }
.pill-success { background: rgba(16,185,129,0.1); color: var(--success); }
.pill-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.pill-danger  { background: rgba(239,68,68,0.1); color: var(--danger); }

/* ── Stat Badge ───────────────────────── */
.stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.stat-label {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 6px;
    font-weight: 500;
}

/* ── Grid Layouts ─────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; align-items: stretch; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: stretch; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: stretch; }

.split-panel {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    min-height: 600px;
    align-items: start;
}

.split-panel-wide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* ── Sidebar / Param Panel ────────────── */
.param-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-h) - 40px);
    position: sticky;
    top: calc(var(--nav-h) + 20px);
}

.param-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-section-title {
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ── Map Container ────────────────────── */
.map-container {
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 500px;
    position: relative;
}

.map-container .leaflet-container {
    height: 100%;
    width: 100%;
    background: var(--bg-elevated);
}

/* Leaflet overrides */
.leaflet-control-zoom a {
    background: var(--panel-solid) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}
.leaflet-control-attribution {
    background: var(--nav-bg) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

/* ── Upload Zone ──────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--input-bg);
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.upload-zone .upload-icon {
    width: 44px; height: 44px;
    margin: 0 auto 12px;
    color: var(--accent);
    opacity: 0.6;
}

/* ── Task Status Card ─────────────────── */
.task-card {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.task-card:hover {
    background: var(--card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.task-card .task-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-card .task-icon.pending  { background: rgba(245,158,11,0.1); color: var(--warning); }
.task-card .task-icon.running  { background: var(--accent-alt-dim); color: var(--accent-alt); }
.task-card .task-icon.done     { background: rgba(16,185,129,0.1); color: var(--success); }
.task-card .task-icon.fail     { background: rgba(239,68,68,0.1); color: var(--danger); }

.task-card .task-info { flex: 1; min-width: 0; }
.task-card .task-title { font-size: 0.84rem; font-weight: 600; font-family: var(--font-body); }
.task-card .task-meta  { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; font-family: var(--font-mono); }

/* ── Progress bar (gradient + pulse) ──── */
.progress-bar {
    height: 4px;
    background: var(--bg-subtle);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
    position: relative;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt), var(--accent));
    background-size: 200% 100%;
    animation: progress-gradient 3s linear infinite;
    transition: width 0.6s ease;
    position: relative;
}

.progress-bar .progress-fill::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 24px; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    border-radius: 2px;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-gradient {
    0%   { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

@keyframes progress-pulse {
    0%, 100% { opacity: 0; }
    50%      { opacity: 1; }
}

/* ── GEE Export Task Card ────────────── */
.gee-task-card {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    border: 1px solid var(--border);
    transition: var(--transition);
    overflow: hidden;
    margin-bottom: 6px;
}

.gee-task-card:last-child {
    margin-bottom: 0;
}

.gee-task-card:hover {
    background: var(--card-hover);
    box-shadow: var(--shadow-sm);
}

.gee-task-card .gee-task-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.gee-task-card .gee-task-title {
    font-size: 0.74rem;
    font-weight: 600;
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.gee-task-card .progress-bar {
    width: 100%;
    margin-top: 8px;
    height: 5px;
}

.gee-task-card .pill {
    flex-shrink: 0;
    font-size: 0.6rem;
    padding: 1px 8px;
}

.gee-task-card .gee-task-status-msg {
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gee-task-card .gee-task-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.gee-task-card .gee-task-dl-btn {
    font-size: 0.65rem;
    padding: 3px 10px;
}

.gee-task-card .gee-task-error {
    font-size: 0.65rem;
    color: var(--danger);
    margin-top: 4px;
    word-break: break-all;
    line-height: 1.3;
}

/* ── Feature Card (Home) ──────────────── */
.feature-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: default;
}

.feature-card .feature-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    color: var(--accent);
    flex-shrink: 0;
}

.feature-card .feature-icon svg { width: 22px; height: 22px; }

.feature-card h3 { font-size: 0.95rem; }
.feature-card p  { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.7; flex: 1; }

/* ── Result List ──────────────────────── */
.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    border-radius: 0;
    gap: 12px;
}

.result-item:last-child { border-bottom: none; }

.result-item:hover {
    background: var(--accent-dim);
}

/* ── Divider ──────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

/* ── Knowledge / Assistant Cards ──────── */
.knowledge-card {
    padding: 28px;
    position: relative;
    overflow: hidden;
}

/* Accent stripe */
.knowledge-card::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--accent), var(--accent-alt));
    border-radius: 0 2px 2px 0;
}

.knowledge-card h3 { margin-bottom: 14px; padding-left: 16px; }
.knowledge-card p { color: var(--text-secondary); line-height: 1.75; font-size: 0.88rem; padding-left: 16px; }

/* ═══════════════════════════════════════════
   Hero V2 — Home Page
   ═══════════════════════════════════════════ */
.hero-v2 {
    position: relative;
    text-align: center;
    padding: 72px 40px 56px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 32px;
    background: var(--card);
    border: 1px solid var(--border);
}

.hero-v2-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 80%, var(--accent-dim) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 20%, var(--accent-alt-dim) 0%, transparent 60%);
    pointer-events: none;
    animation: hero-bg-shift 12s ease-in-out infinite alternate;
}

@keyframes hero-bg-shift {
    0%   { opacity: 0.6; transform: scale(1); }
    100% { opacity: 1;   transform: scale(1.08); }
}

.hero-v2-content { position: relative; z-index: 1; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px 4px 8px;
    border-radius: 999px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.hero-v2 h1 {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.15;
    margin-bottom: 16px;
    color: var(--text);
}

.hero-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 580px;
    margin: 0 auto 28px;
    line-height: 1.8;
    font-family: var(--font-body);
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 28px;
}

.btn-lg {
    padding: 10px 24px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.hero-tech-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.tech-tag {
    display: inline-block;
    padding: 3px 12px;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-muted);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    letter-spacing: 0.02em;
}

/* ── Home Section Title ──────────────── */
.home-section-title {
    text-align: center;
    margin-bottom: 20px;
}
.home-section-title h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.home-section-title p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ── Feature Card V2 ─────────────────── */
.home-features { margin-bottom: 24px; }

.feature-card-v2 {
    position: relative;
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.feature-card-v2:hover {
    background: var(--card-hover);
    border-color: var(--border-accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow), 0 0 0 1px var(--border-accent);
}

.feature-num {
    position: absolute;
    top: 16px; right: 16px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.4;
    letter-spacing: 0.05em;
}

.feature-icon-v2 {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    color: var(--accent);
    flex-shrink: 0;
}

.feature-icon-v2 svg { width: 20px; height: 20px; }

.feature-card-v2 h3 { font-size: 0.92rem; font-weight: 600; }
.feature-card-v2 p  { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.7; flex: 1; }

.feature-link {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    opacity: 0;
    transform: translateX(-4px);
    transition: var(--transition);
}

.feature-card-v2:hover .feature-link {
    opacity: 1;
    transform: translateX(0);
}

/* ── Stats Bar ────────────────────────── */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 32px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.stats-bar-item {
    flex: 1;
    text-align: center;
    padding: 4px 12px;
}

.stats-bar-val {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.stats-bar-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.stats-bar-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
    flex-shrink: 0;
}

/* ── Homepage Features Grid ──────────── */
.hp-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}
.hp-features-grid.four {
    grid-template-columns: repeat(4, 1fr);
}

.feature-card-v2.featured {
    min-height: 220px;
}
.feature-card-v2.featured::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt));
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0;
    transition: opacity 0.3s;
}
.feature-card-v2.featured:hover::after { opacity: 1; }

.feature-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.feature-tags span {
    font-size: 0.62rem;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.hp-card-docs .feature-icon-v2 {
    background: var(--accent-alt-dim);
}
.hp-card-docs .feature-icon-v2 svg {
    color: var(--accent-alt);
}

/* ── Workflow Pipeline ────────────────── */
.hp-pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 28px 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow-x: auto;
}

.hp-pipe-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.hp-pipe-step:hover {
    background: var(--accent-dim);
}

.hp-pipe-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.hp-pipe-icon svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.hp-pipe-step:hover .hp-pipe-icon {
    border-color: var(--border-accent);
    background: var(--accent-dim);
}
.hp-pipe-step:hover .hp-pipe-icon svg {
    color: var(--accent);
}

.hp-pipe-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.hp-pipe-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

.hp-pipe-arrow {
    flex-shrink: 0;
    padding: 0 4px;
    color: var(--text-muted);
    opacity: 0.4;
}
.hp-pipe-arrow svg {
    width: 20px;
    height: 20px;
}

/* ── Architecture Diagram ────────────── */
.arch-diagram {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 28px 32px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.arch-layer {
    display: flex;
    align-items: center;
    gap: 16px;
}

.arch-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: 72px;
    flex-shrink: 0;
}

.arch-nodes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.arch-node {
    padding: 6px 14px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    font-weight: 500;
    border-radius: var(--radius-xs);
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.arch-node.accent {
    background: var(--accent-dim);
    border-color: var(--border-accent);
    color: var(--accent);
}

.arch-arrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    padding-left: 72px;
}
.arch-arrow-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.arch-arrow-text {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Homepage Footer ─────────────────── */
.hp-footer {
    padding: 28px 0 16px;
    text-align: center;
}
.hp-footer-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}
.hp-footer-sep {
    opacity: 0.3;
}

/* ── Dropzone (Indices upload) ────────── */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dropzone:hover {
    border-color: var(--border-accent);
    background: var(--accent-dim);
}
.dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* ── ECharts Container ────────────────── */
.chart-container {
    width: 100%;
    min-height: 320px;
    border-radius: var(--radius);
}

/* ── Section Spacing ──────────────────── */
.section-gap { display: flex; flex-direction: column; gap: 16px; }

/* ── Footer (hidden) ─────────────────── */
.app-footer { display: none; }

/* ═══════════════════════════════════════════
   Toast Notification System
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 360px;
    width: 100%;
}

.toast {
    pointer-events: all;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s var(--ease) forwards;
    position: relative;
    overflow: hidden;
}

.toast.toast-out {
    animation: toast-out 0.25s var(--ease) forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

.toast-icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-body { flex: 1; min-width: 0; }

.toast-title {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.toast-message {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.toast-close {
    width: 20px; height: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
    margin-top: 1px;
}

.toast-close:hover { color: var(--text); background: var(--input-bg); }
.toast-close svg { width: 14px; height: 14px; }

.toast-timer {
    position: absolute;
    bottom: 0; left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt));
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    animation: toast-timer-shrink var(--toast-duration, 4s) linear forwards;
}

@keyframes toast-timer-shrink {
    from { width: 100%; }
    to   { width: 0%; }
}

/* Toast variants */
.toast.toast-success { border-color: rgba(16,185,129,0.25); }
.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error   { border-color: rgba(239,68,68,0.25); }
.toast.toast-error .toast-icon   { color: var(--danger); }
.toast.toast-warning { border-color: rgba(245,158,11,0.25); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-info    { border-color: rgba(139,92,246,0.25); }
.toast.toast-info .toast-icon    { color: var(--accent-alt); }

/* ═══════════════════════════════════════════
   Interactive Modal System
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: modal-bg-in 0.2s ease forwards;
    padding: 24px;
}

.modal-overlay.modal-out {
    animation: modal-bg-out 0.18s ease forwards;
}

@keyframes modal-bg-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modal-bg-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.modal-dialog {
    width: 100%;
    max-width: 460px;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-in 0.25s var(--ease) forwards;
}

.modal-overlay.modal-out .modal-dialog {
    animation: modal-dialog-out 0.18s ease forwards;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modal-dialog-out {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.95) translateY(12px); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    width: 28px; height: 28px;
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
    background: var(--input-bg);
    border-color: var(--border);
}

.modal-close svg { width: 16px; height: 16px; }

.modal-body {
    padding: 20px 24px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px 18px;
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   Full-Screen Map + Floating Panel Layout
   ═══════════════════════════════════════════ */
.map-fullscreen {
    position: relative;
    width: calc(100% + var(--page-px) * 2);
    margin-left: calc(var(--page-px) * -1);
    margin-top: -20px;
    height: calc(100vh - var(--nav-h));
    overflow: hidden;
}

.map-fill {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.map-fill .leaflet-container {
    width: 100%; height: 100%;
    background: var(--bg-elevated);
}

/* ═══════════════════════════════════════════
   CA Tab (Grid Layout Rewrite)
   ═══════════════════════════════════════════ */
.ca-screen {
    width: calc(100% + var(--page-px) * 2);
    margin-left: calc(var(--page-px) * -1);
    margin-top: -20px;
    height: calc(100vh - var(--nav-h));
    overflow: hidden;
}

.ca-grid {
    height: 100%;
    display: grid;
    grid-template-columns: 340px 1fr 300px;
    gap: 14px;
    padding: 16px;
    background: linear-gradient(135deg, #0f172a, #1a2f4a);
}

/* Override floating-panel absolute positioning inside CA layout */
.ca-grid .floating-panel {
    position: relative;
    top: auto; left: auto; right: auto; bottom: auto;
    width: auto;
    min-width: 0;
    max-height: 100%;
}

.ca-canvas-wrap {
    position: relative;
    min-width: 0;
    min-height: 0;
}

.ca-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: radial-gradient(1200px 800px at 50% 30%, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.35));
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.ca-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 2;
}

.ca-gif-frame {
    width: min(1100px, 100%);
    height: min(760px, 100%);
    border-radius: 16px;
    overflow: hidden;
    background: #0a0f1e;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.60);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ca-gif-frame img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* History panel anchored inside canvas area */
.ca-history {
    position: absolute !important;
    top: 14px;
    right: 14px;
    width: 320px;
    max-width: min(42vw, 360px);
    max-height: calc(100% - 28px);
    z-index: 20;
}

.ca-panel { z-index: 10; }
.ca-stats { z-index: 10; }

@media (max-width: 1100px) {
    .ca-grid {
        grid-template-columns: 320px 1fr;
        grid-template-rows: 1fr;
    }
    .ca-stats {
        display: none;
    }
}

@media (max-width: 820px) {
    .ca-screen { height: auto; min-height: calc(100vh - var(--nav-h)); }
    .ca-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(55vh, 1fr) auto;
        padding: 12px;
    }
    .ca-history {
        position: fixed !important;
        right: 12px;
        left: 12px;
        top: calc(var(--nav-h) + 12px);
        width: auto;
        max-width: none;
        max-height: calc(100vh - var(--nav-h) - 24px);
    }
    .ca-stats { display: block; }
}

/* ── Floating Panel (glassmorphism) ───── */
.floating-panel {
    position: absolute;
    top: 16px; left: 16px;
    z-index: 10;
    width: clamp(320px, 27vw, 400px);
    min-width: 300px;
    max-height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.floating-panel:hover {
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-accent);
}

.floating-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.floating-panel-header:active { cursor: grabbing; }
.floating-panel-header h4 { font-size: 0.85rem; }

.floating-panel-body {
    padding: 14px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.two-col-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
}

/* ═══════════════════════════════════════════
   Section Inset (embedded card feel)
   ═══════════════════════════════════════════ */
.section-inset {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.chart-slot {
    padding: 16px;
}

/* ── Knowledge Content ────────────────── */
.knowledge-content {
    line-height: 1.8;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.knowledge-content p { margin-bottom: 0; }
.knowledge-content strong { color: var(--text); font-weight: 600; }

/* ── Stat Chip (overlay stats) ────────── */
.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 64px;
}
.stat-chip-val {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-chip-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}
.stat-chip.accent .stat-chip-val { color: var(--accent); }

/* ── Watermark (replaces footer) ──────── */
.watermark {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 50;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.4;
    pointer-events: none;
    letter-spacing: 0.03em;
}

/* ── Responsive ───────────────────────── */
@media (max-width: 1024px) {
    .split-panel, .split-panel-wide {
        grid-template-columns: 1fr;
    }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .param-panel { position: static; max-height: none; }
    .floating-panel { width: 280px; }
}

@media (max-width: 768px) {
    .top-nav { padding: 0 12px; }
    .page-content { padding: 12px 10px 32px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .nav-tabs { overflow-x: auto; gap: 0; }
    .nav-brand .brand-text { display: none; }
    .hero { padding: 36px 16px; }
    .hero h1 { font-size: 1.6rem; }
    .toast-container { right: 8px; left: 8px; max-width: none; }
    .floating-panel {
        position: relative;
        top: auto; left: auto; right: auto;
        width: 100%;
        max-height: none;
        margin-bottom: 8px;
    }
    .map-fullscreen {
        height: auto;
        min-height: 70vh;
        display: flex;
        flex-direction: column;
    }
    .map-fill { position: relative; min-height: 50vh; }
    .stat-chip { padding: 6px 8px; min-width: 50px; }
    .stat-chip-val { font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
}

/* ═══════════════ Voxel & CA Additional Styles ═══════════════ */

.param-section {
    margin-bottom: 12px;
}
.param-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.stat-card .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.stat-card .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}
.stat-card .stat-unit {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.ca-panel .upload-zone {
    text-align: center;
}

.pill-info {
    background: rgba(14, 165, 233, 0.12);
    color: #38bdf8;
}

.text-accent {
    color: var(--accent);
    font-weight: 600;
    font-family: var(--font-mono);
}

.upload-zone.active {
    border-color: var(--accent) !important;
    background: rgba(14, 165, 233, 0.04);
}

/* ═══════════════ Global Scrollbar ═══════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
[data-theme="light"] * { scrollbar-color: rgba(0,0,0,0.12) transparent; }

/* ═══════════════ Assistant Tab — Full Redesign ═══════════════ */

.assistant-tab .ast-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 0;
    height: calc(100vh - var(--nav-h) - 48px);
    overflow: hidden;
}
.assistant-tab .ast-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

/* ── Search Bar ── */
.ast-search-bar {
    flex-shrink: 0;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.ast-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 6px 4px 14px;
    transition: border-color var(--transition);
}
.ast-search-inner:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.ast-search-icon { color: var(--text-muted); flex-shrink: 0; display: flex; }
.ast-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.85rem;
    padding: 8px 4px;
    min-width: 0;
    font-family: var(--font-body);
}
.ast-search-input::placeholder { color: var(--text-muted); }
.ast-level-select {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.72rem;
    padding: 5px 24px 5px 8px;
    cursor: pointer;
    flex-shrink: 0;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}
.ast-gen-btn {
    flex-shrink: 0;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    padding: 7px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.ast-gen-btn:hover { filter: brightness(1.15); }
.ast-gen-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.ast-btn-loading { display: flex; align-items: center; gap: 6px; }
.ast-dot-pulse {
    width: 6px; height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: ast-pulse 1s ease-in-out infinite;
}
@keyframes ast-pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

.ast-quick-tags {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.ast-tag {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.68rem;
    padding: 3px 12px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.ast-tag:hover { border-color: var(--accent); color: var(--text); }
.ast-tag.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

/* ── Scroll Area ── */
.ast-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ── Loading State ── */
.ast-loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}
.ast-loading-card {
    text-align: center;
    padding: 48px 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    max-width: 380px;
    width: 100%;
}
.ast-loading-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, var(--accent-dim) 0%, transparent 60%);
    pointer-events: none;
}
.ast-loading-title {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.ast-loading-sub {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}
.ast-loading-steps {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 24px;
}
.ast-step {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.ast-step.active { color: var(--accent); }
.ast-step-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}
.ast-step.active .ast-step-dot {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
    animation: ast-pulse 1s ease-in-out infinite;
}

/* ── Result Flow ── */
.ast-result-flow {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Hero Card ── */
.ast-hero-card {
    position: relative;
    padding: 28px 28px 22px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.ast-hero-glow {
    position: absolute;
    top: -40px; left: -40px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
    pointer-events: none;
}
.ast-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
    position: relative;
}
.ast-hero-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    position: relative;
    letter-spacing: -0.02em;
}
.ast-hero-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    position: relative;
}

/* ── Section Cards ── */
.ast-section-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.ast-section-card:hover {
    border-color: rgba(255,255,255,0.12);
    box-shadow: var(--shadow-sm);
}
.ast-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.ast-card-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ast-icon-definition { background: rgba(59,130,246,0.12); color: #3b82f6; }
.ast-icon-explain    { background: rgba(168,85,247,0.12); color: #a855f7; }
.ast-icon-analogy    { background: rgba(34,197,94,0.12);  color: #22c55e; }
.ast-icon-viz        { background: rgba(249,115,22,0.12); color: #f97316; }
.ast-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}
.ast-card-subtitle {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin: 2px 0 0;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ast-card-body {
    padding: 18px 20px 20px;
    font-size: 0.84rem;
    line-height: 1.75;
    color: var(--text-secondary);
}
.ast-card-body p { margin-bottom: 10px; }
.ast-card-body p:last-child { margin-bottom: 0; }
.ast-card-body strong { color: var(--text); }
.ast-card-body em { color: var(--accent); font-style: italic; }

/* Card glass/glow effects (no border-left!) */
.ast-card-definition {
    background: linear-gradient(135deg, rgba(59,130,246,0.06) 0%, var(--bg-elevated) 60%);
    box-shadow: inset 0 1px 0 rgba(59,130,246,0.15), 0 0 20px rgba(59,130,246,0.04);
}
.ast-card-definition:hover { box-shadow: inset 0 1px 0 rgba(59,130,246,0.25), 0 0 30px rgba(59,130,246,0.08); }
.ast-card-explain {
    background: linear-gradient(135deg, rgba(168,85,247,0.06) 0%, var(--bg-elevated) 60%);
    box-shadow: inset 0 1px 0 rgba(168,85,247,0.15), 0 0 20px rgba(168,85,247,0.04);
}
.ast-card-explain:hover { box-shadow: inset 0 1px 0 rgba(168,85,247,0.25), 0 0 30px rgba(168,85,247,0.08); }
.ast-card-analogy {
    background: linear-gradient(135deg, rgba(34,197,94,0.06) 0%, var(--bg-elevated) 60%);
    box-shadow: inset 0 1px 0 rgba(34,197,94,0.15), 0 0 20px rgba(34,197,94,0.04);
}
.ast-card-analogy:hover { box-shadow: inset 0 1px 0 rgba(34,197,94,0.25), 0 0 30px rgba(34,197,94,0.08); }
.ast-card-viz {
    background: linear-gradient(135deg, rgba(249,115,22,0.06) 0%, var(--bg-elevated) 60%);
    box-shadow: inset 0 1px 0 rgba(249,115,22,0.15), 0 0 20px rgba(249,115,22,0.04);
}
.ast-card-viz:hover { box-shadow: inset 0 1px 0 rgba(249,115,22,0.25), 0 0 30px rgba(249,115,22,0.08); }

[data-theme="light"] .ast-card-definition { background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, var(--bg-elevated) 60%); }
[data-theme="light"] .ast-card-explain { background: linear-gradient(135deg, rgba(168,85,247,0.05) 0%, var(--bg-elevated) 60%); }
[data-theme="light"] .ast-card-analogy { background: linear-gradient(135deg, rgba(34,197,94,0.05) 0%, var(--bg-elevated) 60%); }
[data-theme="light"] .ast-card-viz { background: linear-gradient(135deg, rgba(249,115,22,0.05) 0%, var(--bg-elevated) 60%); }

/* ── Progress Bar ── */
.ast-progress-bar {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}
.ast-progress-track {
    height: 4px;
    background: var(--bg-subtle);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}
.ast-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 2px;
    transition: width 0.6s ease;
}
.ast-progress-labels {
    display: flex;
    justify-content: space-between;
}
.ast-progress-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.ast-progress-label.done { color: var(--success); }
.ast-progress-label.active { color: var(--accent); }

/* ── Viz Container ── */
.ast-viz-container {
    background: #0f172a;
    min-height: 520px;
}
.ast-viz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 48px 24px;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}
.ast-viz-loading-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 30%, rgba(249,115,22,0.08) 0%, transparent 60%);
    pointer-events: none;
}
.ast-sandbox-badge {
    margin-left: auto;
    background: rgba(249,115,22,0.1);
    color: #f97316;
    font-size: 0.58rem;
    font-weight: 600;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Markdown Rendering ── */
.ast-md-heading {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin: 18px 0 8px;
}
.ast-md-heading:first-child { margin-top: 0; }
.ast-md-code {
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    font-family: var(--font-mono);
    color: var(--accent);
}
/* Unordered list */
.ast-md-list {
    margin: 8px 0;
    padding-left: 20px;
    list-style: none;
}
.ast-md-list li {
    position: relative;
    padding-left: 14px;
    margin-bottom: 5px;
}
.ast-md-list li::before {
    content: '';
    position: absolute;
    left: 0; top: 9px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.6;
}
/* Ordered list */
.ast-md-ol {
    margin: 8px 0;
    padding-left: 6px;
    list-style: none;
    counter-reset: ast-ol;
}
.ast-md-ol li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 6px;
    counter-increment: ast-ol;
}
.ast-md-ol li::before {
    content: counter(ast-ol);
    position: absolute;
    left: 0; top: 1px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
}
/* Math / KaTeX */
.ast-card-body .katex-display {
    margin: 14px 0;
    overflow-x: auto;
}
.ast-card-body .katex {
    font-size: 0.95em;
}
.ast-hero-sub .katex { font-size: 0.9em; }
/* Blockquote */
.ast-md-blockquote {
    margin: 12px 0;
    padding: 10px 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-style: italic;
    border: 1px solid var(--border);
}

/* ── Empty State ── */
.ast-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}
.ast-empty-card {
    text-align: center;
    padding: 56px 40px;
    position: relative;
    max-width: 420px;
}
.ast-empty-glow {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 300px; height: 200px;
    background: radial-gradient(ellipse, var(--accent-dim) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0.5;
}
.ast-empty-icon {
    color: var(--text-muted);
    opacity: 0.2;
    margin-bottom: 20px;
    position: relative;
}
.ast-empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    position: relative;
}
.ast-empty-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    position: relative;
}
.ast-empty-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    position: relative;
}
.ast-feature-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* ── Sidebar ── */
.ast-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}
.ast-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ast-sidebar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}
.ast-clear-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-size: 0.62rem;
    padding: 3px 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.ast-clear-btn:hover { border-color: var(--danger); color: var(--danger); }
.ast-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}
.ast-history-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 0.72rem;
}
.ast-history-card {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-elevated);
}
.ast-history-card:hover {
    border-color: rgba(255,255,255,0.15);
    background: var(--card-hover);
}
.ast-history-card.active {
    border-color: var(--accent);
    background: rgba(14,165,233,0.05);
    box-shadow: 0 0 0 1px var(--accent-dim);
}
.ast-history-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}
.ast-history-level {
    font-size: 0.55rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ast-history-level.level-intro {
    background: rgba(14,165,233,0.12);
    color: var(--accent);
}
.ast-history-level.level-adv {
    background: rgba(168,85,247,0.12);
    color: #a855f7;
}
.ast-history-time {
    font-size: 0.58rem;
    color: var(--text-muted);
    opacity: 0.6;
    font-family: var(--font-mono);
}
.ast-history-topic {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}
.ast-history-title {
    font-size: 0.65rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Light theme overrides ── */
[data-theme="light"] .ast-section-card:hover {
    border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .ast-history-card:hover {
    border-color: rgba(0,0,0,0.15);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .assistant-tab .ast-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .assistant-tab .ast-main {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .ast-sidebar {
        max-height: 300px;
    }
}
