/* Midterm questions page. Uses the tokens from styles.css. */

/* ---------- header ---------- */
.mt-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center; margin-bottom: 24px; --a: var(--rose); --a-soft: var(--rose-soft); }
.mt-head .lib-icon { width: 60px; height: 60px; border-radius: 18px; }
.mt-head .lib-icon svg, .mt-nav-toggle svg, .lib-midterm .lib-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mt-head .lib-icon svg { width: 28px; height: 28px; }
.mt-head h1 { font-size: clamp(30px, 4.4vw, 46px); letter-spacing: -0.04em; }
.mt-head p { color: var(--ink-2); margin-top: 6px; max-width: 62ch; }
.mt-progress { display: flex; align-items: center; gap: 16px; padding: 12px 18px 12px 12px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.mt-ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.mt-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mt-ring circle { fill: none; stroke-width: 7; }
.mt-ring-bg { stroke: var(--bg-2); }
.mt-ring-fg { stroke: var(--rose); stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease); }
.mt-ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 14px var(--font); }
.mt-stats { display: grid; grid-template-columns: repeat(5, auto); gap: 4px 16px; margin: 0; }
.mt-stats div { display: flex; flex-direction: column; }
.mt-stats dt { font-size: 11px; color: var(--ink-3); }
.mt-stats dd { margin: 0; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.mt-stats .v-ok dd { color: var(--mint); }
.mt-stats .v-part dd { color: var(--gold); }
.mt-stats .v-bad dd { color: var(--rose); }

/* ---------- filters ---------- */
.mt-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.mt-filters .chips { margin: 0; }
.mt-types .chip span { font: 500 11px var(--mono); color: var(--ink-3); margin-left: 4px; }
.mt-types .chip.on span { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.mt-filters [data-reset-all] { margin-left: auto; color: var(--ink-3); }
.mt-filters [data-reset-all][data-armed] { color: var(--rose); background: var(--rose-soft); }

/* ---------- layout ---------- */
.mt-body { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 24px; align-items: start; }
.mt-nav { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; scrollbar-width: thin; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.mt-nav-toggle { display: none; }
.mt-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; color: var(--ink-3); padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg::before { content: ''; width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid var(--line-2); background: var(--surface); }
.lg.answered::before { background: var(--lav-soft); border-color: var(--lav); }
.lg.correct::before { background: var(--mint); border-color: var(--mint); }
.lg.partial::before { background: var(--gold); border-color: var(--gold); }
.lg.incorrect::before { background: var(--rose); border-color: var(--rose); }
.mt-group h3 { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 14px 0 8px; letter-spacing: 0; }
.mt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 5px; }
.mt-dot {
  height: 32px; border-radius: 9px; display: grid; place-items: center; font: 500 12px var(--mono); color: var(--ink-2);
  border: 1.5px solid var(--line); background: var(--surface-2); transition: transform .25s var(--ease-spring), background .3s, border-color .3s, color .3s;
}
.mt-dot:hover { transform: translateY(-2px); border-color: var(--line-2); color: var(--ink); }
.mt-dot.answered { background: var(--lav-soft); border-color: color-mix(in srgb, var(--lav) 55%, transparent); color: var(--ink); }
.mt-dot.reviewed { background: var(--peri-soft); border-color: color-mix(in srgb, var(--peri) 50%, transparent); }
.mt-dot.correct { background: var(--mint); border-color: var(--mint); color: #fff; }
.mt-dot.partial { background: var(--gold); border-color: var(--gold); color: #fff; }
.mt-dot.incorrect { background: var(--rose); border-color: var(--rose); color: #fff; }
.mt-dot.cur { outline: 2px solid var(--ink); outline-offset: 2px; }
.mt-none { color: var(--ink-3); font-size: 14px; padding: 12px 0; }

/* ---------- question card ---------- */
.mt-stage { min-width: 0; }
.mtq { border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md); padding: clamp(18px, 3vw, 32px); }
.mtq.enter { animation: mtq-in .45s var(--ease) both; }
.mtq.leave { animation: mtq-out .17s ease both; }
@keyframes mtq-in { from { opacity: 0; transform: translateX(calc(var(--dir, 1) * var(--flip, 1) * 26px)); } }
@keyframes mtq-out { to { opacity: 0; transform: translateX(calc(var(--dir, 1) * var(--flip, 1) * -18px)); } }
/* right to left */
[dir="rtl"] .mtq-step { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mt-filters [data-reset-all] { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mt-pill { margin-left: 0; margin-right: auto; }
[dir="rtl"] .fc-end { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mt-note { border-left: 0; border-right: 3px solid var(--gold); border-radius: 10px 0 0 10px; }
[dir="rtl"] .mt-nav-toggle b { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mt-videos summary::after { margin-left: 0; margin-right: auto; }
.mt-opt-t code, .mtq-prompt code, .mt-explain code, .mt-note code, .mt-prose code { unicode-bidi: isolate; }
.mtq-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mtq-num { font-size: 14px; color: var(--ink-3); display: flex; align-items: baseline; gap: 6px; }
.mtq-num b { font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -0.03em; }
.mtq-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); }
.mchip.t-mcq { background: var(--lav-soft); color: var(--lav); }
.mchip.t-output { background: var(--peri-soft); color: var(--peri); }
.mchip.t-code { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 80%, var(--ink)); }
.mchip.t-flow { background: var(--mint-soft); color: var(--mint); }
.mchip.t-written { background: var(--rose-soft); color: var(--rose); }
.mtq-src { font-size: 13px; color: var(--ink-3); margin-top: 8px; }
.mtq-src a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.mtq-src a:hover { color: var(--ink); }
.mtq-prompt { margin-top: 18px; font-size: 16.5px; line-height: 1.65; max-width: 78ch; }
.mtq-prompt p { margin: 0 0 10px; }
.mtq-prompt ul, .mtq-prompt ol { margin: 0 0 12px; padding-left: 22px; }
.mtq-prompt li { margin: 4px 0; }
.mtq-prompt code, .mt-prose code, .mt-explain code, .mt-note code, .mt-opt-t code:not(.mt-optcode) {
  font: 500 .88em var(--mono); background: var(--bg-2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line);
}
.mt-code { margin: 6px 0 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.7; max-width: 100%; overflow-x: auto; white-space: pre; }
.mt-code.mini { margin: 0; padding: 10px 14px; font-size: 12.5px; border-radius: 10px; }
.mt-out { margin: 6px 0 14px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font: 400 13.5px/1.7 var(--mono); white-space: pre-wrap; overflow-x: auto; color: var(--ink); }
.mt-fig { margin: 6px 0 14px; }
.mt-fig img { max-width: min(100%, 560px); max-height: 560px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 8px; }
.mt-fig.small img { max-width: min(100%, 320px); }
:root[data-theme="dark"] .mt-fig img, :root[data-theme="dark"] .mt-orig img { filter: brightness(.92); }

/* parts */
.mtp { margin-top: 22px; }
.mtp + .mtp { padding-top: 22px; border-top: 1px dashed var(--line-2); }
.mtp-label { font-size: 15px; font-weight: 600; margin-bottom: 10px; letter-spacing: -0.01em; }

/* multiple choice */
.mt-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.mt-opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 14px; min-height: 56px;
  border: 1.5px solid var(--line); background: var(--surface-2); transition: border-color .2s, background .2s, transform .25s var(--ease-spring), box-shadow .2s;
}
.mt-opt:hover:not(:disabled) { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mt-opt:active:not(:disabled) { transform: scale(.98); }
.mt-opt:disabled { cursor: default; }
.mt-letter { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font: 600 13px var(--mono); background: var(--bg-2); color: var(--ink-2); transition: all .25s; }
.mt-opt-t { min-width: 0; font-size: 15px; line-height: 1.45; }
.mt-optcode { font: 500 14px var(--mono); color: var(--ink); white-space: pre-wrap; }
.mt-opt.on { border-color: var(--lav); background: var(--lav-soft); }
.mt-opt.on .mt-letter { background: var(--lav); color: #fff; }
.mt-opt.is-correct { border-color: var(--mint); background: var(--mint-soft); }
.mt-opt.is-correct .mt-letter { background: var(--mint); color: #fff; }
.mt-opt.is-wrong { border-color: var(--rose); background: var(--rose-soft); }
.mt-opt.is-wrong .mt-letter { background: var(--rose); color: #fff; }

/* text inputs */
.mt-input {
  width: 100%; resize: vertical; min-height: 96px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  font: 400 15px/1.6 var(--font); color: var(--ink); transition: border-color .2s, box-shadow .2s, background .2s;
}
.mt-input.mono { font: 400 14px/1.7 var(--mono); }
.mt-input:focus { outline: none; border-color: var(--lav); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--lav) 16%, transparent); }
.mt-input::placeholder { color: var(--ink-3); }

/* actions */
.mtq-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.mtq-step { margin-left: auto; display: flex; gap: 8px; }
.mtq-step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-reset-q][data-armed] { color: var(--rose); background: var(--rose-soft); }
.mt-verdict { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 14px; animation: pop .45s var(--ease-spring); }
.mt-verdict::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.mt-verdict.correct { background: var(--mint-soft); color: var(--mint); }
.mt-verdict.partial { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 85%, var(--ink)); }
.mt-verdict.incorrect { background: var(--rose-soft); color: var(--rose); }
.mt-verdict.pending { background: var(--peri-soft); color: var(--peri); }

/* ---------- answers ---------- */
.mtp-ans { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .55s var(--ease); }
.mtp-ans.open { grid-template-rows: 1fr; }
.mtp-ans > div { overflow: hidden; min-width: 0; }
.mtp-ans.open > div { padding-top: 16px; }
.mtp-ans > div:empty { padding: 0; }
.mt-ans-head { display: flex; gap: 8px; margin-bottom: 10px; }
.mt-prov { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.mt-prov.official { background: var(--mint-soft); color: var(--mint); }
.mt-prov.collection { background: var(--peri-soft); color: var(--peri); }
.mt-res { padding: 12px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 500; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mt-res::before { content: ''; flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background-position: center; background-repeat: no-repeat; background-size: 12px; }
.mt-res.correct { background: var(--mint-soft); color: color-mix(in srgb, var(--mint) 75%, var(--ink)); }
.mt-res.correct::before { background-color: var(--mint); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.mt-res.partial { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 70%, var(--ink)); }
.mt-res.partial::before { background-color: var(--gold); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E"); }
.mt-res.incorrect { background: var(--rose-soft); color: color-mix(in srgb, var(--rose) 75%, var(--ink)); }
.mt-res.incorrect::before { background-color: var(--rose); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E"); }
.mt-model h4, .mt-compare h4, .mt-explain h4 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; letter-spacing: 0; }
.mt-explain p, .mt-prose p { font-size: 15px; color: var(--ink); margin: 0 0 6px; line-height: 1.6; }
.mt-explain { padding: 2px 0; }
.mt-compare .mt-out span.ok { color: var(--mint); }
.mt-compare .mt-out span.close { color: color-mix(in srgb, var(--gold) 85%, var(--ink)); }
.mt-compare .mt-out span.miss { color: var(--ink); background: color-mix(in srgb, var(--rose) 14%, transparent); border-radius: 3px; }
.mt-note { font-size: 13.5px; color: var(--ink-2); background: var(--gold-soft); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 14px 0 0; }
.mt-runrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.mt-term { margin-top: 10px; border-radius: 12px; background: #150F21; color: #E2DBF2; font: 400 13px/1.65 var(--mono); padding: 12px 16px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.mt-term .tdim, .ce-term .tdim { color: #7D72A0; }
.mt-term .err, .ce-term .err { color: #F6A3A3; }
.mt-self { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.mt-self span { font-size: 14px; color: var(--ink-2); margin-right: 4px; }
.mt-self-b { height: 34px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; transition: all .2s; }
.mt-self-b:hover { border-color: var(--line-2); }
.mt-self-b.correct.on { background: var(--mint); border-color: var(--mint); color: #fff; }
.mt-self-b.partial.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.mt-self-b.incorrect.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.mt-check { margin-top: 12px; }
.mt-check:empty { display: none; }
.mt-test { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.mt-test-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.mt-test-h b { color: var(--ink); }
.mt-pill { margin-left: auto; font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500; }
.mt-pill.correct { background: var(--mint-soft); color: var(--mint); }
.mt-pill.partial { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 85%, var(--ink)); }
.mt-pill.incorrect { background: var(--rose-soft); color: var(--rose); }
.mt-test-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.mt-test-cols h5 { margin: 0 0 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.mt-test-cols .mt-out { margin: 0; font-size: 12.5px; max-height: 200px; }
.mt-fine { font-size: 12.5px; color: var(--ink-3); margin: 4px 0 0; }
.mt-checks { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.mt-checks li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.mt-checks li b { font-weight: 500; }
.mt-checks small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.mt-ck { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; margin-top: 2px; background-position: center; background-repeat: no-repeat; background-size: 11px; }
.mt-checks .ok .mt-ck { background-color: var(--mint); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.mt-checks .part .mt-ck { background-color: var(--gold); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E"); }
.mt-checks .bad .mt-ck { background-color: var(--rose); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E"); }
.mt-flow-answer { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); overflow-x: auto; }
.mt-flow-answer svg { width: 100%; height: auto; margin: 0 auto; }
.mt-orig { margin-top: 10px; font-size: 14px; }
.mt-orig summary { cursor: pointer; color: var(--ink-2); }
.mt-orig img { margin-top: 10px; max-width: min(100%, 520px); border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 8px; }

/* ---------- code editor (terminal style) ---------- */
.ce { border-radius: 16px; overflow: hidden; background: var(--code-bg); color: var(--code-ink); box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(255,255,255,.05); }
.ce-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--code-bg-2); border-bottom: 1px solid var(--code-line); flex-wrap: wrap; }
.ce-file { font: 400 12px var(--mono); color: var(--code-dim); }
.ce-ctrl { margin-left: auto; display: flex; gap: 6px; }
.ce-ctrl .ectl[disabled] { opacity: .6; cursor: progress; }
.ce-edit { position: relative; font: 400 14px/1.7 var(--mono); font-variant-ligatures: none; }
.ce-hl, .ce-ta, .mt-code, .mt-out, .mt-input.mono, .fc-text, .mt-term, .ce-term, .ed-code { font-variant-ligatures: none; }
.ce-hl, .ce-ta {
  margin: 0; padding: 16px 18px; font: inherit; tab-size: 4; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; letter-spacing: 0; border: 0;
}
.ce-hl { position: absolute; inset: 0; pointer-events: none; color: var(--code-ink); overflow: hidden; }
.ce-ta { position: relative; display: block; width: 100%; min-height: 150px; resize: none; background: transparent; color: transparent; caret-color: #F29CC4; outline: none; overflow: hidden; }
.ce-ta::selection { background: rgba(169, 186, 255, .3); color: transparent; }
.ce-ta::placeholder { color: #6E6390; }
.ce-ta:focus-visible { box-shadow: inset 0 0 0 2px rgba(242, 156, 196, .45); }
.ce-term { border-top: 1px solid var(--code-line); background: #150F21; color: #E2DBF2; font: 400 13px/1.65 var(--mono); padding: 12px 18px; min-height: 64px; max-height: 280px; overflow: auto; white-space: pre-wrap; }
.ce-term .tline { animation: fade-up .25s var(--ease) both; }

/* ---------- flowchart editor ---------- */
.fc { border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; }
.fc-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.fc-group { display: flex; gap: 4px; flex-wrap: wrap; padding-right: 8px; border-right: 1px solid var(--line); }
.fc-group:last-child { border-right: 0; }
.fc-end { margin-left: auto; padding-right: 0; border-right: 0; }
.fc-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 13px; transition: all .2s;
}
.fc-btn:hover { border-color: var(--line-2); background: var(--surface); }
.fc-btn svg { width: 22px; height: 16px; fill: var(--lav-soft); stroke: var(--lav); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.fc-btn.icon { width: 36px; padding: 0; justify-content: center; }
.fc-btn.icon svg, .fc-modes svg { width: 17px; height: 17px; fill: none; stroke: currentColor; }
.fc-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fc-btn.armed { background: var(--rose); color: #fff; border-color: var(--rose); }
.fc-btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.fc-btn.danger { color: var(--rose); }
.fc-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); background: var(--lav-soft); animation: fade-in .2s both; }
.fc-edit[hidden] { display: none; }
.fc-edit-l { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; font-size: 12px; color: var(--ink-2); }
.fc-edit-k { white-space: nowrap; }
.fc-label { flex: 1; min-width: 0; resize: none; font: 400 14px/1.4 var(--mono); padding: 7px 10px; border-radius: 9px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); }
.fc-label:focus { outline: none; border-color: var(--lav); }
.fc-edge-btns { display: none; gap: 4px; }
.fc-edit.is-edge .fc-edge-btns { display: flex; }
.fc-canvas { position: relative; overflow: auto; outline: none; background-image: radial-gradient(color-mix(in srgb, var(--ink) 12%, transparent) 1px, transparent 1.2px); background-size: 20px 20px; }
.fc-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--lav); }
.fc-canvas > .fc-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.fc-canvas.connecting { cursor: crosshair; }
.fc-empty { display: none; position: absolute; inset: 0; place-items: center; text-align: center; padding: 24px; color: var(--ink-3); font-size: 14px; pointer-events: none; }
.fc-empty b { color: var(--ink-2); font-weight: 600; }
.fc-canvas.is-empty .fc-empty { display: grid; }
.fc-hint { min-height: 0; font-size: 12.5px; color: var(--ink-2); padding: 0 12px; }
.fc-hint:not(:empty) { padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); }

.fc-svg .fc-shape { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.6; transition: fill .2s, stroke .2s; }
.fc-svg .fc-t .fc-shape { fill: var(--rose-soft); stroke: var(--rose); }
.fc-svg .fc-io .fc-shape { fill: var(--peri-soft); stroke: var(--peri); }
.fc-svg .fc-d .fc-shape { fill: var(--gold-soft); stroke: var(--gold); }
.fc-svg .fc-p .fc-shape { fill: var(--lav-soft); stroke: var(--lav); }
.fc-svg .fc-text { fill: var(--ink); font: 500 13px var(--mono); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fc-svg .fc-node { cursor: grab; }
.fc-svg .fc-node:active { cursor: grabbing; }
.fc-canvas.connecting .fc-node { cursor: crosshair; }
.fc-svg .fc-node.sel .fc-shape { stroke-width: 2.6; filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--lav) 45%, transparent)); }
.fc-svg .fc-node.pending .fc-shape { stroke-dasharray: 5 4; stroke-width: 2.4; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -18; } }
.fc-svg .fc-line { fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linejoin: round; }
.fc-svg .fc-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.fc-svg .fc-edge.sel .fc-line { stroke: var(--lav); stroke-width: 2.6; }
.fc-svg .fc-arrow { fill: var(--ink-2); }
.fc-svg .fc-elabel { fill: var(--ink-2); font: 600 12px var(--font); paint-order: stroke; stroke: var(--surface-2); stroke-width: 4px; stroke-linejoin: round; }
.fc-static .fc-node { cursor: default; }
.fc-static .fc-hit { display: none; }

/* ---------- home card ---------- */
.lib-midterm { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 28px; align-items: center; min-height: 0; }
.lib-midterm .lm-copy h3 { margin-top: 14px; }
.lm-types { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.lm-types li { padding: 10px 12px; border-radius: 12px; background: var(--a-soft); display: flex; flex-direction: column; }
.lm-types b { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; color: var(--ink); }
.lm-types span { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.lib-midterm .lib-meta { flex-direction: column; align-items: flex-end; padding: 0; margin: 0; gap: 14px; }

/* exams page link to the practice section */
.mt-banner { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--r-lg); background: var(--rose-soft); border: 1px solid color-mix(in srgb, var(--rose) 25%, transparent); margin-bottom: 18px; transition: transform .3s var(--ease), box-shadow .3s; }
.mt-banner:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mt-banner b { display: block; font-size: 16px; }
.mt-banner span { font-size: 14px; color: var(--ink-2); }
.mt-banner .btn { margin-left: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .mt-head { grid-template-columns: auto minmax(0, 1fr); }
  .mt-progress { grid-column: 1 / -1; justify-self: start; }
  .mt-body { grid-template-columns: minmax(0, 1fr); }
  .mt-nav { position: relative; top: 0; max-height: none; padding: 0; overflow: visible; }
  .mt-nav-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; border: 0; background: none; font-size: 14px; font-weight: 500; }
  .mt-nav-toggle svg { width: 20px; height: 20px; color: var(--rose); }
  .mt-nav-toggle b { margin-left: auto; font: 500 12px var(--mono); color: var(--ink-3); }
  .mt-nav-body { display: none; padding: 0 16px 16px; max-height: 50vh; overflow: auto; }
  .mt-nav.open .mt-nav-body { display: block; animation: fade-in .25s both; }
  .lib-midterm { grid-template-columns: minmax(0, 1fr); }
  .lib-midterm .lib-meta { flex-direction: row; align-items: center; }
}
@media (max-width: 720px) {
  .mt-head { grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
  .mt-head .lib-icon { width: 48px; height: 48px; border-radius: 14px; }
  .mt-progress { width: 100%; padding: 10px 12px; gap: 12px; }
  .mt-ring { width: 54px; height: 54px; }
  .mt-stats { grid-template-columns: repeat(3, auto); gap: 4px 14px; }
  .mt-types { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
  .mt-types .chip { white-space: nowrap; }
  .mt-filters [data-reset-all] { margin-left: 0; }
  .mtq { border-radius: var(--r-lg); padding: 18px 16px; }
  .mtq-prompt { font-size: 15.5px; }
  .mtq-step { width: 100%; margin-left: 0; }
  .mtq-step .btn { flex: 1; justify-content: center; }
  .mt-test-cols { grid-template-columns: minmax(0, 1fr); }
  .fc-btn span { display: none; }
  .fc-group [data-add] span { display: inline; font-size: 11.5px; }
  .fc-btn { padding: 0 8px; }
  .fc-end { margin-left: 0; }
  .ce-edit { font-size: 13px; }
  .mt-banner { flex-wrap: wrap; }
  .mt-banner .btn { margin-left: 0; }
}
