@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    font-family: 'Montserrat', system-ui, sans-serif;
    user-select: none; -webkit-user-select: none; touch-action: none;
    -webkit-font-smoothing: antialiased;
}

/* ---- Base: dark everywhere. The 3D canvas IS the background. ---- */
body { background: #d8d4de; color: #c8c8d8; }

/* Theme overrides — Chill tab only, kept simple */
:root {
    --surface: rgba(255,255,255,0.05);
    --surface-hover: rgba(255,255,255,0.09);
    --border: rgba(255,255,255,0.08);
    --text-primary: rgba(220,220,235,0.9);
    --text-secondary: rgba(180,180,200,0.55);
    --text-dim: rgba(160,160,180,0.3);
    --accent: #6e8eff;
    --accent-dim: rgba(110,142,255,0.15);
    --danger: rgba(255,100,100,0.7);
    --warn: rgba(255,200,100,0.8);
}

/* ---- Canvas ---- */
#app { position: fixed; inset: 0; z-index: 0; }
#app canvas { display: block; width: 100vw !important; height: 100vh !important; }

/* ---- Quote (Chill tab) ---- */
#quote {
    position: fixed; z-index: 10; top: 36px; left: 50%;
    transform: translateX(-50%) translateY(6px);
    color: var(--text-secondary); font-size: 15px; font-weight: 400;
    font-style: italic; line-height: 1.7; text-align: center;
    max-width: 440px; padding: 12px 24px;
    border-left: 2px solid var(--accent); opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}
#quote.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Bottom sections ---- */
.section {
    position: fixed; z-index: 10; bottom: 24px; left: 50%;
    transform: translateX(-50%); text-align: center; pointer-events: auto;
}

.section-hint {
    color: rgba(40,35,55,0.4); font-size: 10px; font-weight: 500;
    letter-spacing: 1.2px; text-transform: uppercase;
    margin-bottom: 10px; font-family: 'JetBrains Mono', monospace;
}

.deform-controls { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ---- Buttons ---- */
.pill-btn {
    background: rgba(255,255,255,0.7); border: 1px solid rgba(0,0,0,0.1);
    color: rgba(30,25,45,0.65); padding: 7px 14px; border-radius: 6px;
    font-size: 10px; font-weight: 600; cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.6px; text-transform: uppercase;
    min-height: 32px; display: inline-flex; align-items: center; justify-content: center;
}
.pill-btn:hover { background: rgba(255,255,255,0.9); color: rgba(30,25,45,0.85); }
.pill-btn:active { transform: scale(0.97); transition-duration: 0.06s; }
.pill-btn-active {
    background: rgba(196,149,76,0.9);
    border-color: rgba(124,87,31,0.22);
    color: rgba(52,33,7,0.92);
}
.pill-btn-small {
    min-height: 28px;
    padding: 6px 10px;
    font-size: 9px;
}

/* ---- Navigation (right side) ---- */
#nav {
    position: fixed; z-index: 20; right: 14px; top: 50%;
    transform: translateY(-50%); display: flex; flex-direction: column;
    gap: 3px; padding: 5px;
    background: rgba(240,238,245,0.9); border: 1px solid rgba(0,0,0,0.08); border-radius: 10px;
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: none; border: 1px solid transparent;
    color: rgba(40,35,55,0.45); padding: 12px 16px; border-radius: 8px;
    cursor: pointer; transition: all 0.12s ease;
    font-family: 'Montserrat', sans-serif;
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; min-width: 68px;
}
.nav-btn svg { width: 22px; height: 22px; opacity: 0.5; transition: opacity 0.15s ease; }
.nav-btn.active {
    background: var(--accent); border-color: transparent;
    color: #fff;
}
.nav-btn.active svg { opacity: 1; }
.nav-btn:hover:not(.active) { background: rgba(0,0,0,0.05); color: rgba(30,25,45,0.7); }
.nav-btn:hover:not(.active) svg { opacity: 0.8; }

/* ---- Breathing overlay ---- */
.breath-overlay {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    z-index: 8; pointer-events: none;
}
.breathing-ring {
    width: 160px; height: 160px; border-radius: 50%;
    border: 1.5px solid rgba(110,142,255,0.15);
    display: flex; align-items: center; justify-content: center;
}
.breathing-circle {
    width: 50px; height: 50px; border-radius: 50%;
    background: rgba(110,142,255,0.25);
    transition: width 4s cubic-bezier(0.4,0,0.2,1), height 4s cubic-bezier(0.4,0,0.2,1);
}
.breathing-circle.inhale, .breathing-circle.hold { width: 130px; height: 130px; }
.breathing-circle.exhale { width: 50px; height: 50px; }
.breathing-label {
    color: var(--text-secondary); font-size: 16px; font-weight: 300;
    letter-spacing: 1px; min-height: 24px; text-transform: lowercase;
}

/* ---- Gesture tracking ---- */
.gesture-canvas {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    transform: scaleX(-1); z-index: 5; background: transparent;
    display: none; pointer-events: none;
}
.finger-dot {
    position: fixed; width: 14px; height: 14px; border-radius: 50%;
    background: rgba(255,255,255,0.7); pointer-events: none; z-index: 60;
    display: none; transform: translate(-50%,-50%);
    transition: left 0.04s linear, top 0.04s linear;
}
.finger-dot.thumb { background: rgba(110,142,255,0.8); }
.finger-dot.palm {
    width: 32px; height: 32px;
    background: rgba(110,142,255,0.08); border: 1.5px solid rgba(110,142,255,0.2);
}
.finger-dot.hand2 { background: rgba(255,180,80,0.7); }
.finger-conn {
    position: fixed; height: 1.5px; background: rgba(255,255,255,0.12);
    pointer-events: none; z-index: 59; display: none; transform-origin: 0 50%;
}
.gesture-label {
    position: fixed; top: 14px; left: 14px;
    font-size: 10px; font-weight: 500; letter-spacing: 1px;
    text-transform: uppercase; font-family: 'JetBrains Mono', monospace;
    color: rgba(40,35,55,0.6); background: rgba(240,238,245,0.9);
    border: 1px solid rgba(0,0,0,0.08); border-radius: 4px;
    padding: 5px 10px; z-index: 50; display: none;
}
.camera-preview {
    position: fixed; bottom: 16px; right: 16px;
    width: 240px; height: 180px; border-radius: 8px;
    border: 1px solid var(--border); transform: scaleX(-1);
    z-index: 55; background: rgba(0,0,0,0.5); display: none;
}

/* ---- Global gesture toggle ---- */
.gesture-global-btn {
    position: fixed; top: 14px; right: 14px; z-index: 25;
    font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.6px;
}

/* ---- Equation top bar (Maths tab) ---- */
.eq-top-bar {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    display: none; flex-direction: column; align-items: center; gap: 6px;
    z-index: 15; background: rgba(240,238,245,0.95); border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px; padding: 10px 18px;
    font-family: 'JetBrains Mono', monospace;
}
.eq-formula { font-size: 15px; color: #3b5ec9; letter-spacing: 0.3px; white-space: nowrap; }
.eq-inputs { display: flex; gap: 10px; align-items: center; }
.eq-inputs label {
    display: flex; align-items: center; gap: 3px;
    color: rgba(40,35,55,0.5); font-size: 11px;
}
.eq-inputs input {
    width: 52px; padding: 3px 5px;
    background: rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.1);
    border-radius: 3px; color: rgba(30,25,45,0.85);
    font-family: inherit; font-size: 11px; text-align: center;
}
.eq-inputs input:focus { outline: none; border-color: #3b5ec9; background: white; }

/* ---- Graph sidebar panel ---- */
.graph-panel {
    position: fixed; top: 50%; left: 14px; transform: translateY(-50%); width: 220px;
    max-height: 300px; overflow-y: auto; z-index: 15;
    background: rgba(240,238,245,0.95); border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px; padding: 10px;
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    color: rgba(30,25,45,0.85); display: none;
}
.gp-header {
    font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(40,35,55,0.4); margin-bottom: 6px; padding-bottom: 4px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.gp-eq {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 6px; border-radius: 4px; cursor: pointer;
    margin-bottom: 1px; transition: background 0.1s;
    border: 1px solid transparent;
}
.gp-eq:hover { background: rgba(0,0,0,0.04); }
.gp-eq-selected { background: rgba(59,94,201,0.1); border-color: rgba(59,94,201,0.2); }
.gp-eq-selected .gp-formula { font-weight: 500; color: rgba(30,25,45,0.9); }
.gp-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.gp-num { font-size: 9px; color: rgba(40,35,55,0.35); flex-shrink: 0; min-width: 14px; }
.gp-formula { flex: 1; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(30,25,45,0.7); }
.gp-rm {
    background: none; border: none; color: rgba(200,60,60,0.6);
    font-size: 13px; cursor: pointer; padding: 0 3px; line-height: 1;
}
.gp-rm:hover { color: rgba(200,60,60,0.9); }
.gp-actions { display: flex; gap: 3px; margin-top: 5px; }
.gp-btn {
    flex: 1; background: rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.08);
    color: rgba(40,35,55,0.55); padding: 4px 0; border-radius: 4px;
    font-family: inherit; font-size: 9px; cursor: pointer;
    transition: background 0.1s; text-transform: lowercase;
}
.gp-btn:hover { background: rgba(0,0,0,0.08); color: rgba(30,25,45,0.85); }
.gp-lock { flex: 1; }
.gp-locked { background: rgba(200,150,30,0.1); border-color: rgba(200,150,30,0.2); color: rgba(160,120,20,0.8); }
.gp-hint {
    margin-top: 8px; font-size: 9px; color: rgba(40,35,55,0.35);
    line-height: 1.4; text-align: center;
}

/* ---- Maths bottom hint ---- */
.strings-content { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; }
.strings-subtext {
    color: rgba(40,35,55,0.35); font-size: 9px; font-weight: 400;
    letter-spacing: 0.6px; font-family: 'JetBrains Mono', monospace;
}

/* ---- Gesture Guide ---- */
.gesture-guide {
    position: fixed; top: 52px; right: 80px; z-index: 30;
    background: rgba(240,238,245,0.95); border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px; padding: 12px 14px; width: 200px; overflow: hidden;
}
.gesture-guide-title {
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: rgba(40,35,55,0.7);
    text-align: center; margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.gesture-guide-grid { display: flex; flex-direction: column; gap: 3px; }
.gesture-item {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 6px; border-radius: 4px; background: rgba(0,0,0,0.04);
}
.gesture-emoji { font-size: 14px; min-width: 22px; text-align: center; flex-shrink: 0; }
.gesture-name { font-size: 10px; font-weight: 600; color: rgba(30,25,45,0.85); white-space: nowrap; }
.gesture-desc { font-size: 9px; color: rgba(40,35,55,0.5); margin-left: auto; white-space: nowrap; }
.gesture-guide-note {
    margin-top: 8px; font-size: 9px; color: rgba(40,35,55,0.45);
    text-align: center; line-height: 1.4; padding-top: 6px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

/* ---- "IT WILL BE OKAY" popup ---- */
.okay-popup {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%,-50%) scale(0.5);
    z-index: 100; font-size: 42px; font-weight: 700;
    letter-spacing: 2px; color: var(--text-primary);
    background: rgba(10,10,16,0.92); border: 1px solid var(--border);
    border-radius: 10px; padding: 32px 48px;
    text-align: center; opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
}
.okay-popup.visible { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* ---- Accessibility ---- */
::selection { background: var(--accent); color: white; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
    .breathing-circle { transition-duration: 0.5s !important; }
}
