/* Simulator: start, session (flip card), history, analytics, session details.
   Uses tokens.css + questions.css (crumbs, title, lead, fields). Class names of the existing templates/JS are kept. */

.sim { position: relative; padding-top: 8px }
.sim *, .sim *::before, .sim *::after { box-sizing: border-box }

/* ---------- head: same rhythm as the question bank ---------- */
.sim-head { position: relative; isolation: isolate; padding: 32px 0 32px }
.sim-head__row { display: flex; flex-direction: column; align-items: flex-start; gap: 22px }
.sim-head__title { margin-bottom: 12px }
.sim-head .qb-lead { max-width: 60ch }

/* ---------- shared pieces from the old markup ---------- */
.sim .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
    border-radius: var(--sr-r-pill); border: 1px solid var(--sr-line); background: var(--sr-surface); color: var(--sr-text);
    font: 500 14px/1 var(--sr-font); text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s;
}
.sim .btn:hover { border-color: var(--sr-line-strong); color: var(--sr-text) }
.sim .btn.primary { border-color: transparent; background: var(--sr-accent); color: var(--sr-accent-ink); box-shadow: 0 1px 2px rgb(var(--sr-shadow-color) / .3), 0 4px 10px -4px rgb(var(--sr-shadow-color) / .35) }
.sim .btn.primary:hover { background: var(--sr-accent-hover); color: var(--sr-accent-ink) }
.sim .btn.full { width: 100% }
.sim .btn:disabled { opacity: .5; cursor: not-allowed }
.sim-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
.sim-hint { font-size: 13.5px; line-height: 1.45; color: var(--sr-muted) }
.sim-alert { margin: 0; font-size: 14px; color: var(--sr-muted) }
.sim-alert:empty { display: none }
.sim-alert.error { color: var(--sr-error) }
.sim-alert.success { color: var(--sr-success) }

.sim-grid, .sim-secondary { display: grid; gap: 16px; margin-bottom: 16px }
.sim-card {
    min-width: 0; padding: 22px; border-radius: var(--sr-r-lg);
    background: var(--sr-surface); border: 1px solid var(--sr-line); box-shadow: var(--sr-e1);
}
.sim-card__header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px }
.sim-card__header h2, .sim-card__header h3 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em }
.sim-card__header form { margin: 0 }
.sim-subtitle { margin: 0 0 10px; font: 500 11.5px/1.3 var(--sr-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--sr-muted) }

.sim-chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--sr-r-pill); background: var(--sr-raise); color: var(--sr-text); font-size: 13.5px; font-weight: 500; white-space: nowrap }
.sim-chip.is-muted { background: transparent; border: 1px solid var(--sr-line); color: var(--sr-muted) }
.sim-chip.is-success, .sim-chip.choice-know { background: color-mix(in srgb, var(--sr-success) 16%, transparent); color: var(--sr-success) }
.sim-chip.is-warning, .sim-chip.choice-repeat { background: var(--sr-stage-tech-bg); color: var(--sr-stage-tech) }
.sim-chip.choice-dont_know { background: color-mix(in srgb, var(--sr-error) 14%, transparent); color: var(--sr-error) }

.sim-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; text-align: center }
.sim-empty b { font-size: 16px }
.sim-empty span { font-size: 14px; color: var(--sr-muted) }
.sim-empty .btn { margin-top: 6px }

/* ---------- locked ---------- */
.sim-locked { max-width: 640px; padding: 24px 24px 24px; color: var(--sr-feature-ink); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 40px }
.sim-locked .sr-mono-label { color: var(--sr-feature-muted); padding-right: 64px }
.sim-locked h2 { margin: 0; padding-right: 56px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25 }
.sim-locked p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--sr-feature-muted); max-width: 52ch }
.sim-locked .sr-btn { margin-top: 6px }

/* ---------- start ---------- */
/* main column: the weak-spots card, then a new session; the side column (same width as on every page) explains the session */
#sim-start { grid-template-columns: minmax(0, 1fr) var(--sr-side-col); align-items: start; gap: 24px var(--sr-col-gap) }
.sim-start__main { display: flex; flex-direction: column; gap: 16px; min-width: 0 }
.sim-start__main > .sim-card { margin: 0 }
.sim-how { padding: 22px; border-radius: var(--sr-r-lg); border: 1px dashed var(--sr-line-strong) }
.sim-how h2 { margin: 0 0 16px }
.sim-how ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px }
.sim-how li { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 12px; row-gap: 3px }
.sim-how li .sim-si { --c: var(--sr-done); grid-row: span 2; margin-top: 3px }
.sim-how b { font-size: 15px; font-weight: 600 }
.sim-how li > span:last-child { font-size: 13.5px; line-height: 1.5; color: var(--sr-muted) }
.sim-legend { margin: -4px 0 16px; max-width: 90ch; font-size: 13.5px; line-height: 1.55; color: var(--sr-muted) }
.sim-legend b { font-weight: 600; color: var(--sr-text) }
.sim-start-intro { display: flex; flex-direction: column; gap: 16px }
.sim-form { flex-direction: column; gap: 22px }
.sim-form[style*="display: block"], .sim-form[style*="display:block"] { display: flex !important }
.sim-field { display: flex; flex-direction: column; gap: 8px; margin: 0 }
.sim-field > span:first-child { font-size: 14px; font-weight: 600; color: var(--sr-text) }
.sim-field small { font-size: 13.5px; color: var(--sr-muted) }
.sim-option {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 14px;
    border-radius: var(--sr-r-md); border: 1px solid var(--sr-line); background: var(--sr-surface);
    font-size: 14.5px; color: var(--sr-text); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.sim-option:hover { border-color: var(--sr-line-strong) }
.sim-option:has(input:checked) { border-color: color-mix(in srgb, var(--sr-accent) 55%, var(--sr-line)); background: var(--sr-accent-soft) }
.sim-option input { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 0; border: 1.6px solid var(--sr-line-strong); background: var(--sr-surface); display: grid; place-items: center; cursor: pointer }
.sim-option input[type="radio"] { border-radius: 50% }
.sim-option input[type="checkbox"] { border-radius: 5px }
.sim-option input:checked { border-color: var(--sr-accent); background: var(--sr-accent) }
.sim-option input[type="radio"]:checked { background: var(--sr-surface); box-shadow: inset 0 0 0 4px var(--sr-accent) }
.sim-option input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 5px; border: solid var(--sr-accent-ink); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg) }
.sim-option input:focus-visible { outline: 2px solid var(--sr-accent); outline-offset: 2px }
.sim-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px }
.sim-topics .sim-option { min-height: 40px; padding: 8px 12px; font-size: 13.5px }

/* custom select (js/custom-select.js) in the header-menu style */
.custom-select { position: relative; width: 100% }
.custom-select__native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none }
.custom-select__display {
    width: 100%; height: 44px; padding: 0 40px 0 14px; text-align: left;
    border-radius: var(--sr-r-md); border: 1px solid var(--sr-line); background: var(--sr-surface); color: var(--sr-text);
    font: 500 14.5px/1 var(--sr-font); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 14px; transition: border-color .15s;
}
.custom-select__display:hover, .custom-select.open .custom-select__display { border-color: var(--sr-line-strong) }
.custom-select__dropdown {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; min-width: 100%; max-height: 320px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
    border-radius: var(--sr-r-md); background: var(--sr-surface); border: 1px solid var(--sr-line-strong); box-shadow: var(--sr-e3);
    opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .16s, transform .16s var(--sr-ease), visibility 0s .16s;
    scrollbar-width: thin; scrollbar-color: var(--sr-line-strong) transparent;
}
.custom-select.open .custom-select__dropdown { opacity: 1; visibility: visible; transform: none; transition: opacity .16s, transform .16s var(--sr-ease) }
.custom-select__option { display: flex; align-items: center; min-height: 36px; padding: 8px 12px; border-radius: var(--sr-r-sm); font-size: 14px; color: var(--sr-text); cursor: pointer }
.custom-select__option:hover { background: var(--sr-raise) }
.custom-select__option.is-active { font-weight: 600; background: var(--sr-accent-soft) }
.custom-select__option.is-disabled { color: var(--sr-faint); cursor: default; background: none }
.sim-card__header .custom-select { width: auto; min-width: 120px }
.sim-card__header .custom-select__display, .sim-filter .custom-select__display { height: 36px; border-radius: var(--sr-r-pill) }

/* ---------- history & analytics ---------- */
.sim-list { display: flex; flex-direction: column }
.sim-list .sim-option { cursor: default }
.sim-option-history, .sim-direction-card, .sim-subtopic-card {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
    padding: 16px 0; min-height: 0; border: 0; border-radius: 0; background: none; border-top: 1px solid var(--sr-line);
}
.sim-list > :first-child { border-top: 0; padding-top: 4px }
.sim-option-history:hover, .sim-direction-card:hover, .sim-subtopic-card:hover { background: none }
/* a subtopic row keeps its button on the right whatever the name's length: the name wraps instead */
.sim-subtopic-card { flex-wrap: nowrap }
.sim-subtopic-card > div:first-child { flex: 1; min-width: 0 }
.sim-subtopic-card .sim-subtopic-cta { flex: none }
.sim-history-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 420px }
.sim-history-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
.sim-history-title strong { font: 600 13px/1 var(--sr-mono); color: var(--sr-muted) }
.sim-history-num { flex: none; min-width: 22px; font: 500 13px/1 var(--sr-mono); color: var(--sr-faint); font-variant-numeric: tabular-nums }
.sim-history-q { font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--sr-text) }
.sim-complete__stat .value small { font-size: 16px; font-weight: 500; color: var(--sr-muted) }
/* a head with actions: title and lead on the left, the buttons on the title's baseline at the right */
.sim-head__row--actions { flex-direction: row; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap }
.sim-head__actions { display: flex; gap: 8px; align-items: center }
.sim-head__actions form { margin: 0 }
.sim-history-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13.5px; color: var(--sr-muted) }
.sim-history-topics { display: flex; gap: 6px; font-size: 13.5px; color: var(--sr-text) }
.sim-history-right, .sim-history-action { display: flex; align-items: center; gap: 8px }
.sim-history-action form { margin: 0 }

/* the year fills the card: the cell size follows the card's width (53 weeks), between 11 and 20 px */
.sim-heatmap { --cell: clamp(11px, calc((100cqw - 40px) / 53 - 3px), 20px); container-type: inline-size; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 8px; margin-top: 10px }
.sim-heatmap__y { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: 3px; font: 500 10.5px/var(--cell) var(--sr-mono); color: var(--sr-muted) }
.sim-heatmap__grid { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--sr-line-strong) transparent }
.sim-heatmap__col { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: 3px }
.sim-heatmap__cell { width: var(--cell); height: var(--cell); border-radius: 3px; background: var(--sr-raise); cursor: pointer }
.sim-heatmap__cell.level-1 { background: color-mix(in srgb, var(--sr-done) 22%, var(--sr-raise)) }
.sim-heatmap__cell.level-2 { background: color-mix(in srgb, var(--sr-done) 45%, var(--sr-raise)) }
.sim-heatmap__cell.level-3 { background: color-mix(in srgb, var(--sr-done) 70%, var(--sr-raise)) }
.sim-heatmap__cell.level-4 { background: var(--sr-done) }
.sim-heatmap__cell.is-muted { opacity: .3; cursor: default }
.sim-heatmap__cell.is-selected { box-shadow: 0 0 0 2px var(--sr-bg), 0 0 0 3px var(--sr-text) }
.sim-heatmap__legend { grid-column: 2; display: flex; align-items: center; gap: 4px }
.sim-heatmap__legend .sim-hint { font-size: 13.5px; margin: 0 4px }
.sim-heatmap__legend .sim-heatmap__cell { cursor: default; width: 13px; height: 13px }
.sim .btn[aria-current] { background: var(--sr-text); border-color: var(--sr-text); color: var(--sr-bg); pointer-events: none }

.sim-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 }
.sim-filter .custom-select { width: auto; min-width: 200px }
.sim > .sim-card:has(.sim-filter) { padding: 0; margin: 0 0 16px; background: none; border: 0; box-shadow: none }
.sim-direction-main { display: flex; flex-direction: column; gap: 8px; flex: 1 1 320px; min-width: 0 }
.sim-direction-title { font-size: 16px; font-weight: 600 }
.sim-progress { height: 8px; border-radius: 8px; background: var(--sr-well); overflow: hidden }
.sim-progress-bar { height: 100%; border-radius: inherit; background: var(--sr-done) }
.sim-direction-metrics { display: flex; flex-wrap: wrap; gap: 8px }
.sim-metric-pill { display: flex; flex-direction: column; gap: 3px; min-width: 92px; padding: 8px 12px; border-radius: var(--sr-r-sm); background: var(--sr-raise) }
.sim-metric-pill span { font: 500 10.5px/1.2 var(--sr-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--sr-muted) }
.sim-metric-pill strong { font-size: 16px; font-weight: 600 }
/* levels 1–9: from "needs work" to "solid", calm colours */
.sim-metric-pill.level-1 strong, .sim-metric-pill.level-2 strong, .sim-metric-pill.level-3 strong { color: var(--sr-error) }
.sim-metric-pill.level-4 strong, .sim-metric-pill.level-5 strong, .sim-metric-pill.level-6 strong { color: var(--sr-stage-tech) }
.sim-metric-pill.level-7 strong, .sim-metric-pill.level-8 strong, .sim-metric-pill.level-9 strong { color: var(--sr-success) }
.sim-answer-type-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px }
.sim-answer-pill { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--sr-r-md); background: var(--sr-raise) }
.sim-answer-pill__label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500 }
.sim-answer-pill__label::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid currentColor; flex: none }
.sim-answer-pill[data-choice="know"] .sim-answer-pill__label { color: var(--sr-success) }
.sim-answer-pill[data-choice="know"] .sim-answer-pill__label::before { background: currentColor }
.sim-answer-pill[data-choice="repeat"] .sim-answer-pill__label { color: var(--sr-stage-tech) }
.sim-answer-pill[data-choice="repeat"] .sim-answer-pill__label::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%) }
.sim-answer-pill[data-choice="dont_know"] .sim-answer-pill__label { color: var(--sr-error) }
.sim-answer-pill__value { display: flex; align-items: baseline; gap: 8px }
.sim-answer-pill__value strong { font-size: 28px; font-weight: 600; letter-spacing: -0.03em }
.sim-answer-pill__value span { font-size: 14px; color: var(--sr-muted) }
.sim-subgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px }
.sim-subtopic-title { font-size: 14.5px }
.sim-subtopic-title span { color: var(--sr-muted) }
.sim-subtopic-meta { display: flex; gap: 10px; margin-top: 4px; font-size: 13.5px; color: var(--sr-muted) }
.sim-trend.up { color: var(--sr-success) }
.sim-trend.down { color: var(--sr-error) }
.sim .sim-subtopic-cta { height: 34px; font-size: 13.5px }

/* ---------- session details ---------- */
.sim-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: -12px 0 24px }
.sim-meta span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--sr-r-pill); background: var(--sr-raise); font-size: 13.5px; color: var(--sr-text) }
.sim-card-wide[style*="display: flex"] { padding: 0; background: none; border: 0; box-shadow: none; justify-content: flex-start !important; gap: 8px; flex-direction: row-reverse }
.sim-complete__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-top: 1px solid var(--sr-line) }
.sim-complete__stat { display: flex; flex-direction: column-reverse; gap: 4px; padding: 16px 16px 4px 0 }
.sim-complete__stat + .sim-complete__stat { padding-left: 16px; border-left: 1px solid var(--sr-line) }
.sim-complete__stat .label { font: 500 11px/1.3 var(--sr-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--sr-muted) }
.sim-complete__stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em }

/* ---------- session: the flip card ---------- */
.sim--run { max-width: calc(760px + var(--sr-gutter) * 2) }
.sim-run__head { padding: 32px 0 20px }
.sim-run__head .qb-crumbs { margin-bottom: 16px }
.sim-run__status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px }
.sim-segs { list-style: none; display: flex; gap: 3px; margin: 0; padding: 0 }
.sim-segs li { flex: 1; height: 5px; border-radius: 3px; background: var(--sr-raise); transition: background-color .3s }
.sim-segs li.is-current { position: relative; background: var(--sr-line-strong) }
/* the snake's head sits on the card you are answering: the row of segments is its body */
.sim-segs li.is-current::after { content: ""; position: absolute; left: 50%; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 50%;
    background: radial-gradient(circle at 64% 38%, #1D0D06 0 1.4px, #FFF7F2 1.6px 3.2px, transparent 3.4px), var(--sr-accent); box-shadow: 0 0 0 3px var(--sr-bg) }
.sim-segs li[data-choice="know"] { background: var(--sr-success) }
.sim-segs li[data-choice="repeat"] { background: var(--sr-stage-tech) }
.sim-segs li[data-choice="dont_know"] { background: var(--sr-text); opacity: .55 }
.sim-segs li[data-choice="answered"] { background: color-mix(in srgb, var(--sr-done) 45%, var(--sr-raise)) }

.sim-stack { position: relative; perspective: 1600px; margin-top: 10px }
.sim-stack__ghost { position: absolute; left: 0; right: 0; height: 100%; border-radius: 24px 24px 24px 8px; background: var(--sr-surface); border: 1px solid var(--sr-line) }
.sim-stack__ghost--1 { top: 8px; transform: scale(.97); opacity: .7 }
.sim-stack__ghost--2 { top: 16px; transform: scale(.94); opacity: .4 }
.sim-flip { position: relative; display: grid; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3, .9, .3, 1) }
.sim-flip[hidden] { display: none }
.sim-flip.is-flipped { transform: rotateY(180deg) }
.sim-face {
    grid-area: 1 / 1; min-height: 340px; max-height: min(64vh, 620px); overflow-y: auto; overscroll-behavior: contain;
    padding: 24px 28px 28px; border-radius: 24px 24px 24px 8px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
    background: var(--sr-surface); border: 1px solid var(--sr-line); box-shadow: var(--sr-e2);
    display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; scrollbar-color: var(--sr-line-strong) transparent;
}
.sim-face--front { justify-content: flex-start; min-height: 320px }
.sim-face__ctx { display: inline-flex; align-items: center; gap: 10px; min-width: 0 }
.sim-face__topic { font-size: 13.5px; color: var(--sr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.sim-face__main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 12px 0 }
.sim-face__qmini { margin: -4px 0 4px; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--sr-text) }
.sim-face--back { transform: rotateY(180deg) }
.sim-face__top { display: flex; justify-content: space-between; align-items: center; gap: 12px }
.sim-face__q { margin: 0; font: 600 clamp(24px, 3vw, 32px)/1.25 var(--sr-font); letter-spacing: -0.025em; text-wrap: balance }
.sim-face__body { margin: 0; font-size: 16px; line-height: 1.6; color: var(--sr-muted) }
.sim-face__hint { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--sr-muted) }
.sim-face__verdict { font-size: 13.5px; font-weight: 500; color: var(--sr-accent-text) }
.sim-face__answer { font-size: 16px }
.sim-skeleton { display: flex; flex-direction: column; gap: 14px; min-height: 340px; padding: 28px; border-radius: 24px 24px 24px 8px; background: var(--sr-surface); border: 1px solid var(--sr-line) }
.sim-skeleton[hidden] { display: none }

.sim-conf { margin-top: 28px; display: flex; flex-direction: column; gap: 12px }
.sim-conf[hidden] { display: none }
.sim-conf__q { margin: 0; font-size: 14px; font-weight: 500; color: var(--sr-muted) }
.sim-conf__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px }
.sim-choice {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 0 16px;
    border-radius: var(--sr-r-md); border: 1px solid var(--sr-line); background: var(--sr-surface); color: var(--sr-text);
    font: 500 15px/1 var(--sr-font); cursor: pointer; transition: border-color .15s, background-color .15s, opacity .2s;
}
.sim-choice:hover:not(:disabled) { border-color: var(--sr-line-strong) }
.sim-choice:disabled { cursor: default }
.sim-choice:disabled:not(.is-active) { opacity: .4 }
.sim-choice--know { --c: var(--sr-success) }
.sim-choice--repeat { --c: var(--sr-stage-tech) }
.sim-choice--dont_know { --c: var(--sr-muted) }
.sim-choice.is-active { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--sr-surface)) }
/* full / half / empty circle: readable without the label and the same as in analytics */
.sim-si { width: 14px; height: 14px; border-radius: 50%; border: 1.6px solid var(--c, currentColor); flex: none }
.sim-si--full { background: var(--c) }
.sim-si--half { background: linear-gradient(90deg, var(--c) 50%, transparent 50%) }
.sim-conf__next { display: flex; justify-content: flex-end; min-height: 44px }
.sim-conf__next .sr-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round }
.sim-conf .sim-alert { color: var(--sr-error) }

.sim-done { padding: 26px; color: var(--sr-feature-ink); display: flex; flex-direction: column; gap: 12px; margin-top: 10px }
.sim-done[hidden] { display: none }
.sim-done .sr-mono-label { color: var(--sr-feature-muted); padding-right: 64px }
/* verdict on the left, the snake's coil (share of «Знаю») on the right */
.sim-done__head { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 24px; align-items: center }
.sim-done__coil { width: 112px; height: 112px; margin-top: 10px; overflow: visible }
.sim-done__track { fill: none; stroke: color-mix(in srgb, var(--sr-feature-ink) 10%, transparent); stroke-width: 9 }
.sim-done__body { fill: none; stroke: var(--sr-feature-ink); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 0 100; transform: rotate(-90deg); transform-origin: 50px 50px; transition: stroke-dasharray 1s var(--sr-ease) }
[data-done-head] { transform-box: view-box; transform-origin: 50px 50px; transition: transform 1s var(--sr-ease) }
@media (max-width: 640px) { .sim-done__head { grid-template-columns: minmax(0, 1fr) 76px; gap: 14px } .sim-done__coil { width: 76px; height: 76px } }
.sim-done__verdict { margin: 0; padding-right: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.03em }
.sim-done__lead { margin: 0; max-width: 52ch; font-size: 15px; line-height: 1.55; color: var(--sr-feature-muted) }
.sim-done__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 8px 0 4px; border-top: 1px solid color-mix(in srgb, var(--sr-feature-ink) 12%, transparent) }
.sim-done__stats div { display: flex; flex-direction: column-reverse; gap: 4px; padding: 14px 12px 0 0 }
.sim-done__stats dt { font: 500 11px/1.3 var(--sr-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--sr-feature-muted) }
.sim-done__stats dd { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.03em }
.sim-done__cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px }
.sim-done .sr-btn--secondary { background: transparent; border-color: color-mix(in srgb, var(--sr-feature-ink) 22%, transparent); color: var(--sr-feature-ink) }

/* ---------- phone ---------- */
@media (max-width: 760px) {
    .sim-head { padding: 18px 0 24px }
    .sim-subgrid, #sim-start { grid-template-columns: minmax(0, 1fr) }
    /* the three marks stay in one row under the thumb: the icon over the word */
    .sim-conf { margin-top: 20px }
    .sim-choice { flex-direction: column; gap: 8px; height: auto; min-height: 68px; padding: 10px 4px; font-size: 13.5px; line-height: 1.2; text-align: center }
    .sim-conf__next .sr-btn { flex: 1; justify-content: center; height: 48px }
    .sim-complete__stats { grid-template-columns: repeat(2, minmax(0, 1fr)) }
    .sim-complete__stat, .sim-complete__stat + .sim-complete__stat { justify-content: flex-end; padding: 14px 12px 14px 0; border-left: 0 }
    .sim-complete__stat:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--sr-line) }
    .sim-complete__stat:nth-child(n + 3) { border-top: 1px solid var(--sr-line) }
    .sim-complete__stat .value { font-size: 20px; white-space: nowrap }
    .sim-head__actions { display: grid; grid-template-columns: 1fr 1fr; width: 100% }
    .sim-head__actions .sr-btn { width: 100%; justify-content: center; height: 46px }
    /* a question in the review: the number hangs on the left, everything else shares one edge */
    .sim-option-history:has(.sim-history-num) { position: relative; padding-left: 30px }
    .sim-option-history .sim-history-num { position: absolute; left: -30px; top: 0; line-height: 21px }
    .sim-option-history:has(.sim-history-num) .sim-history-right { flex-basis: 100% }
    .sim-option-history:has(.sim-history-num) .sim-history-left { position: relative; flex-basis: auto }
    .sim-option-history:has(.sim-history-num) .sim-history-right .sr-btn { padding-left: 0 }
    .sim-filter { display: grid; grid-template-columns: 1fr 1fr }
    .sim-filter .custom-select { min-width: 0; width: 100% }
    .sim-face { padding: 20px; min-height: 300px }
    .sim-done__stats { grid-template-columns: minmax(0, 1fr) }
}
@media (prefers-reduced-motion: reduce) {
    .sim-flip { transition: none }
}

/* leaving a session is safe: the button says so instead of a bare link */
.sim-exit {
    display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px 0 12px;
    border-radius: var(--sr-r-pill); border: 1px solid var(--sr-line); background: var(--sr-surface);
    color: var(--sr-text); text-decoration: none; transition: border-color .15s;
}
.sim-exit:hover { color: var(--sr-text); border-color: var(--sr-line-strong) }
.sim-exit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.sim-exit span { display: flex; flex-direction: column; font-size: 13.5px; font-weight: 500; line-height: 1.1 }
.sim-exit small { font-size: 11px; font-weight: 400; color: var(--sr-muted) }
.sim-run__status { margin-bottom: 14px }

/* ---------- start: «repeat weak spots» is the main scenario (the featured card) ---------- */
.sim-weak { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 0; padding: 22px 24px; color: var(--sr-feature-ink) }
.sim-weak .sr-mono-label { color: var(--sr-feature-muted); padding-right: 64px }
.sim-weak h2 { margin: 0; padding-right: 56px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em }
.sim-weak p { margin: 0 0 8px; max-width: 60ch; font-size: 15px; line-height: 1.55; color: var(--sr-feature-muted) }
.sim-weak p b { color: var(--sr-feature-ink) }
.sim-weak .sr-bite__dot { border: 0; cursor: pointer }
.sim-weak button:disabled { opacity: .6; cursor: progress }

/* ---------- locked page: the offer + one real card to try ---------- */
/* both columns end on one line: the locked card stretches to the demo's height, its button sits at the bottom */
.sim-guest { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: stretch }
.sim-guest .sim-locked { max-width: none }
.sim-guest .sim-locked .sr-btn { margin-top: auto }
.sim-demo { display: flex; flex-direction: column }
.sim-demo .sim-flip { flex: 1 }
.sim-guest .sim-locked { margin-bottom: 0 }
.sim-demo h2, .sim-preview h2 { margin: 0 0 12px }
.sim-demo .sim-face { min-height: 300px }
.sim-demo .sim-face__q { font-size: clamp(22px, 2.4vw, 28px) }
.sim-demo__choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto }
/* the three marks are one choice: always one row of equal buttons, the long one wraps inside */
@media (max-width: 560px) {
    .sim-demo__choices:has([data-demo-choice]) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) }
    .sim-demo__choices [data-demo-choice] { height: 52px; padding: 4px 6px; justify-content: center; border-radius: var(--sr-r-md); white-space: normal; text-align: center; font-size: 13.5px; line-height: 1.2 }
}
.sim-preview { margin: 32px 0 0; padding: 22px 24px; border-radius: var(--sr-r-lg); background: var(--sr-surface); border: 1px solid var(--sr-line); box-shadow: var(--sr-e1) }

/* ---------- analytics: one bar per direction — confident / due / not met yet, as parts of the base ---------- */
.sim-dirs { display: flex; flex-direction: column }
.sim-dir { display: grid; grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) 170px; gap: 20px; align-items: center; padding: 14px 0; border-top: 1px solid var(--sr-line) }
.sim-dirs .sim-dir:first-child, .sim-preview .sim-dir { border-top: 0 }
.sim-dir__name { display: flex; flex-direction: column; gap: 3px; min-width: 0 }
.sim-dir__name b { font-size: 15.5px; font-weight: 600 }
.sim-dir__name span, .sim-dir__value span { font-size: 13.5px; color: var(--sr-muted) }
.sim-dir__bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; background: var(--sr-well); overflow: hidden }
.sim-dir__bar i { display: block; height: 100%; min-width: 0 }
.sim-dir__bar i.is-sure { background: var(--sr-stage-final) }
.sim-dir__bar i.is-due { background: var(--sr-accent) }
.sim-dir__value { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right }
.sim-dir__value b { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums }
.sim-dir__value.is-few b { font-size: 14px; font-weight: 500; color: var(--sr-muted) }
.sim-dir__legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 0; padding: 0; font-size: 13.5px; color: var(--sr-muted) }
.sim-dir__legend i { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 3px; background: var(--sr-well); vertical-align: -1px }
.sim-dir__legend i.is-sure { background: var(--sr-stage-final) }
.sim-dir__legend i.is-due { background: var(--sr-accent) }
.sim-dir__repeat { font-size: 13.5px; font-weight: 500; color: var(--sr-accent-text); text-decoration: none }
.sim-dir__repeat:hover { text-decoration: underline }
.sim-idle { margin-top: 12px }
.sim-idle summary { cursor: pointer; font-size: 14px; color: var(--sr-muted) }
.sim-idle summary:hover { color: var(--sr-text) }
.sim-idle p { margin: 8px 0 0; font-size: 14px; color: var(--sr-muted) }

@media (max-width: 960px) { .sim-guest { grid-template-columns: minmax(0, 1fr) } }
@media (max-width: 640px) {
    .sim-dir { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px }
    .sim-dir__bar { grid-column: 1 / -1; grid-row: 2 }
}

/* ---------- session on a phone: one screen, nothing to scroll ----------
   Status, card, marks and the next step share the visible height; a long answer scrolls inside the card.
   After the mark its place is taken by «Следующая карточка», so the thumb stays where it was. */
@media (max-width: 760px) {
    .sim--run:has([data-run]) { display: flex; flex-direction: column; height: calc(100vh - var(--sr-header-h)); height: calc(100svh - var(--sr-header-h)); min-height: 430px; padding-bottom: 14px }
    .sim--run:has([data-done]:not([hidden])) { height: auto; padding-bottom: 72px }
    .sim-run__head { flex: none; padding: 10px 0 6px }
    .sim-run__head .qb-crumbs { display: none }
    .sim-run__status { margin-bottom: 12px }
    .sim-exit { height: 36px }
    .sim--run [data-run] { flex: 1; min-height: 0; display: flex; flex-direction: column }
    .sim--run .sim-stack { flex: 1; min-height: 0; margin-top: 8px; display: grid }
    .sim--run:has([data-done]:not([hidden])) .sim-stack { flex: none }
    .sim--run .sim-flip { min-height: 0; grid-template-rows: minmax(0, 1fr) }
    .sim--run .sim-face { min-height: 0; max-height: none; padding: 16px 18px 18px }
    .sim--run .sim-face__q { font-size: clamp(22px, 6.4vw, 28px) }
    .sim--run .sim-face__answer { font-size: 15.5px }
    .sim--run .sim-skeleton { min-height: 0 }
    .sim--run .sim-conf { flex: none; gap: 8px; margin-top: 26px }
    .sim--run .sim-conf__q { font-size: 13.5px }
    .sim--run .sim-choice { min-height: 60px }
    .sim--run .sim-conf__next { min-height: 0 }
    .sim--run .sim-conf:has([data-next]:not([hidden])) :is(.sim-conf__q, .sim-conf__row) { display: none }
    .sim--run .sim-conf__next .sr-btn:not([hidden]) { height: 60px }
}
