:root {
    --bg: #0a0e1a;
    --bg-2: #10162a;
    --bg-3: #161d38;
    --card: #131a2e;
    --border: #232c4a;
    --text: #e8ecf5;
    --muted: #97a0bd;
    --dim: #6a7494;
    --fire: #ff8a3d;
    --fire-2: #ffb347;
    --portal: #4ad9d9;
    --portal-2: #7c9bff;
    --accent: linear-gradient(135deg, #ff8a3d, #ffb347 50%, #4ad9d9);
    --radius: 14px;
    --shadow: 0 10px 40px rgba(0,0,0,.45);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed; inset: 0;
    background:
        radial-gradient(circle at 15% 10%, rgba(255,138,61,.10), transparent 40%),
        radial-gradient(circle at 85% 90%, rgba(74,217,217,.08), transparent 45%);
    pointer-events: none;
    z-index: 0;
}

/* ===== Topbar ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(10,14,26,.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    z-index: 100;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; white-space: nowrap; }
.brand-logo {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); display: grid; place-items: center;
    font-size: 18px; box-shadow: 0 0 20px rgba(255,138,61,.5);
    animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
    0%,100% { box-shadow: 0 0 20px rgba(255,138,61,.4); }
    50%     { box-shadow: 0 0 32px rgba(255,138,61,.8); }
}
.brand-text small {
    display: block; font-size: 10px; font-weight: 400;
    color: var(--dim); letter-spacing: 1px; text-transform: uppercase;
}
.stats { display: flex; gap: 20px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; }
.stat-label { color: var(--dim); text-transform: uppercase; letter-spacing: .6px; font-size: 10px; }
.stat-value { font-weight: 800; font-size: 16px; color: var(--fire-2); font-variant-numeric: tabular-nums; }

.menu-toggle {
    display: none;
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--bg-3); border: 1px solid var(--border);
    color: var(--text); font-size: 20px; cursor: pointer;
}

/* ===== Layout ===== */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    max-width: 1280px;
    margin: 0 auto;
    padding-top: 64px;
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    position: sticky; top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
    padding: 20px 14px 40px;
    border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.nav-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
    color: var(--dim); padding: 0 12px 10px; font-weight: 600;
}
.nav-list { list-style: none; }
.nav-list a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 10px;
    color: var(--muted); text-decoration: none;
    font-size: 14px; transition: all .18s;
    border-left: 2px solid transparent; cursor: pointer;
}
.nav-list a:hover { background: var(--bg-3); color: var(--text); }
.nav-list a.active {
    background: linear-gradient(90deg, rgba(255,138,61,.15), transparent);
    color: var(--fire-2); border-left-color: var(--fire);
}
.nav-list a.locked { opacity: .45; cursor: not-allowed; }
.nav-num {
    font-size: 11px; font-weight: 700; color: var(--dim);
    min-width: 18px; font-variant-numeric: tabular-nums;
}

/* ===== Main ===== */
main { padding: 32px 32px 100px; min-width: 0; }
.view { animation: fadeUp .35s ease; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Hero ===== */
.hero {
    padding: 40px 32px;
    border-radius: 20px;
    background:
        radial-gradient(ellipse at top left, rgba(255,138,61,.18), transparent 55%),
        radial-gradient(ellipse at bottom right, rgba(74,217,217,.15), transparent 55%),
        var(--bg-2);
    border: 1px solid var(--border);
    margin-bottom: 32px;
}
.hero.small { padding: 28px 24px; margin-bottom: 24px; }
.hero-badge {
    display: inline-block; padding: 6px 14px; border-radius: 999px;
    background: rgba(255,138,61,.15); border: 1px solid rgba(255,138,61,.35);
    color: var(--fire-2); font-size: 12px; font-weight: 600;
    letter-spacing: .5px; margin-bottom: 16px; text-transform: uppercase;
}
.hero h1 {
    font-size: clamp(24px, 4vw, 38px); font-weight: 800;
    letter-spacing: -.5px; margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, #ffb347 60%, #4ad9d9 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); max-width: 720px; margin-bottom: 8px; }
.hero .muted { color: var(--dim); font-size: 14px; }

/* ===== Typography ===== */
.block-title { font-size: 20px; font-weight: 700; margin: 24px 0 12px; }
.page-title { font-size: clamp(22px, 3vw, 30px); font-weight: 800; margin-bottom: 12px; letter-spacing: -.3px; }
.muted { color: var(--muted); }

/* ===== Stats cards ===== */
.grid-3 {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px; margin: 16px 0 24px;
}
.stat-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--accent); opacity: .7;
}
.stat-num { font-size: 28px; font-weight: 800; color: var(--fire-2); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--bg-3);
    color: var(--text); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all .18s; font-family: inherit;
}
.btn:hover { background: var(--border); transform: translateY(-1px); }
.btn.primary {
    background: var(--accent); color: #0a0e1a; border: none;
    box-shadow: 0 6px 20px rgba(255,138,61,.35);
}
.btn.primary:hover { box-shadow: 0 8px 28px rgba(255,138,61,.55); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { color: var(--text); background: var(--bg-3); }
.btn.mic.rec { background: #ff5722; color: #fff; border-color: #ff5722; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .7; } }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

/* ===== Tasks ===== */
.tasks { display: grid; gap: 12px; }
.task-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    cursor: pointer; transition: all .2s;
}
.task-card:hover { border-color: rgba(255,138,61,.5); transform: translateY(-2px); }
.task-card h3 { font-size: 16px; margin-bottom: 6px; }
.task-card p { color: var(--muted); font-size: 14px; }

/* ===== Entries ===== */
.entries { display: grid; gap: 10px; }
.entry-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px;
    cursor: pointer; transition: all .2s;
}
.entry-card:hover { border-color: rgba(255,138,61,.4); }
.entry-meta {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    font-size: 12px; margin-bottom: 8px; color: var(--muted);
}
.pill {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .4px;
    text-transform: uppercase; background: rgba(255,138,61,.15); color: var(--fire-2);
}
.pill.done { background: rgba(74,217,217,.18); color: var(--portal); }
.entry-text { color: var(--muted); font-size: 14px; line-height: 1.55; }

/* ===== Write ===== */
.write-toolbar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    margin-bottom: 12px;
}
.timer, .counter {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 14px; color: var(--muted);
    background: var(--bg-3); padding: 6px 12px; border-radius: 8px;
    border: 1px solid var(--border);
}
.textarea {
    width: 100%; padding: 16px;
    background: var(--bg-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-family: inherit; font-size: 15px; line-height: 1.65;
    resize: vertical; outline: none; transition: border-color .2s;
}
.textarea:focus { border-color: rgba(255,138,61,.6); }
.row { margin: 16px 0; }
.label { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
input[type="range"] { flex: 1; max-width: 240px; accent-color: var(--fire); }

/* ===== Prompt ===== */
.prompt-box {
    background: #05080f; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12.5px; line-height: 1.6; color: #c8d3e8;
    white-space: pre-wrap; word-break: break-word;
    max-height: 400px; overflow-y: auto; margin: 8px 0 24px;
}

/* ===== Result ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0 24px; }
.col h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .8px; color: var(--fire-2); margin-bottom: 10px; }
.text-box {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    font-size: 14px; line-height: 1.65; max-height: 480px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-word; color: var(--muted);
}

.portal-banner {
    padding: 16px 20px; border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(255,138,61,.18), rgba(74,217,217,.18));
    border: 1px solid rgba(255,138,61,.5);
    color: var(--fire-2); font-weight: 700; margin-bottom: 20px;
    animation: portalPulse 2s ease-in-out infinite;
}
@keyframes portalPulse {
    0%,100% { box-shadow: 0 0 20px rgba(255,138,61,.3); }
    50%     { box-shadow: 0 0 40px rgba(255,138,61,.6); }
}

.scores { display: grid; gap: 8px; margin: 12px 0 24px; }
.score-row {
    display: grid; grid-template-columns: 120px 1fr 30px;
    gap: 12px; align-items: center; font-size: 13px; color: var(--muted);
    text-transform: capitalize;
}
.score-bar { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.score-bar > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .6s ease; }

.recs { display: grid; gap: 10px; margin: 12px 0 24px; }
.rec-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px;
}
.rec-skill { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--portal); font-weight: 700; margin-bottom: 6px; }
.rec-advice { font-size: 14px; margin-bottom: 6px; }
.rec-exercise { font-size: 13px; color: var(--muted); font-style: italic; }

/* ===== Overlay ===== */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity .3s;
    z-index: 95;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .menu-toggle { display: grid; place-items: center; }
    .stats { display: none; }
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: 0; left: 0;
        height: 100vh; width: min(320px, 85vw);
        background: var(--bg-2); border-right: 1px solid var(--border);
        transform: translateX(-100%); transition: transform .3s ease;
        z-index: 100; padding-top: 80px;
        box-shadow: 10px 0 40px rgba(0,0,0,.5);
    }
    .sidebar.open { transform: translateX(0); }
    main { padding: 20px 16px 80px; }
    .hero { padding: 28px 20px; }
    .two-col { grid-template-columns: 1fr; }
}

.btn.mic-stop {
    background: #ff5722;
    color: #fff;
    border-color: #ff5722;
    box-shadow: 0 6px 20px rgba(255,87,34,.35);
}
.btn.mic-stop:hover {
    background: #e64a19;
    border-color: #e64a19;
}
#micStatus {
    color: var(--fire-2);
    animation: micPulse 1.6s ease-in-out infinite;
}
@keyframes micPulse {
    0%,100% { opacity: .6; }
    50%     { opacity: 1; }
}
