/* The study page (/study). It shares the citation generator's buttons, fields,
   menus, sheets and toast (/cite/cite.css); this file adds the rest. */
.study-page { --mid: #ff9f0a; --flip: .5s; }
.study { max-width: 860px; outline: none; }

.muted { color: var(--muted); }
.hint.bad, .bad.hint { color: var(--danger); }
.btn-big { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-big.btn-icon { width: 44px; padding: 0; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn .ico, .btn > svg:not(.chev) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a.btn:hover { text-decoration: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s;
}
.icon-btn:hover { background: var(--line); color: var(--fg); }
.icon-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.star.on { color: #ffb400; }
.icon-btn.star.on svg { fill: currentColor; }

.check { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--button); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  margin-bottom: 18px;
  color: var(--link);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back svg { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.pop-panel .pop-label { margin: 6px 12px 2px; color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pop-panel button[aria-checked] { position: relative; padding-left: 32px; }
.pop-panel button[aria-checked="true"]::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 9px;
  height: 5px;
  margin-top: -4px;
  border: solid var(--button);
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}
.pop-panel button:disabled { opacity: .4; cursor: default; background: none; }

/* ---------- all sets ---------- */
.lib-actions { display: flex; justify-content: center; gap: 10px; margin-bottom: 28px; }
.set-list { padding: 8px; }
.set-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 14px;
  border-radius: 14px;
  color: var(--fg);
}
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row:hover { background: var(--bg-alt); text-decoration: none; }
.set-row-main { display: grid; gap: 1px; flex: 1; min-width: 0; }
.set-row-main strong { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row-main small { color: var(--muted); font-size: 13px; }
.meter { flex: none; width: 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; background: var(--ok); }

.start { padding: 14px; }
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.start-tile {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-alt);
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .2s var(--ease), transform .15s var(--ease);
}
.start-tile:hover { background: var(--line); text-decoration: none; }
.start-tile:active { transform: scale(.98); }
.start-tile strong { font-size: 16px; }
.start-tile span { color: var(--muted); font-size: 14px; line-height: 1.4; }

/* ---------- one set ---------- */
.set-head { margin-bottom: 22px; }
.set-head h1 { margin: 0; font-size: clamp(30px, 5vw, 44px); line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.set-desc { margin: 10px 0 0; color: var(--muted); font-size: 17px; white-space: pre-wrap; }
.set-meta { margin: 8px 0 0; color: var(--faint); font-size: 14px; }
.eyebrow { margin: 0 0 6px; color: var(--link); font-size: 13px; font-weight: 600; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.mode {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--fg);
  transition: transform .2s var(--ease-out), border-color .2s;
}
.mode:hover { text-decoration: none; border-color: var(--button); transform: translateY(-2px); }
.mode svg { width: 26px; height: 26px; margin-bottom: 8px; fill: none; stroke: var(--button); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mode strong { font-size: 16px; }
.mode small { color: var(--muted); font-size: 13px; line-height: 1.35; }

.set-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.set-tools .pop-panel { left: 0; right: auto; transform-origin: top left; }

.list-title { margin: 4px 4px 12px; font-size: 18px; font-weight: 700; }
.list-title span { color: var(--faint); font-weight: 500; }
.term-list { list-style: none; margin: 0; padding: 0; }
.term-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto;
  gap: 18px;
  align-items: start;
  padding: 14px 4px;
  border-top: 1px solid var(--line);
}
.term-row:first-child { border-top: 0; }
.term-t, .term-d { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.4; }
.term-t { font-weight: 600; }
.term-d { color: var(--fg); }
.term-row em { color: var(--faint); font-style: normal; }
.term-tools { display: flex; margin: -5px -4px 0 0; }

/* ---------- editing ---------- */
.edit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.edit-head h1 { margin: 0; font-size: clamp(28px, 5vw, 38px); font-weight: 700; letter-spacing: -0.03em; }
.edit-meta { display: grid; gap: 14px; }
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea:focus { outline: none; border-color: var(--button); box-shadow: 0 0 0 3px color-mix(in srgb, var(--button) 18%, transparent); }
.field textarea::placeholder { color: var(--faint); }
.edit-meta #set-title { height: 48px; font-size: 20px; font-weight: 600; }

.edit-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.edit-card { border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.edit-card-head { display: flex; align-items: center; gap: 2px; padding: 8px 10px 0 18px; }
.edit-num { color: var(--faint); font-size: 14px; font-weight: 600; }
.edit-card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 6px 18px 16px; }
.edit-card-body .field { display: flex; flex-direction: column; gap: 5px; }
.edit-card-body .field > span { order: 2; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.add-card {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 22px;
  border: 1.5px dashed var(--field-line);
  border-radius: 18px;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s;
}
.add-card:hover { background: var(--card); border-color: var(--button); }
.add-card:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.edit-foot { display: flex; justify-content: flex-end; margin-top: 18px; }

/* ---------- import sheet ---------- */
#importer { width: min(760px, calc(100vw - 24px)); }
.import-help { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.import-help code { padding: 1px 5px; border-radius: 5px; background: var(--bg-alt); font-size: 13px; }
.import-file { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 12px; }
.import-file .hint { margin: 0; font-size: 13px; }
#import-text { min-height: 180px; max-height: 40vh; overflow: auto; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; tab-size: 12; white-space: pre; }
.seg-mode { margin: 14px 0 12px; }
.import-seps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 12px; }
.import-seps[hidden] { display: none; }
.radios { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.radios label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.radios input[type="radio"] { width: 16px; height: 16px; margin: 0; padding: 0; border: 0; box-shadow: none; accent-color: var(--button); }
.radios .custom input[type="text"] {
  width: 110px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}
.import-preview { margin-top: 14px; }
.import-preview .preview-label { display: block; margin-bottom: 6px; }
.import-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 12px; max-height: 260px; overflow-y: auto; counter-reset: card; }
.import-list li { display: grid; grid-template-columns: 28px minmax(0, 2fr) minmax(0, 3fr); gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 14px; counter-increment: card; }
.import-list li::before { content: counter(card); color: var(--faint); font-size: 12px; padding-top: 2px; }
.import-list li:first-child { border-top: 0; }
.import-list span { white-space: pre-wrap; overflow-wrap: anywhere; }
.import-list span:first-child { font-weight: 600; }
.import-list em { color: var(--faint); font-style: normal; font-weight: 400; }
.import-count { color: var(--muted); font-size: 13px; }

/* ---------- study modes ---------- */
.mode-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 20px; }
.mode-bar .back { margin: 0; }
.mode-bar > :last-child { justify-self: end; }
.mode-name { font-size: 15px; font-weight: 700; }

.progress { height: 4px; margin: 10px 0 18px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--button); transition: width .3s var(--ease); }

.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px; padding: 0 10px; border-radius: 980px; font-size: 13px; font-weight: 600; }
.pill-good { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill-bad { background: color-mix(in srgb, var(--mid) 18%, transparent); color: color-mix(in srgb, var(--mid) 70%, var(--fg)); }

/* Flashcards */
.fc-top { display: flex; align-items: center; justify-content: space-between; }
.fc-count { color: var(--muted); font-size: 15px; font-weight: 600; }
.fc-card { perspective: 1600px; height: clamp(300px, 52vh, 440px); cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.fc-card:focus-visible .fc-face { box-shadow: 0 0 0 3px color-mix(in srgb, var(--button) 40%, transparent); }
.fc-inner { position: relative; height: 100%; transform-style: preserve-3d; transition: transform var(--flip) var(--ease-out); }
.fc-card.flipped .fc-inner { transform: rotateX(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.fc-back { transform: rotateX(180deg); }
.fc-tools { display: flex; align-items: center; gap: 2px; }
.fc-side { color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.fc-text {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0 8px;
  overflow-y: auto;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.3;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fc-text.tx-m { font-size: clamp(18px, 2.8vw, 23px); }
.fc-text.tx-s { font-size: 16px; line-height: 1.45; text-align: left; place-items: start; }
.fc-card.in-right .fc-inner { animation: in-right .3s var(--ease-out); }
.fc-card.in-left .fc-inner { animation: in-left .3s var(--ease-out); }
@keyframes in-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes in-left { from { opacity: 0; transform: translateX(-40px); } }
.fc-controls { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px; }
.fc-controls .btn svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fc-no { color: color-mix(in srgb, var(--mid) 75%, var(--fg)); }
.fc-yes { color: var(--ok); }
.fc-no, .fc-yes { min-width: 150px; }
.kbd-hint { margin: 14px 0 0; color: var(--faint); font-size: 12px; text-align: center; }
@media (hover: none) { .kbd-hint { display: none; } }

/* Finish screens */
.done { padding: 40px 12px; text-align: center; }
.done h2 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 32px); font-weight: 700; letter-spacing: -0.025em; }
.done .muted { margin: 0 0 6px; font-size: 16px; }
.done-badge { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 50%; background: color-mix(in srgb, var(--button) 12%, transparent); color: var(--button); }
.done-badge svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.done-stats { display: flex; justify-content: center; gap: 8px; margin: 12px 0 0; }
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.done-actions.left { justify-content: flex-start; margin-top: 14px; }

/* Learn */
.learn-progress { margin-bottom: 18px; }
.seg-bar { display: flex; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.seg-bar span { height: 100%; transition: width .4s var(--ease); }
.seg-bar .good, .seg-legend i.good { background: var(--ok); }
.seg-bar .mid, .seg-legend i.mid { background: var(--mid); }
.seg-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.seg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.seg-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }

.q-card { padding: 22px; border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.q-top { display: flex; align-items: center; justify-content: space-between; margin: -6px -6px 0 0; }
.q-kind { color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.q-prompt { min-height: 80px; margin: 10px 0 24px; font-size: clamp(22px, 3.6vw, 28px); line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.q-prompt.tx-m { font-size: 20px; }
.q-prompt.tx-s { font-size: 16px; line-height: 1.45; }
.q-label { display: block; margin: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border: 1.5px solid var(--field-line);
  border-radius: 14px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.choice span { white-space: pre-wrap; overflow-wrap: anywhere; }
.choice:hover:not(:disabled) { border-color: var(--button); }
.choice:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.choice:disabled { cursor: default; }
.choice kbd { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 6px; color: var(--faint); font: 600 12px var(--font); }
.choice.is-right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--field)); }
.choice.is-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--field)); }
.choice input { flex: none; margin: 2px 0 0; accent-color: var(--button); }

.q-write input, .tq-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1.5px solid var(--field-line);
  border-radius: 14px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 17px;
}
.q-write input:focus, .tq-input:focus { outline: none; border-color: var(--button); box-shadow: 0 0 0 3px color-mix(in srgb, var(--button) 18%, transparent); }
.q-write input.is-right { border-color: var(--ok); }
.q-write input.is-wrong { border-color: var(--danger); text-decoration: line-through; }
.q-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.q-feedback:empty { display: none; }
.q-feedback { margin-top: 14px; }
.fb-good, .fb-bad { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 700; }
.fb-good { color: var(--ok); }
.fb-bad { color: var(--danger); }
.fb-good svg, .fb-bad svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fb-label { margin: 12px 0 4px; color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.fb-answer, .fb-given { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-answer { border: 1.5px solid var(--ok); }
.fb-given { border: 1.5px dashed var(--danger); }
.q-feedback > .fb-answer:nth-child(2) { margin-top: 8px; }

.round-list { max-width: 560px; margin: 20px auto 0; padding: 0; list-style: none; text-align: left; }
.round-list li { display: grid; grid-template-columns: 24px minmax(0, 2fr) minmax(0, 3fr); gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); font-size: 15px; }
.round-list li > span:last-child { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.round-list strong { font-weight: 600; overflow-wrap: anywhere; }
.round-list svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round-list .good { color: var(--ok); }
.round-list .bad { color: var(--danger); }

/* Test */
.test-setup { max-width: 520px; margin: 0 auto; padding: 24px; }
.test-setup h2 { margin: 0 0 18px; font-size: 22px; font-weight: 700; }
.row-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 15px; }
.row-field small { color: var(--faint); }
.row-field input { width: 84px; height: 36px; padding: 0 10px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--fg); font: inherit; font-size: 15px; text-align: center; }
.row-kinds { display: grid; gap: 10px; margin: 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); }
.row-kinds legend { float: left; width: 100%; margin-bottom: 4px; padding: 0; font-size: 15px; }
.test-setup .hint { margin-top: 10px; }
.test-meta { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.test-section h2 { margin: 28px 0 12px; font-size: 20px; font-weight: 700; }
.tq { display: block; min-width: 0; margin: 0 0 12px; padding: 20px; }
fieldset.tq { border: 1px solid var(--line); }
.tq-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tq-num { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--bg-alt); color: var(--muted); font-size: 13px; font-weight: 600; }
.tq-prompt { margin: 0 0 16px; font-size: 20px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.tq-prompt.tx-m, .tq-prompt.tx-s { font-size: 16px; }
.tq-shown { display: grid; gap: 4px; margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; background: var(--bg-alt); font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tf { display: flex; gap: 10px; }
.tf label { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: 1.5px solid var(--field-line); border-radius: 980px; font-size: 15px; cursor: pointer; }
.tf label:has(input:checked) { border-color: var(--button); background: color-mix(in srgb, var(--button) 8%, transparent); }
.tf input { margin: 0; accent-color: var(--button); }
label.choice:has(input:checked) { border-color: var(--button); }
.tq-fix { margin-top: 12px; font-size: 15px; }
.tq-fix:empty { display: none; }
.tq.is-right { border-color: var(--ok); }
.tq.is-wrong { border-color: var(--danger); }
.tq-match .bank { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 0 0 16px; padding: 12px 14px 12px 34px; border-radius: 12px; background: var(--bg-alt); font-size: 15px; }
.tq-match .bank li { padding-left: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tq-match .bank li::marker { color: var(--faint); font-weight: 600; }
.match-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 28px; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.match-prompt { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.match-row .select { width: 84px; }
.match-row .tq-fix { margin: 0; color: var(--danger); font-weight: 700; text-align: center; }
.match-row.is-right .tq-fix { color: var(--ok); }
.match-row .tq-fix svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.test-submit { display: flex; justify-content: center; margin-top: 24px; }

.score { display: flex; align-items: center; gap: 24px; margin-bottom: 8px; padding: 24px; }
.score h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
.score .muted { margin: 0; }
.ring {
  flex: none;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0);
}
.ring span { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--card); font-size: 24px; font-weight: 700; }

/* Match */
.match-time { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.match-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile {
  min-height: 128px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, opacity .25s, transform .25s var(--ease-out);
}
.tile.tx-m { font-size: 14px; }
.tile.tx-s { font-size: 12px; text-align: left; }
.tile:hover { border-color: var(--field-line); }
.tile:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.tile.sel { border-color: var(--button); background: color-mix(in srgb, var(--button) 8%, var(--card)); }
.tile.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--card)); }
.tile.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); animation: shake .4s; }
.tile.gone { opacity: 0; transform: scale(.9); visibility: hidden; transition: opacity .25s, transform .25s, visibility 0s .25s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .modes { grid-template-columns: 1fr 1fr; }
  .start-grid { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .lib-actions { flex-wrap: wrap; }
  .term-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .term-t { grid-column: 1; }
  .term-d { grid-column: 1; grid-row: 2; }
  .term-tools { grid-column: 2; grid-row: 1 / 3; }
  .edit-card-body { grid-template-columns: 1fr; gap: 10px; padding: 4px 14px 14px; }
  .edit-card-head { padding-left: 14px; }
  .import-seps { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .fc-no, .fc-yes { min-width: 0; flex: 1; }
  .fc-no span, .fc-yes span { font-size: 14px; }
  .match-grid { gap: 8px; }
  .tile { min-height: 100px; padding: 8px; font-size: 14px; }
  .tile.tx-m { font-size: 12px; }
  .tile.tx-s { font-size: 11px; }
  .q-card { padding: 18px; }
  .score { flex-direction: column; align-items: flex-start; gap: 14px; }
  .tq-match .bank { grid-template-columns: 1fr; }
  .mode-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .mode-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .study-page { --flip: 0s; }
  .fc-card.in-right .fc-inner, .fc-card.in-left .fc-inner, .tile.bad { animation: none; }
  .mode:hover { transform: none; }
}
