
:root {
  --background: #f7f6f1;
  --surface: #fffdfa;
  --surface-soft: #f3f5f1;
  --surface-strong: #eeece5;
  --foreground: #2d2a24;
  --muted: #777167;
  --muted-2: #958f84;
  --border: #dedbd2;
  --border-strong: #cec9bd;
  --primary: #158a82;
  --primary-strong: #0f706a;
  --primary-soft: #e5f2ef;
  --primary-softer: #f1f8f6;
  --success: #267857;
  --success-soft: #e9f4ee;
  --info: #456b94;
  --info-soft: #edf3f8;
  --danger: #b3453d;
  --danger-soft: #fff0ee;
  --warning: #b67c22;
  --shadow-xs: 0 1px 2px rgba(45,42,36,.035);
  --shadow-sm: 0 6px 20px rgba(45,42,36,.055);
  --shadow-md: 0 18px 45px rgba(45,42,36,.08);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-width: 248px;
  --topbar-height: 66px;
  --bottom-nav-height: 66px;
  --content-max: 1180px;
}

* { box-sizing: border-box; }
html { direction: rtl; background: var(--background); scroll-behavior: smooth; }
body.app-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% -10%, color-mix(in srgb, var(--primary) 5%, transparent) 0, transparent 32rem),
    var(--background);
  color: var(--foreground);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--primary) 20%, transparent); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
input, textarea { direction: rtl; }
input[dir="auto"], textarea[dir="auto"] { text-align: start; unicode-bidi: plaintext; }
input[type="datetime-local"], input[type="number"], input[dir="ltr"] { direction: ltr; text-align: left; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }
.mb-2 { margin-bottom: .5rem; }
.stack { display: grid; gap: 1rem; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 24%, transparent); outline-offset: 2px; }

/* Progressive MPA smoothness: no client router, no shell state risk. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 110ms ease both page-out; }
::view-transition-new(root) { animation: 170ms ease both page-in; }
@keyframes page-out { to { opacity: .75; transform: translateY(2px); } }
@keyframes page-in { from { opacity: .75; transform: translateY(3px); } }

/* Icon system: tiny local masks, no runtime icon dependency. */
.ui-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--icon) center/contain no-repeat;
  mask: var(--icon) center/contain no-repeat;
}
.i-quiz { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Crect%20x%3D%273%27%20y%3D%274%27%20width%3D%2718%27%20height%3D%2717%27%20rx%3D%272%27%2F%3E%3Cpath%20d%3D%27M8%202v4M16%202v4M7%2010h10M8%2015l2%202%204-4%27%2F%3E%3C%2Fsvg%3E"); }
.i-results { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M4%2020V10M10%2020V4M16%2020v-7M22%2020H2%27%2F%3E%3C%2Fsvg%3E"); }
.i-settings { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M4%206h10M18%206h2M4%2012h2M10%2012h10M4%2018h7M15%2018h5%27%2F%3E%3Ccircle%20cx%3D%2716%27%20cy%3D%276%27%20r%3D%272%27%2F%3E%3Ccircle%20cx%3D%278%27%20cy%3D%2712%27%20r%3D%272%27%2F%3E%3Ccircle%20cx%3D%2713%27%20cy%3D%2718%27%20r%3D%272%27%2F%3E%3C%2Fsvg%3E"); }
.i-plus { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272.2%27%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M12%205v14M5%2012h14%27%2F%3E%3C%2Fsvg%3E"); }
.i-copy { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Crect%20x%3D%278%27%20y%3D%278%27%20width%3D%2712%27%20height%3D%2712%27%20rx%3D%272%27%2F%3E%3Cpath%20d%3D%27M16%208V6a2%202%200%200%200-2-2H6a2%202%200%200%200-2%202v8a2%202%200%200%200%202%202h2%27%2F%3E%3C%2Fsvg%3E"); }
.i-logout { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M10%2017l5-5-5-5M15%2012H3M15%204h4a2%202%200%200%201%202%202v12a2%202%200%200%201-2%202h-4%27%2F%3E%3C%2Fsvg%3E"); }
.i-check { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272.4%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M5%2012l4%204L19%206%27%2F%3E%3C%2Fsvg%3E"); }
.i-info { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Ccircle%20cx%3D%2712%27%20cy%3D%2712%27%20r%3D%279%27%2F%3E%3Cpath%20d%3D%27M12%2011v5M12%208h.01%27%2F%3E%3C%2Fsvg%3E"); }
.i-calendar { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Crect%20x%3D%273%27%20y%3D%275%27%20width%3D%2718%27%20height%3D%2716%27%20rx%3D%272%27%2F%3E%3Cpath%20d%3D%27M16%203v4M8%203v4M3%2010h18%27%2F%3E%3C%2Fsvg%3E"); }
.i-eye { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M2%2012s3.5-6%2010-6%2010%206%2010%206-3.5%206-10%206S2%2012%202%2012z%27%2F%3E%3Ccircle%20cx%3D%2712%27%20cy%3D%2712%27%20r%3D%272.5%27%2F%3E%3C%2Fsvg%3E"); }
.i-users { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Ccircle%20cx%3D%279%27%20cy%3D%278%27%20r%3D%273%27%2F%3E%3Cpath%20d%3D%27M3%2020c0-4%202.5-6%206-6s6%202%206%206M16%205.5a3%203%200%200%201%200%205.5M17%2014c2.5.5%204%202.3%204%205%27%2F%3E%3C%2Fsvg%3E"); }
.i-clock { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Ccircle%20cx%3D%2712%27%20cy%3D%2712%27%20r%3D%279%27%2F%3E%3Cpath%20d%3D%27M12%207v5l3%202%27%2F%3E%3C%2Fsvg%3E"); }
.i-send { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%202L11%2013%27%2F%3E%3Cpath%20d%3D%27M22%202l-7%2020-4-9-9-4%2020-7z%27%2F%3E%3C%2Fsvg%3E"); }
.i-list { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M9%206h11M9%2012h11M9%2018h11M4%206h.01M4%2012h.01M4%2018h.01%27%2F%3E%3C%2Fsvg%3E"); }

/* Buttons */
.btn {
  min-height: 42px;
  padding: .64rem 1rem;
  border-radius: .72rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .48rem;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: transform .12s ease, background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 94%, white), var(--primary));
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 16%, transparent);
}
.btn-primary:hover { background: var(--primary-strong); box-shadow: 0 9px 22px color-mix(in srgb, var(--primary) 20%, transparent); }
.btn-secondary { background: color-mix(in srgb, var(--surface) 96%, white); border-color: var(--border); color: var(--foreground); }
.btn-secondary:hover { border-color: var(--border-strong); background: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { background: color-mix(in srgb, var(--foreground) 3%, transparent); }
.btn-danger { background: var(--danger-soft); border-color: #efc8c3; color: var(--danger); }
.btn-sm { min-height: 37px; padding: .45rem .76rem; font-size: .84rem; border-radius: .66rem; }
.btn-lg { min-height: 50px; padding: .82rem 1.25rem; font-size: 1rem; }

/* Shared fields */
.field { display: grid; gap: .42rem; min-width: 0; }
.field-label { font-weight: 650; font-size: .88rem; color: #454139; }
.field-hint { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.55; }
.input, .select, .textarea, .student-select {
  width: 100%;
  border: 1px solid #d9d5cc;
  background: color-mix(in srgb, var(--surface) 97%, white);
  color: var(--foreground);
  border-radius: .78rem;
  padding: .72rem .84rem;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input, .select { min-height: 46px; }
.textarea { resize: vertical; min-height: 94px; }
.input::placeholder, .textarea::placeholder { color: #aaa499; opacity: 1; }
.input:hover, .select:hover, .textarea:hover, .student-select:hover { border-color: #c8c3b9; }
.input:focus, .select:focus, .textarea:focus, .student-select:focus {
  border-color: color-mix(in srgb, var(--primary) 58%, #fff);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent), 0 5px 15px rgba(45,42,36,.035);
}
.form-grid { display: grid; gap: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: flex-start; }
.form-actions.start { justify-content: flex-start; }
.check-row {
  min-height: 48px;
  padding: .7rem .78rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: var(--primary-softer);
}
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-label { font-weight: 700; }
.password-control { position: relative; }
.password-input { padding-inline-end: 5.3rem; }
.password-toggle {
  position: absolute;
  inset-inline-end: .48rem;
  top: 50%;
  transform: translateY(-50%);
  min-height: 34px;
  padding: .3rem .55rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: 0;
  border-radius: .6rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .76rem;
}
.password-toggle:hover { background: var(--surface-soft); color: var(--foreground); }

/* Teacher shell */
.app-shell { min-height: 100vh; }
.teacher-frame { min-height: 100vh; display: flex; }
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: color-mix(in srgb, #f2f0e8 94%, white);
  border-left: 1px solid color-mix(in srgb, var(--foreground) 7%, var(--border));
  box-shadow: -1px 0 0 rgba(255,255,255,.55) inset;
}
.brand {
  min-height: 78px;
  padding: 1rem .9rem;
  display: flex;
  align-items: center;
  gap: .72rem;
  border-bottom: 1px solid color-mix(in srgb, var(--foreground) 6%, var(--border));
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: .86rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 77%, #4bb0a7));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 20%, transparent);
}
.brand-mark .ui-icon { width: 1.18rem; height: 1.18rem; }
.brand-copy { min-width: 0; display: grid; line-height: 1.25; }
.brand-name { font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-subtitle { color: var(--muted); font-size: .75rem; margin-top: .16rem; }
.teacher-id {
  margin: .72rem .68rem .55rem;
  padding: .72rem;
  display: flex;
  align-items: center;
  gap: .66rem;
  border: 1px solid color-mix(in srgb, var(--foreground) 6%, var(--border));
  border-radius: .9rem;
  background: rgba(255,255,255,.44);
}
.teacher-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: .78rem;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.teacher-copy { min-width: 0; display: grid; line-height: 1.25; }
.teacher-name { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teacher-username { color: var(--muted); font-size: .72rem; margin-top: .14rem; text-align: right; }
.side-nav { display: grid; gap: .16rem; padding: .25rem .62rem; }
.nav-link {
  min-height: 42px;
  padding: .6rem .72rem;
  border-radius: .72rem;
  display: flex;
  align-items: center;
  gap: .72rem;
  color: #625d54;
  font-weight: 600;
  font-size: .88rem;
  transition: background-color .14s ease, color .14s ease, transform .14s ease;
}
.nav-link .ui-icon { color: #8c867b; }
.nav-link:hover { background: rgba(255,255,255,.55); color: var(--foreground); transform: translateX(-1px); }
.nav-link.is-active {
  position: relative;
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  color: var(--primary-strong);
  font-weight: 700;
}
.nav-link.is-active .ui-icon { color: var(--primary); }
.nav-link.is-active::after {
  content: "";
  position: absolute;
  inset-inline-start: -.62rem;
  width: 3px;
  height: 22px;
  border-radius: 999px;
  background: var(--primary);
}
.sidebar-note {
  margin: 1rem .68rem 0;
  padding: .75rem;
  border-radius: .8rem;
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  border: 1px dashed color-mix(in srgb, var(--primary) 18%, var(--border));
}
.sidebar-note-title { margin: 0; font-weight: 700; font-size: .78rem; color: var(--primary-strong); }
.sidebar-note-copy { margin: .2rem 0 0; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.logout-form { margin-top: auto; padding: .8rem .7rem 1rem; border-top: 1px solid color-mix(in srgb, var(--foreground) 6%, var(--border)); }
.logout-button { justify-content: flex-start; color: #665f55; }
.teacher-main { width: 100%; min-width: 0; padding: 2.25rem clamp(1rem, 3vw, 3rem) 4.5rem; }
.teacher-main > div { max-width: var(--content-max); margin-inline: auto; }
.mobile-topbar, .mobile-bottom { display: none; }

/* Page structure */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.15rem;
  margin-bottom: 1.45rem;
}
.page-heading-copy { min-width: 0; }
.page-eyebrow { margin: 0 0 .15rem; color: var(--primary); font-size: .78rem; font-weight: 800; }
.page-title { margin: 0; font-size: clamp(1.65rem, 2.4vw, 2.15rem); line-height: 1.25; letter-spacing: -.025em; color: #65806c; }
.page-subtitle { margin: .35rem 0 0; color: var(--muted); max-width: 760px; font-size: .92rem; }
.header-actions { display: flex; flex-wrap: wrap; gap: .62rem; align-items: center; }
.block-heading { margin: 1.7rem 0 .85rem; }
.block-title { margin: 0; font-size: 1.2rem; }
.section-title { margin: 0; font-size: 1rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin: 1.2rem 0 .72rem; }
.section-heading h2 { margin: 0; font-size: 1.1rem; }
.section-heading p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }

.card {
  background: color-mix(in srgb, var(--surface) 98%, white);
  border: 1px solid color-mix(in srgb, var(--foreground) 5%, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.form-card { padding: clamp(1rem, 2.5vw, 1.5rem); box-shadow: var(--shadow-sm); }
.narrow-card { padding: 1.25rem; max-width: 650px; box-shadow: var(--shadow-sm); }

/* Dashboard */
.dashboard-hero {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  padding: clamp(1.2rem, 3vw, 1.7rem);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid color-mix(in srgb, var(--primary) 15%, var(--border));
  border-radius: 1.25rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 7%, var(--surface)) 0%, var(--surface) 58%);
  box-shadow: var(--shadow-sm);
}
.dashboard-hero::before {
  content: "";
  position: absolute;
  inset-inline-end: -3rem;
  top: -4rem;
  width: 14rem;
  height: 14rem;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 14%, transparent), transparent 69%);
  pointer-events: none;
}
.dashboard-hero-copy { position: relative; z-index: 1; min-width: 0; }
.dashboard-kicker { margin: 0 0 .18rem; color: var(--primary); font-size: .78rem; font-weight: 800; }
.dashboard-title { margin: 0; font-size: clamp(1.75rem, 3.4vw, 2.45rem); line-height: 1.25; letter-spacing: -.035em; }
.dashboard-subtitle { margin: .4rem 0 0; color: var(--muted); max-width: 660px; font-size: .9rem; }
.dashboard-hero-action { position: relative; z-index: 1; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .85rem; margin-bottom: 1.35rem; }
.stat-card { min-height: 116px; padding: .95rem 1rem; display: flex; flex-direction: column; justify-content: space-between; }
.stat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.stat-copy { display: grid; gap: .14rem; }
.stat-value { font-size: 1.6rem; line-height: 1.15; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .78rem; color: var(--muted); }
.stat-icon-wrap {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: .8rem;
  color: var(--primary);
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 10%, white), color-mix(in srgb, var(--primary) 4%, white));
}
.stat-subtitle { margin: .35rem 0 0; color: var(--muted-2); font-size: .73rem; }

.quiz-list, .builder-stack, .answers-list { display: grid; gap: .78rem; }
.quiz-row-card {
  position: relative;
  overflow: hidden;
  padding: 1rem 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.quiz-row-card:hover { border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.quiz-row-card::before {
  content: "";
  position: absolute;
  inset-block: 1rem;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 78%, transparent);
}
.quiz-card-copy { min-width: 0; }
.quiz-card-actions { display: flex; flex-wrap: wrap; gap: .48rem; justify-content: flex-end; }
.quiz-title { margin: .42rem 0 .24rem; font-size: 1.04rem; line-height: 1.5; }
.row-meta, .mini-metrics { display: flex; flex-wrap: wrap; gap: .45rem .65rem; align-items: center; }
.mini-metrics { color: var(--muted); font-size: .8rem; margin-top: .48rem; }
.schedule-line { margin: .32rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; color: var(--muted); font-size: .81rem; }
.schedule-line .schedule-icon { width: .9rem; height: .9rem; color: var(--muted-2); margin-inline-end: .2rem; }
.audience-pill { display: inline-flex; align-items: center; padding: .22rem .56rem; background: #f1efe9; border: 1px solid #e8e4dc; border-radius: 999px; color: #625d54; font-size: .74rem; font-weight: 700; }
.badge { display: inline-flex; align-items: center; padding: .22rem .52rem; border-radius: 999px; font-size: .72rem; font-weight: 800; border: 1px solid transparent; }
.badge-muted { background: #f1f0ec; color: #69645b; border-color: #dfdcd4; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #cedce9; }
.badge-warn { background: color-mix(in srgb, var(--warning) 11%, var(--surface)); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 28%, var(--border)); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #c8e0d2; }
.badge-error { background: var(--danger-soft); color: var(--danger); border-color: #efcac6; }
.empty-card { padding: 2.25rem 1.5rem; text-align: center; display: grid; gap: .72rem; justify-items: center; }
.empty-card h2, .empty-card p { margin: 0; }
.empty-card p { color: var(--muted); }
.link-card { padding: 1rem 1.1rem; margin-bottom: .9rem; box-shadow: var(--shadow-sm); }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: .55rem; }
.details-card { margin-bottom: 1rem; overflow: hidden; }
.details-summary { cursor: pointer; padding: .95rem 1rem; font-weight: 750; }
.details-summary:hover { background: var(--surface-soft); }
.details-body { padding: 1rem; border-top: 1px solid var(--border); }
.group-add-form { padding: 1rem; background: var(--primary-softer); border: 1px dashed color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: .9rem; }
.question-group-card { overflow: hidden; box-shadow: var(--shadow-xs); }
.group-heading { padding: 1rem 1.05rem; background: linear-gradient(180deg, #f7f8f5, #f4f5f1); border-bottom: 1px solid var(--border); }
.group-heading p { margin: .2rem 0 0; }
.question-summary { padding: .95rem 1.05rem; display: flex; justify-content: space-between; gap: .9rem; border-bottom: 1px solid #ebe8df; }
.question-summary:last-child { border-bottom: 0; }
.question-summary-copy { min-width: 0; }
.question-summary-prompt { margin: .35rem 0 .2rem; font-weight: 700; }
.teacher-answer { margin: .1rem 0 0; color: var(--success); font-size: .8rem; }
.question-summary-actions { display: flex; align-items: center; gap: .42rem; }
.inline-form { display: inline-flex; }
.question-type-panel { display: grid; gap: .66rem; }
.option-editor { display: grid; gap: .55rem; }
.option-editor-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .65rem; }
.option-editor-row input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }
.result-overview-card { padding: 1rem 1.05rem; display: flex; align-items: center; justify-content: space-between; gap: .9rem; transition: border-color .15s ease, box-shadow .15s ease; }
.result-overview-card:hover { border-color: color-mix(in srgb, var(--primary) 15%, var(--border)); box-shadow: var(--shadow-sm); }
.table-card { padding: 1rem; box-shadow: var(--shadow-sm); }
.table-wrap { overflow-x: auto; margin-top: .8rem; border: 1px solid var(--border); border-radius: .8rem; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; background: var(--surface); }
.data-table th, .data-table td { padding: .75rem .7rem; border-bottom: 1px solid #ebe8df; text-align: right; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table th { font-size: .76rem; color: var(--muted); background: #f7f6f2; font-weight: 700; }
.score-cell { direction: ltr; text-align: right !important; font-weight: 800; }
.text-link { color: var(--primary); font-weight: 800; }
.metric-chip { padding: .32rem .58rem; background: #f2f0ea; border: 1px solid #e7e3da; border-radius: .6rem; font-size: .79rem; }
.empty-inline { padding: 1.2rem; color: var(--muted); text-align: center; }
.attempt-summary { padding: 1rem 1.2rem; display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.attempt-summary > div { display: grid; gap: .15rem; }
.big-score { font-size: 1.25rem; direction: ltr; }
.answer-review-card { padding: 1rem 1.1rem; box-shadow: var(--shadow-xs); }
.answer-prompt { margin: .55rem 0; font-size: 1rem; }
.correct-answer { color: var(--success); }

/* Login */
.public-main { min-height: 100vh; }
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 480px);
  align-items: center;
  gap: clamp(2rem, 7vw, 6rem);
  max-width: 1080px;
  margin-inline: auto;
  padding: 2rem;
}
.login-copy { position: relative; padding: 1.2rem; }
.login-copy::before {
  content: "";
  position: absolute;
  width: 17rem;
  height: 17rem;
  inset-inline-start: -5rem;
  top: -7rem;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 10%, transparent), transparent 68%);
  pointer-events: none;
}
.login-brand-row { position: relative; display: flex; align-items: center; gap: .65rem; margin-bottom: 1rem; }
.login-brand-mark { width: 38px; height: 38px; border-radius: .78rem; display: grid; place-items: center; color: #fff; background: var(--primary); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 18%, transparent); }
.login-kicker { color: var(--primary); font-weight: 800; font-size: .82rem; }
.login-title { position: relative; font-size: clamp(2.35rem, 5vw, 3.9rem); line-height: 1.12; letter-spacing: -.04em; margin: .38rem 0; }
.login-subtitle { position: relative; color: var(--muted); font-size: 1rem; max-width: 540px; }
.login-feature-list { position: relative; display: grid; gap: .55rem; margin-top: 1.35rem; color: #5d584f; font-size: .86rem; }
.login-feature { display: flex; align-items: center; gap: .55rem; }
.login-feature .ui-icon { color: var(--primary); }
.login-card { padding: 1.25rem; box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--foreground) 7%, var(--border)); }
.login-card-title { margin: 0 0 .2rem; font-size: 1.08rem; }
.login-card-subtitle { margin: 0 0 1rem; color: var(--muted); font-size: .82rem; }
.demo-note { margin-top: 1rem; background: var(--primary-softer); border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); border-radius: .78rem; padding: .75rem; }
.demo-note strong { color: var(--primary-strong); }
.demo-note p { margin: .16rem 0; }

/* Student/public experience */
.public-wrap { width: min(100% - 1.5rem, 780px); margin-inline: auto; padding: 2.2rem 0 4rem; }
.public-wrap.narrow { width: min(100% - 1.5rem, 580px); }
.public-brand { display: inline-flex; align-items: center; gap: .45rem; color: var(--primary); font-weight: 850; letter-spacing: .01em; margin-bottom: .72rem; }
.landing-card, .notice-card { padding: clamp(1.15rem, 4vw, 1.7rem); box-shadow: var(--shadow-md); }
.public-title { margin: .5rem 0 .35rem; font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.35; letter-spacing: -.02em; }
.public-subtitle { color: var(--muted); margin: 0 0 1rem; }
.public-schedule { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin: 1rem 0; }
.public-schedule > div { background: #f5f4ef; border: 1px solid #e9e5dc; border-radius: .78rem; padding: .7rem .78rem; display: grid; gap: .1rem; }
.public-schedule span { color: var(--muted); font-size: .76rem; }
.start-form { margin-top: 1.1rem; }
.privacy-note, .submit-note { color: var(--muted); font-size: .79rem; margin: .85rem 0 0; }
.student-wrap { width: min(100% - 1rem, 780px); margin-inline: auto; padding: 1rem 0 5.5rem; }
.student-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface) 62%);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
  border-radius: 1.15rem;
  padding: 1.15rem 1.2rem;
  margin-bottom: .82rem;
  box-shadow: var(--shadow-sm);
}
.student-hero::after { content: ""; position: absolute; width: 10rem; height: 10rem; border-radius: 999px; inset-inline-end: -4rem; top: -5rem; background: radial-gradient(circle, color-mix(in srgb, var(--primary) 13%, transparent), transparent 70%); }
.student-top-meta { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.student-title { position: relative; z-index: 1; margin: .5rem 0 .25rem; font-size: clamp(1.4rem, 5vw, 2rem); }
.student-intro { position: relative; z-index: 1; margin: .25rem 0 .8rem; color: var(--muted); }
.student-attempt-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: .4rem .7rem; color: var(--muted); font-size: .78rem; }
.student-attempt-meta strong { color: var(--foreground); }
.student-form { display: grid; gap: .82rem; }
.student-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.student-group-head { padding: 1rem 1.05rem; background: linear-gradient(180deg, #f7f8f5, #f4f5f1); border-bottom: 1px solid var(--border); }
.student-group-title { margin: 0; font-size: 1.05rem; }
.student-group-instructions { margin: .2rem 0 0; color: var(--muted); font-size: .84rem; }
.student-question { padding: 1rem 1.05rem; border-bottom: 1px solid #ebe8df; }
.student-question:last-child { border-bottom: 0; }
.student-question-head { display: flex; align-items: flex-start; gap: .7rem; margin-bottom: .78rem; }
.question-number { width: 29px; height: 29px; flex: 0 0 29px; display: grid; place-items: center; border-radius: .66rem; background: var(--primary); color: #fff; font-weight: 850; font-size: .8rem; box-shadow: 0 5px 12px color-mix(in srgb, var(--primary) 15%, transparent); }
.student-question-prompt { margin: 0; font-weight: 700; line-height: 1.75; }
.choices { display: grid; gap: .56rem; }
.choice-card { display: flex; align-items: center; gap: .68rem; border: 1px solid #ddd9d0; background: #fff; border-radius: .78rem; padding: .74rem .82rem; cursor: pointer; transition: border-color .12s ease, background-color .12s ease, transform .12s ease; }
.choice-card:hover { border-color: #b9cec8; transform: translateY(-1px); }
.choice-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 7%, transparent); }
.choice-card input { width: 18px; height: 18px; accent-color: var(--primary); flex: 0 0 auto; }
.choice-text { min-width: 0; }
.student-select { min-height: 48px; }
.student-submit { position: sticky; z-index: 10; bottom: .6rem; padding: .78rem; border-radius: 1rem; background: color-mix(in srgb, var(--background) 88%, transparent); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: space-between; gap: .8rem; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); box-shadow: 0 12px 30px rgba(45,42,36,.08); }
.student-submit .submit-note { margin: 0; }
.notice-card { text-align: center; }
.notice-dot { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 999px; }
.notice-info { color: var(--info); background: var(--info-soft); }
.notice-muted { color: #777; background: #eee; }
.notice-quiz { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.notice-quiz-title { margin: 0; font-weight: 800; }
.done-screen { min-height: 100vh; width: min(100% - 2rem, 520px); margin-inline: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.done-check { width: 66px; height: 66px; border-radius: 999px; display: grid; place-items: center; background: var(--success-soft); color: var(--success); font-size: 2rem; font-weight: 900; box-shadow: var(--shadow-sm); }

/* Flash */
.flash-stack { position: fixed; inset-inline: 1rem; top: calc(env(safe-area-inset-top, 0px) + .7rem); z-index: 100; display: grid; gap: .42rem; pointer-events: none; }
.flash { width: min(100%, 560px); margin-inline: auto; padding: .72rem .9rem; border-radius: .78rem; box-shadow: var(--shadow-md); border: 1px solid var(--border); background: #fff; font-weight: 650; font-size: .86rem; display: flex; align-items: center; gap: .55rem; }
.flash .ui-icon { width: .95rem; height: .95rem; }
.flash-error { color: var(--danger); background: var(--danger-soft); border-color: #efc5c0; }
.flash-success { color: var(--success); background: var(--success-soft); border-color: #c4e3d0; }
.flash-info { color: var(--info); background: var(--info-soft); border-color: #cbdbea; }

@media (min-width: 760px) {
  .form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid.three { grid-template-columns: 1fr 1fr .55fr; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .teacher-main { padding: calc(var(--topbar-height) + 1.15rem) .78rem calc(var(--bottom-nav-height) + 1.5rem); }
  .teacher-main > div { max-width: 760px; }
  .mobile-topbar {
    position: fixed;
    z-index: 40;
    top: 0;
    inset-inline: 0;
    min-height: var(--topbar-height);
    padding: max(.55rem, env(safe-area-inset-top)) .75rem .55rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--background) 97%, transparent), color-mix(in srgb, var(--background) 91%, transparent));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    transition: box-shadow .18s ease, background-color .18s ease;
  }
  .mobile-topbar.is-scrolled { box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 60%, transparent), 0 12px 30px rgba(0,0,0,.05); }
  .mobile-title { min-width: 0; display: grid; line-height: 1.18; }
  .mobile-brand { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
  .mobile-screen-title { color: var(--muted); font-size: .72rem; margin-top: .12rem; }
  .mobile-new-quiz { box-shadow: none; }
  .mobile-bottom {
    position: fixed;
    z-index: 40;
    bottom: 0;
    inset-inline: 0;
    min-height: var(--bottom-nav-height);
    display: grid;
    grid-template-columns: repeat(3,1fr);
    background: color-mix(in srgb, #faf9f4 96%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: .25rem .35rem env(safe-area-inset-bottom,0px);
  }
  .bottom-link { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .18rem; border-radius: .72rem; font-size: .7rem; color: var(--muted); }
  .bottom-link .ui-icon { width: 1.08rem; height: 1.08rem; }
  .bottom-link.is-active { color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); font-weight: 750; }
  .page-header { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-hero { align-items: stretch; flex-direction: column; }
  .dashboard-hero-action .btn { width: 100%; }
  .quiz-row-card, .result-overview-card { align-items: stretch; flex-direction: column; }
  .quiz-card-actions { justify-content: flex-start; }
  .question-summary { flex-direction: column; }
  .question-summary-actions { justify-content: flex-start; }
  .login-screen { grid-template-columns: 1fr; gap: .7rem; padding: 1rem; }
  .login-copy { text-align: center; padding-bottom: 0; }
  .login-brand-row { justify-content: center; }
  .login-feature-list { width: fit-content; margin-inline: auto; text-align: right; }
}

@media (max-width: 520px) {
  .teacher-main { padding-inline: .65rem; }
  .page-title { font-size: 1.48rem; }
  .stats-grid { gap: .6rem; }
  .stat-card { min-height: 105px; padding: .84rem; }
  .stat-value { font-size: 1.42rem; }
  .quiz-card-actions .btn { flex: 1 1 calc(50% - .25rem); }
  .copy-field { grid-template-columns: 1fr; }
  .public-wrap { padding-top: 1rem; }
  .public-schedule { grid-template-columns: 1fr; }
  .student-submit { align-items: stretch; flex-direction: column; bottom: calc(var(--bottom-safe, 0px) + .35rem); }
  .student-submit .btn { width: 100%; }
  .dashboard-title { font-size: 1.72rem; }
  .dashboard-subtitle { font-size: .84rem; }
  .mobile-new-quiz span:not(.ui-icon) { display: none; }
  .mobile-new-quiz { width: 38px; padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:hover, .quiz-row-card:hover, .choice-card:hover, .nav-link:hover { transform: none !important; }
}

/* V0.3 grading foundation: future review queue, built from existing tokens. */
.review-queue-card { display: grid; gap: .9rem; }
.review-form { display: grid; grid-template-columns: minmax(9rem, .55fr) minmax(14rem, 1fr) auto; gap: .75rem; align-items: end; padding-top: .8rem; border-top: 1px solid var(--border); }
.teacher-note { color: var(--muted-foreground); }
@media (max-width: 767px) {
  .review-form { grid-template-columns: 1fr; }
  .review-form .btn { width: 100%; }
}

/* V0.4 Source Intake: private source review + assisted import. */
.i-upload { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M12%2016V4M7%209l5-5%205%205M4%2020h16%27%2F%3E%3C%2Fsvg%3E"); }
.i-search { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%3E%3Ccircle%20cx%3D%2711%27%20cy%3D%2711%27%20r%3D%277%27%2F%3E%3Cpath%20d%3D%27M20%2020l-4-4%27%2F%3E%3C%2Fsvg%3E"); }
.i-external { --icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27black%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M14%203h7v7M10%2014L21%203M21%2014v5a2%202%200%200%201-2%202H5a2%202%200%200%201-2-2V5a2%202%200%200%201%202-2h5%27%2F%3E%3C%2Fsvg%3E"); }
.file-input { padding-block: .56rem; }
.source-policy-card { padding: .9rem 1rem; margin-bottom: 1rem; background: var(--primary-softer); border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); }
.source-policy-card p { margin: .2rem 0 0; color: var(--muted); }
.source-row-main { min-width: 0; display: flex; align-items: center; gap: .8rem; }
.source-file-icon { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: .85rem; color: var(--primary); background: var(--primary-soft); }
.source-row-card { gap: 1rem; }
.source-summary-card { padding: 1rem 1.05rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.source-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; margin-top: .85rem; }
.source-metric { display: grid; gap: .1rem; padding: .72rem .8rem; background: #f6f5f0; border: 1px solid #e9e5dc; border-radius: .78rem; }
.source-metric strong { font-size: 1.2rem; }
.source-metric span { color: var(--muted); font-size: .76rem; }
.source-split { display: grid; grid-template-columns: minmax(360px,.9fr) minmax(520px,1.35fr); gap: 1rem; align-items: start; }
.source-preview-pane { position: sticky; top: 1rem; min-height: 580px; background: #e9e6df; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.source-preview-pane.standalone { width: min(100%, 900px); }
.source-preview-frame { display: block; width: 100%; min-height: 720px; border: 0; background: #fff; }
.source-preview-image { display: block; width: 100%; height: auto; max-height: 78vh; object-fit: contain; background: #fff; }
.source-review-pane { min-width: 0; }
.source-import-toolbar { position: sticky; top: .7rem; z-index: 8; display: grid; grid-template-columns: minmax(240px,1fr) auto; gap: .75rem; align-items: end; padding: .75rem; margin-bottom: .75rem; border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); border-radius: .95rem; background: color-mix(in srgb, var(--background) 90%, white); backdrop-filter: blur(12px); box-shadow: var(--shadow-sm); }
.source-import-toolbar .field { margin: 0; }
.source-review-form { display: grid; gap: .72rem; }
.candidate-card { display: grid; gap: .58rem; padding: .9rem 1rem; box-shadow: var(--shadow-xs); }
.candidate-card.is-ready { border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.candidate-card.is-unsupported { background: color-mix(in srgb, var(--surface) 88%, #f5f1e8); }
.candidate-top { display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
.candidate-select { display: inline-flex; gap: .45rem; align-items: center; font-size: .82rem; font-weight: 750; color: var(--primary-strong); }
.candidate-select input { width: 17px; height: 17px; accent-color: var(--primary); }
.candidate-section { margin: 0; color: var(--primary); font-weight: 800; font-size: .8rem; }
.candidate-prompt { margin: 0; font-size: .97rem; line-height: 1.75; }
.candidate-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.candidate-option { padding: .3rem .54rem; border: 1px solid #e2ded5; border-radius: .58rem; background: #f8f7f3; font-size: .78rem; }
.candidate-actions { display: flex; justify-content: flex-end; padding-top: .2rem; }
.manual-text-card { padding: 1rem; margin-bottom: 1rem; }

@media (max-width: 1100px) {
  .source-split { grid-template-columns: 1fr; }
  .source-preview-pane { position: relative; top: auto; min-height: 400px; }
  .source-preview-frame { min-height: 560px; }
}
@media (max-width: 900px) {
  .mobile-bottom { grid-template-columns: repeat(5,1fr); }
  .source-import-toolbar { top: calc(var(--topbar-height) + .45rem); }
}
@media (max-width: 620px) {
  .source-metrics { grid-template-columns: 1fr; }
  .source-import-toolbar { grid-template-columns: 1fr; }
  .source-import-action .btn { width: 100%; }
  .candidate-top { align-items: flex-start; flex-direction: column; }
  .source-preview-frame { min-height: 440px; }
  .bottom-link { font-size: .61rem; }
}

/* V0.4 fast answer-key review: optimized for dozens of extracted closed questions. */
.answer-key-form { display: grid; gap: 1rem; padding-bottom: 5rem; }
.answer-key-section { display: grid; gap: .65rem; }
.answer-key-section > .section-title { margin: .15rem 0 .1rem; padding-inline: .15rem; }
.answer-key-card { display: grid; gap: .7rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: .95rem; box-shadow: var(--shadow-xs); }
.answer-key-prompt { margin: 0; font-size: .96rem; line-height: 1.75; }
.answer-key-options { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: .48rem; }
.answer-key-option { min-width: 0; display: flex; align-items: center; gap: .55rem; padding: .62rem .68rem; border: 1px solid #dfdbd2; border-radius: .72rem; background: #faf9f5; cursor: pointer; transition: border-color .12s ease, background-color .12s ease, transform .12s ease; }
.answer-key-option:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); transform: translateY(-1px); }
.answer-key-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 7%, transparent); }
.answer-key-option input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--primary); }
.answer-key-option-text { min-width: 0; line-height: 1.55; }
.answer-key-card-footer { display: flex; justify-content: flex-end; padding-top: .1rem; }
.answer-key-savebar { position: sticky; z-index: 12; bottom: .7rem; display: flex; justify-content: flex-end; gap: .6rem; padding: .72rem; margin-top: .4rem; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: .95rem; background: color-mix(in srgb, var(--background) 90%, transparent); backdrop-filter: blur(12px); box-shadow: 0 12px 30px rgba(45,42,36,.08); }
@media (max-width: 620px) {
  .answer-key-options { grid-template-columns: 1fr; }
  .answer-key-savebar { bottom: calc(var(--bottom-nav-height) + .45rem); }
  .answer-key-savebar .btn { flex: 1; }
}
