:root {
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --bg: #0d0f12;
    --surface-1: #12151a;
    --surface-2: #171b21;
    --surface-3: #1e232b;
    --surface-hover: #202630;
    --text: #ecf0f4;
    --text-soft: #abb4c0;
    --text-muted: #707b89;
    --border: #282e37;
    --border-strong: #39414d;
    --accent: #79a7ff;
    --accent-strong: #5b8ff0;
    --accent-soft: rgba(121, 167, 255, .12);
    --success: #72d6a0;
    --success-soft: rgba(114, 214, 160, .11);
    --warning: #edbf69;
    --warning-soft: rgba(237, 191, 105, .11);
    --danger: #ef7e86;
    --danger-soft: rgba(239, 126, 134, .1);
    --purple: #b49af5;
    --shadow: 0 20px 60px rgba(0, 0, 0, .25);
    --radius-sm: 5px;
    --radius: 8px;
    --radius-lg: 12px;
    --topbar-height: 56px;
}

:root[data-theme="light"] {
    --bg: #f4f5f7;
    --surface-1: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef1f4;
    --surface-hover: #f0f3f7;
    --text: #171a1f;
    --text-soft: #505966;
    --text-muted: #7b8490;
    --border: #dfe3e8;
    --border-strong: #cbd1d8;
    --accent: #346fd4;
    --accent-strong: #255fc4;
    --accent-soft: rgba(52, 111, 212, .1);
    --success: #24875a;
    --success-soft: rgba(36, 135, 90, .09);
    --warning: #9d6811;
    --warning-soft: rgba(157, 104, 17, .09);
    --danger: #c4434d;
    --danger-soft: rgba(196, 67, 77, .09);
    --purple: #7254bb;
    --shadow: 0 20px 60px rgba(20, 32, 48, .1);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
}

body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
code, pre, kbd { font-family: var(--font-mono); }
::selection { background: rgba(121, 167, 255, .26); }

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.desktop-required { display: none; }
.app-shell { min-height: 100vh; }

.topbar {
    height: var(--topbar-height);
    padding: 0 32px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface-1);
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 720;
    letter-spacing: -.025em;
    font-size: 17px;
}

.brand--large { font-size: 20px; }

.brand-mark {
    width: 31px;
    height: 31px;
    display: block;
    flex: 0 0 auto;
    border-radius: 7px;
}

.topbar-actions form { margin: 0; }
.logout-link { padding: 5px 2px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 11px; font-weight: 650; }
.logout-link:hover { color: var(--text); }

.primary-nav { height: 100%; display: flex; gap: 28px; }

.primary-nav a {
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 560;
    position: relative;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] { color: var(--text); }
.primary-nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
}

.topbar-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
}

.icon-button:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.theme-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="dark"] .theme-icon--moon,
[data-theme="light"] .theme-icon--sun { display: none; }

.identity-chip {
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-family: var(--font-mono);
    font-size: 11px;
}

.identity-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--success-soft);
}

.main-content {
    width: min(1180px, calc(100% - 64px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

.page-heading { margin-bottom: 32px; }
.page-heading--split { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; }
.page-heading h1 {
    margin: 3px 0 7px;
    font-size: clamp(32px, 3.2vw, 45px);
    line-height: 1.05;
    letter-spacing: -.045em;
    font-weight: 690;
}
.page-heading > div > p:last-child,
.page-heading > p:last-child { color: var(--text-soft); margin: 0; max-width: 620px; }
.eyebrow {
    margin: 0 0 7px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.muted { color: var(--text-muted) !important; }
.lede { color: var(--text-soft); font-size: 17px; }

.button {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    padding: 0 15px;
    background: transparent;
    color: var(--text);
    font-weight: 640;
    font-size: 12px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .6; cursor: wait; transform: none; }
.button--primary { background: var(--accent); color: #0a1423; border-color: var(--accent); }
[data-theme="light"] .button--primary { color: white; }
.button--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button--secondary { border-color: var(--border-strong); background: var(--surface-2); }
.button--secondary:hover, .button--ghost:hover { background: var(--surface-hover); }
.button--ghost { border-color: var(--border); }
.button--danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); background: var(--danger-soft); }
.button--small { min-height: 32px; padding: 0 11px; font-size: 11px; }
.button--large { min-height: 46px; padding: 0 19px; font-size: 13px; }
.button--full { width: 100%; }

.field { display: grid; gap: 7px; }
.field > span,
.test-row label > span {
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 650;
}
.field small { color: var(--text-muted); font-weight: 450; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text);
    padding: 10px 11px;
}
input, select { min-height: 40px; }
textarea { resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .64; cursor: not-allowed; background: var(--surface-2); }
.form-stack { display: grid; gap: 18px; }

.alert {
    margin: 20px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.alert--error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); }
.alert--success { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-soft); }

/* Authentication */
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(460px, 1.05fr) minmax(480px, .95fr); }
.auth-intro {
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 48px clamp(50px, 7vw, 110px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-intro::after {
    content: "";
    position: absolute;
    width: 460px;
    height: 460px;
    border: 1px solid var(--border);
    border-radius: 50%;
    right: -230px;
    bottom: -130px;
    box-shadow: 0 0 0 70px transparent, 0 0 0 71px var(--border), 0 0 0 140px transparent, 0 0 0 141px var(--border);
    opacity: .45;
}
.auth-intro__copy { position: relative; z-index: 1; max-width: 580px; }
.auth-intro__copy h1 { margin: 0 0 22px; font-size: clamp(48px, 5.4vw, 78px); line-height: .98; letter-spacing: -.065em; font-weight: 650; }
.auth-intro__copy > p:last-child { max-width: 490px; color: var(--text-soft); font-size: 17px; }
.code-motif {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 8px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}
.code-motif i { color: var(--border-strong); font-style: normal; margin-right: 18px; }
.auth-panel { position: relative; display: grid; place-items: center; padding: 60px; }
.auth-theme { position: absolute; top: 35px; right: 35px; }
.auth-card { width: min(390px, 100%); }
.auth-card h2 { margin: 0 0 7px; font-size: 30px; letter-spacing: -.04em; }
.auth-card > .muted { margin: 0 0 30px; }
.demo-credentials {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 10px;
}
.demo-credentials > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-muted); font-size: 10px; }
.demo-credentials button { border: 0; background: none; color: var(--text-soft); cursor: pointer; font-size: 10px; padding: 3px 0; }
.demo-credentials button:hover { color: var(--accent); }
.demo-credentials code { font-size: 10px; }

/* Onboarding */
.onboarding-layout { min-height: calc(100vh - var(--topbar-height) - 120px); display: grid; place-items: center; }
.onboarding-card { width: min(600px, 100%); padding: 42px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); box-shadow: var(--shadow); }
.onboarding-card h1 { margin: 5px 0 10px; font-size: 35px; letter-spacing: -.045em; }
.step-indicator { display: flex; align-items: center; width: 90px; margin-bottom: 34px; }
.step-indicator span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--success); color: #07160f; font-size: 10px; font-weight: 800; }
.step-indicator span.is-active { background: var(--accent); color: #081427; box-shadow: 0 0 0 5px var(--accent-soft); }
.step-indicator i { height: 1px; background: var(--border-strong); flex: 1; }
.input-with-count { position: relative; }
.input-with-count input { padding-right: 70px; font-family: var(--font-mono); }
.input-with-count span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 10px; }
.field-help { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-muted); font-size: 10px; margin-top: -7px; }
.field-help span::before { content: "·"; color: var(--accent); margin-right: 7px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 11px; }
.notice svg { width: 17px; flex: 0 0 auto; fill: none; stroke: var(--warning); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Problems overview */

.progress-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    overflow: hidden;
    margin-bottom: 28px;
}
.progress-panel__main { display: flex; align-items: center; gap: 25px; padding: 27px 30px; border-right: 1px solid var(--border); }
.progress-panel__main h2 { margin: 2px 0 3px; font-size: 21px; letter-spacing: -.025em; }
.progress-panel__main p:last-child { margin: 0; font-size: 12px; }
.progress-ring {
    width: 86px;
    height: 86px;
    flex: 0 0 86px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--accent) var(--progress), var(--surface-3) 0);
    position: relative;
}
.progress-ring::after { content: ""; position: absolute; inset: 7px; background: var(--surface-1); border-radius: 50%; }
.progress-ring > div { position: relative; z-index: 1; text-align: center; line-height: 1; }
.progress-ring strong { display: block; font-family: var(--font-mono); font-size: 22px; }
.progress-ring span { color: var(--text-muted); font-size: 9px; }
.tag-progress-list { padding: 18px 25px; display: grid; gap: 9px; }
.tag-progress > div:first-child { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 10px; color: var(--text-soft); }
.tag-progress strong { color: var(--text-muted); font-family: var(--font-mono); font-size: 9px; }
.mini-progress { height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.mini-progress i { height: 100%; display: block; background: var(--accent); border-radius: inherit; }

.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0 0 14px;
}
.filter-bar select { min-width: 150px; background: var(--surface-1); font-size: 11px; }
.filter-spacer { flex: 1; }
.sort-control { display: flex; align-items: center; gap: 10px; }
.sort-control > span { color: var(--text-muted); font-size: 10px; }

.problem-table { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); overflow: hidden; }
.problem-table__head,
.problem-row {
    display: grid;
    grid-template-columns: minmax(400px, 1fr) 130px 85px 110px 28px;
    align-items: center;
    column-gap: 15px;
}
.problem-table__head { min-height: 40px; padding: 0 18px; background: var(--surface-2); color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--border); }
.problem-row { min-height: 106px; padding: 16px 18px; border-bottom: 1px solid var(--border); transition: background 130ms ease; }
.problem-row:last-child { border-bottom: 0; }
.problem-row:hover { background: var(--surface-hover); }
.problem-row__title { display: flex; gap: 16px; min-width: 0; }
.problem-index { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; padding-top: 3px; }
.problem-row__title strong { display: block; margin-bottom: 2px; font-size: 14px; }
.problem-row__title > div > span { display: block; color: var(--text-muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 490px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { padding: 2px 6px; border: 1px solid var(--border); border-radius: 3px; color: var(--text-muted); background: var(--surface-2); font-family: var(--font-mono); font-size: 8px; }
.difficulty { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 10px; font-weight: 650; }
.difficulty::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.difficulty--beginner::before { background: var(--success); }
.difficulty--easy::before { background: #63c7cf; }
.difficulty--moderate::before { background: var(--accent); }
.difficulty--hard::before { background: var(--warning); }
.difficulty--nightmare::before { background: var(--danger); }
.problem-row > div:nth-child(2) small { display: block; color: var(--text-muted); font-size: 8px; margin: 4px 0 0 12px; }
.score-value { font-family: var(--font-mono); font-size: 12px; }
.solved-label { color: var(--success); font-size: 10px; font-weight: 600; }
.solved-label i { font-style: normal; display: inline-grid; place-items: center; width: 17px; height: 17px; margin-right: 5px; border-radius: 50%; background: var(--success-soft); }
.row-arrow { color: var(--text-muted); transition: transform 120ms ease, color 120ms ease; }
.problem-row:hover .row-arrow, .admin-row:hover .row-arrow { transform: translateX(3px); color: var(--accent); }
.empty-state { padding: 64px 30px; display: grid; justify-items: center; text-align: center; }
.empty-state__icon { color: var(--accent); font-family: var(--font-mono); font-size: 30px; }
.empty-state h2 { margin: 11px 0 4px; font-size: 18px; }
.empty-state p { color: var(--text-muted); margin: 0 0 20px; }

/* Problem workspace */
.workspace-page { overflow: hidden; }
.workspace {
    height: calc(100vh - var(--topbar-height));
    min-height: 704px;
    display: grid;
    grid-template-columns: var(--statement-width, 43%) 7px 1fr;
    background: var(--surface-1);
}
.workspace-pane { min-width: 0; overflow: hidden; }
.workspace-pane--statement { border-right: 0; }
.workspace-pane--code { display: grid; grid-template-rows: 48px minmax(330px, 1fr) auto auto; background: var(--surface-1); }
.workspace-pane__bar { height: 52px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.back-link { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 14px; font-weight: 650; }
.back-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 140ms ease; }
.back-link:hover { color: var(--accent); }
.back-link:hover svg { transform: translateX(-2px); }
.workspace-status { display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 13px; font-weight: 620; }
.workspace-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-muted) 13%, transparent); }
.workspace-status--progress { color: var(--text-soft); }
.workspace-status--progress i { background: var(--text-muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-muted) 13%, transparent); }
.workspace-status--solved { color: var(--success); }
.workspace-status--solved i { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.problem-statement { height: calc(100% - 52px); overflow-y: auto; padding: 35px clamp(28px, 4vw, 58px) 80px; }
.statement-heading { padding-bottom: 31px; border-bottom: 1px solid var(--border); }
.statement-heading h1 { margin: 14px 0 12px; font-size: clamp(29px, 3vw, 41px); letter-spacing: -.045em; line-height: 1.08; }
.difficulty-line { display: flex; gap: 17px; align-items: center; color: var(--text-muted); font-size: 10px; }
.problem-statement section { margin-top: 32px; }
.problem-statement h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-soft); margin: 0 0 12px; }
.problem-statement p { color: var(--text-soft); line-height: 1.75; font-size: 13px; }
.constraint-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.constraint-list li { color: var(--text-soft); font-size: 12px; display: flex; gap: 9px; }
.constraint-list li::before { content: "—"; color: var(--border-strong); }
.constraint-list code { padding: 1px 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; color: var(--accent); font-size: 10px; }
.example-block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 13px; }
.example-block > div { min-height: 31px; padding: 0 11px; display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; border-bottom: 1px solid var(--border); }
.example-block > div:not(:first-child) { border-top: 1px solid var(--border); }
.example-block pre { margin: 0; padding: 13px; color: var(--text-soft); font-size: 10px; white-space: pre-wrap; }
.copy-button { border: 0; background: none; padding: 2px; color: var(--text-muted); font-size: 9px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.copy-button:hover { color: var(--accent); }
.workspace-resizer { width: 7px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--bg); padding: 0; cursor: col-resize; display: grid; place-items: center; z-index: 2; }
.workspace-resizer span { width: 1px; height: 32px; background: var(--border-strong); }
.workspace-resizer:hover, .workspace-resizer.is-dragging { background: var(--accent-soft); border-color: var(--accent); }
.editor-toolbar { min-width: 0; padding: 0 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor-tabs { height: 100%; display: flex; }
.editor-tabs span { display: flex; align-items: center; gap: 8px; padding: 0 13px; color: var(--text); font-family: var(--font-mono); font-size: 13px; font-weight: 600; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--surface-1); position: relative; }
.editor-tabs svg { width: 16px; height: 16px; fill: none; stroke: var(--code-function); stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.editor-tabs span::after { content: ""; position: absolute; top: -1px; left: -1px; right: -1px; height: 2px; background: var(--accent); }
.editor-actions { display: flex; align-items: center; gap: 6px; }
.editor-actions .file-button,
.editor-actions .editor-reset { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-soft); font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer; transform: none; }
.editor-actions .file-button:hover,
.editor-actions .editor-reset:hover { background: var(--surface-hover); color: var(--text); transform: none; }
.file-button input { display: none; }
.file-button svg, .editor-reset svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.submission-form { min-height: 0; display: grid; grid-template-rows: 1fr 52px; }
.submission-form > textarea { opacity: 0; position: absolute; pointer-events: none; }
.editor-host, .cm-editor { height: 100%; min-height: 0; }
.cm-editor { background: var(--surface-1); color: var(--text); font-size: 13px; }
.cm-editor.cm-focused { outline: none; }
.cm-scroller { font-family: var(--font-mono) !important; line-height: 1.65; }
.cm-gutters { background: var(--surface-1) !important; color: var(--text-muted) !important; border-right-color: var(--border) !important; }
.cm-activeLine, .cm-activeLineGutter { background: var(--surface-2) !important; }
.submit-bar { min-height: 52px; padding: 0 14px 0 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.submit-bar__meta { min-width: 0; display: flex; align-items: center; gap: 16px; }
.keyboard-hint, .runtime-label, .save-state { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.keyboard-hint { color: var(--text-soft); }
.keyboard-hint kbd { border: 1px solid var(--border-strong); border-radius: 3px; padding: 2px 5px; background: var(--surface-1); color: var(--text); font-size: 12px; }
.keyboard-hint b { font-weight: 400; margin: 0 2px; }
.runtime-label { padding-left: 16px; border-left: 1px solid var(--border); }
.save-state { display: inline-flex; align-items: center; gap: 7px; }
.save-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 14%, transparent); }
.submit-bar .button { min-width: 142px; min-height: 42px; display: inline-flex; gap: 9px; padding-inline: 16px; font-size: 14px; font-weight: 700; }
.submit-bar .button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 140ms ease; }
.submit-bar .button:hover svg { transform: translateX(2px); }
.result-panel { min-height: 0; max-height: 220px; overflow-y: auto; border-top: 1px solid var(--border); background: var(--surface-2); }
.result-empty { min-height: 108px; padding: 16px 20px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.result-empty__icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); }
.result-empty__icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.result-empty strong { font-size: 14px; }
.result-empty p { color: var(--text-muted); margin: 3px 0 0; font-size: 12px; }
.grading-loading { min-height: 108px; display: grid; place-items: center; text-align: center; }
.grading-loading i { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.grading-loading strong { display: block; margin-top: 7px; font-size: 14px; }
.grading-loading p { margin: 3px 0 0; color: var(--text-muted); font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-content { min-height: 0; padding: 14px 18px 16px; }
.result-content.is-solved { background: var(--success-soft); animation: result-in 300ms ease both; }
@keyframes result-in { from { opacity: 0; transform: translateY(5px); } }
.result-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 10px; }
.result-heading > div { display: flex; gap: 10px; align-items: center; }
.result-icon { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); color: var(--warning); background: var(--warning-soft); }
.result-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.is-solved .result-icon { color: var(--success); border-color: color-mix(in srgb, var(--success) 50%, transparent); }
.result-content--failed .result-icon, .result-content--error .result-icon { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.result-content--partial .result-heading strong { color: var(--warning); }
.result-content--failed .result-heading strong, .result-content--error .result-heading strong { color: var(--danger); }
.result-content.is-solved .result-heading strong { color: var(--success); }
.result-heading strong { font-size: 14px; }
.result-heading p { margin: 2px 0 0; color: var(--text-muted); font-size: 11px; }
.result-total { min-width: 112px; text-align: right; }
.result-total strong { display: block; color: var(--text); font-family: var(--font-mono); font-size: 15px; line-height: 1.15; }
.result-total span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.result-cases { margin-left: 40px; }
.case-list { display: flex; flex-wrap: wrap; gap: 5px; }
.case { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 4px; color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; font-style: normal; }
.case--pass { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); background: var(--success-soft); }
.recent-submissions { border-top: 1px solid var(--border); background: var(--surface-1); }
.recent-submissions__heading { min-height: 38px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--text-soft); font-size: 13px; }
.recent-submissions__heading span { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; }
.recent-submissions__heading i { color: var(--text-muted); font-style: normal; }
.recent-submissions__heading a { color: var(--accent); font-size: 12px; font-weight: 700; }
.recent-submissions__heading a:hover { color: var(--accent-strong); }
.recent-submissions > [data-recent-list] { padding: 0 18px 8px; display: grid; }
.recent-row { min-height: 32px; display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; color: var(--text-muted); font-size: 11px; border-top: 1px solid var(--border); }
.recent-row strong { color: var(--text-soft); font-family: var(--font-mono); }
.submission-status { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--text-muted); }
.submission-status--solved { background: var(--success); }
.submission-status--partial { background: var(--warning); }
.submission-status--failed, .submission-status--platform_error { background: var(--danger); }

/* History */
.submissions-page .main-content { padding-top: 28px; }
.history-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); overflow: hidden; }
.submission-filter { min-height: 48px; margin: 0 0 18px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text-soft); font-size: 14px; }
.submission-filter strong { color: var(--text); }
.submission-filter a { color: var(--accent); font-weight: 700; }
.submission-filter a:hover { color: var(--accent-strong); }
.history-entry { border-bottom: 1px solid var(--border); }
.history-entry:last-child { border-bottom: 0; }
.history-entry summary { min-height: 76px; padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) 126px 112px 32px; gap: 18px; align-items: center; list-style: none; cursor: pointer; transition: background 140ms ease; }
.history-entry summary::-webkit-details-marker { display: none; }
.history-entry summary:hover { background: var(--surface-hover); }
.history-entry summary:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.history-entry[open] summary { background: var(--surface-2); }
.history-entry summary strong { display: block; font-size: 13px; }
.history-entry__identity { min-width: 0; }
.history-entry time { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.history-score { display: inline-flex; align-items: baseline; gap: 5px; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.history-score strong { color: var(--text-soft); font-family: var(--font-mono); font-size: 12px !important; font-weight: 600; }
.history-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 12px; font-weight: 650; white-space: nowrap; }
.history-label--solved { color: var(--success); }
.history-label--partial { color: var(--warning); }
.history-label--failed, .history-label--platform_error { color: var(--danger); }
.disclosure-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--text-muted); transition: color 140ms ease, background 140ms ease, transform 150ms ease; }
.disclosure-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.history-entry summary:hover .disclosure-icon { color: var(--text); background: var(--surface-3); }
.history-entry[open] .disclosure-icon { transform: rotate(180deg); }
.history-detail { padding: 14px 0 0; background: var(--surface-2); }
.history-result { margin: 0 20px 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); }
.history-result__heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.history-result__heading > span { color: var(--text-soft); font-size: 13px; font-weight: 700; }
.history-result__heading strong { color: var(--text); font-family: var(--font-mono); font-size: 13px; }
.history-result__heading small { color: var(--text-muted); font-family: var(--font-ui); font-size: 10px; font-weight: 500; }
.history-result__cases { min-height: 22px; }
.history-code { padding: 0 20px 24px; background: var(--surface-2); }
.history-code__toolbar { min-height: 42px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-1); color: var(--text-muted); font-size: 11px; }
.history-code .copy-button { padding: 6px; font-size: 11px; font-weight: 650; }
.history-code__source { min-height: 62px; max-height: 360px; margin: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 20px; border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--bg); color: var(--text-soft); font-size: 12px; line-height: 1.65; tab-size: 4; white-space: pre; }
.history-code__source code { display: block; min-width: max-content; }

/* Leaderboard */

/* Admin */
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.admin-stats > div { padding: 17px 20px; display: flex; justify-content: space-between; align-items: center; border-right: 1px solid var(--border); }
.admin-stats > div:last-child { border-right: 0; }
.admin-stats span { color: var(--text-muted); font-size: 10px; }
.admin-stats strong { font-family: var(--font-mono); font-size: 18px; }
.admin-table { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); overflow: hidden; }
.admin-table__head, .admin-row { display: grid; grid-template-columns: minmax(270px, 1fr) 110px 100px 70px 100px 25px; gap: 15px; align-items: center; }
.admin-table__head { min-height: 39px; padding: 0 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.admin-row { min-height: 69px; padding: 0 18px; border-bottom: 1px solid var(--border); font-size: 10px; }
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: var(--surface-hover); }
.admin-row > div strong { display: block; font-size: 12px; }
.admin-row > div span { color: var(--text-muted); font-size: 8px; }
.status-badge { width: max-content; display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-soft); font-size: 8px; }
.status-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); }
.status-badge--draft { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.status-badge--draft i { background: var(--warning); }
.status-badge--published { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.status-badge--published i { background: var(--success); }
.status-badge--archived { color: var(--text-muted); }

.editor-page-header { margin: -20px 0 30px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.editor-title-line { display: flex; align-items: center; gap: 15px; margin-top: 9px; }
.editor-title-line h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.editor-header-actions { display: flex; gap: 8px; }
.lock-notice { display: flex; gap: 13px; padding: 14px 16px; margin-bottom: 22px; border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border)); background: var(--warning-soft); border-radius: var(--radius); }
.lock-notice > span { color: var(--warning); }
.lock-notice strong { font-size: 11px; }
.lock-notice p { margin: 2px 0 0; color: var(--text-muted); font-size: 9px; }
.admin-editor-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 30px; align-items: start; }
.section-nav { position: sticky; top: calc(var(--topbar-height) + 25px); display: grid; gap: 3px; }
.section-nav > span { color: var(--text-muted); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 8px 10px; }
.section-nav a { padding: 8px 10px; border-left: 1px solid var(--border); color: var(--text-muted); font-family: var(--font-mono); font-size: 9px; }
.section-nav a:hover, .section-nav a.is-active { border-left-color: var(--accent); color: var(--text); background: linear-gradient(90deg, var(--accent-soft), transparent); }
.problem-editor-form { display: grid; gap: 16px; }
.editor-section { scroll-margin-top: calc(var(--topbar-height) + 15px); display: grid; grid-template-columns: 46px minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); overflow: hidden; }
.section-number { padding-top: 23px; text-align: center; color: var(--text-muted); background: var(--surface-2); border-right: 1px solid var(--border); font-family: var(--font-mono); font-size: 9px; }
.section-content { padding: 23px 25px 26px; min-width: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.section-heading h3 { margin: 0; font-size: 13px; }
.section-heading p { margin: 3px 0 0; color: var(--text-muted); font-size: 9px; }
.section-heading--nested { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field--wide { grid-column: 1 / -1; }
.field--choices { margin: 0; padding: 0; border: 0; min-width: 0; }
.field--choices > legend { padding: 0; margin: 0 0 7px; font-size: 13px; font-weight: 650; }
.code-textarea { font-family: var(--font-mono); font-size: 10px; }
.editor-section .field + .field { margin-top: 16px; }
.form-grid .field + .field { margin-top: 0; }
#id_tags { display: flex; flex-wrap: wrap; gap: 8px; }
#id_tags > div { display: contents; }
#id_tags label { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
#id_tags input[type="checkbox"] { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.editor-section.is-locked .section-number { color: var(--warning); }
.editor-section.is-locked .repeater,
.editor-section.is-locked .form-grid { opacity: .62; pointer-events: none; }
.language-link { color: var(--text-muted); font-size: 12px; font-weight: 700; text-decoration: none; }
.language-link:hover { color: var(--accent); }
.problem-search input { min-width: 230px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 24px 0; color: var(--text-muted); }
.pagination a { color: var(--accent); font-weight: 700; text-decoration: none; }
.repeater { display: grid; gap: 9px; }
.test-row { display: grid; grid-template-columns: 22px 1fr 1fr 30px; gap: 9px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.test-row label { display: grid; gap: 5px; }
.test-row textarea { background: var(--surface-1); font-family: var(--font-mono); font-size: 9px; resize: vertical; }
.drag-handle { color: var(--text-muted); cursor: grab; font-size: 12px; letter-spacing: -4px; }
.row-remove { color: var(--text-muted); font-size: 18px; }
.row-remove:hover { color: var(--danger); background: var(--danger-soft); }
.repeater-empty { padding: 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-muted); text-align: center; font-size: 10px; }
.validation-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); }
.validation-card > div { display: flex; align-items: center; gap: 11px; }
.validation-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--success); background: var(--success-soft); }
.validation-card strong { font-size: 11px; }
.validation-card p { margin: 2px 0 0; color: var(--text-muted); font-size: 9px; }
.text-danger { border: 0; background: transparent; color: var(--danger); padding: 0; margin-top: 21px; font-size: 10px; cursor: pointer; }
.text-danger:hover { text-decoration: underline; }

/* Dialogs */
.modal {
    width: min(460px, calc(100% - 40px));
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    color: var(--text);
    box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(3, 5, 8, .7); backdrop-filter: blur(3px); }
.modal > form { padding: 29px; position: relative; }
.modal-close { position: absolute; top: 13px; right: 13px; color: var(--text-muted); font-size: 18px; }
.modal-icon { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); color: var(--accent); border-radius: 50%; }
.modal h2 { margin: 16px 0 7px; font-size: 21px; letter-spacing: -.03em; }
.modal > form > p { color: var(--text-soft); font-size: 11px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }
.diagnostics-modal { width: min(620px, calc(100% - 40px)); }
.diagnostic-list { display: grid; gap: 8px; margin-top: 18px; }
.diagnostic-row { display: grid; grid-template-columns: 1fr 70px; gap: 4px 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.diagnostic-row strong { font-size: 10px; }
.diagnostic-row > span { color: var(--success); text-align: right; font-size: 9px; }
.diagnostic-row p { margin: 0; color: var(--text-muted); font-size: 8px; }

.demo-toolbar {
    position: fixed;
    z-index: 80;
    right: 17px;
    bottom: 17px;
    width: 230px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-1);
    box-shadow: var(--shadow);
}
.demo-toolbar summary { min-height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 12px; list-style: none; cursor: pointer; color: var(--text-soft); font-size: 10px; font-weight: 650; }
.demo-toolbar summary::-webkit-details-marker { display: none; }
.status-dot--demo { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 15%, transparent); }
.demo-toolbar__body { padding: 12px; border-top: 1px solid var(--border); }
.demo-toolbar__body label { display: block; color: var(--text-muted); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px; }
.demo-toolbar__body select { min-height: 34px; font-size: 9px; }
.demo-toolbar__body p { color: var(--text-muted); font-size: 8px; margin: 8px 0 11px; }
.toast-region { position: fixed; z-index: 100; right: 20px; top: 78px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 360px; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-1); box-shadow: var(--shadow); font-size: 10px; animation: toast-in 180ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-5px); } }

@media (max-width: 1180px) {
    .topbar { padding: 0 22px; }
    .main-content { width: calc(100% - 42px); }
    .problem-table__head, .problem-row { grid-template-columns: minmax(350px, 1fr) 110px 70px 95px 20px; }
}

@media (max-width: 1023px), (max-height: 767px) {
    .app-shell, .demo-toolbar, .toast-region { display: none !important; }
    .desktop-required { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
    .desktop-required__panel { max-width: 430px; padding: 36px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); text-align: center; }
    .desktop-required__panel .brand-mark { margin: 0 auto 18px; }
    .desktop-required h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.03em; }
    .desktop-required p { color: var(--text-muted); margin: 0; }
}

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

/* Rose Pine refresh: 60% canvas, 30% surfaces, 10% accent and states. */
:root {
    --bg: #191724;
    --surface-1: #232136;
    --surface-2: #2a273f;
    --surface-3: #393552;
    --surface-hover: #302d47;
    --text: #e0def4;
    --text-soft: #c8c5df;
    --text-muted: #908caa;
    --border: #393552;
    --border-strong: #524f67;
    --accent: #ea9a97;
    --accent-strong: #ebbcba;
    --accent-soft: rgba(234, 154, 151, .12);
    --success: #9ccfd8;
    --success-soft: rgba(156, 207, 216, .12);
    --warning: #c8a36e;
    --warning-soft: rgba(200, 163, 110, .08);
    --danger: #eb6f92;
    --danger-soft: rgba(235, 111, 146, .12);
    --purple: #c4a7e7;
    --code-text: #c8c5df;
    --code-keyword: #c4a7e7;
    --code-function: #9ccfd8;
    --code-string: #f6c177;
    --code-number: #ebbcba;
    --code-comment: #908caa;
    --code-operator: #c8c5df;
    --code-property: #ea9a97;
    --code-invalid: #eb6f92;
    --topbar-height: 56px;
}

:root[data-theme="light"] {
    --bg: #faf4ed;
    --surface-1: #fffaf3;
    --surface-2: #f2e9e1;
    --surface-3: #dfdad9;
    --surface-hover: #f4ede8;
    --text: #575279;
    --text-soft: #6e6a86;
    --text-muted: #9893a5;
    --border: #dfdad9;
    --border-strong: #cecacd;
    --accent: #d7827e;
    --accent-strong: #b4637a;
    --accent-soft: rgba(215, 130, 126, .12);
    --success: #56949f;
    --success-soft: rgba(86, 148, 159, .12);
    --warning: #8f6637;
    --warning-soft: rgba(143, 102, 55, .08);
    --danger: #b4637a;
    --danger-soft: rgba(180, 99, 122, .12);
    --purple: #907aa9;
    --code-text: #6e6a86;
    --code-keyword: #765489;
    --code-function: #367680;
    --code-string: #865a16;
    --code-number: #9b4d65;
    --code-comment: #746f81;
    --code-operator: #625e78;
    --code-property: #9b4d65;
    --code-invalid: #a33e5c;
}

.tok-variableName { color: var(--code-text); }
.tok-keyword, .tok-bool, .tok-atom { color: var(--code-keyword); }
.tok-variableName.tok-definition, .tok-function, .tok-typeName, .tok-className, .tok-namespace { color: var(--code-function); }
.tok-string, .tok-string2, .tok-regexp { color: var(--code-string); }
.tok-number, .tok-literal { color: var(--code-number); }
.tok-comment { color: var(--code-comment); }
.tok-operator, .tok-punctuation { color: var(--code-operator); }
.tok-propertyName, .tok-variableName2, .tok-labelName { color: var(--code-property); }
.tok-meta { color: var(--text-muted); }
.tok-invalid { color: var(--code-invalid); text-decoration: underline wavy currentColor; text-underline-offset: 3px; }

html { font-size: 16px; }
.topbar { padding-inline: 3vw; }
.topbar .icon-button { width: 32px; height: 32px; }
.topbar .identity-chip { height: 32px; }
.primary-nav a { font-size: 14px; }
.main-content { width: min(1480px, calc(100% - 6vw)); padding-top: 32px; }
.field > span, .test-row label > span { font-size: 13px; }
input, select { min-height: 46px; font-size: 15px; }
textarea { font-size: 15px; }
.button { min-height: 42px; font-size: 14px; }
.button--large { min-height: 50px; font-size: 15px; }
.tag { padding: 4px 8px; font-size: 11px; }
.difficulty { font-size: 13px; }
.identity-chip { font-size: 12px; }

.minimal-login { min-height: 100vh; display: grid; place-items: center; padding: 40px; background: var(--bg); }
.minimal-login__card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); box-shadow: var(--shadow); }
.minimal-login__brand { justify-content: center; margin-bottom: 38px; }
.minimal-login__heading { text-align: center; margin-bottom: 28px; }
.minimal-login__heading h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.04em; }
.minimal-login__heading p { margin: 0; color: var(--text-soft); font-size: 15px; }
.auth-page--minimal .auth-theme { position: fixed; top: 24px; right: 24px; }
.demo-credentials--compact { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.demo-credentials--compact summary { color: var(--text-muted); cursor: pointer; font-size: 13px; }
.demo-credentials--compact[open] summary { margin-bottom: 14px; }
.demo-credentials--compact > div { margin-top: 10px; }

.problems-page .main-content { width: calc(100% - 6vw); max-width: none; }
.problem-toolbar { min-height: 38px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.problem-toolbar p { margin: 0; color: var(--text-muted); font-size: 14px; }
.progress-summary { display: flex; align-items: center; gap: 10px; }
.progress-summary strong { font-family: var(--font-mono); font-size: 17px; }
.progress-summary span { color: var(--text-soft); font-size: 13px; }
.progress-summary__bar { width: clamp(180px, 18vw, 240px); height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-summary__bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.filter-bar--cards { align-items: end; margin-bottom: 20px; }
.filter-bar--cards label { display: grid; gap: 7px; }
.filter-bar--cards label > span { color: var(--text-soft); font-size: 14px; font-weight: 650; }
.filter-bar--cards select { min-width: 180px; font-size: 14px; }
.problem-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.problem-card { height: 300px; min-width: 0; display: flex; flex-direction: column; padding: 22px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); transition: transform 140ms ease, border-color 140ms ease, background 140ms ease; }
.problem-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--surface-hover); }
.problem-card--solved { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.problem-card__top, .problem-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.problem-card__body { flex: 1; padding: 24px 0; }
.problem-card__body h2 { min-height: 53px; margin: 0 0 8px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 22px; line-height: 1.2; letter-spacing: -.025em; }
.problem-card__body p { min-height: 48px; margin: 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--text-soft); font-size: 15px; line-height: 1.6; }
.problem-card__body .tag-list { max-height: 52px; margin-top: 14px; overflow: hidden; }
.problem-card__footer { min-height: 40px; padding-top: 16px; border-top: 1px solid var(--border); }
.problem-card__score { color: var(--text-soft); font-family: var(--font-mono); font-size: 13px; }
.problem-card__status { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; font-size: 13px; font-weight: 500; line-height: 1; }
.problem-card__status i { position: relative; width: 15px; height: 15px; flex: 0 0 auto; display: inline-grid; place-items: center; border: 1.25px solid currentColor; border-radius: 50%; font-size: 11px; font-style: normal; line-height: 1; }
.problem-card__status--new { color: var(--text-muted); }
.problem-card__status--progress { color: var(--text-soft); font-weight: 600; }
.problem-card__status--progress i { color: var(--text-muted); }
.problem-card__status--progress i::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.problem-card__status--solved { gap: 7px; color: var(--success); font-size: 14px; font-weight: 700; }
.problem-card__status--solved i { width: 18px; height: 18px; border-color: color-mix(in srgb, var(--success) 50%, var(--border)); background: var(--success-soft); font-weight: 800; }
.problem-grid-empty { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); }

.problem-statement p, .constraint-list li { font-size: 15px; }
.problem-statement h2 { font-size: 13px; }
.example-block pre { font-size: 13px; }
.result-empty strong { font-size: 14px; }
.result-heading strong { font-size: 14px; }
.result-empty p { font-size: 12px; }
.result-heading p { font-size: 11px; }
.case { width: 22px; height: 22px; font-size: 10px; }
.history-entry summary strong { font-size: 15px; }
.admin-row { font-size: 13px; }
.admin-row > div strong { font-size: 15px; }
.admin-row > div span { font-size: 12px; }

/* Administrator readability and grading-case authoring */
.admin-stats span { font-size: 12px; }
.admin-table__head { font-size: 12px; letter-spacing: .055em; }
.admin-row { min-height: 76px; font-size: 13px; }
.admin-row .status-badge,
.admin-row .muted { font-size: 12px; }
.status-badge { padding: 4px 8px; font-size: 12px; }
.status-badge i { width: 6px; height: 6px; }
.section-nav > span { font-size: 11px; }
.section-nav a { padding-block: 9px; font-size: 12px; }
.section-number { font-size: 11px; }
.section-heading p,
.lock-notice p,
.validation-card p { font-size: 12px; }
.lock-notice strong,
.validation-card strong { font-size: 13px; }
.field > span,
.test-row label > span,
.field-label { font-size: 13px; }
.test-row textarea { font-size: 15px; }
.section-title-line,
.field-label { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.optional-badge {
    display: inline-flex;
    align-items: center;
    min-height: 21px;
    padding: 2px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
}

#id_tags label { gap: 8px; font-size: 13px; }
#id_tags input[type="checkbox"] {
    appearance: none;
    width: 15px;
    height: 15px;
    min-height: 0;
    display: inline-grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: var(--surface-1);
    cursor: pointer;
}
#id_tags input[type="checkbox"]::after {
    content: "";
    width: 7px;
    height: 4px;
    border-left: 2px solid var(--surface-1);
    border-bottom: 2px solid var(--surface-1);
    opacity: 0;
    transform: translateY(-1px) rotate(-45deg);
}
#id_tags input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
#id_tags input[type="checkbox"]:checked::after { opacity: 1; }
#id_tags input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#id_tags input[type="checkbox"]:disabled { border-color: var(--border); background: var(--surface-2); opacity: .55; cursor: not-allowed; }

.test-row__controls { display: flex; align-items: center; gap: 12px; }
.test-row__controls .row-remove { margin-left: auto; flex: 0 0 auto; }
.test-row--public { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 14px; padding: 14px; }
.public-type-field { width: min(260px, 100%); }
.public-type-field select { width: 100%; min-height: 42px; }
.test-row__columns,
.file-case-fields__content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.public-fields,
.file-case-fields { min-width: 0; }
.public-fields[hidden] { display: none; }
.file-case-fields { display: grid; gap: 12px; }
.file-case-fields__name { width: 100%; }
.file-case-fields__name input { width: 100%; }
.file-case-fields__content textarea { width: 100%; min-height: 112px; }
.test-row--file { grid-template-columns: 28px minmax(0, 1fr); align-items: start; padding: 14px; }
.test-row--file > .test-row__controls { min-height: 42px; flex-direction: column; justify-content: space-between; }
.test-row--file > .test-row__controls .row-remove { margin: 10px 0 0; }
.drag-handle { font-size: 15px; }
.row-remove { width: 28px; height: 28px; }

@media (max-width: 1200px) {
    .problem-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar--cards { flex-wrap: wrap; }
    .filter-bar--cards .filter-spacer { flex-basis: 100%; height: 0; }
    .filter-bar--cards select { min-width: 150px; }
    .progress-summary__bar { width: 180px; }
}
