/* Slice 3: questions, quiz screen, figures, keypad, editor */

/* Figures (SVG drawn on the server) */
.fig { margin: .75rem 0; display: flex; justify-content: center; color: var(--text); }
.fig svg { max-width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.fig-shape { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.fig-fill { fill: var(--primary-soft); fill-opacity: .55; }
.fig-line { stroke: currentColor; stroke-width: 1.6; }
.fig-dashed { stroke-dasharray: 5 4; }
.fig-mark { fill: none; stroke: currentColor; stroke-width: 1.4; }
.fig-arc { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.fig-dot { fill: currentColor; }
.fig-label { font-size: 15px; fill: var(--primary); font-weight: 700; }
.fig-angle-label { fill: var(--accent); font-size: 14px; }
.fig-name { font-size: 15px; fill: currentColor; font-weight: 700; font-style: italic; }
.fig-grid { stroke: var(--border); stroke-width: 1; }
.fig-axis { stroke: currentColor; stroke-width: 1.3; opacity: .8; }
.fig-arrow { fill: currentColor; opacity: .8; }
.fig-tick { font-size: 11px; fill: var(--muted); }
.fig-legend { font-size: 13px; fill: currentColor; }
.fig-fn { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.fig-fn1 { stroke: #1f6f5c; } .fig-fn2 { stroke: #c0562b; } .fig-fn3 { stroke: #3a62b8; } .fig-fn4 { stroke: #8a4bb3; }
@media (prefers-color-scheme: dark) {
  .fig-fn1 { stroke: #4cb79a; } .fig-fn2 { stroke: #f08a5d; } .fig-fn3 { stroke: #7ea4f2; } .fig-fn4 { stroke: #c792ea; }
}
.fig-pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }

/* Practice entry points */
.practice-box { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; border-left: 4px solid var(--accent); }
.practice-box h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.practice-box p { margin: 0; }
.practice-box-lesson { margin-top: 1rem; }

/* Quiz screen */
.quiz { max-width: 720px; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; }
.quiz-mode { font-weight: 700; padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; background: var(--primary-soft); color: var(--primary); }
.quiz-mode-quiz { background: var(--warn-soft); color: var(--accent); }
.quiz-count { color: var(--muted); font-size: .92rem; }
.quiz-stop { margin-left: auto; color: var(--muted); }
.quiz-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 1rem; }
.quiz-bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.quiz-card { padding: 1.1rem; }
.quiz-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.q-diff { color: var(--accent); letter-spacing: 1px; font-size: .8rem; }
.q-prompt { font-size: 1.12rem; }
.q-prompt p:first-child { margin-top: 0; }
.q-second { margin: .25rem 0 .75rem; font-size: .92rem; color: var(--muted); }
.q-second summary { cursor: pointer; }
.q-image img { max-width: 100%; height: auto; max-height: 360px; border-radius: 10px; display: block; margin: .5rem auto; }
.q-answer { margin-top: .9rem; }
.q-options { display: grid; gap: .55rem; }
.q-tf { grid-template-columns: 1fr 1fr; }
.q-opt { display: flex; gap: .7rem; align-items: center; padding: .8rem .9rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; min-height: 3rem; font-weight: 400; margin: 0; }
.q-opt:hover { border-color: var(--primary); }
.q-opt input { width: 1.2rem; height: 1.2rem; accent-color: var(--primary); flex-shrink: 0; margin: 0; }
.q-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.q-opt.is-correct { border-color: #2e8b57; background: var(--success-soft); }
.q-opt.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.q-opt:has(input:disabled) { cursor: default; }
.q-input { font-size: 1.1rem; padding: .6rem .75rem; border-radius: 10px; }
.q-text, .q-num { width: 100%; max-width: 22rem; }
.q-blank { width: auto; min-width: 4rem; display: inline-block; padding: .3rem .5rem; margin: .15rem 0; text-align: center; }
.q-input.is-correct, .q-match-row.is-correct select { border-color: #2e8b57; background: var(--success-soft); }
.q-input.is-wrong, .q-match-row.is-wrong select { border-color: var(--danger); background: var(--danger-soft); }
.q-number-row { display: flex; align-items: center; gap: .5rem; }
.q-unit { font-weight: 700; }
.q-fix { color: #2e8b57; font-weight: 700; margin-left: .3rem; }
.q-match { display: grid; gap: .5rem; }
.q-match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; align-items: center; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 10px; }
.q-match-row .q-fix { grid-column: 2; margin: 0; }
.q-match-row select { width: 100%; margin: 0; }
.q-order { list-style: none; counter-reset: ord; padding: 0; margin: 0; display: grid; gap: .45rem; }
.q-order-item { counter-increment: ord; display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); }
.q-order-item::before { content: counter(ord); display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.q-order-text { flex: 1; }
.q-order-btns { display: flex; gap: .3rem; }
.q-order-item.is-correct { border-color: #2e8b57; }
.q-order-item.is-wrong { border-color: var(--danger); }
.q-expected-list { margin-top: .7rem; }
.q-expected-list ol { margin: .3rem 0 0; }
.q-label-img { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; line-height: 0; user-select: none; -webkit-user-select: none; }
.q-label-img.is-done { cursor: default; }
.q-label-img img { max-width: 100%; height: auto; border-radius: 10px; display: block; }
.q-regions { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.q-regions circle, .q-regions rect { fill: rgba(46, 139, 87, .25); stroke: #2e8b57; stroke-width: .6; vector-effect: non-scaling-stroke; }
.q-marker { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid var(--accent); background: rgba(255,255,255,.5); box-shadow: 0 0 0 2px rgba(0,0,0,.35); pointer-events: none; }
.q-marker.is-correct { border-color: #2e8b57; }
.q-marker.is-wrong { border-color: var(--danger); }
.q-passage { background: var(--surface-2); border-radius: 12px; padding: .8rem 1rem; max-height: 50vh; overflow: auto; margin-bottom: 1rem; }
.q-subs { padding-left: 1.3rem; display: grid; gap: 1rem; }
.q-sub { padding: .2rem 0; }
.q-sub > .q .q-prompt { font-size: 1rem; }
.q-sub.is-correct::marker { color: #2e8b57; }
.q-sub.is-wrong::marker { color: var(--danger); }
.q-hint { margin-top: 1rem; background: var(--warn-soft); border-radius: 12px; padding: .5rem .8rem; }
.q-hint summary { cursor: pointer; font-weight: 700; }
.q-hint-nudge:not([open]) { animation: q-nudge .6s ease 2; }
@keyframes q-nudge { 50% { transform: translateX(4px); } }
.quiz-msg:empty { display: none; }
.quiz-note { padding: .55rem .8rem; border-radius: 10px; margin: .8rem 0 0; font-weight: 700; }
.quiz-note-retry { background: var(--warn-soft); }
.quiz-note-warn { background: var(--info-soft); color: var(--info-ink); }
.quiz-note-ok { background: var(--success-soft); color: var(--success-ink); }
.quiz-actions { margin-top: 1.1rem; display: flex; justify-content: flex-end; }
.quiz-actions .btn-lg { min-width: 10rem; }
.quiz-feedback { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: 12px; margin-bottom: .9rem; font-size: 1.1rem; }
.quiz-feedback-icon { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; color: #fff; font-weight: 700; }
.quiz-feedback.is-correct { background: var(--success-soft); color: var(--success-ink); }
.quiz-feedback.is-correct .quiz-feedback-icon { background: #2e8b57; }
.quiz-feedback.is-partial { background: var(--warn-soft); }
.quiz-feedback.is-partial .quiz-feedback-icon { background: var(--accent); }
.quiz-feedback.is-wrong { background: var(--danger-soft); color: var(--danger); }
.quiz-feedback.is-wrong .quiz-feedback-icon { background: var(--danger); }
.q-expected { margin-top: .9rem; padding: .6rem .8rem; border-radius: 10px; background: var(--success-soft); }
.q-explain { margin-top: .8rem; padding: .6rem .8rem; border-radius: 10px; background: var(--info-soft); }
.q-explain .lesson-body p:last-child { margin-bottom: 0; }

/* Summary */
.quiz-summary { max-width: 720px; margin: 0 auto; text-align: center; }
.quiz-score { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 8.5rem; height: 8.5rem; border-radius: 50%; border: 8px solid var(--primary); margin: .5rem auto; }
.quiz-score.is-ok { border-color: var(--accent); }
.quiz-score.is-low { border-color: var(--muted); }
.quiz-score-n { font-size: 2rem; font-weight: 700; }
.quiz-score-l { font-size: .85rem; color: var(--muted); }
.quiz-review { text-align: left; list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .35rem; }
.quiz-review li { display: flex; gap: .6rem; align-items: baseline; padding: .45rem .6rem; border-radius: 10px; background: var(--surface-2); }
.quiz-review-mark { font-weight: 700; width: 1.2rem; flex-shrink: 0; text-align: center; }
.quiz-review .is-correct .quiz-review-mark { color: #2e8b57; }
.quiz-review .is-partial .quiz-review-mark { color: var(--accent); }
.quiz-review .is-wrong .quiz-review-mark { color: var(--danger); }
.quiz-summary-actions { justify-content: center; }

/* Keypad */
.keypad { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 0; max-width: 26rem; }
.keypad[hidden] { display: none; }
.keypad-key { flex: 1 0 2.6rem; min-height: 2.6rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; font-size: 1.05rem; font-family: var(--font); cursor: pointer; }
.keypad-key:active { background: var(--primary-soft); }
.keypad-preview { margin-top: .4rem; padding: .3rem .6rem; border-radius: 8px; background: var(--surface-2); display: inline-block; font-size: 1.15rem; }

/* Admin */
.q-admin-list { list-style: none; padding: 0; margin: 0; }
.q-admin-item { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.q-admin-main { flex: 1 1 18rem; min-width: 0; }
.q-admin-title { font-weight: 700; display: block; margin-bottom: .15rem; overflow-wrap: anywhere; }
.q-type-tag { background: var(--primary-soft); color: var(--primary); padding: .05rem .45rem; border-radius: 6px; margin-right: .3rem; }
.q-problem { color: var(--danger); margin: .3rem 0 0; }
.q-hidden-note { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.q-editor-grid { display: grid; gap: 1rem; }
@media (min-width: 980px) {
  .q-editor-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .q-preview-col { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; width: 100%; tab-size: 2; }
.q-type-help { margin-top: .4rem; }
.q-preview-box { border: 1px dashed var(--border); border-radius: 12px; padding: .8rem; }
.q-preview-check { margin-top: .8rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.q-preview-check .quiz-note { margin: 0; }
.q-hint-preview { margin-top: .8rem; padding: .6rem .8rem; border-radius: 10px; background: var(--warn-soft); }
