:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --bg-glow: rgba(255, 255, 255, 0.85);
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --control-bg: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --primary-text: #ffffff;
  --accent: #ff46a2;
  --accent-soft: #fff0f8;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --danger-border: #f1b2ac;
  --warn: #946200;
  --warn-soft: #fff7df;
  --ok: #067647;
  --ok-soft: #e8f8ef;
  --bad-soft: #feecec;
  --badge-bg: #eef2f6;
  --badge-text: #3f4a5d;
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --attempt-head-bg: rgba(255, 255, 255, 0.92);
  --sticky-bg: rgba(245, 246, 248, 0.92);
  --progress-track: #e8ecf2;
  --image-bg: #ffffff;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.07);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101216;
  --bg-glow: rgba(42, 49, 61, 0.42);
  --surface: #181b21;
  --surface-soft: #20242c;
  --control-bg: #15181e;
  --text: #edf1f7;
  --muted: #a4adbc;
  --subtle: #818b9b;
  --line: #303744;
  --line-strong: #475163;
  --primary: #f3f6fb;
  --primary-hover: #dce4ef;
  --primary-text: #101216;
  --accent: #ff46a2;
  --accent-soft: #421a30;
  --danger: #ff9b92;
  --danger-soft: #3b1d1c;
  --danger-border: #7d3934;
  --warn: #f4ca6a;
  --warn-soft: #352b12;
  --ok: #67d99a;
  --ok-soft: #173522;
  --bad-soft: #3a1d20;
  --badge-bg: #29313d;
  --badge-text: #c4ccd8;
  --topbar-bg: rgba(24, 27, 33, 0.88);
  --attempt-head-bg: rgba(24, 27, 33, 0.94);
  --sticky-bg: rgba(16, 18, 22, 0.92);
  --progress-track: #2b3340;
  --image-bg: #0f1115;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, var(--bg-glow), rgba(245, 246, 248, 0) 260px),
    var(--bg);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  display: flex;
  flex-direction: column;
}

body.has-site-footer {
  padding-bottom: 0;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  outline-color: var(--accent);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  box-shadow: 0 1px 16px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  width: min(1180px, calc(100vw - 32px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 820;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.nav a,
.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  padding: 8px 12px;
}

.theme-toggle {
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -5px -5px 0 0 currentColor;
}

:root[data-theme="dark"] .theme-toggle-icon {
  box-shadow: inset 5px -5px 0 0 var(--surface);
}

.nav a:hover,
.nav-action {
  background: var(--surface-soft);
  color: var(--text);
}

.shell {
  flex: 1 0 auto;
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 54px;
}

.page-head,
.attempt-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.attempt-head {
  position: sticky;
  top: 69px;
  z-index: 10;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--attempt-head-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(30px, 4vw, 48px);
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 17px;
}

.lead {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.muted {
  margin: 7px 0 0;
  color: var(--muted);
}

.toolbar,
.actions,
.upload-box,
.sticky-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar {
  margin-bottom: 20px;
}

.toolbar.compact {
  align-items: stretch;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 680;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-text);
}

.btn.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.btn.small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

.btn.loading {
  opacity: 0.72;
  pointer-events: none;
}

.search {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

input[type="search"],
input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--control-bg);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

input[type="search"] {
  width: min(460px, 100%);
}

.auth-panel {
  width: min(520px, 100%);
  margin: 0 auto;
}

textarea {
  width: 100%;
  resize: vertical;
}

select {
  min-width: 160px;
}

.hidden {
  display: none;
}

.test-grid,
.question-list,
.upload-layout {
  display: grid;
  gap: 16px;
}

.test-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}

.upload-layout {
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: start;
}

.card,
.panel,
.empty,
.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card,
.panel,
.empty,
.notice {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.card {
  padding: 18px;
}

.panel,
.empty,
.notice {
  padding: 22px;
  margin-bottom: 18px;
}

.test-card {
  min-height: 218px;
  display: grid;
  gap: 12px;
  align-content: space-between;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.test-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.test-card p {
  margin: 0;
  color: var(--muted);
}

.test-card-head {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.test-card-head h2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.test-card-head p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.test-card-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.test-card-summary span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 4px 8px;
}

.test-start {
  width: 100%;
}

.mode-launcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-launcher form {
  min-width: 0;
}

.mode-card {
  width: 100%;
  min-height: 58px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.mode-card:hover {
  border-color: var(--line-strong);
  background: var(--control-bg);
}

.mode-card:active {
  transform: translateY(1px);
}

.mode-card strong {
  font-size: 14px;
}

.mode-card span,
.review-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.review-link {
  justify-self: start;
}

.review-link:hover {
  color: var(--text);
}

a.mode-card {
  text-decoration: none;
}

.mode-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.mode-details summary {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
  user-select: none;
}

.mode-details summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--subtle);
  font-weight: 780;
}

.mode-details summary:hover {
  color: var(--text);
}

.mode-details summary:hover::after {
  border-color: var(--line-strong);
  color: var(--text);
}

.mode-details[open] summary {
  margin-bottom: 8px;
}

.mode-details[open] summary::after {
  content: "-";
}

.home-more-panel {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.home-more-panel h2 {
  margin: 0;
}

.home-more-panel .btn {
  flex: 0 0 auto;
}

.admin-table {
  display: grid;
  gap: 16px;
}

.admin-table-head,
.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.admin-table-head .btn {
  justify-self: end;
}

.table-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.8fr) auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.admin-row h3 {
  margin-top: 8px;
}

.admin-row-metrics {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.admin-row-metrics span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--control-bg);
  padding: 4px 8px;
}

.admin-row-actions {
  justify-content: flex-end;
}

.meta,
.stats {
  display: grid;
  gap: 12px;
}

.meta {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 20px;
}

.meta div,
.stats div {
  min-width: 0;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.meta dt,
.stats span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.meta dd {
  margin: 0;
  font-size: 22px;
  font-weight: 780;
}

.stats strong {
  font-size: 28px;
  line-height: 1;
}

.solved-count {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.empty {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
}

.empty p {
  max-width: 430px;
  margin: 0 0 8px;
  color: var(--muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 24px;
  font-weight: 740;
}

.notice {
  border-color: #f0cf83;
  background: var(--warn-soft);
  color: var(--warn);
}

.notice p {
  margin: 0 0 8px;
}

.notice p:last-child {
  margin-bottom: 0;
}

.guide-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 26px;
  box-shadow: var(--shadow);
}

.guide-dialog::backdrop {
  background: rgba(12, 14, 18, 0.42);
  backdrop-filter: blur(3px);
}

.guide-dialog h2 {
  margin-bottom: 8px;
  padding-right: 34px;
}

.guide-dialog .actions {
  margin-top: 18px;
}

.guide-dialog-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 820;
  margin-bottom: 14px;
}

.flash-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  box-shadow: var(--shadow);
}

.flash-dialog::backdrop {
  background: rgba(12, 14, 18, 0.48);
  backdrop-filter: blur(4px);
}

.flash-dialog-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.flash-dialog-head h2 {
  overflow-wrap: anywhere;
}

.flash-dialog-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.flash-dialog-option {
  min-height: 210px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 16px;
}

.flash-dialog-option:hover {
  border-color: var(--line-strong);
  background: var(--control-bg);
}

.flash-dialog-option .btn {
  width: 100%;
}

.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

body.no-site-footer {
  padding-bottom: 0;
}

.site-footer-inner {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 92px;
  padding: 16px 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(280px, auto);
  gap: 24px;
  align-items: center;
}

.footer-brand {
  justify-self: start;
}

.footer-copy {
  max-width: 420px;
  margin: 10px 0 0;
  color: var(--muted);
}

.footer-links,
.social-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 680;
}

.footer-links a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.social-links {
  justify-content: flex-end;
}

.social-links a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px 12px;
  color: var(--text);
  font-weight: 680;
}

.social-links a:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.social-links span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 820;
}

.guide-layout {
  display: grid;
  gap: 16px;
}

.guide-section {
  display: grid;
  gap: 12px;
}

.guide-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.format-example {
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
  color: var(--text);
}

.format-example code {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.upload-panel {
  display: grid;
  gap: 18px;
}

.upload-box {
  align-items: stretch;
}

.file-drop {
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 24px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.compact-drop {
  min-height: 124px;
}

.file-drop input {
  width: min(320px, 100%);
  margin-top: 8px;
  background: var(--control-bg);
}

.file-drop-title {
  color: var(--text);
  font-weight: 760;
}

.file-drop-hint {
  max-width: 360px;
}

.start-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.review-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.comment-mock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.comment-mock div {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.comment-mock strong,
.comment-mock span {
  display: block;
}

.comment-mock span {
  margin-top: 4px;
  color: var(--muted);
}

.confirm-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.6fr) minmax(160px, 0.6fr);
  gap: 10px;
  margin-bottom: 12px;
}

.mode-form {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.switch,
.chip-check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--control-bg);
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 660;
}

.switch input,
.chip-check input {
  accent-color: var(--primary);
}

.filter-bar {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.question {
  display: grid;
  gap: 12px;
}

.question header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.question header .btn {
  margin-left: auto;
}

.question h2 {
  max-width: 920px;
  font-size: 18px;
  line-height: 1.35;
}

.question-images {
  display: grid;
  gap: 10px;
}

.question-images img {
  max-width: min(100%, 760px);
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--image-bg);
  object-fit: contain;
}

.option-images {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.option-images img {
  max-width: min(100%, 360px);
  max-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--image-bg);
  object-fit: contain;
}

.choice-content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.text-answer,
.text-answer-preview {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 13px;
}

.text-answer span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.text-answer input {
  width: 100%;
}

.text-answer.correct {
  border-color: #93d7b0;
  background: var(--ok-soft);
}

.text-answer.wrong {
  border-color: #f4a6a0;
  background: var(--bad-soft);
}

.text-answer-preview {
  display: block;
  margin: 0;
  color: var(--muted);
  font-weight: 680;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 760;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.options {
  display: grid;
  gap: 8px;
  margin: 2px 0 0;
  padding-left: 0;
  list-style: none;
}

.options li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.options li.correct {
  border-color: #b7e2ca;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 720;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 13px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.choice:hover {
  border-color: var(--line-strong);
  background: var(--control-bg);
  transform: translateY(-1px);
}

.choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--control-bg);
}

.choice input {
  margin-top: 4px;
  accent-color: var(--primary);
}

.choice-correct {
  border-color: #93d7b0;
  background: var(--ok-soft);
}

.choice-wrong {
  border-color: #f4a6a0;
  background: var(--bad-soft);
}

.progress-wrap {
  width: min(360px, 100%);
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 720;
}

.progress {
  width: 100%;
  height: 10px;
  border: 0;
}

.progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--progress-track);
}

.progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  justify-content: flex-end;
  margin-top: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
}

.flash-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
}

.flash-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.flash-mode-option {
  display: grid;
  align-content: space-between;
  gap: 28px;
}

.flash-trainer {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.flash-trainer-head {
  position: sticky;
  top: 69px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--attempt-head-bg);
  padding: 16px;
  backdrop-filter: blur(14px);
}

.flash-trainer-head h1 {
  font-size: clamp(24px, 4vw, 36px);
}

.flash-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
}

.flash-scoreboard span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.flash-scoreboard strong {
  color: var(--text);
  font-size: 18px;
}

.flash-progress {
  display: grid;
  gap: 8px;
}

.flashcard-study-card {
  min-height: min(560px, calc(100vh - 260px));
  display: grid;
  align-content: center;
  gap: 16px;
  padding: clamp(18px, 4vw, 34px);
  box-shadow: var(--shadow);
}

.flashcard-study-card h2 {
  font-size: clamp(21px, 4vw, 30px);
  line-height: 1.25;
}

.flash-answer-form {
  display: grid;
  gap: 14px;
}

.flash-main-action {
  width: min(240px, 100%);
  justify-self: end;
  min-width: 180px;
  min-height: 48px;
}

.flash-action-hint {
  justify-self: end;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 720;
  text-align: center;
}

.flash-feedback {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.flash-feedback h2 {
  margin-bottom: 6px;
}

.flash-feedback p {
  margin: 0;
}

.flash-feedback.correct {
  border-color: #93d7b0;
  background: var(--ok-soft);
  color: var(--ok);
}

.flash-feedback.wrong {
  border-color: #f4a6a0;
  background: var(--bad-soft);
  color: var(--danger);
}

.flash-trainer-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
}

.flash-trainer-actions form {
  display: contents;
}

.flash-exit-menu {
  position: relative;
  justify-self: start;
}

.flash-exit-menu summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.flash-exit-menu summary:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.flash-exit-menu[open] summary {
  margin-bottom: 8px;
}

.flash-exit-menu .btn {
  min-width: 150px;
}

.result-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(24px, 5vw, 42px);
  box-shadow: var(--shadow);
}

.result-hero h1 {
  font-size: clamp(56px, 11vw, 110px);
}

.result-hero p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.edit-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.edit-form .inline {
  justify-self: start;
}

.option-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.option-edit-body {
  display: grid;
  gap: 8px;
}

@media (max-width: 860px) {
  .test-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .flash-mode-grid {
    grid-template-columns: 1fr;
  }

  .page-head,
  .attempt-head,
  .start-panel,
  .review-panel,
  .upload-layout {
    grid-template-columns: 1fr;
  }

  .page-head,
  .attempt-head {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-form {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comment-mock,
  .confirm-fields,
  .admin-table-head,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-table-head .btn,
  .admin-row-actions {
    justify-self: stretch;
  }

  .site-footer-inner {
    grid-template-columns: 1fr;
    align-items: start;
    min-height: 0;
  }

  .social-links {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  body {
    background: var(--bg);
    font-size: 14px;
  }

  body.has-site-footer {
    padding-bottom: 0;
  }

  .site-footer {
    position: static;
    box-shadow: none;
  }

  .site-footer-inner {
    width: min(100% - 24px, 1180px);
    padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
    gap: 14px;
  }

  .footer-copy {
    margin-top: 6px;
  }

  .topbar-inner {
    width: min(100% - 24px, 1180px);
    min-height: 58px;
    gap: 10px;
  }

  .brand span:last-child {
    display: none;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .nav {
    gap: 4px;
  }

  .nav a,
  .theme-toggle {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .theme-toggle {
    gap: 6px;
  }

  .theme-toggle-icon {
    width: 14px;
    height: 14px;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    margin: 18px auto 32px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.08;
  }

  h2 {
    font-size: 17px;
  }

  .lead {
    font-size: 14px;
  }

  .page-head,
  .attempt-head {
    gap: 14px;
    margin-bottom: 16px;
  }

  .page-head > form {
    width: 100%;
  }

  .attempt-head {
    top: 59px;
    padding: 12px;
    box-shadow: none;
  }

  .attempt-head h1 {
    font-size: 22px;
  }

  .progress-wrap {
    width: 100%;
  }

  .toolbar,
  .actions,
  .upload-box,
  .mode-form,
  .sticky-actions,
  .flash-actions,
  .flash-trainer-actions,
  .search {
    align-items: stretch;
    flex-direction: column;
  }

  .btn,
  .search input[type="search"],
  select,
  .switch,
  .chip-check {
    width: 100%;
  }

  .search {
    gap: 8px;
  }

  input[type="search"],
  input[type="text"],
  input[type="password"],
  input[type="file"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px;
  }

  .test-grid,
  .question-list,
  .upload-layout,
  .guide-layout {
    gap: 12px;
  }

  .test-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .panel,
  .empty,
  .notice {
    padding: 14px;
  }

  .empty {
    min-height: 220px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }

  .stats div,
  .meta div {
    padding: 10px 12px;
  }

  .stats strong {
    font-size: 24px;
  }

  .test-card {
    min-height: 0;
    gap: 10px;
  }

  .test-card:hover {
    box-shadow: 0 1px 0 rgba(20, 23, 31, 0.02);
    transform: none;
  }

  .test-card-summary {
    gap: 6px;
    font-size: 12px;
  }

  .test-card-summary span {
    min-height: 26px;
    padding: 3px 7px;
  }

  .home-more-panel {
    align-items: stretch;
    flex-direction: column;
    margin-top: 12px;
  }

  .home-more-panel .btn {
    width: 100%;
  }

  .mode-details {
    padding-top: 8px;
  }

  .mode-card {
    min-height: 52px;
  }

  .upload-panel {
    gap: 12px;
  }

  .file-drop {
    min-height: 136px;
    padding: 16px;
  }

  .compact-drop {
    min-height: 104px;
  }

  .file-drop input {
    width: 100%;
  }

  .format-example {
    padding: 12px;
  }

  .format-example code {
    font-size: 12px;
    line-height: 1.45;
  }

  .flash-trainer {
    gap: 12px;
  }

  .flash-trainer-head {
    position: static;
    grid-template-columns: 1fr;
    padding: 12px;
    box-shadow: none;
  }

  .flash-scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .flash-scoreboard span {
    padding: 8px;
  }

  .flashcard-study-card {
    min-height: min(520px, calc(100vh - 190px));
    padding: 16px;
    gap: 12px;
    box-shadow: 0 1px 0 rgba(20, 23, 31, 0.02);
  }

  .flashcard-study-card h2 {
    font-size: 20px;
  }

  .flash-main-action {
    width: 100%;
    justify-self: stretch;
    min-height: 52px;
  }

  .flash-feedback {
    padding: 12px;
  }

  .filter-bar {
    padding: 10px;
  }

  .review-panel,
  .comment-mock {
    gap: 10px;
  }

  .comment-mock {
    grid-template-columns: 1fr;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .mode-launcher {
    grid-template-columns: 1fr;
  }

  .option-edit {
    grid-template-columns: 1fr;
  }

  .question {
    gap: 10px;
  }

  .question h2 {
    font-size: 16px;
  }

  .question header {
    flex-wrap: wrap;
  }

  .question header .btn {
    width: auto;
    margin-left: 0;
  }

  .choice {
    padding: 12px;
    gap: 10px;
  }

  .choice:hover {
    transform: none;
  }

  .question-images img {
    width: 100%;
    max-height: 360px;
  }

  .option-images img {
    width: 100%;
    max-height: 220px;
  }

  .options li {
    padding: 9px 10px;
  }

  .text-answer,
  .text-answer-preview {
    padding: 12px;
  }

  .sticky-actions,
  .flash-actions,
  .flash-trainer-actions {
    bottom: 0;
    margin-left: -12px;
    margin-right: -12px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .flash-trainer-actions {
    grid-template-columns: 1fr;
  }

  .flash-action-hint {
    width: 100%;
    order: 1;
  }

  .flash-exit-menu,
  .flash-exit-menu summary,
  .flash-exit-menu .btn {
    width: 100%;
  }

  .flash-exit-menu {
    order: 2;
  }

  .flash-main-action {
    order: 1;
  }

  .result-hero {
    gap: 10px;
    padding: 22px;
  }

  .result-hero h1 {
    font-size: 48px;
  }

  .result-hero p:not(.eyebrow) {
    font-size: 15px;
  }

  .edit-form {
    gap: 12px;
    margin-top: 14px;
  }

  .option-edit {
    align-items: stretch;
  }

  .guide-dialog {
    width: min(100% - 20px, 520px);
    padding: 18px;
  }

  .flash-dialog {
    width: min(100% - 20px, 680px);
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }

  .flash-dialog-head {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .flash-dialog-head .btn {
    width: 100%;
  }

  .flash-dialog-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .flash-dialog-option {
    min-height: 0;
    gap: 14px;
    padding: 14px;
  }
}

@media (max-width: 460px) {
  .topbar-inner {
    width: min(100% - 16px, 1180px);
  }

  .nav a {
    display: none;
  }

  .theme-toggle {
    width: auto;
  }

  .theme-toggle [data-theme-toggle-label] {
    display: none;
  }

  .shell,
  .site-footer-inner {
    width: min(100% - 16px, 1180px);
  }

  .page-head > .btn {
    width: 100%;
  }

  .page-head h1 {
    overflow-wrap: anywhere;
  }

  .test-card-head .badge {
    max-width: 100%;
  }

  .mode-card strong {
    font-size: 13px;
  }

  .mode-card span,
  .review-link {
    font-size: 11px;
  }

  .footer-links,
  .social-links {
    align-items: stretch;
    flex-direction: column;
  }

  .footer-links a,
  .social-links a {
    width: 100%;
    justify-content: center;
  }

  .attempt-head {
    position: static;
  }

  .sticky-actions,
  .flash-actions,
  .flash-trainer-actions {
    position: sticky;
  }
}
