/* ============================================================
   GLOBAL THEME — Dark Mode
   ============================================================ */
:root {
    --bg: #0d0d0f;
    --bg-alt: #16161a;
    --text: #e6e6e6;
    --text-dim: #a0a0a0;
    --accent: #4da3ff;
    --accent-soft: #1f4f7a;
    --border: #2a2a2d;
    --code-bg: #1a1a1d;
    --radius: 6px;
}

/* ============================================================
   BASE ELEMENTS
   ============================================================ */
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    overflow: hidden;
}

h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-content {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

section {
    max-width: 900px;
    margin: 2.5rem auto;
    padding: 0 1rem;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    background: var(--bg-alt);
    padding: 1.2rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 0 40px rgba(77,163,255,0.05);
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
}

header h2 {
    margin-top: 0.3rem;
    font-weight: 400;
    font-size: 1.05rem;
    color: var(--text-dim);
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px rgba(0,0,0,0.25);
}

.panel h3 {
    margin-top: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.button-row {
    margin-top: 1rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.button-secondary {
    background: #444;
    color: #fff;
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s ease;
}

.button-secondary:hover {
    background: #666;
}

.button-secondary.active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* ============================================================
   SPHERE VISUALIZATION
   ============================================================ */
#sphere-container {
    position: relative;
    width: 100%;
    height: 420px;
    background: radial-gradient(
        circle at center,
        rgba(77,163,255,0.18) 0%,
        rgba(13,13,15,1) 70%
    );
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

#sphere-canvas {
    width: 100%;
    height: 100%;
}

/* ============================================================
   LOSS CHART
   ============================================================ */
canvas {
    background: #111;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ============================================================
   TIMELINE
   ============================================================ */
#timeline {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.timeline-entry {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.timeline-entry.expansion { color: #4da3ff; }
.timeline-entry.normalization { color: #8affc1; }
.timeline-entry.frame { color: #ffdd66; }
.timeline-entry.stability { color: #ff9f4d; }
.timeline-entry.error { color: #ff4d4d; }

/* ============================================================
   DIAGNOSTICS
   ============================================================ */
.diag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1rem;
}

.diag-item {
    background: var(--code-bg);
    padding: 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: "Consolas", "Fira Code", monospace;
    font-size: 0.85rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    text-align: center;
    padding: 1.2rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
    font-size: 0.95rem;
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--accent-soft);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-alt);
}