/* PaperWize KS3 Science Assessment Bank — Canonical Cut-Paper Collage Design System */
:root {
  --paper: #F6F0E3;
  --paper-deep: #ECE3D1;
  --ink: #302D29;
  --ink-soft: #5E5850;
  --red: #DA211D;
  --red-deep: #A43129;
  --purple-deep: #6E3580;
  --blue: #1B5A86;
  --blue-soft: #DCEBF0;
  --good: #1F5C2E;
  --good-bg: #DCEBD7;
  --warn: #7A4608;
  --warn-bg: #F7E2C6;
  --plan: #4A463F;
  --plan-bg: #E4DECF;
  --card: #FFFDF8;
  --tape: #E9D9A6;
  --focus: #0B57D0;
  --bio: #1F5C2E;
  --bio-bg: #DCEBD7;
  --chm: #6E3580;
  --chm-bg: #EDE2F2;
  --phy: #1B5A86;
  --phy-bg: #DCEBF0;
  --hsw: #7A4608;
  --hsw-bg: #F7E2C6;
  --shadow: 0 1px 0 rgba(48, 45, 41, 0.08), 0 6px 14px -6px rgba(48, 45, 41, 0.35);
  --shadow-lift: 0 2px 0 rgba(48, 45, 41, 0.1), 0 12px 24px -8px rgba(48, 45, 41, 0.42);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .19 0 0 0 0 .17 0 0 0 0 .16 0 0 0 .065 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper) var(--grain);
  font: 400 17px/1.55 "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--purple-deep); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  background: var(--card);
  color: var(--ink);
  padding: 10px 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
  border: 2px solid var(--ink);
}

h1 { font-weight: 800; font-size: clamp(26px, 3.6vw, 38px); line-height: 1.08; margin: 6px 0 10px; }
h2 { font-weight: 800; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.15; margin: 20px 0 8px; }
h3 { font-weight: 700; font-size: 18px; line-height: 1.25; margin: 14px 0 6px; }
p { margin: 0 0 12px; }
.kicker { font-weight: 800; font-size: 12.5px; letter-spacing: 0.08em; color: var(--red-deep); text-transform: uppercase; display: block; }
.sub { color: var(--ink-soft); }
.small, small { color: var(--ink-soft); font-size: 14.5px; }

/* Header & Navigation */
.topbar {
  background: rgba(246, 240, 227, 0.95);
  border-bottom: 2px dashed rgba(48, 45, 41, 0.16);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(4px);
}
.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
}
.brand {
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand b { font-weight: 800; font-size: 21px; letter-spacing: -0.01em; }
.brand span { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

.topnav { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.topnav a, .topnav button {
  text-decoration: none;
  color: var(--ink);
  padding: 7px 14px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 2px solid rgba(48, 45, 41, 0.2);
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
}
.topnav a[aria-current="page"], .topnav button[aria-pressed="true"] {
  background: var(--tape);
  border-color: var(--ink);
}

.page { max-width: 1060px; margin: 0 auto; padding: 18px 18px 80px; }

/* Cut-paper sheets */
.sheet {
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin: 18px 0;
  position: relative;
  border: 1px solid rgba(48, 45, 41, 0.09);
  clip-path: polygon(0 .4%, 32% 0, 65% .4%, 100% 0, 99.7% 42%, 100% 99.5%, 68% 100%, 34% 99.6%, 0 100%, .3% 54%);
}
.sheet.tape::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 24px;
  width: 78px;
  height: 20px;
  background: var(--tape);
  opacity: 0.92;
  transform: rotate(-2.5deg);
  box-shadow: 0 1px 2px rgba(48, 45, 41, 0.18);
}
.sheet.note { background: var(--warn-bg); }
.sheet.good { background: var(--good-bg); }
.sheet.info { background: var(--blue-soft); }

/* Pills & Badges */
.pill {
  display: inline-block;
  font-weight: 700;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 12px;
  margin: 0 6px 6px 0;
  background: var(--paper-deep);
  color: var(--ink);
}
.pill.bio { background: var(--bio-bg); color: var(--bio); }
.pill.chm { background: var(--chm-bg); color: var(--chm); }
.pill.phy { background: var(--phy-bg); color: var(--phy); }
.pill.hsw { background: var(--hsw-bg); color: var(--hsw); }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.plan { background: var(--plan-bg); color: var(--plan); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  padding: 9px 18px;
  border: 2px solid transparent;
  color: #fff;
  background: var(--purple-deep);
  box-shadow: var(--shadow);
  min-height: 44px;
  border-radius: 4px;
  clip-path: polygon(0 4%, 50% 0, 100% 4%, 99% 100%, 50% 97%, 1% 100%);
}
.btn:hover { filter: brightness(1.07); }
.btn.alt { background: var(--card); color: var(--ink); border-color: rgba(48, 45, 41, 0.28); }
.btn.good { background: var(--good); }
.btn.blue { background: var(--blue); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { background: var(--plan-bg); color: var(--plan); cursor: not-allowed; filter: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; align-items: center; }

/* Discipline Tabs & Filter Bar */
.disc-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.disc-tab {
  padding: 9px 16px;
  min-height: 44px;
  font-weight: 800;
  background: var(--card);
  border: 2px solid rgba(48, 45, 41, 0.22);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.disc-tab[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.disc-tab[data-disc="Biology"][aria-pressed="true"] { background: var(--bio); border-color: var(--bio); }
.disc-tab[data-disc="Chemistry"][aria-pressed="true"] { background: var(--chm); border-color: var(--chm); }
.disc-tab[data-disc="Physics"][aria-pressed="true"] { background: var(--phy); border-color: var(--phy); }
.disc-tab[data-disc="Working Scientifically"][aria-pressed="true"] { background: var(--hsw); border-color: var(--hsw); }

.premade-bar {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1.5px dashed rgba(48, 45, 41, 0.24);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.premade-bar strong { font-size: 14.5px; color: var(--red-deep); text-transform: uppercase; letter-spacing: 0.05em; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 10px;
}
.filters label { display: grid; gap: 4px; font-weight: 700; font-size: 13.5px; }
select, input[type="text"], input[type="number"], input[type="email"], textarea {
  background: #fff;
  border: 2px solid #8A8478;
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 42px;
  width: 100%;
}
textarea { min-height: 92px; resize: vertical; }

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.stat-box {
  background: var(--paper);
  border: 1px solid rgba(48, 45, 41, 0.16);
  padding: 10px 14px;
  border-radius: 6px;
}
.stat-box strong { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-box span { font-size: 13px; color: var(--ink-soft); font-weight: 600; }

/* Question Cards — calm cut-paper layout */
.q-card {
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid rgba(48, 45, 41, 0.09);
  padding: 24px 26px;
  margin: 22px 0;
  border-radius: 4px;
  clip-path: polygon(0 .3%, 35% 0, 72% .4%, 100% 0, 99.8% 50%, 100% 99.6%, 65% 100%, 28% 99.6%, 0 100%, .2% 48%);
}
.q-card.selected { border: 2.5px solid var(--purple-deep); box-shadow: var(--shadow-lift); }
.q-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 14px; margin-bottom: 12px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.q-submeta { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; }

/* Large tactile teacher selection panel */
.select-panel {
  width: 100%;
  margin-top: 16px;
  padding: 13px 18px;
  min-height: 50px;
  border: 2px dashed rgba(48, 45, 41, 0.35);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}
.select-panel:hover { background: var(--tape); border-style: solid; border-color: var(--ink); }
.select-panel[aria-pressed="true"] {
  background: var(--purple-deep);
  color: #fff;
  border-style: solid;
  border-color: var(--purple-deep);
}
.q-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, 1fr); gap: 20px; align-items: start; }
.q-layout.no-visual { grid-template-columns: 1fr; }

.q-visual {
  background: var(--paper);
  border: 1px solid rgba(48, 45, 41, 0.16);
  padding: 10px;
  border-radius: 6px;
}
.q-visual img, .q-visual svg {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  height: auto;
  margin: 0 auto;
}
.q-visual figcaption {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: center;
}

.q-stem { font-size: 18px; font-weight: 700; line-height: 1.4; margin: 0 0 12px; }

/* Options & Inputs */
.q-options { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.q-opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 2px solid #8A8478;
  border-radius: 6px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
.q-opt input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }
.q-opt:has(input:checked) { background: var(--tape); border-color: var(--ink); }
.q-opt.is-correct { background: var(--good-bg); border-color: var(--good); }
.q-opt.is-wrong { background: var(--warn-bg); border-color: var(--red-deep); }

.num-row { display: flex; gap: 8px; align-items: center; max-width: 280px; margin: 8px 0 12px; }
.num-unit { font-weight: 800; font-size: 18px; padding: 0 4px; }

.seq-list { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.seq-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid #8A8478;
  border-radius: 6px;
  padding: 8px 12px;
}
.seq-num { font-weight: 800; min-width: 26px; color: var(--purple-deep); }
.seq-text { flex: 1; font-weight: 600; }
.seq-btns { display: flex; gap: 4px; }
.seq-btns button {
  min-width: 36px; min-height: 36px;
  border: 1px solid #8A8478; background: var(--paper); border-radius: 4px; cursor: pointer; font-weight: 800;
}

.class-grid { display: grid; gap: 8px; margin: 8px 0 12px; }
.class-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.3fr);
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid #C9BFA9;
  padding: 8px 12px;
  border-radius: 6px;
}

/* Feedback & Teacher Guidance */
.q-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  border-left: 6px solid var(--ink);
  background: var(--paper);
}
.q-feedback.correct { background: var(--good-bg); border-left-color: var(--good); }
.q-feedback.incorrect { background: var(--warn-bg); border-left-color: var(--red-deep); }
.q-feedback.model { background: var(--blue-soft); border-left-color: var(--blue); }

.teacher-details {
  margin-top: 12px;
  background: var(--paper);
  border: 1px solid rgba(48, 45, 41, 0.2);
  border-radius: 6px;
  padding: 10px 14px;
}
.teacher-details summary { cursor: pointer; font-weight: 800; color: var(--purple-deep); }
.teacher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 10px; font-size: 14.5px; }
.teacher-grid p { margin: 0 0 6px; }

/* Quiz Progress Bar */
.quiz-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--paper-deep);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.progress-track { flex: 1; min-width: 180px; height: 10px; background: #fff; border-radius: 6px; overflow: hidden; border: 1px solid rgba(48, 45, 41, 0.2); }
.progress-fill { height: 100%; background: var(--purple-deep); transition: width 0.2s; }

/* Teacher Sticky Selection Bar */
.selection-bar {
  position: sticky;
  bottom: 12px;
  z-index: 25;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.selection-bar .btn.alt { background: #fff; color: var(--ink); }

.share-box {
  background: #fff;
  border: 2px solid var(--purple-deep);
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 10px;
  word-break: break-all;
  font-size: 14px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 60;
  font-weight: 700;
  box-shadow: var(--shadow-lift);
}

table { border-collapse: collapse; width: 100%; font-size: 14.5px; background: #fff; }
th, td { border: 1px solid #C9BFA9; padding: 7px 10px; text-align: left; vertical-align: top; }
th { background: var(--paper-deep); font-weight: 800; }

@media (max-width: 780px) {
  .q-layout { grid-template-columns: 1fr; }
  .class-row { grid-template-columns: 1fr; }
}

@media print {
  .noprint, .topbar, .selection-bar, .actions, .disc-tabs, .filters { display: none !important; }
  body { background: #fff !important; font-size: 12pt; }
  .sheet, .q-card { box-shadow: none !important; clip-path: none !important; border: 1px solid #ccc; break-inside: avoid; }
  .sheet.tape::before { display: none; }
}
