:root {
  color-scheme: dark;
  --bg: #04131c;
  --surface: #092530;
  --surface-2: #0f3541;
  --line: #2f5c68;
  --line-strong: #4b7d85;
  --ink: #f4fcfd;
  --muted: #adc4ca;
  --cyan: #62ead7;
  --cyan-dark: #073a3a;
  --gold: #ffd57a;
  --red: #ff9ba3;
  --green: #85efb6;
  --shadow: 0 18px 60px #0008;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 88% -5%, #176b7c 0, transparent 32rem),
    radial-gradient(circle at -10% 35%, #123c4c 0, transparent 29rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a, button, input, select, textarea, summary { font: inherit; }
a { color: var(--ink); }
button, input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0d303b;
  color: var(--ink);
}
button, input, select { min-height: 44px; }
button { padding: 10px 14px; font-weight: 850; cursor: pointer; }
input, select, textarea { width: 100%; padding: 10px 12px; }
textarea { resize: vertical; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:hover:not(:disabled), a:hover { border-color: var(--cyan); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--gold);
  color: #172020;
  font-weight: 900;
}
.skip-link:focus { transform: none; }

main { width: min(1450px, 100%); margin: 0 auto; padding: 14px clamp(8px, 2vw, 24px) 40px; }
.session-nav {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 4px 0 12px;
  padding: 7px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #071e28ed;
}
.session-nav a { padding: 10px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 800; white-space: nowrap; }
.session-nav .brand { display: flex; gap: 8px; align-items: center; margin-right: auto; color: var(--ink); }
.session-nav .brand img { width: 28px; height: 28px; border-radius: 8px; }
.session-nav .brand i { color: var(--cyan); font-size: .72rem; font-style: normal; }

.session-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(130deg, #123e4c 0%, #0b2732 62%, #0d4450 100%);
  box-shadow: var(--shadow);
}
.eyebrow, small { color: var(--cyan); font-weight: 900; letter-spacing: .08em; }
.session-hero h1 { max-width: 900px; margin: 9px 0; font-size: clamp(2.5rem, 6vw, 4.8rem); line-height: .95; letter-spacing: -.055em; }
.session-hero p { max-width: 850px; margin-bottom: 0; color: var(--muted); }
.session-hero-actions { display: grid; gap: 12px; min-width: 205px; }
.role-badge { justify-self: end; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--cyan); background: #061a23; font-size: .75rem; font-weight: 900; }
.primary-action, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--cyan);
  border-radius: 12px;
  background: var(--cyan);
  color: #042229;
  font-weight: 900;
  text-decoration: none;
}

.notice { display: flex; gap: 12px; align-items: center; margin: 12px 0; padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; }
.notice span { color: var(--muted); }
.notice button { margin-left: auto; }
.notice-offline { border-color: #8d7439; background: #322b18; }
.notice-offline strong { color: var(--gold); }
.notice-error { border-color: #98525a; background: #321c23; }
.notice-error strong { color: var(--red); }

.start-card, .session-summary, .stepper-panel, .result-section, .session-follow-through, .action-panel, .coach-controls, .parent-boundary, .advanced-details {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.start-card { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(440px, 1.5fr) auto; gap: 18px; align-items: end; padding: 20px; }
.start-card h2, .start-card p { margin: 4px 0; }
.start-card p { color: var(--muted); }
.start-fields { display: grid; grid-template-columns: 1.2fr .7fr 1fr; gap: 9px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: .85rem; font-weight: 800; }
label span { font-weight: 600; }

.session-summary { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 22px; background: linear-gradient(120deg, #0c303b, #0c3e46); }
.session-summary h2 { margin: 4px 0; font-size: clamp(1.8rem, 4vw, 3rem); }
.session-summary p { margin: 0; color: var(--muted); }
.session-state { min-width: 190px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: #061d26; }
.session-state span, .session-state strong, .session-state small { display: block; }
.session-state span { color: var(--muted); }
.session-state strong { margin: 4px 0; color: var(--cyan); font-size: 1.25rem; }

.stepper-panel, .result-section, .coach-controls { padding: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 16px; }
.section-heading h2 { margin: 4px 0; font-size: clamp(1.65rem, 3.5vw, 2.6rem); }
.section-heading p { max-width: 540px; margin: 0; color: var(--muted); }
.session-stepper { display: grid; grid-template-columns: repeat(8, minmax(110px, 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; }
.session-stepper li { position: relative; min-width: 0; }
.session-stepper a, .session-stepper .step-body {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 132px;
  padding: 13px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--line);
  border-radius: 12px;
  background: #061c25;
  text-decoration: none;
}
.session-stepper .step-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; color: var(--muted); background: #123743; font-size: .76rem; font-weight: 900; }
.session-stepper b { line-height: 1.2; }
.session-stepper small { color: var(--muted); font-size: .67rem; }
.session-stepper li.complete a, .session-stepper li.complete .step-body { border-top-color: var(--green); }
.session-stepper li.complete .step-number { color: #073423; background: var(--green); }
.session-stepper li.current a, .session-stepper li.current .step-body { border-top-color: var(--gold); box-shadow: inset 0 0 0 1px #ffd57a55; }
.session-stepper li.current .step-number { color: #32270d; background: var(--gold); }
.session-stepper li.upcoming { opacity: .78; }

.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-card { min-height: 190px; padding: 22px; border: 1px solid var(--line); border-top: 4px solid var(--cyan); border-radius: 16px; background: linear-gradient(145deg, #0b2b36, #0d3741); }
.result-card:nth-child(2) { border-top-color: var(--gold); }
.result-card:nth-child(3) { border-top-color: var(--green); }
.result-card h3 { margin: 8px 0; font-size: 1.45rem; }
.result-card p { color: var(--muted); }

.session-follow-through { padding: 20px; border-left: 5px solid var(--cyan); }
.follow-through-status { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--cyan); background: #061a23; font-size: .72rem; font-weight: 900; }
.follow-through-grid { display: grid; grid-template-columns: 1.25fr 1.25fr .6fr; gap: 10px; }
.follow-through-grid article { display: grid; align-content: start; gap: 8px; min-height: 120px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #071e28; }
.follow-through-grid strong { font-size: 1.12rem; }
.matched-retest-lock { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-top: 10px; padding: 17px; border: 1px solid #8d7439; border-left: 5px solid var(--gold); border-radius: 14px; background: #2c281b; }
.matched-retest-lock > div { display: grid; gap: 5px; }
.matched-retest-lock p { margin: 0; color: #c9bd9d; }

.action-panel, .parent-boundary { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 20px; }
.action-panel h2, .action-panel p, .parent-boundary h2, .parent-boundary p { margin: 4px 0; }
.action-panel p, .parent-boundary p { color: var(--muted); }
.step-action-panel { border-left: 4px solid var(--cyan); }
.step-action-form { display: flex; justify-content: flex-end; gap: 9px; align-items: end; }
.parent-boundary { border-left: 4px solid var(--gold); }
.parent-boundary > span { padding: 7px 10px; border-radius: 999px; color: var(--gold); background: #352d17; font-weight: 900; white-space: nowrap; }

.coach-grid { display: grid; grid-template-columns: .8fr 1.2fr 1.2fr; gap: 10px; }
.coach-grid article { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #071e28; }
.coach-grid h3, .coach-grid p { margin: 0; }
.coach-grid p { color: var(--muted); }
.coach-grid .check { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.coach-grid .check input { width: auto; min-height: auto; }
.canonical-review-callout { border-left: 4px solid var(--gold) !important; }
.canonical-review-callout .primary-action { margin-top: auto; }
.review-hold-details { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.review-hold-details summary { color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 800; }
.review-hold-details[open] { display: grid; gap: 9px; }

.advanced-details { padding: 0 20px 20px; }
.advanced-details > summary { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 20px 0; cursor: pointer; }
.advanced-details > summary span:first-child { display: grid; }
.advanced-details > summary span:last-child { color: var(--gold); font-weight: 900; }
.advanced-details > p { color: var(--muted); }
.advanced-tool-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.advanced-tool-links a { display: grid; gap: 4px; min-height: 86px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #071e28; text-decoration: none; font-weight: 850; }
.advanced-tool-links a span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.session-records { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.record-group { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #071e28; }
.record-group h3 { margin: 0 0 9px; color: var(--cyan); font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; }
.record { padding: 9px 0; border-bottom: 1px solid var(--line); }
.record:last-child { border-bottom: 0; }
.record b, .record span { display: block; overflow-wrap: anywhere; }
.record span { color: var(--muted); font-size: .82rem; }
.empty-record { color: var(--muted); }

footer { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 28px 5px; color: var(--muted); }
footer b { color: var(--cyan); }
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; max-width: 380px; padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: #061c25; box-shadow: var(--shadow); }

body[data-role="parent"] .session-hero { background: linear-gradient(130deg, #26394a, #102936 65%, #31424d); }
body[data-role="parent"] .result-card { border-top-color: var(--gold); }

.session-evidence-proof {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 14px;
  background: var(--panel);
}

.session-evidence-proof[hidden] { display: none !important; }
.session-evidence-proof.is-ready { border-left-color: var(--aqua); }
.session-evidence-proof > div { display: grid; gap: 4px; }
.session-evidence-proof small { color: var(--muted); font-weight: 900; letter-spacing: .08em; }
.session-evidence-proof strong { color: var(--ink); font-size: 1rem; }
.session-evidence-proof p { margin: 0; color: var(--muted); line-height: 1.4; }
.session-retake-guidance { display: grid; gap: 4px; margin-top: 8px; padding: 9px; border: 1px solid rgba(180,112,28,.35); border-radius: 8px; background: rgba(255,248,232,.72); font-size: .72rem; line-height: 1.4; }
.session-retake-guidance[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .start-card { grid-template-columns: 1fr; }
  .session-stepper { grid-template-columns: repeat(4, 1fr); }
  .advanced-tool-links { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .session-hero, .session-summary, .section-heading, .action-panel, .parent-boundary, .session-evidence-proof { align-items: flex-start; flex-direction: column; }
  .session-hero-actions { width: 100%; }
  .role-badge { justify-self: start; }
  .start-fields, .coach-grid, .result-grid, .follow-through-grid, .session-records { grid-template-columns: 1fr; }
  .session-state { width: 100%; }
  .step-action-form { justify-content: flex-start; width: 100%; min-width: 0; }
  .matched-retest-lock { align-items: flex-start; flex-direction: column; }
  .advanced-tool-links { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  main { padding-inline: 8px; }
  .session-hero { padding: 25px 18px; border-radius: 21px; }
  .session-stepper, .advanced-tool-links { grid-template-columns: 1fr; }
  .session-stepper a, .session-stepper .step-body { min-height: 96px; }
  .notice { align-items: flex-start; flex-direction: column; }
  .notice button { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
