:root {
  color-scheme: light;
  --wine: #790d2a;
  --wine-dark: #550b20;
  --gold: #a77937;
  --paper: #fdfbf7;
  --ink: #282526;
  --muted: #655e5b;
  --line: #e6dcd2;
  --pink: #f5e9eb;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
#lex-exam-root { color: var(--ink); background: var(--paper); font: 16px/1.52 var(--sans); }
h1, h2, h3, p, dl, dd { margin: 0; }
button { font: inherit; }
a { color: var(--wine); text-decoration: none; }
:focus-visible { outline: 3px solid #976818; outline-offset: 4px; }
h1[tabindex]:focus, main:focus { outline: none; }
.symbols { position: absolute; width: 0; height: 0; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.wrap { width: min(100% - 56px, 1100px); margin: 0 auto; }
.skip { position: fixed; z-index: 10; left: 16px; top: 12px; transform: translateY(-150%); border-radius: 8px; background: #fff; padding: 12px 16px; }
.skip:focus { transform: none; }

.site-header { background: #f9f5ed; border-bottom: 1px solid var(--line); position: sticky; z-index: 5; top: 0; }
.header-inner { min-height: 73px; display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.brand { display: inline-flex; }
.brand img { display: block; width: 180px; height: auto; }
.home-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.home-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.home-link .icon { width: 16px; height: 16px; }
.live-tools { display: flex; gap: 12px; align-items: center; }
.timebox { display: flex; align-items: center; gap: 8px; color: var(--wine); background: white; border: 1px solid #e5ccd2; border-radius: 8px; padding: 7px 12px; }
.timebox.near-end { color: #842c23; background: #fff1e9; border-color: #d89886; }
.timebox strong { font-size: 1.27rem; font-variant-numeric: tabular-nums; min-width: 3.1em; }
.time-label { font-size: .78rem; font-weight: 700; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 14px; border: 1px solid transparent; border-radius: 7px; font-weight: 700; line-height: 1.25; font-size: .86rem; cursor: pointer; text-align: center; }
.button .icon { width: 17px; height: 17px; }
.primary { color: #fff; background: var(--wine); border-color: var(--wine); }
.primary:hover:not(:disabled) { background: var(--wine-dark); }
.outline { color: var(--wine); border-color: #e0cbd0; background: #fff; }
.outline:hover:not(:disabled) { background: var(--pink); }
.button:disabled { color: #746c68; border-color: #e9e3dd; background: #faf8f5; cursor: default; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 22px #54382008; }

.welcome { background: linear-gradient(112deg, #fcf8f0, #f3e9dc); border-bottom: 1px solid var(--line); min-height: min(585px, 75vh); display: grid; align-items: center; }
.welcome-grid { display: grid; grid-template-columns: 1.17fr 1fr; gap: clamp(25px, 5vw, 70px); align-items: start; padding-block: 35px 42px; }
.kicker { color: var(--wine); display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; font-size: .83rem; font-weight: 750; }
.kicker::before { content: ''; width: 23px; height: 2px; margin-right: 2px; background: var(--gold); }
.welcome h1 { color: var(--wine); font: 500 clamp(2.45rem, 4.7vw, 4rem)/1.01 var(--serif); letter-spacing: -.047em; margin-top: 12px; scroll-margin-top: 87px; }
.lead { max-width: 465px; color: var(--muted); margin-top: 17px; font-size: 1.04rem; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 0 21px; padding: 0; list-style: none; }
.facts li { display: flex; align-items: center; gap: 6px; font-size: .83rem; font-weight: 700; }
.facts .icon { color: var(--wine); width: 17px; height: 17px; }
.start-button { width: 100%; min-height: 50px; margin-top: 14px; padding-inline: 18px; }
.setup-note { color: var(--muted); font-size: .81rem; margin-top: 9px; }
.setup-note.error { color: #872c24; }
#retry-load, #back-to-result { margin-top: 10px; }
.rules { padding: clamp(16px, 3vw, 25px); background: #fffdf9; }
.rules h2, .candidate-card h2, .progress-heading h2, .results-heading h2, .dialog h2 { font: 500 1.7rem/1.1 var(--serif); color: var(--wine); letter-spacing: -.026em; }
.rule-topic { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 11px; align-items: center; padding: 14px 0; }
.rule-topic + .rule-topic { border-top: 1px solid var(--line); }
.rule-topic h3 { font-size: .89rem; }
.rule-topic h3 span { color: var(--wine); }
.rule-topic p, .rules-list, .selection-note { color: var(--muted); font-size: .82rem; }
.iconbox { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 9px; background: var(--pink); color: var(--wine); }
.selection-note { margin-bottom: 10px; }
.rules-list { margin: 0; padding: 11px 0 0 18px; border-top: 1px solid var(--line); }
.rules-list li + li { margin-top: 6px; }

.candidate-card { margin-top: 16px; padding: clamp(17px, 3vw, 28px); }
.candidate-card h2 { font-size: clamp(1.65rem, 3vw, 2.1rem); }
.candidate-intro { margin: 6px 0 16px; color: var(--muted); font-size: .89rem; }
.candidate-fields { display: grid; gap: 10px; }
.candidate-field { display: grid; gap: 4px; min-width: 0; }
.candidate-field label { color: var(--ink); font-size: .86rem; font-weight: 700; }
.candidate-field input { width: 100%; min-height: 44px; border: 1px solid #cdbeb2; border-radius: 7px; padding: 8px 11px; background: #fffefa; font: inherit; color: var(--ink); }
.candidate-field input::placeholder { color: #756961; font-size: .82rem; }
.candidate-field input[aria-invalid="true"] { border-color: #a13e31; }
.field-hint, .field-error, .candidate-purpose { color: var(--muted); font-size: .78rem; }
.field-error { color: #872c24; font-weight: 600; }
.candidate-purpose { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 13px; }

.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 306px; gap: 18px; padding-block: 27px 48px; align-items: start; }
.question-panel { padding: clamp(16px, 2.8vw, 29px); }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topic-label { color: var(--wine); background: var(--pink); font-size: .78rem; font-weight: 750; border-radius: 6px; padding: 4px 8px; }
.question-number { color: var(--muted); font-weight: 680; font-size: .83rem; }
.question-area { color: var(--muted); font-size: .81rem; margin-top: 12px; }
.question-title { font: 500 clamp(1.47rem, 2.65vw, 2rem)/1.18 var(--serif); letter-spacing: -.023em; margin-top: 4px; scroll-margin-top: 104px; }
.passage { font: 1.04rem/1.53 var(--serif); color: #4c3831; border-left: 3px solid var(--gold); border-radius: 0 7px 7px 0; background: #faf5ec; margin: 14px 0 0; padding: 11px 14px; }
.choices { display: grid; gap: 8px; margin-top: 16px; }
.choice { display: grid; grid-template-columns: 29px minmax(0, 1fr) 17px; align-items: center; width: 100%; min-height: 49px; padding: 8px 10px; text-align: left; gap: 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; cursor: pointer; font-size: .94rem; }
.choice:hover:not(:disabled), .choice[aria-pressed="true"] { border-color: var(--wine); }
.choice[aria-pressed="true"] { background: #fbf0f2; color: var(--wine-dark); }
.choice:disabled { cursor: wait; }
.choice-letter { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 5px; background: #f4ede5; color: #69432f; font-size: .79rem; font-weight: 750; }
.choice[aria-pressed="true"] .choice-letter { background: var(--wine); color: #fff; }
.choice .icon { width: 17px; height: 17px; visibility: hidden; }
.choice[aria-pressed="true"] .icon { visibility: visible; }
.choice-actions, .question-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.choice-actions { margin-top: 5px; }
.text-button { display: inline-flex; gap: 5px; align-items: center; min-height: 40px; border: 0; padding: 3px 0; background: transparent; color: var(--wine); font-weight: 650; font-size: .81rem; cursor: pointer; }
.text-button:disabled { color: #746c68; cursor: default; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.flag-button[aria-pressed="true"] { color: #835315; }
.flag-button .icon { width: 16px; height: 16px; }
.operation-status { min-height: 1.4em; color: var(--muted); font-size: .78rem; }
.operation-status.error { color: #8a3328; font-weight: 650; }
.question-actions { border-top: 1px solid var(--line); padding-top: 13px; margin-top: 8px; }

.progress-panel { padding: 16px; }
.progress-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.progress-heading h2 { font-size: 1.45rem; }
#progress-count { color: var(--wine); font-size: .82rem; font-weight: 700; }
.meter { height: 6px; background: #eee6dc; border-radius: 5px; overflow: hidden; margin-top: 10px; }
.meter span { display: block; width: var(--fill, 0%); height: 100%; border-radius: inherit; background: var(--wine); }
.map-section { margin-top: 13px; }
.map-section h3 { margin: 0 0 6px; font-size: .79rem; }
.map-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.map-button { min-height: 31px; position: relative; padding: 1px; border: 1px solid var(--line); border-radius: 5px; background: #fdfaf6; color: #5b4b45; font-weight: 750; font-size: .77rem; cursor: pointer; }
.map-button:hover { border-color: var(--wine); }
.map-button.answered { color: var(--wine); border-color: #ddbec6; background: var(--pink); }
.map-button[aria-current="step"] { background: var(--wine); border-color: var(--wine); color: white; }
.map-button.flagged::after, .key-flagged { content: ''; background: #ae701d; border-radius: 50%; }
.map-button.flagged::after { position: absolute; right: 4px; top: 4px; width: 5px; height: 5px; }
.map-button.flagged[aria-current="step"]::after { background: #f8d18e; }
.map-key { display: flex; flex-wrap: wrap; list-style: none; gap: 4px 9px; margin: 13px 0 0; padding: 0; font-size: .72rem; color: var(--muted); }
.map-key li { display: flex; align-items: center; gap: 4px; }
.map-key span { width: 8px; height: 8px; }
.key-active { background: var(--wine); }
.key-answered { background: var(--pink); border: 1px solid #b78191; }
.key-blank { background: #fdfaf6; border: 1px solid #a39387; }

.results { padding-block: 28px 48px; }
.score-panel { display: grid; grid-template-columns: 145px minmax(0, 1fr); align-items: center; gap: 27px; padding: clamp(17px, 3vw, 30px); }
.score-ring { border-radius: 50%; aspect-ratio: 1; display: grid; align-content: center; text-align: center; background: radial-gradient(closest-side, white 83%, transparent 84%), conic-gradient(var(--wine) var(--fill, 0%), #efe4d9 0); }
.score-value { font: 500 clamp(1.65rem, 4vw, 2.8rem)/1 var(--serif); color: var(--wine); }
.score-unit { color: var(--muted); margin-top: 4px; font-size: .72rem; }
.score-copy h1 { font: 500 clamp(1.85rem, 4vw, 2.9rem)/1.04 var(--serif); color: var(--wine); letter-spacing: -.036em; margin-top: 4px; }
.score-stats { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 14px; }
.score-stats div { min-width: 65px; padding: 4px 10px; background: #f7f2eb; border-radius: 6px; }
.score-stats dt { font-size: .77rem; color: var(--muted); }
.score-stats dd { font-weight: 750; font-variant-numeric: tabular-nums; }
.score-stats .net-stat { background: var(--pink); color: var(--wine); }
.formula { font-size: .82rem; color: var(--muted); margin-top: 9px; }
.results-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 23px 0 12px; }
.results-heading p { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.topic-results { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.topic-results section { padding: 15px; }
.topic-results h3 { font: 500 1.35rem/1.12 var(--serif); color: var(--wine); margin-bottom: 8px; }
.topic-row { border-top: 1px solid var(--line); padding: 8px 0; }
.topic-row strong { font-size: .84rem; }
.topic-row p { color: var(--muted); font-size: .78rem; }

.site-footer { border-top: 1px solid var(--line); background: #fff; }
.footer-inner { display: flex; justify-content: space-between; gap: 5px 14px; flex-wrap: wrap; padding-block: 16px; color: var(--muted); font-size: .77rem; }
.footer-dot { color: var(--gold); padding-inline: 3px; }
.dialog { width: min(100% - 30px, 430px); border: 1px solid var(--line); border-radius: 12px; padding: 21px; color: var(--ink); background: #fff; }
.dialog::backdrop { background: #25191bb3; }
.dialog p { margin-top: 10px; color: var(--muted); font-size: .89rem; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 17px; }

@media (max-width: 850px) {
  .exam-layout { grid-template-columns: minmax(0, 1fr) 255px; gap: 11px; }
  .welcome-grid { grid-template-columns: 1.1fr 1fr; gap: 22px; }
}
@media (max-width: 660px) {
  .wrap { width: min(100% - 28px, 1100px); }
  .header-inner { min-height: 61px; gap: 6px; }
  .brand img { width: 128px; }
  .home-link { font-size: .76rem; }
  .live-tools { gap: 5px; }
  .timebox { gap: 4px; padding: 5px 6px; }
  .timebox .icon { width: 15px; height: 15px; }
  .timebox strong { font-size: 1.03rem; min-width: auto; }
  .time-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .header-submit { padding-inline: 7px; font-size: .73rem; }
  .welcome-grid { grid-template-columns: 1fr; gap: 16px; padding-block: 25px; }
  .candidate-card { margin-top: 0; }
  .lead { font-size: .94rem; margin-top: 13px; }
  .exam-layout { grid-template-columns: minmax(0, 1fr); padding-block: 15px 31px; }
  .map-button { min-height: 40px; }
  .topic-results { grid-template-columns: 1fr; }
  .score-panel { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
  .score-stats { gap: 4px; }
  .score-stats div { min-width: 40px; padding-inline: 6px; }
  .score-stats dt { font-size: .69rem; }
  .results-heading { flex-wrap: wrap; }
}
@media (max-width: 350px) {
  .brand img { width: 108px; }
  .welcome h1 { font-size: 2.35rem; }
  .question-actions .button { padding-inline: 7px; }
}
.choice[aria-disabled="true"] { cursor: wait; }
