:root {
    --signal-blue: #185adb;
    --signal-blue-dark: #1045ad;
    --packet-orange: #f36f21;
    --lab-paper: #f7f9fc;
    --panel: #ffffff;
    --ink: #17223b;
    --muted: #61708a;
    --wire: #d7dfea;
    --wire-dark: #aebbd0;
    --success: #16866b;
    --danger: #c23b42;
    --display: Bahnschrift, "Arial Narrow", sans-serif;
    --body: "Segoe UI Variable", "Segoe UI", sans-serif;
    --utility: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    --shadow: 0 18px 45px rgba(23, 34, 59, .09);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background-color: var(--lab-paper);
    background-image: linear-gradient(rgba(24, 90, 219, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(24, 90, 219, .035) 1px, transparent 1px);
    background-size: 28px 28px;
    font-family: var(--body);
    line-height: 1.55;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(243, 111, 33, .55); outline-offset: 3px; }
.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 99; padding: .75rem 1rem; background: var(--ink); color: #fff; }
.skip-link:focus { top: 1rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.site-header {
    position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr auto;
    align-items: center; min-height: 72px; padding: 0 clamp(1rem, 4vw, 4rem);
    border-bottom: 1px solid var(--wire); background: rgba(247, 249, 252, .94); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; gap: .7rem; align-items: center; text-decoration: none; font-family: var(--display); letter-spacing: -.03em; }
.brand b { font-size: 1.2rem; color: var(--signal-blue); }
.brand em { font-size: .78rem; font-style: normal; letter-spacing: .06em; color: var(--muted); }
.brand-mark { position: relative; width: 34px; height: 28px; display: inline-block; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 8px; width: 18px; height: 1px; background: var(--signal-blue); transform-origin: left; }
.brand-mark::before { top: 10px; transform: rotate(-24deg); }
.brand-mark::after { top: 17px; transform: rotate(24deg); }
.brand-mark i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--signal-blue); }
.brand-mark i:nth-child(1) { left: 0; top: 10px; }
.brand-mark i:nth-child(2) { right: 0; top: 2px; background: var(--packet-orange); }
.brand-mark i:nth-child(3) { right: 0; bottom: 2px; }
.primary-nav { justify-self: center; display: flex; gap: .25rem; }
.primary-nav a { padding: .65rem .9rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 650; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: var(--signal-blue-dark); background: #eaf0fd; }
.session-actions { display: flex; align-items: center; gap: .75rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.user-chip span { display: grid; line-height: 1.15; }
.user-chip small { color: var(--muted); font-family: var(--utility); font-size: .67rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: #fff; font-family: var(--display); font-weight: 700; }

#app-main { width: min(1240px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem) 0; }
.eyebrow { margin: 0 0 .7rem; color: var(--signal-blue); font-family: var(--utility); font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; font-family: var(--display); line-height: 1.08; letter-spacing: -.035em; }
h1 { max-width: 800px; margin-bottom: 1rem; font-size: clamp(2.3rem, 6vw, 5.5rem); font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3vw, 2.5rem); }
h3 { font-size: 1.2rem; }
.lede { max-width: 680px; margin: 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.2rem); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.page-heading h1 { font-size: clamp(2.2rem, 5vw, 4.4rem); }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: .5rem; padding: .68rem 1rem; border: 1px solid transparent; border-radius: 7px; cursor: pointer; text-decoration: none; font-weight: 700; }
.button-primary { background: var(--signal-blue); color: #fff; box-shadow: 0 6px 16px rgba(24, 90, 219, .2); }
.button-primary:hover { background: var(--signal-blue-dark); transform: translateY(-1px); }
.button-secondary { border-color: var(--wire-dark); background: #fff; color: var(--ink); }
.button-secondary:hover, .button-quiet:hover { border-color: var(--signal-blue); color: var(--signal-blue); }
.button-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button-danger { border-color: #f1c4c6; background: #fff3f3; color: var(--danger); }
.button[disabled] { opacity: .55; cursor: wait; transform: none; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .62fr); gap: clamp(2rem, 7vw, 7rem); align-items: center; min-height: 64vh; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.protocol-board { padding: 1.3rem; border: 1px solid var(--wire); border-radius: 18px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); }
.protocol-board header { display: flex; justify-content: space-between; margin-bottom: 1.5rem; color: var(--muted); font-family: var(--utility); font-size: .7rem; }
.packet-route { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: .5rem; }
.packet-node { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--wire-dark); border-radius: 50%; background: #fff; font-family: var(--utility); font-size: .65rem; }
.packet-node.active { border-color: var(--packet-orange); box-shadow: 0 0 0 5px rgba(243,111,33,.1); }
.packet-wire { position: relative; height: 2px; overflow: hidden; background: var(--wire); }
.packet-wire::after { content: ""; position: absolute; width: 18px; height: 2px; background: var(--signal-blue); animation: packet-run 2s linear infinite; }
.trace-log { display: grid; gap: .45rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--wire-dark); font-family: var(--utility); font-size: .7rem; color: var(--muted); }
.trace-log span::before { content: "›"; margin-right: .5rem; color: var(--success); }
@keyframes packet-run { from { left: -18px; } to { left: 100%; } }

.auth-layout { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(320px, 1fr); gap: clamp(2rem, 8vw, 8rem); align-items: center; min-height: 62vh; }
.auth-note { padding-left: 1rem; border-left: 3px solid var(--packet-orange); color: var(--muted); }
.form-panel, .detail-card, .attempt-panel { padding: clamp(1.4rem, 4vw, 2.5rem); border: 1px solid var(--wire); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.field { display: grid; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .82rem; font-weight: 700; }
.field small { color: var(--muted); }
.field input, .field select, .search-input { width: 100%; min-height: 44px; padding: .65rem .8rem; border: 1px solid var(--wire-dark); border-radius: 7px; background: #fff; color: var(--ink); }
.field textarea { width: 100%; padding: .7rem; resize: vertical; border: 1px solid var(--wire-dark); border-radius: 7px; color: var(--ink); font-family: var(--utility); font-size: .75rem; }
.field input:focus, .field select:focus, .search-input:focus { border-color: var(--signal-blue); box-shadow: 0 0 0 3px rgba(24,90,219,.1); outline: none; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.form-error { min-height: 1.5rem; color: var(--danger); font-size: .85rem; }

.catalog-toolbar { display: grid; grid-template-columns: 1fr 210px 160px auto; gap: .75rem; padding: 1rem; border: 1px solid var(--wire); border-radius: 12px; background: rgba(255,255,255,.8); }
.question-list { display: grid; gap: .7rem; margin-top: 1.2rem; }
.question-row { display: grid; grid-template-columns: 108px minmax(0, 1fr) 160px 100px 22px; gap: 1rem; align-items: center; padding: 1rem 1.1rem; border: 1px solid var(--wire); border-radius: 10px; background: #fff; text-decoration: none; transition: border-color .18s, transform .18s; }
.question-row:hover { border-color: var(--signal-blue); transform: translateX(3px); }
.question-alias { font-family: var(--utility); color: var(--signal-blue-dark); font-size: .78rem; font-weight: 700; }
.question-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.protocol-tag, .level-tag, .state-tag { width: fit-content; padding: .28rem .5rem; border-radius: 4px; font-family: var(--utility); font-size: .66rem; font-weight: 700; }
.protocol-tag { background: #eaf0fd; color: var(--signal-blue-dark); }
.level-tag { background: #f0f3f7; color: var(--muted); }
.level-tag[data-level="HARD"] { background: #fff0ea; color: #a3471a; }
.level-tag[data-level="EASY"] { background: #e9f6f2; color: #0d7058; }
.row-arrow { color: var(--packet-orange); font-size: 1.3rem; }
.catalog-heading { margin-bottom: 1.4rem; }
.catalog-heading h1 { margin-bottom: 0; font-size: clamp(2.2rem, 4vw, 3.8rem); }
.catalog-page .catalog-toolbar { grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, 1fr)) auto; align-items: end; padding: 1rem; border-radius: 14px; background: rgba(255,255,255,.92); box-shadow: 0 10px 28px rgba(23,34,59,.06); }
.catalog-page .catalog-toolbar label { display: grid; gap: .38rem; min-width: 0; color: var(--muted); font-size: .74rem; font-weight: 700; }
.catalog-page .catalog-toolbar label > span { padding-left: .1rem; }
.catalog-page .catalog-toolbar input,
.catalog-page .catalog-toolbar select { width: 100%; min-width: 0; min-height: 44px; padding: .65rem .75rem; border: 1px solid var(--wire-dark); border-radius: 8px; background: #fff; color: var(--ink); }
.catalog-page .catalog-toolbar select:disabled { background: #f1f4f8; color: #8a96a9; cursor: not-allowed; }
.catalog-page .catalog-toolbar input:focus,
.catalog-page .catalog-toolbar select:focus { border-color: var(--signal-blue); box-shadow: 0 0 0 3px rgba(24,90,219,.1); outline: 0; }
.catalog-actions { display: flex; gap: .35rem; }
.catalog-actions .button { white-space: nowrap; }
.catalog-status { margin: 1rem 0 .65rem; color: var(--muted); font-size: .86rem; }
.catalog-page .question-list { gap: .28rem; margin-top: 0; }
.catalog-page .question-row { grid-template-columns: 70px auto minmax(0, 1fr) auto 22px; gap: .7rem; min-height: 51px; padding: .65rem .85rem; border: 2px solid #dfe6f0; border-left-width: 4px; border-radius: 8px; box-shadow: none; }
.catalog-page .question-row:hover { border-color: #79a5ef; background: #f8fbff; transform: translateX(2px); }
.catalog-page .question-row[data-accepted="true"] { border-color: #57dca9; background: #effcf7; }
.catalog-page .question-row[data-accepted="true"]:hover { border-color: #20b984; background: #e8faf3; }
.question-qcode { overflow: hidden; padding: .22rem .42rem; border-radius: 4px; background: #f2f5fa; color: #536783; font-family: var(--utility); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.catalog-page .protocol-tag { padding: .25rem .62rem; border-radius: 999px; background: #eaf0fd; color: #174fae; white-space: nowrap; }
.catalog-page .protocol-tag[data-family="UDP"] { background: #dcfaed; color: #087454; }
.catalog-page .protocol-tag[data-family="RMI"] { background: #f1e7ff; color: #6c2bb8; }
.catalog-page .protocol-tag[data-family="WS"],
.catalog-page .protocol-tag[data-family="SOAP"] { background: #fff0dd; color: #9a4c0d; }
.catalog-page .protocol-tag[data-family="REST"] { background: #e4f6ff; color: #08729a; }
.catalog-page .protocol-tag[data-family="GRPC"] { background: #ffe8ef; color: #a82b56; }
.catalog-page .question-title { font-size: .9rem; }
.question-level { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.question-check { display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%; color: #059669; font-size: .62rem; font-weight: 800; }
.question-open { color: var(--wire-dark); font-size: 1.25rem; line-height: 1; }
.catalog-loading { display: grid; place-items: center; min-height: 220px; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1.2rem; color: var(--muted); font-size: .85rem; }
.pagination div { display: flex; gap: .5rem; }
.empty-state { padding: 3rem 1rem; border: 1px dashed var(--wire-dark); border-radius: 12px; text-align: center; color: var(--muted); }
.spaced-state, .admin-workspace { margin-top: 1.5rem; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 1.5rem; align-items: start; }
.detail-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.statement { font-size: 1rem; }
.statement code { padding: .15rem .35rem; border-radius: 4px; background: #edf1f7; font-family: var(--utility); font-size: .86em; }
.statement pre { overflow-x: auto; padding: 1rem; border-left: 3px solid var(--signal-blue); background: #f3f6fb; }
.side-panel { position: sticky; top: 96px; display: grid; gap: 1rem; }
.side-panel section { padding: 1.2rem; border: 1px solid var(--wire); border-radius: 12px; background: #fff; }
.side-panel dl { display: grid; grid-template-columns: auto 1fr; gap: .6rem .8rem; margin: 0; font-size: .84rem; }
.side-panel dt { color: var(--muted); }
.side-panel dd { margin: 0; text-align: right; font-family: var(--utility); font-size: .75rem; }
.communication-panel { margin-top: 1.5rem; padding: clamp(1rem, 2.5vw, 1.5rem); border: 1px solid var(--wire); border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(23, 34, 59, .06); }
.communication-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; }
.communication-header h2 { display: flex; align-items: center; gap: .65rem; margin: 0; font-family: var(--body); font-size: 1rem; letter-spacing: 0; }
.communication-header h2 span { color: var(--muted); font-family: var(--utility); }
.communication-refresh { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; font-size: 1.25rem; }
.communication-refresh:hover { background: #edf2fb; color: var(--signal-blue); }
.communication-refresh[disabled] { opacity: .45; cursor: wait; }
#question-communications { display: grid; gap: .75rem; }
.communication-entry { padding: 1rem; border: 1px solid var(--wire); border-radius: 10px; background: #fff; }
.communication-result { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .55rem; margin-bottom: .85rem; }
.communication-check { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%; color: var(--success); font-size: .66rem; font-weight: 800; }
.communication-verdict { padding: .25rem .65rem; border-radius: 999px; background: #dff5ec; color: #0c7058; font-size: .75rem; font-weight: 700; }
.communication-entry[data-verdict="rejected"] .communication-check { color: var(--danger); }
.communication-entry[data-verdict="rejected"] .communication-verdict { background: #fff0f0; color: var(--danger); }
.communication-result time { justify-self: end; color: var(--muted); font-family: var(--utility); font-size: .68rem; }
.communication-entry pre { margin: 0; overflow-x: auto; padding: .85rem; border-radius: 7px; background: #f6f8fb; color: #263249; font-family: var(--utility); font-size: .72rem; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.communication-entry pre span { color: var(--ink); font-weight: 700; }
.communication-empty, .communication-loading { display: grid; gap: .25rem; padding: 2rem 1rem; border: 1px dashed var(--wire-dark); border-radius: 9px; color: var(--muted); text-align: center; }
.communication-empty b { color: var(--ink); }
.version-list { display: grid; gap: .5rem; }
.admin-exam-builder { margin-top: 1rem; border: 1px solid var(--wire); border-radius: 12px; background: #fff; }
.admin-exam-builder summary { padding: 1rem; cursor: pointer; font-weight: 700; }
.admin-exam-builder .form-panel { box-shadow: none; border: 0; border-top: 1px solid var(--wire); border-radius: 0; }
.exam-template-form { display: grid; gap: 1.25rem; }
.exam-basics { display: grid; grid-template-columns: 1fr 1.5fr repeat(3, minmax(130px, .7fr)); gap: .8rem; }
.exam-basics .field { margin: 0; }
.exam-mode { min-width: 0; margin: 0; padding: 0; border: 0; }
.exam-mode legend { margin-bottom: .55rem; font-size: .82rem; font-weight: 700; }
.exam-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.exam-mode-options label { position: relative; display: block; cursor: pointer; }
.exam-mode-options input { position: absolute; opacity: 0; pointer-events: none; }
.exam-mode-options span { display: grid; gap: .15rem; min-height: 76px; padding: 1rem 1rem 1rem 3rem; border: 1px solid var(--wire); border-radius: 11px; background: #fff; }
.exam-mode-options span::before { content: ""; position: absolute; top: 1.15rem; left: 1rem; width: 15px; height: 15px; border: 1px solid var(--wire-dark); border-radius: 50%; background: #fff; }
.exam-mode-options input:checked + span { border-color: var(--signal-blue); background: #f3f7ff; box-shadow: inset 4px 0 0 var(--signal-blue); }
.exam-mode-options input:checked + span::before { border: 4px solid var(--signal-blue); }
.exam-mode-options input:focus-visible + span { outline: 3px solid rgba(243,111,33,.55); outline-offset: 3px; }
.exam-mode-options small { color: var(--muted); font-weight: 400; }
.exam-mode-panel[hidden] { display: none; }
.random-exam-intro { display: grid; gap: .2rem; margin-bottom: .8rem; color: var(--muted); font-size: .84rem; }
.random-exam-intro b { color: var(--ink); }
.random-exam-slots { display: grid; gap: .55rem; }
.random-exam-slot { display: grid; grid-template-columns: 34px 1fr 1.35fr; align-items: end; gap: .75rem; padding: .75rem; border: 1px solid var(--wire); border-radius: 10px; background: #f9fbfe; }
.random-slot-number { display: grid; place-items: center; align-self: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff; font-family: var(--utility); font-size: .72rem; font-weight: 700; }
.random-exam-slot label { display: grid; gap: .3rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
.random-exam-slot select { width: 100%; min-width: 0; min-height: 42px; padding: .55rem .65rem; border: 1px solid var(--wire-dark); border-radius: 7px; background: #fff; color: var(--ink); }
.random-exam-slot select:disabled { background: #eef2f7; color: #8a96a9; cursor: not-allowed; }
.admin-user-panel { padding: 1rem; border-top: 1px solid var(--wire); }
.admin-user-panel > label { display: block; margin-bottom: .4rem; font-weight: 700; }
.admin-user-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--wire); border-radius: 12px; background: var(--panel); }
.admin-user-row > div { display: grid; gap: .25rem; min-width: 0; }
.admin-user-row code { width: fit-content; }
.admin-user-row small { color: var(--muted); }
.admin-exam-list { display: grid; gap: .65rem; padding: 1rem; border-top: 1px solid var(--wire); }
.admin-exam-list .boot-state { min-height: 160px; }
.admin-exam-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--wire); border-radius: 11px; background: #fff; }
.admin-exam-code, .admin-exam-name { display: grid; gap: .2rem; min-width: 0; }
.admin-exam-code span { color: var(--signal-blue-dark); font-family: var(--utility); font-size: .78rem; font-weight: 700; }
.admin-exam-code small, .admin-exam-name small { color: var(--muted); }
.admin-exam-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-exam-actions { display: flex; gap: .45rem; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.exam-card { padding: 1.5rem; border: 1px solid var(--wire); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.exam-card dl { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
.exam-card dt { color: var(--muted); }
.exam-card dd { margin: 0; font-family: var(--utility); font-size: .8rem; }
.score-strip { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding: 1rem 1.2rem; border-radius: 10px; background: var(--ink); color: #fff; }
.score-strip b { font-family: var(--display); font-size: 1.4rem; }

.exam-workspace { width: min(1120px, 100%); margin: 0 auto; }
.exam-session-header { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1rem; }
.exam-session-header h1 { margin-bottom: .45rem; font-size: clamp(2rem, 4vw, 3.4rem); }
.exam-session-header p:last-child { margin: 0; color: var(--muted); }
.exam-clock { flex: 0 0 auto; min-width: 150px; padding: .8rem 1rem; border: 1px solid #bcd0f5; border-radius: 12px; background: #f4f8ff; text-align: right; }
.exam-clock > span { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.exam-clock .countdown { display: block; color: var(--signal-blue-dark); line-height: 1.1; }
.exam-progress { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 1px; overflow: hidden; margin-bottom: 1.25rem; border: 1px solid var(--wire); border-radius: 12px; background: var(--wire); }
.exam-progress > div { display: grid; min-width: 110px; padding: .75rem 1rem; background: var(--ink); color: #fff; }
.exam-progress > div b { font-family: var(--display); font-size: 1.25rem; }
.exam-progress > div span { color: #bfc9da; font-size: .72rem; }
.exam-progress nav { display: flex; align-items: stretch; justify-content: flex-end; gap: .35rem; padding: .55rem; background: #fff; }
.exam-question-jump { display: grid; place-items: center; min-width: 58px; padding: .3rem .55rem; border: 1px solid var(--wire); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.exam-question-jump span { font-family: var(--utility); font-size: .78rem; font-weight: 700; }
.exam-question-jump small { color: var(--muted); font-size: .62rem; }
.exam-question-jump[data-state="accepted"] { border-color: #8dd9c3; background: #eaf8f3; color: #0c7058; }
.exam-question-jump[data-state="judged"] { border-color: #f0b99f; background: #fff3ed; color: #9a461e; }
.exam-question-list { display: grid; gap: .85rem; }
.exam-question { scroll-margin-top: 92px; overflow: hidden; border: 1px solid var(--wire); border-radius: 14px; background: #fff; box-shadow: 0 8px 24px rgba(23,34,59,.045); }
.exam-question[open] { border-color: #a9c3f1; box-shadow: 0 12px 30px rgba(24,90,219,.08); }
.exam-question > summary { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto auto 24px; align-items: center; gap: 1rem; min-height: 78px; padding: 1rem 1.15rem; cursor: pointer; list-style: none; }
.exam-question > summary::-webkit-details-marker { display: none; }
.exam-question > summary:hover { background: #f8faff; }
.exam-question-number { color: var(--signal-blue-dark); font-family: var(--utility); font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.exam-question-heading { display: grid; min-width: 0; }
.exam-question-heading b { overflow: hidden; font-family: var(--display); font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; }
.exam-question-heading small { color: var(--muted); font-family: var(--utility); font-size: .68rem; }
.exam-verdict { padding: .3rem .55rem; border-radius: 5px; background: #f0f3f7; color: var(--muted); font-family: var(--utility); font-size: .65rem; font-weight: 700; }
.exam-verdict[data-state="accepted"] { background: #e0f5ed; color: #0c7058; }
.exam-verdict[data-state="judged"] { background: #fff0e9; color: #99441c; }
.exam-chevron { color: var(--muted); font-size: 1.25rem; transition: transform .18s ease; }
.exam-question[open] .exam-chevron { transform: rotate(180deg); }
.exam-question-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.2rem; padding: 1.25rem; border-top: 1px solid var(--wire); }
.exam-question-body > article { min-width: 0; }
.exam-statement { font-size: .96rem; }
.exam-statement > :first-child { margin-top: 0; }
.exam-statement > :last-child { margin-bottom: 0; }
.exam-connection { align-self: start; display: grid; gap: .85rem; padding: 1rem; border: 1px solid #cbd8ed; border-radius: 11px; background: #f7faff; }
.exam-connection > div { display: grid; gap: .18rem; }
.exam-connection span { color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.exam-connection code, .exam-connection strong { overflow-wrap: anywhere; font-family: var(--utility); font-size: .78rem; }
.exam-connection > div:first-child code { color: var(--signal-blue-dark); font-size: 1.05rem; font-weight: 800; letter-spacing: .04em; }
.exam-review-locked { display: grid; gap: .3rem; padding: 2rem; border: 1px dashed var(--wire-dark); border-radius: 9px; color: var(--muted); text-align: center; }
.exam-review-locked b { color: var(--ink); }
.exam-session-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; padding: 1rem 1.2rem; border-top: 1px solid var(--wire); }
.exam-session-footer p { margin: 0; color: var(--muted); }

.attempt-route { margin: 1.5rem 0; padding: 1.4rem; border-radius: 12px; background: #f3f6fb; }
.attempt-code { display: block; margin: .7rem 0; padding: .8rem; border: 1px dashed var(--signal-blue); border-radius: 7px; background: #fff; color: var(--signal-blue-dark); font-family: var(--utility); font-size: 1.05rem; word-break: break-all; }
.status-line { display: flex; align-items: center; gap: .7rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--packet-orange); box-shadow: 0 0 0 5px rgba(243,111,33,.1); }
.status-dot.done { background: var(--success); box-shadow: 0 0 0 5px rgba(22,134,107,.1); }
.status-dot.failed { background: var(--danger); }
.countdown { font-family: var(--utility); font-size: 1.8rem; font-weight: 700; }

.boot-state { display: grid; place-items: center; align-content: center; min-height: 55vh; color: var(--muted); }
.packet-loader { width: 70px; height: 2px; background: var(--wire); position: relative; }
.packet-loader::after { content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--packet-orange); animation: packet-run 1s linear infinite; }
.site-footer { display: flex; justify-content: space-between; padding: 1.3rem clamp(1rem,4vw,4rem); border-top: 1px solid var(--wire); color: var(--muted); font-family: var(--utility); font-size: .68rem; }
#system-status i { display: inline-block; width: 7px; height: 7px; margin-right: .4rem; border-radius: 50%; background: var(--packet-orange); }
#system-status.online i { background: var(--success); }

@media (max-width: 720px) {
    .admin-user-row { grid-template-columns: 1fr auto; }
    .admin-user-row .button { grid-column: 1 / -1; }
}
.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: grid; gap: .5rem; }
.toast { max-width: 360px; padding: .85rem 1rem; border-left: 4px solid var(--signal-blue); border-radius: 7px; background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--packet-orange); }

@media (max-width: 800px) {
    .site-header { grid-template-columns: 1fr auto; }
    .primary-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; padding: .5rem; border-top: 1px solid var(--wire); background: #fff; }
    .primary-nav a { flex: 1; text-align: center; font-size: .78rem; }
    .hero, .auth-layout, .detail-layout { grid-template-columns: 1fr; }
    .hero { min-height: auto; }
    .page-heading { align-items: start; flex-direction: column; gap: .7rem; }
    .catalog-toolbar { grid-template-columns: 1fr 1fr; }
    .catalog-toolbar .search-input { grid-column: 1 / -1; }
    .catalog-page .catalog-toolbar { grid-template-columns: 1fr 1fr; align-items: end; }
    .catalog-page .catalog-search { grid-column: 1 / -1; }
    .catalog-actions { align-self: stretch; }
    .question-row { grid-template-columns: 85px 1fr auto; }
    .question-row .protocol-tag { grid-column: 2; }
    .question-row .level-tag { grid-column: 3; grid-row: 1; }
    .row-arrow { display: none; }
    .catalog-page .question-row { grid-template-columns: 70px auto minmax(0, 1fr) 18px; }
    .catalog-page .question-level { display: none; }
    .side-panel { position: static; }
    .site-footer { margin-bottom: 58px; flex-direction: column; gap: .3rem; }
    .exam-basics { grid-template-columns: 1fr 1fr; }
    .admin-exam-row { grid-template-columns: 1fr auto; }
    .admin-exam-name { grid-column: 1 / -1; grid-row: 2; }
    .admin-exam-actions { grid-column: 1 / -1; }
    .exam-session-header { align-items: stretch; flex-direction: column; gap: 1rem; }
    .exam-clock { text-align: left; }
    .exam-progress { grid-template-columns: 1fr 1fr; }
    .exam-progress nav { grid-column: 1 / -1; justify-content: flex-start; overflow-x: auto; }
    .exam-question > summary { grid-template-columns: 64px minmax(0, 1fr) auto 20px; gap: .65rem; }
    .exam-question > summary .protocol-tag { grid-column: 2; grid-row: 2; }
    .exam-verdict { grid-column: 3; grid-row: 1 / span 2; }
    .exam-chevron { grid-column: 4; grid-row: 1 / span 2; }
    .exam-question-body { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    #app-main { width: min(100% - 1.2rem, 1240px); padding-top: 2rem; }
    .session-actions .button { padding-inline: .65rem; font-size: .8rem; }
    .user-chip span { display: none; }
    .catalog-toolbar { grid-template-columns: 1fr; }
    .catalog-toolbar .search-input { grid-column: auto; }
    .catalog-page .catalog-toolbar { grid-template-columns: 1fr; }
    .catalog-page .catalog-search { grid-column: auto; }
    .catalog-actions .button-primary { flex: 1; }
    .question-row { grid-template-columns: 1fr auto; gap: .4rem; }
    .question-title { grid-column: 1 / -1; grid-row: 2; }
    .question-row .protocol-tag { grid-column: 1; grid-row: 3; }
    .question-row .level-tag { grid-column: 2; grid-row: 1; }
    .catalog-page .question-row { grid-template-columns: 64px minmax(0, 1fr) 18px; gap: .5rem; }
    .catalog-page .question-row .protocol-tag { grid-column: 2; grid-row: 1; }
    .catalog-page .question-title { grid-column: 1 / -1; grid-row: 2; padding-left: 0; }
    .catalog-page .question-check, .catalog-page .question-open { grid-column: 3; grid-row: 1; }
    .communication-result { grid-template-columns: auto 1fr; }
    .communication-result time { grid-column: 1 / -1; justify-self: start; }
    .exam-basics, .exam-mode-options { grid-template-columns: 1fr; }
    .random-exam-slot { grid-template-columns: 34px 1fr; }
    .random-exam-slot label:last-child { grid-column: 2; }
    .admin-exam-row { grid-template-columns: 1fr; }
    .admin-exam-row .state-tag, .admin-exam-name, .admin-exam-actions { grid-column: 1; grid-row: auto; }
    .admin-exam-actions .button { flex: 1; }
    .exam-question > summary { grid-template-columns: 1fr auto; align-items: start; }
    .exam-question-number { grid-column: 1; }
    .exam-question-heading { grid-column: 1 / -1; grid-row: 2; }
    .exam-question > summary .protocol-tag { grid-column: 1; grid-row: 3; }
    .exam-verdict { grid-column: 2; grid-row: 1; }
    .exam-chevron { grid-column: 2; grid-row: 3; }
    .exam-question-body { padding: .9rem; }
    .exam-session-footer { align-items: stretch; flex-direction: column; }
}

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