
        *,
        *::before,
        *::after {
            box-sizing: border-box;
        }
        :root {
            --bg: #020617;
            --bg2: #0b1120;
            --panel: #0f172a;
            --panel2: #111827;
            --line: #334155;
            --text: #f8fafc;
            --muted: #94a3b8;
            --accent: #8b5cf6;
            --accent2: #22d3ee;
            --cyan: #22d3ee;
            --amber: #f59e0b;
            --green: #22c55e;
            --red: #f43f5e;
            --orange: #fb923c;
        }
        html {
            scroll-behavior: smooth;
        }
        body {
            margin: 0;
            min-height: 100vh;
            font-family: 'Inter', Arial, sans-serif;
            color: var(--text);
            background: radial-gradient(circle at 20% 10%, #1a1040 0%, #0b1120 40%, #020617 85%);
            background-attachment: fixed;
        }
        .wrap {
            max-width: 1040px;
            margin: 0 auto;
            padding: 20px 16px 60px;
        }
        .hero,
        .panel {
            background: linear-gradient(145deg, rgba(15, 23, 42, 0.97), rgba(2, 6, 23, 0.95));
            border: 1px solid var(--line);
            border-radius: 20px;
            padding: 22px 24px;
            box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
            margin-bottom: 18px;
        }
        .hero {
            border-color: #3a6b8a;
            box-shadow: 0 18px 55px rgba(10, 5, 30, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
        }
        .tag {
            display: inline-flex;
            padding: 4px 10px;
            border-radius: 999px;
            background: #0f2a3a;
            border: 1px solid #3a8ab0;
            color: #b8e2f5;
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.3px;
            text-transform: uppercase;
        }
        h1 {
            font-size: clamp(1.8rem, 4.2vw, 2.8rem);
            margin: 10px 0 6px;
            color: #fff;
            font-weight: 800;
            letter-spacing: -0.5px;
        }
        h2 {
            font-size: 1.2rem;
            margin: 18px 0 10px;
            font-weight: 700;
        }
        .sub {
            color: var(--muted);
            line-height: 1.6;
            font-size: 0.95rem;
        }
        .chips {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            margin: 14px 0 6px;
        }
        .chip {
            font-size: 0.7rem;
            padding: 4px 10px;
            background: #0f1a2e;
            border: 1px solid #2a3a55;
            border-radius: 999px;
            color: #cbd5e1;
        }
        .controls {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin: 14px 0 8px;
        }
        .btn {
            border: 1px solid #475569;
            background: #0f172a;
            color: #f1f5f9;
            border-radius: 10px;
            padding: 10px 16px;
            font-weight: 700;
            font-size: 0.85rem;
            cursor: pointer;
            transition: 0.15s;
            font-family: inherit;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }
        .btn:hover,
        .btn:focus-visible {
            border-color: var(--accent);
            outline: none;
            transform: translateY(-1px);
            box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
        }
        .btn.active,
        .btn[aria-pressed="true"] {
            background: linear-gradient(135deg, #7c3aed, #0891b2);
            border-color: var(--accent);
            color: #fff;
            box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
        }
        .btn.secondary {
            background: #0b1424;
            color: #cbd5e1;
        }
        .btn.primary {
            background: linear-gradient(135deg, #7c3aed, #06b6d4);
            color: #fff;
            border-color: #8b5cf6;
            font-weight: 800;
        }
        .btn:disabled {
            opacity: 0.4;
            pointer-events: none;
        }
        .choice-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
        }
        .choice-card {
            padding: 16px 18px;
            border: 1px solid #2a3a55;
            border-radius: 14px;
            background: #0b1424;
            cursor: pointer;
            transition: 0.16s;
        }
        .choice-card:hover {
            border-color: var(--accent);
        }
        .choice-card.active {
            border-color: var(--accent);
            box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
            background: #16132e;
        }
        .choice-card b {
            display: block;
            margin-bottom: 4px;
            font-size: 1rem;
        }
        .choice-card .sub {
            font-size: 0.85rem;
        }
        .setting-row {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
            padding-top: 10px;
        }
        .setting-row .label {
            font-size: 0.78rem;
            color: #94a3b8;
            font-weight: 700;
            min-width: 80px;
        }
        .hidden {
            display: none !important;
        }
        .notice {
            font-size: 0.8rem;
            color: #94a3b8;
            padding: 10px 14px;
            border: 1px dashed #334155;
            border-radius: 10px;
            background: rgba(2, 6, 23, 0.5);
            margin-top: 12px;
            line-height: 1.5;
        }
        .mode-note {
            margin-top: 12px;
            padding: 10px 14px;
            border-radius: 10px;
            background: #12102a;
            border-left: 4px solid var(--accent);
            color: #e2e8f0;
            font-size: 0.82rem;
            line-height: 1.6;
        }
        .qhead {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
        }
        .qmeta {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-wrap: wrap;
        }
        .mode-badge {
            display: inline-flex;
            padding: 4px 10px;
            border-radius: 999px;
            font-size: 0.7rem;
            font-weight: 800;
            border: 1px solid #475569;
            background: #0f172a;
            color: #e2e8f0;
            text-transform: uppercase;
        }
        .mode-badge.practice {
            background: #0f2a3a;
            border-color: #3a8ab0;
            color: #b8e2f5;
        }
        .mode-badge.exam {
            background: #083344;
            border-color: var(--cyan);
            color: #cffafe;
        }
        .progress {
            height: 6px;
            background: #0b1424;
            border-radius: 99px;
            overflow: hidden;
            margin: 12px 0 18px;
        }
        .bar {
            height: 100%;
            width: 0;
            background: linear-gradient(90deg, #3a8ab0, #22d3ee, #a855f7);
            transition: 0.3s;
        }
        .question {
            font-size: 1.05rem;
            line-height: 1.6;
            margin: 8px 0 14px;
            word-wrap: break-word;
        }
        .arena-fig {
            max-width: 100%;
            height: auto;
            display: block;
            margin: 12px auto;
            border-radius: 12px;
            border: 1px solid #2a3a55;
            background: #07101f;
            padding: 8px;
        }
        .arena-fig .axis {
            stroke: #cbd5e1;
            stroke-width: 2;
        }
        .arena-fig .grid {
            stroke: #2a3a55;
            stroke-width: 1;
            stroke-dasharray: 3 4;
        }
        .arena-fig .label {
            font: 700 13px Inter;
            fill: #f8fafc;
        }
        .arena-fig .tick {
            font: 11px Inter;
            fill: #cbd5e1;
        }
        .arena-fig .fig-label {
            font: 700 13px Inter;
            fill: #f8fafc;
        }
        .arena-fig .fig-note {
            font: 700 12px Inter;
            fill: #e2e8f0;
        }
        .arena-fig .fig-note.green {
            fill: #22d3ee;
        }
        .arena-fig .fig-note.red {
            fill: #fb7185;
        }
        .arena-fig .fig-note.purple {
            fill: #c084fc;
        }
        .arena-fig .fig-note.amber {
            fill: #fbbf24;
        }
        .options {
            display: grid;
            gap: 8px;
        }
        .option {
            width: 100%;
            text-align: left;
            border: 1px solid #2a3a55;
            background: #0b1424;
            color: #f1f5f9;
            padding: 11px 14px;
            border-radius: 10px;
            cursor: pointer;
            line-height: 1.5;
            transition: 0.13s;
            font-family: inherit;
            font-size: 0.95rem;
        }
        .option:hover,
        .option:focus-visible {
            border-color: var(--accent);
            outline: none;
            background: #121a2e;
        }
        .option.selected {
            border-color: var(--cyan);
            background: #0b2940;
            box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.10);
        }
        .option.correct {
            border-color: #4ade80;
            background: #052e16;
        }
        .option.wrong {
            border-color: #fb7185;
            background: #4c0519;
        }
        .confidence {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-wrap: wrap;
            margin: 14px 0 10px;
        }
        .confidence button {
            border: 1px solid #2a3a55;
            background: #0b1424;
            color: #cbd5e1;
            padding: 6px 12px;
            border-radius: 999px;
            cursor: pointer;
            font-size: 0.78rem;
            font-weight: 600;
            font-family: inherit;
            transition: 0.13s;
        }
        .confidence button.active {
            border-color: var(--accent);
            background: #1f143a;
            color: #fff;
        }
        .feedback {
            padding: 12px 14px;
            border: 1px solid #2a3a55;
            border-radius: 10px;
            background: #0b1424;
            color: #e2e8f0;
            margin-top: 10px;
            line-height: 1.6;
            font-size: 0.92rem;
        }
        .feedback.correct-feedback {
            border-color: #4ade80;
            background: #052e16;
            color: #dcfce7;
        }
        .feedback.wrong-feedback {
            border-color: #fb7185;
            background: #4c0519;
            color: #ffe4e6;
        }
        .nav {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            margin-top: 16px;
        }
        .score {
            font-size: 2.8rem;
            font-weight: 900;
            color: var(--cyan);
            line-height: 1.2;
        }
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 10px;
            margin: 14px 0;
        }
        .metric {
            background: #0b1424;
            border: 1px solid #2a3a55;
            border-radius: 10px;
            padding: 10px 12px;
            text-align: center;
        }
        .metric b {
            display: block;
            font-size: 0.85rem;
        }
        .metric span {
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--cyan);
        }
        .review {
            background: #0b1424;
            border: 1px solid #2a3a55;
            border-radius: 11px;
            padding: 12px 14px;
            margin: 8px 0;
            line-height: 1.6;
        }
        .review a {
            color: #67e8f9;
        }
        .struct-scenario {
            font-size: 0.98rem;
            line-height: 1.6;
            margin: 8px 0 14px;
            color: #e2e8f0;
        }
        .part {
            border-top: 1px solid #1f2a44;
            padding: 14px 0 10px;
        }
        .part:first-of-type {
            border-top: 0;
        }
        .part-label {
            font-weight: 700;
            margin-bottom: 6px;
            font-size: 0.95rem;
        }
        input.answer,
        textarea.answer {
            width: 100%;
            background: #07101f;
            border: 1px solid #2a3a55;
            color: #f1f5f9;
            border-radius: 9px;
            padding: 10px 12px;
            font: inherit;
            font-size: 0.92rem;
            transition: 0.13s;
        }
        textarea.answer {
            min-height: 70px;
            resize: vertical;
        }
        input.answer:focus,
        textarea.answer:focus {
            border-color: var(--cyan);
            outline: none;
            box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.10);
        }
        .unit-hint {
            font-size: 0.72rem;
            color: #94a3b8;
            margin-top: 4px;
        }
        .markguide {
            margin-top: 8px;
            padding: 10px 12px;
            background: #0b1b32;
            border-left: 3px solid var(--cyan);
            border-radius: 7px;
            color: #e0f2fe;
            font-size: 0.88rem;
            line-height: 1.5;
        }
        .markguide b {
            color: #fff;
        }
        .self-buttons {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            margin-top: 8px;
        }
        .self-buttons button {
            padding: 4px 10px;
            border-radius: 7px;
            border: 1px solid #475569;
            background: #111827;
            color: #e2e8f0;
            cursor: pointer;
            font-family: inherit;
            font-size: 0.8rem;
        }
        .self-buttons button.active {
            background: var(--accent);
            color: #fff;
            border-color: var(--accent);
        }
        .flag-btn {
            border: 1px solid #475569;
            background: #0b1220;
            color: #cbd5e1;
            border-radius: 999px;
            padding: 5px 10px;
            cursor: pointer;
            font-size: .73rem;
            font-weight: 800;
            font-family: inherit;
            transition: .13s;
        }
        .flag-btn.flagged {
            border-color: #f59e0b;
            background: #3a2505;
            color: #fde68a;
        }
        .qpalette {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
            gap: 6px;
            margin: 0 0 18px;
        }
        .qpalette button {
            min-height: 34px;
            border: 1px solid #334155;
            border-radius: 8px;
            background: #0b1220;
            color: #94a3b8;
            cursor: pointer;
            font-size: .72rem;
            font-weight: 800;
            font-family: inherit;
        }
        .qpalette button:hover,
        .qpalette button:focus-visible {
            border-color: #8b5cf6;
            outline: none;
        }
        .qpalette button.answered {
            border-color: #0891b2;
            color: #cffafe;
            background: #082f49;
        }
        .qpalette button.active {
            border-color: #c084fc;
            color: #fff;
            background: #3b0764;
            box-shadow: 0 0 0 2px rgba(168, 85, 247, .15);
        }
        .qpalette button.flagged {
            box-shadow: inset 0 -3px 0 #f59e0b;
        }
        .practice-guide {
            display: none;
            margin-top: 8px;
            padding: 9px 11px;
            border-radius: 8px;
            background: #0b1b32;
            border-left: 3px solid #22d3ee;
            color: #cfeffc;
            font-size: .78rem;
            line-height: 1.5;
        }
        .practice-guide.show {
            display: block;
        }
        @media (max-width: 720px) {
            .choice-grid {
                grid-template-columns: 1fr 1fr;
            }
            .wrap {
                padding: 12px 8px 50px;
            }
            .hero,
            .panel {
                padding: 16px;
            }
        }
        @media (max-width: 480px) {
            .choice-grid {
                grid-template-columns: 1fr;
            }
            .qmeta {
                width: 100%;
                justify-content: flex-start;
            }
            .grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        .katex-display { overflow-x:auto; overflow-y:hidden; padding:2px 0; }
        .question, .struct-scenario, .part-label, .feedback, .review, .option { overflow-wrap:anywhere; word-break:normal; }
        .answer-line { margin-top:5px; }
        .section-pill { display:inline-flex; padding:3px 8px; border-radius:999px; background:#172554; color:#bfdbfe; border:1px solid #1d4ed8; font-size:.68rem; font-weight:800; }
        @media (prefers-reduced-motion: reduce) { * { scroll-behavior:auto!important; transition:none!important; } }
    