:root {
  --text-scale: 1;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef4fa;
  --text: #162230;
  --muted: #5f6c7a;
  --primary: #123a63;
  --primary-2: #1d5b91;
  --border: #cbd5df;
  --success: #17643a;
  --warning: #8a5600;
  --danger: #9d1c1c;
  --focus: #ffbf47;
  --shadow: 0 8px 30px rgba(22, 34, 48, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
body.high-contrast {
  --bg: #000;
  --surface: #000;
  --surface-2: #151515;
  --text: #fff;
  --muted: #fff;
  --primary: #ffdd00;
  --primary-2: #fff;
  --border: #fff;
  --success: #7dff9c;
  --warning: #ffe57a;
  --danger: #ff8f8f;
  --focus: #00ffff;
  --shadow: none;
}
body.high-contrast .btn-primary { color: #000; background: #ffdd00; border-color: #ffdd00; }
body.high-contrast a { color: #7dd3ff; }
body.high-contrast input, body.high-contrast textarea, body.high-contrast select { background: #000; color: #fff; border-color: #fff; }

button, input, select, textarea { font: inherit; }
button, .btn { min-height: 44px; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .72rem .8rem;
  background: var(--surface);
  color: var(--text);
}
textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-width: 1.15rem; min-height: 1.15rem; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: .5rem;
  left: .5rem;
  transform: translateY(-160%);
  background: var(--surface);
  color: var(--text);
  padding: .75rem 1rem;
  border: 2px solid var(--text);
  border-radius: 8px;
}
.skip-link:focus { transform: none; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 3rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-wrap { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-logo { width: 46px; height: 46px; flex: 0 0 auto; }
.brand-name { display: block; color: var(--primary); font-size: 1.18rem; letter-spacing: .01em; }
.brand-tagline { display: block; color: var(--muted); font-size: .78rem; }
.session-summary { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }

.access-toolbar {
  display: flex;
  gap: .8rem;
  align-items: end;
  flex-wrap: wrap;
  padding: .7rem clamp(1rem, 4vw, 3rem);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.access-toolbar label { font-size: .88rem; font-weight: 650; }
.access-toolbar select { min-width: 105px; margin-top: .25rem; }
.check-control { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; }

#app-main { width: min(1180px, calc(100% - 2rem)); margin: 1.4rem auto 3rem; min-height: 58vh; }
.site-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.2rem clamp(1rem, 4vw, 3rem); background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }

.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  border-radius: 24px;
  padding: clamp(1.4rem, 5vw, 3rem);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
body.high-contrast .hero { background: #000; border: 2px solid #fff; color: #fff; }
.hero h1 { margin: 0 0 .55rem; font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.08; }
.hero p { max-width: 760px; margin: 0; font-size: 1.05rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.card-muted { background: var(--surface-2); }
.section-title { margin: 1.8rem 0 .7rem; }
.loading-card { max-width: 620px; margin: 4rem auto; text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border-radius: 10px;
  padding: .65rem .9rem;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.status-chip, .role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: .25rem .65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .8rem;
  font-weight: 750;
}
.role-chip { text-transform: capitalize; }
.status-success { color: var(--success); }
.status-warning { color: var(--warning); }
.status-danger { color: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.form-field { display: flex; flex-direction: column; gap: .25rem; }
.form-field label { font-weight: 700; }
.form-field.full { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: .86rem; margin-top: .2rem; }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; min-width: 620px; background: var(--surface); }
th, td { text-align: left; padding: .72rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); }

.item-list { display: grid; gap: .75rem; }
.item-card { border: 1px solid var(--border); border-radius: 14px; padding: .9rem; background: var(--surface); }
.item-card h3 { margin: 0 0 .3rem; }
.item-meta { color: var(--muted); font-size: .86rem; margin-bottom: .5rem; }
.lesson-body { white-space: pre-wrap; }
.transcript { margin-top: .8rem; padding: .8rem; background: var(--surface-2); border-left: 4px solid var(--primary); border-radius: 8px; }

.mode-banner, .connection-banner {
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .8rem 1rem;
  background: var(--surface);
}
.mode-banner.demo { border-left: 6px solid var(--warning); }
.connection-banner { border-left: 6px solid var(--danger); }
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100% - 2rem));
  background: var(--text);
  color: var(--surface);
  padding: .8rem 1rem;
  border-radius: 12px;
  z-index: 100;
  box-shadow: var(--shadow);
}
body.high-contrast .toast { border: 2px solid #fff; background: #000; color: #fff; }

.exam-shell { max-width: 900px; margin: 0 auto; }
.exam-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; flex-wrap: wrap; }
.timer { font-size: 1.1rem; font-weight: 800; padding: .6rem .8rem; border: 2px solid var(--primary); border-radius: 12px; }
.question-panel { margin-top: 1rem; }
.question-panel fieldset { border: 0; padding: 0; margin: 0; }
.question-panel legend { font-size: 1.25rem; font-weight: 800; margin-bottom: 1rem; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .8rem;
  margin: .55rem 0;
  cursor: pointer;
}
.choice:has(input:checked) { border: 3px solid var(--primary); background: var(--surface-2); }
.exam-progress { width: 100%; height: 10px; border-radius: 999px; accent-color: var(--primary); }
.shortcut-help { background: var(--surface-2); padding: .7rem; border-radius: 10px; font-size: .86rem; }
.flagged { color: var(--warning); font-weight: 800; }

.question-editor { border: 1px dashed var(--border); border-radius: 14px; padding: .9rem; margin: .8rem 0; }
.question-editor h4 { margin: 0 0 .6rem; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 800px) {
  .site-header { position: static; align-items: flex-start; }
  .brand-tagline { display: none; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .access-toolbar { align-items: stretch; }
  .access-toolbar > * { flex: 1 1 145px; }
  .session-summary { justify-content: flex-start; }
  #app-main { width: min(100% - 1rem, 1180px); }
  .mode-banner, .connection-banner { width: min(100% - 1rem, 1180px); }
}

.auth-grid { align-items: start; }
.sign-search-card { margin-bottom: .8rem; }
.sign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.sign-card { display: flex; flex-direction: column; gap: .55rem; }
.sign-card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.sign-card .item-meta { margin: 0; }
.sign-picture {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.sign-picture-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 180px;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: 12px;
}
body.high-contrast .sign-picture,
body.high-contrast .sign-picture-placeholder { border-color: #fff; }

@media (max-width: 560px) {
  .sign-grid { grid-template-columns: 1fr; }
}

/* V1.2 simplified tabbed learning layout */
.compact-hero { padding: clamp(1.15rem, 3vw, 1.8rem); border-radius: 18px; }
.compact-hero h1 { font-size: clamp(1.7rem, 4vw, 2.45rem); }
.section-lead { color: var(--muted); margin: -.25rem 0 1rem; max-width: 760px; }

.dashboard-tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .35rem 0 .75rem;
  margin-bottom: .85rem;
  scrollbar-width: thin;
}
.dashboard-tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .58rem .9rem;
  background: var(--surface);
  color: var(--text);
  font-weight: 750;
}
.dashboard-tab.active,
.dashboard-tab[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
body.high-contrast .dashboard-tab.active,
body.high-contrast .dashboard-tab[aria-selected="true"] { background: #ffdd00; color: #000; }
.dashboard-panel { animation: panel-in .14s ease-out; }
.dashboard-panel[hidden] { display: none !important; }
@keyframes panel-in { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.quick-guide { margin-top: 1rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.section-block { margin-top: 1.35rem; }
.section-block > h2 { margin-bottom: .25rem; }
.section-block > p { color: var(--muted); max-width: 850px; margin-top: .25rem; }
.section-heading-row { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }

.learning-intro { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; align-items: start; }
.learning-intro h2 { margin: .45rem 0 .35rem; }
.learning-path { display: grid; gap: .85rem; margin-top: .9rem; }
.learning-step { padding: 1rem 1.05rem; }
.learning-step h3 { margin: .15rem 0 .45rem; }
.learning-step h4 { margin-bottom: .35rem; }
.learning-step ul { margin-top: .25rem; padding-left: 1.25rem; }
.learning-step-number { color: var(--primary); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.practice-box { background: var(--surface-2); border-radius: 10px; padding: .7rem .8rem; }
.source-note { color: var(--muted); font-size: .78rem; }
.text-link { display: inline-block; font-weight: 750; margin-top: .25rem; }

.fsl-reference-chart {
  display: block;
  width: min(100%, 520px);
  max-height: 520px;
  object-fit: contain;
  margin: .75rem auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.fsl-reference-chart.compact { width: 100%; height: 230px; object-fit: contain; margin: .55rem 0; }
.dictionary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; margin-top: .8rem; }
.dictionary-card { box-shadow: none; }
.search-box { display: grid; gap: .3rem; max-width: 620px; font-weight: 700; }

.optional-tools { margin-top: 1.2rem; }
.optional-tools > summary { cursor: pointer; font-size: 1.05rem; }
.optional-tools .details-body { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }

.warning-note { background: var(--surface-2); border-left: 5px solid var(--warning); padding: .75rem .85rem; border-radius: 9px; margin: 0; }
.sned-overview-grid,
.sned-service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: .75rem; margin-top: .8rem; }
.sned-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .7rem; margin-top: .8rem; }
.sned-card { box-shadow: none; padding: .85rem; }
.sned-card summary { cursor: pointer; line-height: 1.35; }
.sned-card h3 { font-size: 1rem; }
.compact-grid .sned-card p { margin-bottom: 0; }
.support-list { display: grid; gap: .1rem; padding: .3rem 1rem; }
.support-list > div { display: grid; grid-template-columns: minmax(150px, .75fr) 2fr; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.support-list > div:last-child { border-bottom: 0; }
.reference-list { display: grid; gap: .6rem; }
.reference-card { display: flex; justify-content: space-between; gap: .7rem; align-items: center; text-decoration: none; color: var(--text); box-shadow: none; }
.reference-card span { color: var(--primary-2); font-weight: 750; white-space: nowrap; }

@media (max-width: 800px) {
  .learning-intro { grid-template-columns: 1fr; }
  .dashboard-tabs { margin-left: -.1rem; margin-right: -.1rem; }
  .support-list > div { grid-template-columns: 1fr; gap: .2rem; }
  .reference-card { align-items: flex-start; flex-direction: column; }
}

/* V1.3 student-only natural voice controls */
.student-audio-controls {
  display: grid;
  gap: .75rem;
  margin: .85rem 0 1rem;
  padding: .9rem 1rem;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.audio-control-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.audio-control-title h2,
.audio-control-title h3 { margin: 0; font-size: 1rem; }
.audio-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: end;
}
.audio-control-row .btn { flex: 0 0 auto; }
.audio-control-row label {
  display: grid;
  gap: .25rem;
  min-width: 135px;
  font-size: .82rem;
  font-weight: 700;
}
.audio-status {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 650;
}
.voice-warning {
  margin: 0;
  padding: .6rem .7rem;
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .84rem;
}
body.high-contrast .student-audio-controls { border-color: #ffdd00; }

/* Reading-support presentation: no special font required. */
body.dyslexia-friendly {
  line-height: 1.75;
  letter-spacing: .025em;
  word-spacing: .08em;
}
body.dyslexia-friendly #app-main p,
body.dyslexia-friendly #app-main li,
body.dyslexia-friendly #app-main legend,
body.dyslexia-friendly #app-main .lesson-body {
  max-width: 72ch;
  text-align: left;
}
body.dyslexia-friendly .choice { padding-block: 1rem; }

/* Attention/sensory support: reduce visual competition and add breathing room. */
body.focus-friendly .hero { box-shadow: none; }
body.focus-friendly .card { box-shadow: none; }
body.focus-friendly .dashboard-panel { animation: none; }
body.focus-friendly .item-list,
body.focus-friendly .learning-path { gap: 1rem; }
body.focus-friendly .question-panel { padding: 1.15rem; }

@media (max-width: 560px) {
  .student-audio-controls { padding: .75rem; }
  .audio-control-row .btn { flex: 1 1 44%; }
  .audio-control-row label { flex: 1 1 45%; min-width: 0; }
}

/* V1.4 combined learner supports, support-plan editor, and in-app FSL video library */
.support-picker {
  margin: .55rem 0;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.support-picker legend { padding: 0 .35rem; font-weight: 800; }
.support-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .5rem;
  margin-top: .65rem;
}
.support-chip {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  padding: .62rem .7rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  line-height: 1.35;
}
.support-chip input { margin-top: .18rem; flex: 0 0 auto; }
.support-options { margin-top: .75rem; }
.support-options > summary,
.support-manager > summary { cursor: pointer; }
.support-manager { min-width: 250px; }
.support-manager form { margin-top: .75rem; padding: .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.accommodation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .55rem;
  margin: .75rem 0;
}
.support-badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.support-badge {
  display: inline-flex;
  padding: .28rem .52rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .78rem;
  font-weight: 700;
}
.active-support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .55rem;
}
.active-support-item { padding: .65rem .7rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }

.fsl-video-library { margin-top: 1.15rem; }
.fsl-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .75rem;
  margin-top: .8rem;
}
.fsl-video-card { display: flex; flex-direction: column; gap: .5rem; box-shadow: none; }
.fsl-video-card h4 { margin: .1rem 0; font-size: 1.05rem; }
.fsl-video-thumbnail {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.fsl-video-dialog {
  width: min(94vw, 820px);
  max-height: 90vh;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
}
.fsl-video-dialog::backdrop { background: rgb(0 0 0 / .68); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: .7rem; }
.dialog-head h3 { margin: 0; }
.video-frame-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.video-frame-wrap iframe { width: 100%; height: 100%; border: 0; }

body.simplified-layout .section-lead,
body.simplified-layout .help { max-width: 65ch; line-height: 1.5; }
body.simplified-layout .card { padding: .9rem; }
body.simplified-layout .hero p { max-width: 62ch; }
body.simplified-layout .reference-card span { white-space: normal; }

@media (max-width: 650px) {
  .support-chip-grid,
  .accommodation-grid,
  .fsl-video-grid,
  .active-support-grid { grid-template-columns: 1fr; }
  .support-manager { min-width: 220px; }
  .fsl-video-dialog { width: 96vw; padding: .75rem; }
}
