/* ═══════════════════════════════════════════════════════════
   Math Placement Test Prep — Design System
   Dark-dashboard aesthetic (MB / CA family)
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    /* backgrounds */
    --bg-primary:    #0b0f14;
    --bg-secondary:  #0f1720;
    --bg-tertiary:   #151e2b;
    --bg-surface:    #111a27;
    --bg-elevated:   #1a2535;
    --bg-card:       #111a27;
    --bg-hover:      #1e293b;

    /* accent */
    --accent:        #4cc9f0;
    --accent-dim:    rgba(76, 201, 240, 0.15);
    --accent-glow:   rgba(76, 201, 240, 0.25);
    --secondary:     #7c3aed;
    --secondary-dim: rgba(124, 58, 237, 0.15);

    /* status */
    --success:  #10b981;
    --warning:  #f59e0b;
    --danger:   #ef4444;
    --info:     #3b82f6;

    /* text */
    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    /* borders */
    --border:        #1e293b;
    --border-subtle: #2a3556;
    --border-accent: rgba(76, 201, 240, 0.3);

    /* typography */
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;

    /* sizing */
    --nav-height:      48px;
    --sidebar-width:   240px;
    --sidebar-collapsed: 52px;

    /* radius */
    --radius:    10px;
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;

    /* shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
    --shadow-md:  0 4px 12px rgba(0,0,0,.4);
    --shadow-lg:  0 8px 30px rgba(0,0,0,.5);
    --shadow-xl:  0 12px 48px rgba(0,0,0,.6);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   TOP NAVBAR
   ═══════════════════════════════════════════════════════════ */
.top-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* brand */
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand i { color: var(--accent); }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    margin-right: 4px;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

/* nav links */
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

/* dropdown */
.nav-dropdown { position: relative; }
.dropdown-trigger .dd-arrow { font-size: 0.55rem; margin-left: 2px; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 180px;
    padding: 4px 0;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
}
.nav-dropdown:hover .dropdown-menu,
.dropdown-menu.show { display: block; }
.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
}
.dropdown-menu a:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-menu a.active { color: var(--accent); }

/* version pill */
.version-pill {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    text-decoration: none;
}
.icon-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT: SIDEBAR + MAIN
   ═══════════════════════════════════════════════════════════ */
.app-body {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 12px 0;
    position: sticky;
    top: var(--nav-height);
    height: calc(100vh - var(--nav-height));
    transition: width 0.25s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .section-label,
.sidebar.collapsed .section-count,
.sidebar.collapsed .section-arrow,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-collapse-btn,
.sidebar.collapsed .section-links { display: none !important; }

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 8px 16px 6px;
    gap: 8px;
}
.sidebar-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    flex: 1;
}
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.sidebar-collapse-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
}

.sidebar-section { margin-bottom: 2px; }

.section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.94rem;
    cursor: pointer;
    text-align: left;
}
.section-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.section-toggle-icon { width: 18px; text-align: center; color: var(--accent); font-size: 0.88rem; }
.section-label { flex: 1; font-weight: 600; }
.section-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 1px 6px;
    border-radius: 8px;
}
.section-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.section-toggle[aria-expanded="true"] .section-arrow { transform: rotate(90deg); }

.section-links { padding: 2px 0 6px 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 16px 5px 42px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
}
.sidebar-link:hover { color: var(--accent); background: rgba(76,201,240,0.04); text-decoration: none; }
.sidebar-link.active { color: var(--accent); background: var(--accent-dim); }
.sidebar-link i { width: 16px; text-align: center; font-size: 0.82rem; }

/* Math in Action demo section */
.sidebar-demos { border-bottom: 1px solid rgba(245,158,11,.15); margin-bottom: 4px; padding-bottom: 4px; }
.sidebar-demo-link i { color: var(--warning); opacity: 0.7; }
.sidebar-demo-link:hover i { opacity: 1; }

/* Bottom sidebar links */
.sidebar-bottom-links {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 8px;
}
.sidebar-bottom-link {
    padding-left: 16px;
    font-weight: 500;
}
.sidebar-bottom-link i { color: var(--accent); opacity: 0.8; }
.sidebar-bottom-link:hover i { opacity: 1; }

.main-content {
    flex: 1;
    padding: 24px;
    min-width: 0;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV
   ═══════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
}
.mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border: none;
    background: none;
    cursor: pointer;
}
.mbn-item i { font-size: 1.1rem; }
.mbn-item.active { color: var(--accent); }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .nav-center { display: none; }
    .mobile-bottom-nav { display: flex; }
    .main-content { padding: 16px; padding-bottom: 72px; }
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: #38b6db; color: #fff; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
}
.login-card h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
}
.login-card h1 i { color: var(--accent); margin-right: 8px; }
.login-card .login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 28px;
}
.login-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   ERROR PAGES
   ═══════════════════════════════════════════════════════════ */
.error-page {
    text-align: center;
    padding: 80px 24px;
}
.error-page h1 { font-size: 4rem; font-weight: 800; color: var(--accent); margin-bottom: 12px; }
.error-page p { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 24px; }

/* ═══════════════════════════════════════════════════════════
   NAV TOOL BUTTONS (calc, notes)
   ═══════════════════════════════════════════════════════════ */
.nav-tool-btn {
    background: none; border: 1px solid transparent;
    color: var(--text-secondary); font-size: 1rem;
    padding: 5px 8px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all .15s;
}
.nav-tool-btn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.nav-tool-btn.active  { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   GRAPHING CALCULATOR — Floating Draggable Window
   ═══════════════════════════════════════════════════════════ */
.calc-window {
    display: none; position: fixed; z-index: 5000;
    top: 60px; left: calc(50% - 420px);
    width: 840px; max-width: 96vw;
    max-height: 92vh;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(0,0,0,.6), 0 0 0 1px rgba(76,201,240,.08);
    flex-direction: column; overflow: hidden;
    resize: both;
}
.calc-window.open { display: flex; }
.calc-window.minimized { max-height: none; height: auto !important; resize: none; }
.calc-window.minimized .calc-pane { display: none !important; }

/* Header / drag handle */
.calc-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-bottom: 1px solid var(--border);
    flex-shrink: 0; cursor: grab; user-select: none;
    background: var(--bg-tertiary);
}
.calc-header:active { cursor: grabbing; }
.calc-header h3 { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); margin: 0; white-space: nowrap; }

/* Tabs */
.calc-tabs { display: flex; gap: 2px; margin-left: 8px; flex: 1; }
.calc-tab {
    background: none; border: 1px solid transparent; color: var(--text-muted);
    font-size: 0.72rem; padding: 4px 10px; border-radius: var(--radius-sm);
    cursor: pointer; transition: .15s; white-space: nowrap;
}
.calc-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.calc-tab.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(76,201,240,.2); }

/* Theme swatches */
.calc-theme-swatches { display: flex; gap: 5px; align-items: center; margin-right: 4px; }
.calc-swatch {
    width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border);
    cursor: pointer; padding: 0; transition: border-color .15s, box-shadow .15s;
    background: #1a1f2b;
}
.calc-swatch:hover { border-color: var(--text-secondary); }
.calc-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.calc-swatch.swatch-grey { background: #3a3f4a; }
.calc-swatch.swatch-pink { background: #e8a0b4; }
.calc-swatch.swatch-blue { background: #5b9bd5; }

/* Header buttons */
.calc-header-btns { display: flex; gap: 4px; }
.calc-minimize, .calc-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 2px 5px;
    border-radius: 4px;
}
.calc-minimize:hover { color: var(--warning); background: rgba(245,158,11,.1); }
.calc-close:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── Calculator colour themes ── */
.calc-window.theme-grey {
    background: #2e3238; border-color: #4a4e56;
    box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(200,200,210,.08);
}
.calc-window.theme-grey .calc-header { background: #383c42; }
.calc-window.theme-grey .calc-screen { background: #24272c; }
.calc-window.theme-grey .ck { background: #3a3e44; border-color: #4e525a; }
.calc-window.theme-grey .ck:hover { background: #484c54; }
.calc-window.theme-grey .ck-num { background: #44484e; }
.calc-window.theme-grey .calc-fn-input,
.calc-window.theme-grey .calc-expr-input { color: #eee; }
.calc-window.theme-grey #calcCanvas { background: #1e2126; }

.calc-window.theme-pink {
    background: #2d1f24; border-color: #5a3040;
    box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(232,160,180,.12);
}
.calc-window.theme-pink .calc-header { background: #352530; }
.calc-window.theme-pink .calc-screen { background: #221a1e; }
.calc-window.theme-pink .ck { background: #3a2530; border-color: #5a3545; color: #f0d0dc; }
.calc-window.theme-pink .ck:hover { background: #4a3040; }
.calc-window.theme-pink .ck-num { background: #402a36; }
.calc-window.theme-pink .ck-op { color: #f0a0c0; }
.calc-window.theme-pink .ck-enter { background: linear-gradient(135deg, #d06090, #e080a0); }
.calc-window.theme-pink .calc-tab.active { color: #f0a0c0; background: rgba(240,160,192,.12); border-color: rgba(240,160,192,.2); }
.calc-window.theme-pink .calc-fn-input,
.calc-window.theme-pink .calc-expr-input { color: #f5dce5; }
.calc-window.theme-pink #calcCanvas { background: #1a1418; }
.calc-window.theme-pink .calc-history .ch-result { color: #f0a0c0; }
.calc-window.theme-pink .calc-tool-btn:hover { border-color: #e090b0; color: #f0a0c0; }

.calc-window.theme-blue {
    background: #1a2535; border-color: #2e4a6a;
    box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(91,155,213,.12);
}
.calc-window.theme-blue .calc-header { background: #1e2d42; }
.calc-window.theme-blue .calc-screen { background: #121c2a; }
.calc-window.theme-blue .ck { background: #1e3048; border-color: #2e4a6a; color: #c0d8f0; }
.calc-window.theme-blue .ck:hover { background: #284060; }
.calc-window.theme-blue .ck-num { background: #243850; }
.calc-window.theme-blue .ck-op { color: #70b0e0; }
.calc-window.theme-blue .ck-enter { background: linear-gradient(135deg, #3080c0, #5098d0); }
.calc-window.theme-blue .calc-tab.active { color: #70b8f0; background: rgba(91,155,213,.15); border-color: rgba(91,155,213,.25); }
.calc-window.theme-blue .calc-fn-input,
.calc-window.theme-blue .calc-expr-input { color: #d0e4f8; }
.calc-window.theme-blue #calcCanvas { background: #0e1820; }
.calc-window.theme-blue .calc-history .ch-result { color: #70b8f0; }
.calc-window.theme-blue .calc-tool-btn:hover { border-color: #5090d0; color: #70b8f0; }

/* ── Panes ── */
.calc-pane { display: none; flex-direction: column; overflow-y: auto; }
.calc-pane.active { display: flex; flex: 1; min-height: 0; }

/* ── CALCULATE PANE ── */
.calc-screen {
    background: #050a10; padding: 10px 14px; min-height: 100px;
    max-height: 200px; overflow-y: auto; font-family: var(--mono);
    border-bottom: 1px solid var(--border);
}
.calc-history { font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; }
.calc-history .ch-expr { color: var(--text-secondary); }
.calc-history .ch-result { color: var(--accent); font-weight: 600; text-align: right; }
.calc-history .ch-error { color: var(--danger); font-size: 0.78rem; }
.calc-input-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.calc-expr-input {
    flex: 1; background: transparent; border: none; border-bottom: 1px solid var(--border);
    color: var(--text-primary); font-family: var(--mono); font-size: 1rem;
    padding: 4px 0; outline: none;
}
.calc-expr-input:focus { border-bottom-color: var(--accent); }

/* ── Keypad ── */
.calc-keypad { padding: 6px 8px 8px; }
.calc-key-row {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
    margin-bottom: 4px;
}
.ck {
    padding: 8px 2px; border: 1px solid var(--border); border-radius: 5px;
    background: var(--bg-card); color: var(--text-primary);
    font-size: 0.82rem; font-weight: 600; cursor: pointer;
    transition: background .1s, border-color .1s;
    text-align: center; line-height: 1.1;
    font-family: var(--sans);
}
.ck:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.ck:active { background: var(--accent-dim); border-color: var(--accent); }
.ck-num { background: var(--bg-elevated); font-size: 0.95rem; }
.ck-op  { background: rgba(76,201,240,0.08); color: var(--accent); }
.ck-fn  { font-size: 0.74rem; color: var(--text-secondary); }
.ck-const { color: var(--warning); font-size: 0.85rem; font-weight: 700; }
.ck-enter {
    background: linear-gradient(135deg, var(--accent), #38b6db);
    color: #fff; border-color: var(--accent); font-weight: 700; font-size: 0.88rem;
}
.ck-enter:hover { background: linear-gradient(135deg, #38b6db, var(--accent)); }
.ck-2nd-active { color: var(--warning); border-color: var(--warning); background: rgba(245,158,11,.12); }
.calc-2nd-row .ck-fn { color: var(--warning); }

/* ── GRAPH PANE ── */
.calc-fn-list { display: flex; flex-direction: column; gap: 5px; padding: 8px 12px 4px; }
.calc-fn-row { display: flex; align-items: center; gap: 6px; }
.calc-fn-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.calc-fn-toggle { display: flex; align-items: center; flex-shrink: 0; }
.calc-fn-toggle input { accent-color: var(--accent); width: 14px; height: 14px; }
.calc-fn-check { display: none; }
.calc-fn-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; font-family: var(--mono); }
.calc-fn-input {
    flex: 1; padding: 4px 8px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 0.82rem; font-family: var(--mono); outline: none;
    min-width: 0;
}
.calc-fn-input:focus { border-color: var(--accent); }
.calc-fn-del { background: none; border: none; color: var(--text-muted); font-size: 1rem; cursor: pointer; }
.calc-fn-del:hover { color: var(--danger); }

/* Toolbar */
.calc-toolbar {
    display: flex; align-items: center; gap: 4px; padding: 4px 10px; flex-wrap: wrap;
    border-bottom: 1px solid var(--border); border-top: 1px solid var(--border);
}
.calc-tool-btn {
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); border-radius: var(--radius-sm);
    padding: 3px 7px; font-size: 0.72rem; cursor: pointer; transition: .15s;
    display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.calc-tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.calc-trace-lbl { gap: 3px; }
.calc-trace-lbl input { accent-color: var(--accent); width: 12px; height: 12px; }
.calc-coords {
    margin-left: auto; font-size: 0.72rem; color: var(--text-muted); font-family: var(--mono);
}

/* Graph canvas wrapper */
.calc-graph-wrap {
    position: relative; flex: 1; min-height: 280px;
}
#calcCanvas {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; display: block;
    background: #0a0f16; cursor: crosshair;
}
.calc-trace-dot {
    display: none; position: absolute; width: 10px; height: 10px;
    border-radius: 50%; background: var(--accent); border: 2px solid #fff;
    box-shadow: 0 0 6px var(--accent); transform: translate(-50%,-50%);
    pointer-events: none; z-index: 2;
}
.calc-trace-label {
    display: none; position: absolute; padding: 3px 8px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 4px; font-size: 0.72rem; color: var(--text-primary);
    font-family: var(--mono); pointer-events: none; z-index: 2; white-space: nowrap;
}

/* Window settings bar */
.calc-window-bar {
    display: flex; align-items: center; gap: 8px; padding: 5px 12px;
    border-top: 1px solid var(--border); flex-wrap: wrap;
}
.calc-window-bar label {
    font-size: 0.7rem; color: var(--text-muted); display: flex; align-items: center; gap: 3px;
}
.calc-window-bar input {
    width: 56px; padding: 2px 4px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 3px;
    color: var(--text-primary); font-size: 0.72rem; font-family: var(--mono);
    outline: none;
}
.calc-window-bar input:focus { border-color: var(--accent); }

/* ── TABLE PANE ── */
.calc-table-controls {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.calc-table-controls label {
    font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; gap: 3px;
}
.calc-table-controls input {
    width: 56px; padding: 2px 4px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 3px;
    color: var(--text-primary); font-size: 0.72rem; font-family: var(--mono); outline: none;
}
.calc-table-wrap {
    flex: 1; overflow: auto; max-height: 400px; padding: 0 4px 4px;
}
.calc-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem; font-family: var(--mono);
}
.calc-table th {
    background: var(--bg-tertiary); color: var(--text-secondary);
    padding: 4px 10px; border: 1px solid var(--border);
    position: sticky; top: 0; font-weight: 600; text-align: center;
}
.calc-table td {
    padding: 3px 10px; border: 1px solid var(--border);
    color: var(--text-primary); text-align: right;
}
.calc-table tbody tr:hover { background: rgba(76,201,240,.04); }

/* ═══════════════════════════════════════════════════════════
   NOTES PANEL (slide-out right)
   ═══════════════════════════════════════════════════════════ */
.notes-panel {
    position: fixed; top: var(--nav-height); right: 0; bottom: 0;
    width: 340px; max-width: 90vw;
    background: var(--bg-secondary); border-left: 1px solid var(--border);
    z-index: 4000; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,.3);
}
.notes-panel.open { transform: translateX(0); }
.notes-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-shrink:0;
}
.notes-header h3 { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin:0; }
.notes-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.notes-close:hover { color: var(--danger); }
.notes-toolbar {
    padding: 8px 12px; border-bottom: 1px solid var(--border);
    display: flex; gap: 6px; flex-wrap: wrap; flex-shrink:0;
}
.notes-tool-btn {
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); border-radius: 5px; padding: 4px 8px;
    font-size: 11px; cursor: pointer; transition: border-color .15s, color .15s;
}
.notes-tool-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.notes-tool-btn.mic-active { border-color: var(--danger); color: var(--danger); }
.notes-tool-btn:disabled { opacity: 0.6; cursor: wait; }
.notes-ai {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.notes-ai-label {
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--text-muted);
}
.notes-ai-input {
    width: 100%; min-height: 72px; resize: vertical;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 10px;
    color: var(--text-primary); font: 400 0.84rem/1.55 var(--sans); outline: none;
}
.notes-ai-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76,201,240,.08); }
.notes-ai-actions { display: flex; gap: 6px; align-items: center; }
.notes-ai-btn { color: var(--accent); border-color: var(--border-accent); }
.notes-ai-answer {
    padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid rgba(76,201,240,.16); background: rgba(76,201,240,.06);
    color: var(--text-secondary); font-size: 0.82rem; line-height: 1.65;
    white-space: pre-wrap;
}
.notes-ai-answer.is-loading {
    color: var(--text-muted); border-color: var(--border); background: var(--bg-card); font-style: italic;
}
.notes-ai-answer.is-error {
    color: #fecaca; border-color: rgba(239,68,68,.28); background: rgba(239,68,68,.10);
}
.notes-body { flex: 1; padding: 12px; overflow-y: auto; }
.notes-editor {
    min-height: 180px; outline: none; font-size: 0.85rem;
    color: var(--text-primary); line-height: 1.65; white-space: pre-wrap;
}
.notes-editor:empty::before {
    content: attr(data-placeholder); color: var(--text-muted); pointer-events: none;
}
.notes-footer {
    padding: 8px 12px; border-top: 1px solid var(--border);
    font-size: 11px; color: var(--text-muted); flex-shrink:0;
    display: flex; align-items: center; justify-content: space-between;
}

/* ═══════════════════════════════════════════════════════════
   INTERACTIVE TOOLS — Lesson Explorers
   ═══════════════════════════════════════════════════════════ */
.interactive-tool {
    margin: 36px 0;
    border: 1.5px solid rgba(245,158,11,0.3);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(245,158,11,0.03);
}
.tool-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px;
    background: rgba(245,158,11,0.08);
    border-bottom: 1px solid rgba(245,158,11,0.2);
    font-weight: 700; font-size: 0.92rem;
    color: #f59e0b;
    letter-spacing: 0.02em;
}
.tool-header i { font-size: 1.05rem; }
.tool-body { padding: 20px; }

/* Controls */
.tool-controls {
    display: flex; flex-direction: column; gap: 14px;
    margin-bottom: 18px;
}
.tool-control-row {
    display: flex; flex-direction: column; gap: 6px;
}
.tool-control-row label {
    font-size: 0.88rem; font-weight: 600; color: var(--text-secondary);
}
.tool-val {
    display: inline-block;
    font-weight: 800;
    color: var(--accent);
    min-width: 50px;
}
.tool-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px; outline: none;
    cursor: pointer;
}
.tool-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-main);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(76,201,240,0.4);
}
.tool-slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-main);
    cursor: pointer;
}
.tool-select {
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.88rem;
    cursor: pointer;
    outline: none;
    max-width: 260px;
}
.tool-select:focus { border-color: var(--accent); }

/* Output rows */
.tool-output {
    margin-bottom: 16px;
    padding: 14px 18px;
    background: rgba(76,201,240,0.04);
    border: 1px solid rgba(76,201,240,0.15);
    border-radius: 8px;
}
.tool-result-row {
    display: flex; align-items: baseline; gap: 8px;
    padding: 4px 0;
    flex-wrap: wrap;
}
.tool-result-label {
    font-size: 0.88rem; color: var(--text-muted); font-weight: 500;
}
.tool-result-value {
    font-size: 1.15rem; font-weight: 800; color: var(--accent);
    font-family: var(--mono);
}
.tool-result-unit {
    font-size: 0.82rem; color: var(--text-muted);
}

/* Gauge bar */
.tool-gauge { margin-top: 10px; }
.gauge-label-row {
    display: flex; justify-content: space-between;
    font-size: 0.72rem; color: var(--text-muted); margin-bottom: 4px;
}
.gauge-track {
    position: relative;
    height: 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 5px;
    overflow: visible;
}
.gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius: 5px;
    transition: width 0.15s;
}
.gauge-marker {
    position: absolute; top: -3px;
    width: 2px; height: 16px;
    background: #f59e0b;
    border-radius: 1px;
}
.gauge-pct {
    font-size: 0.78rem; color: var(--text-muted); margin-top: 4px;
    font-weight: 600;
}

/* Canvas */
.tool-canvas {
    width: 100%;
    height: auto;
    border-radius: 6px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.06);
}

@media (max-width: 600px) {
    .tool-body { padding: 14px; }
    .tool-result-value { font-size: 1rem; }
}
.notes-save-status.saved  { color: var(--success); }
.notes-save-status.saving { color: var(--warning); }

/* Annotations in notes */
.notes-annotations {
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    max-height: 240px; overflow-y: auto; flex-shrink:0;
}
.notes-annotations h4 {
    font-size: 0.78rem; color: var(--text-muted); margin: 0 0 8px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
}
.ann-list { display: flex; flex-direction: column; gap: 6px; }
.ann-item {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 10px;
    font-size: 0.78rem; cursor: pointer; transition: border-color .15s;
    position: relative;
}
.ann-item:hover { border-color: var(--warning); }
.ann-quote {
    color: var(--warning); font-style: italic; margin-bottom: 4px;
    border-left: 2px solid var(--warning); padding-left: 6px;
    max-height: 40px; overflow: hidden; text-overflow: ellipsis;
}
.ann-note-input {
    width: 100%; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 4px; padding: 4px 6px; color: var(--text-primary);
    font-size: 0.78rem; outline: none; margin-top: 4px;
}
.ann-note-input:focus { border-color: var(--accent); }
.ann-del {
    position: absolute; top: 4px; right: 6px;
    background: none; border: none; color: var(--text-muted);
    font-size: 0.9rem; cursor: pointer; line-height: 1;
}
.ann-del:hover { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   ANNOTATION HIGHLIGHT (in-content)
   ═══════════════════════════════════════════════════════════ */
mark._ann_hl {
    background: rgba(254,240,138,.45); border-bottom: 2px solid #eab308;
    cursor: pointer; padding: 0 1px; border-radius: 2px;
    transition: background .2s;
}
mark._ann_hl:hover { background: rgba(251,191,36,.65); }

/* Floating annotate fab */
._ann_fab {
    display: none; position: absolute; z-index: 9999;
    padding: 6px 14px; background: var(--warning); color: #000;
    border-radius: 6px; font: 700 13px/1 var(--sans);
    cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.35);
    user-select: none; align-items: center; gap: 6px;
    transition: opacity .12s; opacity: 0; pointer-events: none;
}
