/* Classroom look: graph-paper ground, hoodie-blue primary, warm XP gold. Light by default, dark follows the device. */
:root {
    --bg: #f3f6fc;
    --grid: rgb(47 92 180 / 7%);
    --surface: #ffffff;
    --surface-2: #edf1f9;
    --border: #dde4f0;
    --border-strong: #c7d1e4;
    --text: #172038;
    --muted: #5f6a85;
    --primary: #2f6fe4;
    --primary-edge: #1f4fb3;
    --primary-soft: #e4ecfd;
    --success: #1c9f62;
    --success-edge: #12784a;
    --success-soft: #e1f5ea;
    --error: #e0464b;
    --error-edge: #b13237;
    --error-soft: #fde9e9;
    --gold: #f4a51c;
    --gold-edge: #c27c0a;
    --gold-soft: #fff3d9;
    --flame: #ff7417;
    --code-bg: #141b2e;
    --code-text: #e7ecf8;
    --code-muted: #8a97b8;
    --board: #24453c;
    --board-edge: #b88352;
    --chalk: #f4f1e8;
    --shadow: 0 1px 2px rgb(23 32 56 / 6%), 0 8px 24px rgb(23 32 56 / 8%);
    --radius: 14px;
    --radius-lg: 22px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --font: "Lexend", "Segoe UI", system-ui, sans-serif;
    --display: "Baloo 2", "Lexend", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1322;
        --grid: rgb(120 150 220 / 6%);
        --surface: #161d31;
        --surface-2: #1c2440;
        --border: #283253;
        --border-strong: #35416a;
        --text: #e9edf8;
        --muted: #9ba6c4;
        --primary: #5b8fff;
        --primary-edge: #3463c9;
        --primary-soft: #1b2a50;
        --success: #34c47f;
        --success-edge: #20925a;
        --success-soft: #12322a;
        --error: #ff6a6e;
        --error-edge: #c4454a;
        --error-soft: #3b1c24;
        --gold: #ffb840;
        --gold-edge: #c98a1c;
        --gold-soft: #3a2d12;
        --code-bg: #0b1020;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px rgb(0 0 0 / 30%);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0e1322;
    --grid: rgb(120 150 220 / 6%);
    --surface: #161d31;
    --surface-2: #1c2440;
    --border: #283253;
    --border-strong: #35416a;
    --text: #e9edf8;
    --muted: #9ba6c4;
    --primary: #5b8fff;
    --primary-edge: #3463c9;
    --primary-soft: #1b2a50;
    --success: #34c47f;
    --success-edge: #20925a;
    --success-soft: #12322a;
    --error: #ff6a6e;
    --error-edge: #c4454a;
    --error-soft: #3b1c24;
    --gold: #ffb840;
    --gold-edge: #c98a1c;
    --gold-soft: #3a2d12;
    --code-bg: #0b1020;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px rgb(0 0 0 / 30%);
    color-scheme: dark;
}

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

body {
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button,
select {
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

pre,
kbd,
code,
.mono {
    font-family: var(--mono);
    font-variant-ligatures: none;
}

h1,
h2,
h3 {
    font-family: var(--display);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.2px;
    text-wrap: balance;
}

h1 {
    font-size: 30px;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.logo {
    display: grid;
    place-items: center;
    width: 38px;
    aspect-ratio: 1;
    border-radius: 11px;
    background: var(--primary);
    box-shadow: 0 3px 0 var(--primary-edge);
    color: #fff;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
}

.brand.is-large {
    font-size: 30px;
}

.brand.is-large .logo {
    width: 50px;
    border-radius: 14px;
    font-size: 17px;
}

/* Buttons sit on a darker edge and press down into it. */
.button {
    --fill: var(--primary);
    --edge: var(--primary-edge);
    --ink: #fff;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border: 0;
    border-radius: var(--radius);
    background: var(--fill);
    color: var(--ink);
    font-family: var(--display);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 0 var(--edge);
    transition: transform 0.08s, box-shadow 0.08s, filter 0.2s, opacity 0.2s;
}

.button:hover:not(:disabled) {
    filter: brightness(1.06);
}

.button:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--edge);
}

.button:disabled {
    --fill: var(--surface-2);
    --edge: var(--border-strong);
    --ink: var(--muted);
    cursor: not-allowed;
}

.button.is-ghost {
    --fill: var(--surface);
    --edge: var(--border-strong);
    --ink: var(--primary);
    border: 2px solid var(--border-strong);
}

.button.is-danger {
    --fill: var(--surface);
    --edge: var(--border-strong);
    --ink: var(--error);
    border: 2px solid var(--border-strong);
}

.button.is-gold {
    --fill: var(--gold);
    --edge: var(--gold-edge);
    --ink: #3b2600;
}

.button.is-success {
    --fill: var(--success);
    --edge: var(--success-edge);
}

.button.is-error {
    --fill: var(--error);
    --edge: var(--error-edge);
}

.button.is-small {
    min-height: 38px;
    padding: 0 14px;
    font-size: 15px;
    box-shadow: 0 3px 0 var(--edge);
}

.button[aria-busy="true"] {
    color: transparent;
}

.button[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 22px;
    aspect-ratio: 1;
    border: 3px solid rgb(255 255 255 / 40%);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.input {
    width: 100%;
    min-height: 50px;
    padding: 0 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.input[aria-invalid="true"] {
    border-color: var(--error);
    box-shadow: 0 0 0 4px var(--error-soft);
}

.code-input {
    width: 100%;
    min-height: 180px;
    padding: 16px 18px;
    background: var(--code-bg);
    color: var(--code-text);
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 14px;
    font-variant-ligatures: none;
    line-height: 1.7;
    resize: vertical;
    caret-color: var(--gold);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.code-input::placeholder {
    color: var(--code-muted);
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.bar {
    flex: 1;
    height: 14px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    position: relative;
    width: 0;
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 0.6s var(--ease);
}

.bar-fill::after {
    content: "";
    position: absolute;
    inset: 3px 6px auto;
    height: 3px;
    border-radius: 999px;
    background: rgb(255 255 255 / 35%);
}

.toasts {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    z-index: 1000;
    display: grid;
    gap: 8px;
    translate: -50%;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: rise-in 0.3s var(--ease), fade-out 0.3s 2.9s forwards;
}

.toast.is-success {
    border-color: var(--success);
    color: var(--success);
}

.toast.is-error {
    border-color: var(--error);
    color: var(--error);
}

@keyframes rise-in {
    from { opacity: 0; translate: 0 12px; }
}

@keyframes fade-out {
    to { opacity: 0; }
}

@keyframes spin {
    to { rotate: 1turn; }
}

@keyframes pop {
    0% { scale: 0.6; opacity: 0; }
    60% { scale: 1.06; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
