/*
 * Страница варианта и результата.
 *
 * По макету exam_full.html: полоса с таймером, липкий лист ответов слева,
 * колонка заданий справа. Условие, общий текст, рисунки и таблицы рисуются
 * теми же компонентами, что на странице задачи, поэтому рядом подключён
 * task.css — здесь только каркас варианта и то, чего у одиночной задачи нет:
 * клетки листа, части, флажки, итог.
 */

  /* ============ ПОЛОСА СВЕРХУ ============ */
  .exam-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(250, 250, 250, 0.88);
    border-bottom: 1px solid var(--border);
  }
  .exam-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 13px 28px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
  }
  .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    transition: all 0.2s;
    width: fit-content;
  }
  .back-btn:hover { background: var(--surface-2); }
  .back-btn .mi { font-size: 15px; }

  .exam-info { display: flex; align-items: center; gap: 14px; }
  .exam-info .ttl {
    font-family: "Instrument Serif", serif;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .exam-info .ttl em { font-style: italic; color: var(--accent); }
  .exam-info .sep { width: 1px; height: 22px; background: var(--border-strong); }
  .exam-info .meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
  .exam-info .meta b { color: var(--ink); font-weight: 600; }

  .timer-wrap { justify-self: end; display: flex; align-items: center; gap: 14px; }
  .exam-bar .btn-ghost {
    padding: 9px 16px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--ink-2);
    border: 1px solid var(--border);
  }
  .exam-bar .btn-ghost:hover { background: var(--surface-3); }
  .progress-mini { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
  .progress-mini .v { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
  .progress-mini-bar {
    width: 90px; height: 6px;
    background: var(--surface-3);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
  }
  .progress-mini-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    width: var(--w, 0%);
    background: linear-gradient(90deg, var(--accent), var(--pink));
    border-radius: 99px;
    transition: width 0.3s;
  }

  .timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 11px;
    border-radius: 999px;
    background: var(--ink);
    color: white;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  }
  .timer.late { background: var(--red); }
  .timer.soon { background: var(--orange); }
  .timer .clock-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.85);
    position: relative;
    flex-shrink: 0;
  }
  .timer .clock-icon::before {
    content: "";
    position: absolute;
    top: 2px; left: 50%;
    width: 1.5px; height: 6px;
    background: white;
    transform-origin: bottom;
    animation: tickMin 60s steps(60) infinite;
  }
  .timer .clock-icon::after {
    content: "";
    position: absolute;
    top: 4px; left: 50%;
    width: 1.5px; height: 4px;
    background: white;
    transform-origin: bottom;
    animation: tickSec 6s linear infinite;
  }
  @keyframes tickMin { to { transform: translateX(-50%) rotate(360deg); } }
  @keyframes tickSec { to { transform: translateX(-50%) rotate(360deg); } }
  .timer .time { font-family: "Geist Mono", monospace; font-size: 15px; letter-spacing: 0.02em; }

  /* ============ КАРКАС ============ */
  .workspace {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 28px 60px;
    position: relative;
    z-index: 1;
  }
  .mock-form, .workspace.result {
    display: grid;
    grid-template-columns: 232px 1fr;
    gap: 28px;
  }
  .workspace.result { padding-top: 24px; }
  .mock-form { padding: 0; }

  /* ============ ЛИСТ ОТВЕТОВ ============ */
  .sheet {
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 20px 18px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }
  .sheet::-webkit-scrollbar { width: 4px; }
  .sheet::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
  .sheet-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
  .sheet-h h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .sheet-h .count { font-family: "Geist Mono", monospace; font-size: 12px; color: var(--muted); }
  .sheet-h .count b { color: var(--ink); font-weight: 600; }
  .sheet-divider {
    margin: 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: "Geist Mono", monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }
  .sheet-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

  .q-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .q-cell {
    aspect-ratio: 1;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1.5px solid transparent;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--ink-2);
    transition: all 0.15s;
    position: relative;
  }
  .q-cell:hover { background: var(--surface-3); transform: translateY(-1px); }
  .q-cell.done { background: var(--accent-50); color: var(--accent-700); }
  .q-cell.done::after {
    content: "";
    position: absolute;
    top: 3px; right: 3px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--green);
  }
  .q-cell.flag { background: var(--yellow-soft); color: #946d00; }
  .q-cell.flag::after {
    content: "";
    position: absolute;
    top: 2px; right: 2px;
    width: 0; height: 0;
    border-style: solid;
    border-width: 0 0 7px 7px;
    border-color: transparent transparent var(--yellow) transparent;
  }
  .q-cell.empty { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--muted-2); }
  .q-cell.empty:hover { transform: none; }
  .q-cell.viewing { background: var(--ink); color: white; border-color: var(--ink); box-shadow: 0 4px 10px rgba(0,0,0,0.18); }


  .legend {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 11.5px;
  }
  .legend-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
  .legend-row .swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); flex-shrink: 0; }
  .swatch.done { background: var(--accent-50); }
  .swatch.flag { background: var(--yellow-soft); }
  .swatch.empty { background: transparent; border: 1px dashed var(--border-strong); }
  /* номер на слух: пустой, как «нет задачи», но зачёркнут — пропущен нарочно */
  .q-cell.skip { text-decoration: line-through; text-decoration-color: var(--muted-2); }
  .swatch.empty.skip { background: repeating-linear-gradient(135deg, transparent 0 2px, var(--border-strong) 2px 3px); }

  /* вердикты на листе результата */
  .q-cell.v-right, .legend-row .swatch.v-right { background: var(--green-soft); color: var(--green); }
  .q-cell.v-partial, .legend-row .swatch.v-partial { background: var(--yellow-soft); color: #946d00; }
  .q-cell.v-wrong, .legend-row .swatch.v-wrong { background: var(--red-soft); color: var(--red); }
  .q-cell.v-empty, .legend-row .swatch.v-empty { background: var(--surface-3); color: var(--muted); }
  .q-cell.v-unknown, .legend-row .swatch.v-unknown { background: var(--blue-soft); color: var(--blue); }

  .stats-mini {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: 10px;
    font-size: 12px;
  }
  .stats-mini .row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
  .stats-mini .row b { font-weight: 600; color: var(--ink); font-family: "Geist Mono", monospace; font-size: 13px; }

  /* ============ КОЛОНКА ЗАДАНИЙ ============ */
  .questions-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

  .exam-intro {
    background: linear-gradient(135deg, #1a1530 0%, #2a1f55 35%, var(--accent) 100%);
    color: white;
    border-radius: 22px;
    padding: 28px 32px;
    position: relative;
    overflow: hidden;
  }
  .exam-intro::before {
    content: "";
    position: absolute;
    top: -80px; right: -60px;
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(255,255,255,0.16), transparent 70%);
    pointer-events: none;
  }
  .exam-intro::after {
    content: "";
    position: absolute;
    bottom: -100px; left: 100px;
    width: 240px; height: 240px;
    background: radial-gradient(circle, rgba(255, 184, 0, 0.25), transparent 70%);
    pointer-events: none;
  }
  .exam-intro .kicker {
    font-family: "Geist Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-200);
    margin-bottom: 12px;
    position: relative;
    display: block;
    background: none;
    padding: 0;
    border-radius: 0;
    font-weight: 500;
  }
  .exam-intro h1 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: -0.015em;
    margin-bottom: 8px;
    position: relative;
  }
  .exam-intro h1 em { font-style: italic; color: var(--accent-200); }
  .exam-intro p { max-width: 62ch; color: rgba(255,255,255,0.75); font-size: 14px; position: relative; }
  .skip-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 68ch;
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.88);
    font-size: 13px;
    line-height: 1.45;
    position: relative;
  }
  .skip-note .mi { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: #ffd966; }
  .exam-intro-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.18);
    position: relative;
  }
  .exam-intro-stats .item { display: flex; flex-direction: column; }
  .exam-intro-stats .v { font-family: "Instrument Serif", serif; font-size: 24px; line-height: 1; margin-bottom: 4px; }
  .exam-intro-stats .item.big .v { font-size: 44px; color: #ffd966; }
  .exam-intro-stats .l { font-size: 11px; color: rgba(255,255,255,0.6); font-weight: 500; }

  .part-divider { display: flex; align-items: center; gap: 14px; padding: 12px 4px 8px; margin-top: 6px; }
  .part-divider .num { font-family: "Instrument Serif", serif; font-size: 26px; line-height: 1; color: var(--accent); }
  .part-divider .body { flex: 1; }
  .part-divider h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
  .part-divider small { font-size: 12px; color: var(--muted); }
  .part-divider .right {
    font-family: "Geist Mono", monospace;
    font-size: 11px;
    color: var(--muted-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: right;
  }

  /* ---------- карточка задания ---------- */
  .qc {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px 24px;
    scroll-margin-top: 76px;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .qc.done { border-color: var(--accent-100); }
  .qc.done::before, .qc.flagged::before {
    content: "";
    position: absolute;
    top: 0; left: 24px;
    height: 3px; width: 36px;
    background: var(--green);
    border-radius: 0 0 3px 3px;
  }
  .qc.flagged { border-color: var(--yellow-soft); }
  .qc.flagged::before { background: var(--yellow); }
  .qc.empty { border-style: dashed; background: transparent; box-shadow: none; padding-bottom: 20px; }
  .qc.empty .qc-num { color: var(--muted-2); }
  .qc.skip .qc-num { font-size: 32px; }
  .q-anchor { position: absolute; top: 0; scroll-margin-top: 76px; }
  .qc.is-right { border-color: var(--green-soft); }
  .qc.is-wrong { border-color: var(--red-soft); }
  .qc.is-partial { border-color: var(--yellow-soft); }

  .qc-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 16px; }
  .qc-num-row { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
  .qc-num {
    font-family: "Instrument Serif", serif;
    font-size: 44px;
    line-height: 0.85;
    letter-spacing: -0.02em;
    color: var(--accent);
    font-feature-settings: "tnum";
  }
  .qc-label { display: flex; flex-direction: column; gap: 2px; }
  .qc-label b { font-weight: 600; font-size: 14px; color: var(--ink); }
  /* название — ссылка на задачу в новой вкладке, но выглядит заголовком */
  .qc-link { color: inherit; text-decoration: none; }
  .qc-link:hover { color: var(--accent-700); text-decoration: underline; text-underline-offset: 3px; }
  .qc-ext { width: 13px; height: 13px; margin-left: 5px; vertical-align: -1px; fill: currentColor; opacity: 0.45; }
  .qc-link:hover .qc-ext { opacity: 1; }
  .qc-label small { font-size: 11.5px; color: var(--muted); }
  .qc-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .meta-chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }
  .meta-chip.chip-violet { background: var(--accent-50); color: var(--accent-700); }
  .meta-chip.chip-yellow { background: var(--yellow-soft); color: #946d00; }
  .meta-chip.chip-red { background: var(--red-soft); color: var(--red); }
  .meta-chip.chip-green { background: var(--green-soft); color: var(--green); }
  .meta-chip.chip-ghost { background: var(--surface-2); color: var(--muted); }

  .flag-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted-2);
    display: grid;
    place-items: center;
    transition: all 0.15s;
  }
  .flag-btn:hover { background: var(--surface-2); color: var(--muted); }
  .flag-btn[aria-pressed="true"] { background: var(--yellow-soft); color: #946d00; border-color: var(--yellow); }
  .flag-btn .mi { font-size: 16px; }

  .qc .material { margin-bottom: 16px; }
  .m-ref {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
  }
  .m-ref:hover { color: var(--accent-700); background: var(--accent-50); }

  .qc-body { min-width: 0; }

  .qc-answer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
  .qc-answer .ttl {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .ans-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .ans-input {
    flex: 1;
    min-width: 220px;
    max-width: 320px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 2px solid transparent;
    font-family: "Geist Mono", monospace;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.2s;
    outline: none;
  }
  .ans-input::placeholder { color: var(--muted-2); font-weight: 400; }
  .ans-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
  .ans-input.filled { background: var(--accent-50); border-color: var(--accent-100); color: var(--accent-700); }
  .ans-hint { font-size: 12px; color: var(--muted); max-width: 48ch; }

  /*
   * Раскладка ответа — варианты, соответствие, порядок. Сами правила в
   * task.css, который подключён рядом: раскладка та же, что на странице
   * задачи. Здесь только посадка в карточку: подсказка над раскладкой, у
   * последнего блока нет хвостового отступа.
   */
  .qc-answer .ans-lead { margin: 0 0 12px; }
  .qc-answer > :last-child { margin-bottom: 0; }
  /* Разбор: сданный выбор только показывается — без наведения и руки-курсора. */
  .qc-answer .is-locked { margin-bottom: 14px; }
  .qc-answer .is-locked .opt,
  .qc-answer .is-locked .tf-b { cursor: default; pointer-events: none; }
  .qc-answer .is-locked .picker:disabled,
  .qc-answer .is-locked .blank-input:disabled { opacity: 1; cursor: default; }

  /* вердикт результата: свои цвета по типу */
  .qc-answer .verdict { margin-top: 0; }
  .verdict .v-h { display: flex; align-items: center; gap: 8px; }
  .verdict .v-pts {
    margin-left: auto;
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
  }
  .verdict.v-right { background: var(--green-tint); color: var(--green); }
  .verdict.v-right .v-mark { color: var(--green); }
  .verdict.v-partial { background: var(--yellow-soft); color: #946d00; }
  .verdict.v-partial .v-mark { color: #946d00; }
  .verdict.v-wrong { background: var(--red-tint); color: var(--red); }
  .verdict.v-wrong .v-mark { color: var(--red); }
  .verdict.v-empty { background: var(--surface-2); color: var(--muted); }
  .verdict.v-unknown { background: var(--blue-soft); color: var(--blue); }
  .verdict .v-body { color: var(--ink-2); }

  /* ---------- сдача ---------- */
  .submit-block {
    margin-top: 24px;
    padding: 32px;
    background: var(--surface);
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
    overflow: hidden;
  }
  .submit-block::before {
    content: "";
    position: absolute;
    top: -100px; right: -100px;
    width: 300px; height: 300px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    pointer-events: none;
  }
  .submit-block h3 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: 28px;
    letter-spacing: -0.015em;
    margin-bottom: 6px;
    position: relative;
  }
  .submit-block h3 em { font-style: italic; color: var(--accent); }
  .submit-block p { color: var(--muted); margin-bottom: 20px; position: relative; }
  .submit-summary {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 22px;
    padding: 18px 22px;
    background: var(--surface-2);
    border-radius: var(--radius);
    position: relative;
  }
  .submit-summary .item { display: flex; flex-direction: column; align-items: center; }
  .submit-summary .v {
    font-family: "Instrument Serif", serif;
    font-size: 32px;
    line-height: 1;
    letter-spacing: -0.02em;
    margin-bottom: 2px;
  }
  .submit-summary .v.green { color: var(--green); }
  .submit-summary .v.yellow { color: #946d00; }
  .submit-summary .v.red { color: var(--red); }
  .submit-summary .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
  .submit-actions { display: inline-flex; gap: 10px; position: relative; }
  .submit-actions .btn { padding: 13px 28px; }

  .reveal { opacity: 0; transform: translateY(8px); animation: rev 0.7s cubic-bezier(.2,.8,.2,1) forwards; }
  @keyframes rev { to { opacity: 1; transform: translateY(0); } }

  /* ============ АДАПТИВ ============ */
  @media (max-width: 1000px) {
    .exam-bar-inner { grid-template-columns: 1fr auto; gap: 12px; padding: 12px 16px; }
    .exam-info { display: none; }
    .progress-mini { display: none; }
    .workspace { padding: 16px; }
    .mock-form, .workspace.result { grid-template-columns: 1fr; gap: 18px; }
    .sheet { position: static; max-height: none; }
    .q-grid { grid-template-columns: repeat(8, 1fr); }
    .qc { padding: 22px 22px 20px; }
    .qc-num { font-size: 36px; }
    /* узко: чипы уходят под название, а не наезжают на ссылку */
    .qc-head { flex-wrap: wrap; gap: 10px; }
    .qc-ext { display: none; }
    .submit-summary { gap: 20px; padding: 16px; }
    .ans-input { min-width: 0; max-width: 100%; width: 100%; }
    .exam-intro { padding: 22px; }
    .exam-intro h1 { font-size: 30px; }
  }
