/* Structure, palette and typography adapted from Sentit (MIT). */
:root {
  color-scheme: light;
  --bg: #f7f5ee;
  --panel: #fffefa;
  --stage: #ebece3;
  --ink: #192d27;
  --quiet: #52645b;
  --line: #d5dace;
  --green: #234d43;
  --on-green: #fffefa;
  --soft: #e7eee5;
  --accent: #a44631;
  --focus: #a44631;
  --motion: 220ms;
  --serif: Georgia, "Times New Roman", serif;
  font: 16px/1.45 "Instrument Sans", "Segoe UI", system-ui, sans-serif;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131f1b;
  --panel: #192823;
  --stage: #101b17;
  --ink: #eef1e7;
  --quiet: #b1c2b7;
  --line: #3b4d43;
  --green: #b8dec6;
  --on-green: #14241c;
  --soft: #243931;
  --accent: #ef9c83;
  --focus: #ef9c83;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-height: 100dvh; margin: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); color: var(--ink); }
a { color: var(--green); text-underline-offset: .22em; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: fixed; z-index: 10; inset: .5rem auto auto .5rem; padding: .6rem; background: var(--panel); }
.top, .bottom { background: var(--panel); }
.top { position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); }
.bottom { border-top: 1px solid var(--line); }
.top-inner, .bottom-inner { width: min(100%, 1480px); margin: auto; padding-inline: clamp(16px, 3vw, 38px); }
.top-inner, .bottom-inner, .identity, .top-actions { display: flex; align-items: center; }
.top-inner, .bottom-inner { justify-content: space-between; gap: 14px; }
.top-inner { min-height: 68px; }
.bottom-inner { min-height: 56px; font-size: .875rem; color: var(--quiet); }
.identity { gap: 18px; min-width: 0; }
.brand { flex: none; font: 700 2.13rem/1 var(--serif); letter-spacing: -.065em; text-decoration: none; }
.brand-dot { color: var(--accent); }
.header-motto { border-inline-start: 1px solid var(--line); padding-inline-start: 18px; font-size: .875rem; color: var(--quiet); }
.top-actions { gap: 8px; }
.parent-brand { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 650; }
.icon-button, select, input, .button { border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.icon-button { width: 40px; min-height: 40px; font-size: 1.25rem; }
select, input { min-height: 40px; padding: 6px 9px; }
.icon-button:hover, select:hover, .secondary:hover { background: var(--soft); }
.button { min-height: 42px; padding: 8px 12px; color: var(--on-green); background: var(--green); }
.button:hover { filter: brightness(.92); }
.button.secondary { background: var(--panel); color: var(--green); }
.subtle { text-decoration: underline; border: 0; padding: 0; color: var(--green); background: transparent; text-underline-offset: .24em; }
.catalogue, .workspace { width: min(100%, 1480px); margin: auto; display: grid; align-items: start; grid-template-columns: 230px minmax(0, 1fr); gap: clamp(14px, 2vw, 24px); padding: clamp(16px, 3vw, 38px); }
.pane { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.catalogue-filters, .workspace-tools { padding: 17px; }
.catalogue-filters h2 { font-size: 1.15rem; }
#filters { display: grid; gap: 13px; margin-top: 14px; }
#filters label { display: grid; gap: 4px; color: var(--quiet); font-size: .875rem; }
#filters select { width: 100%; color: var(--ink); }
#filters button { justify-self: start; font-size: .875rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.section-heading h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); letter-spacing: -.025em; }
.catalogue-search { flex: 0 1 270px; }
.catalogue-search input { width: 100%; }
#result-count { margin: 8px 0 16px; }
.meta, .card-kicker { color: var(--quiet); font-size: .875rem; }
.activity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 410px), 1fr)); gap: 18px; }
.activity-card { min-width: 0; overflow: hidden; display: grid; grid-template-columns: minmax(120px, .9fr) minmax(0, 1fr); align-items: stretch; border: 1px solid var(--line); border-top: 3px solid #91b28a; border-radius: 12px; text-decoration: none; color: var(--ink); background: var(--panel); transition: transform var(--motion), box-shadow var(--motion), border-color var(--motion); }
.activity-card:hover { transform: translateY(-2px); border-color: var(--green); box-shadow: 0 9px 18px #11291f14; }
.activity-card-art { overflow: hidden; background: var(--soft); }
.activity-card-art img { width: 100%; height: 100%; object-fit: cover; object-position: 55% center; }
.activity-card-content { display: grid; align-content: start; gap: 10px; padding: clamp(14px, 2vw, 22px); }
.activity-card-content h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); }
.card-summary { color: var(--quiet); }
.card-footer { display: flex; align-items: center; gap: 7px 12px; flex-wrap: wrap; }
.pill { width: fit-content; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--green); font-size: .875rem; font-weight: 600; }
.load-state, .empty { padding: 24px; color: var(--quiet); }
.workspace { grid-template-columns: 260px minmax(0, 1fr); }
.workspace-tools > a { font-size: .875rem; }
.activity-details, #workspace-actions { display: grid; gap: 10px; margin-top: 16px; }
.activity-details h1 { font-size: 1.65rem; }
.copy-link { width: 100%; }
.preview { overflow: hidden; }
.preview-bar { display: flex; flex-wrap: wrap; gap: 5px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.preview-bar button { padding: 7px 12px; border: 1px solid transparent; border-radius: 7px; background: var(--panel); }
.preview-bar button[aria-pressed="true"] { background: var(--soft); color: var(--green); border-color: var(--line); font-weight: 650; }
.paper-stage { max-height: calc(100dvh - 180px); overflow: auto; padding: clamp(10px, 2.5vw, 27px); background: var(--stage); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.paper { width: min(100%, 210mm); margin-inline: auto; padding: clamp(12px, 3vw, 42px); color-scheme: light; background: #fff; color: #222e29; box-shadow: 0 8px 22px #11291f1b; }
.paper a { color: #234d43; }
.paper-heading, .paper-identity, .paper-intro { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 15px; }
.paper-heading h2 { margin-top: 4px; font-size: clamp(1.3rem, 2.5vw, 1.8rem); }
.paper-brand { font: 700 1.3rem/1 var(--serif); color: #234d43; }
.paper-kind { white-space: nowrap; color: #52645b; font-size: .875rem; }
.paper-identity span { flex: 1; display: flex; align-items: baseline; gap: 8px; }
.paper-identity span:last-child { flex: .5; }
.paper-identity i { flex: 1; border-bottom: 1px solid #9ea9a0; }
.paper-intro { align-items: center; padding: 12px; border-radius: 6px; background: #f7f5ee; }
.paper-listening { flex: 0 0 120px; display: grid; justify-items: center; text-align: center; gap: 3px; font-size: .78rem; }
.paper-qr svg { display: block; width: 80px; height: 80px; background: #fff; }
.print-url { display: none; overflow-wrap: anywhere; }
.questions { padding-inline-start: 1.6em; }
.questions > li { padding-inline-start: .14em; margin-bottom: 12px; }
.questions > li::marker { font-weight: 650; color: #234d43; }
.options { list-style: none; padding: 4px 0 0; }
.response-lines span { display: block; min-height: 1.25em; border-bottom: 1px solid #b0bcb0; }
.transcription { padding: 12px; background: #f7f5ee; }
.transcription h3 { font-size: 1.05rem; margin-bottom: 5px; }
.answer-evidence { margin-top: 3px; color: #435950; font-size: .875rem; }
.source-documents { display: grid; gap: 17px; }
.source-sheet { padding: 10px; }
.source-sheet.landscape { width: min(100%, 297mm); }
.source-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 13px; margin: 4px 5px 10px; }
.source-heading h2 { margin-inline-end: auto; font-size: 1.15rem; }
.source-heading a { font-size: .875rem; }
.source-sheet img { width: 100%; }
.listening { min-height: 66dvh; display: grid; place-items: center; padding: 20px; }
.listening-mode .bottom { display: none; }
.listening-card { display: grid; gap: 14px; width: min(100%, 620px); padding: clamp(18px, 4vw, 40px); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.listening-card h1 { font-size: clamp(1.8rem, 4vw, 2.3rem); }
.listening-card audio { width: 100%; }
.status-box { padding: 14px; border-radius: 7px; background: var(--soft); }
.status-box p { margin-top: 4px; }
@media (max-width: 760px) {
  .catalogue, .workspace { grid-template-columns: minmax(0, 1fr); }
  .paper-stage { max-height: none; }
  #filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); }
  .header-motto, .bottom-inner > span { display: none; }
}
@media (max-width: 435px) {
  .activity-card { grid-template-columns: minmax(0, 1fr); }
  .activity-card-art { height: 140px; }
  .paper-intro { flex-direction: column; align-items: start; }
  .paper-listening { flex: auto; justify-items: start; text-align: start; }
  .paper-heading { flex-direction: column; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@page { size: A4 portrait; margin: 12mm; }
@page map { size: A4 landscape; margin: 8mm; }
@media print {
  body, main, .workspace, .preview, .paper-stage, .source-documents { display: block; height: auto; margin: 0; padding: 0; overflow: visible; max-height: none; background: #fff; border: 0; }
  .top, .bottom, .workspace-tools, .preview-bar, .skip, .source-heading { display: none !important; }
  .paper, .paper.landscape { width: auto; margin: 0; padding: 0; box-shadow: none; font-size: 11pt; }
  .paper-intro { flex-direction: row; align-items: center; print-color-adjust: exact; }
  .paper-listening { flex: 0 0 120px; justify-items: center; text-align: center; }
  .paper-heading { flex-direction: row; }
  .questions > li, .transcription { break-inside: avoid; }
  .source-sheet { break-after: page; }
  .source-sheet:last-child { break-after: auto; }
  .source-sheet.landscape { page: map; }
  .source-sheet img { max-height: 270mm; object-fit: contain; }
  .source-sheet.landscape img { max-height: 192mm; }
  .print-url { display: block; }
}
