:root {
  color-scheme: light;
  --ink: #10282a;
  --muted: #657572;
  --teal: #126d67;
  --teal-dark: #0a4f4c;
  --teal-pale: #dfeee9;
  --cream: #f4f1e8;
  --paper: #fffef9;
  --line: #d7dfda;
  --orange: #da6b39;
  --red: #a83f3f;
  --gold: #cf9633;
  --shadow: 0 18px 50px rgba(16, 40, 42, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; margin: 0; color: var(--ink); background: var(--cream); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
.app-header { min-height: 72px; padding: 12px clamp(18px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: white; background: var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 50%; }
.brand span { display: grid; line-height: 1.1; }
.brand strong { font-size: 1.08rem; }
.brand small { margin-top: 4px; color: #b8d1cc; }
.header-actions { display: flex; align-items: center; gap: 18px; color: #bdd3ce; font-size: .76rem; }
.header-actions a { color: #dce9e6; text-decoration: none; }
.header-actions a:hover { color: white; }
.language-switch { display: inline-grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid #547371; border-radius: 999px; }
.language-switch button { min-width: 34px; min-height: 27px; padding: 0 7px; color: #bdd3ce; background: transparent; border: 0; font-size: .62rem; font-weight: 850; }
.language-switch button + button { border-left: 1px solid #547371; }
.language-switch button.active { color: var(--ink); background: #dce9e6; }
.app-shell { max-width: 1680px; margin: 0 auto; padding: clamp(30px, 5vw, 68px) clamp(16px, 4vw, 64px) 64px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 370px); align-items: end; gap: 48px; }
.eyebrow { margin: 0 0 9px; color: var(--teal); font-size: .72rem; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.intro h1 { max-width: 820px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.6rem, 5.7vw, 5.3rem); font-weight: 500; letter-spacing: -.055em; line-height: .96; }
.intro > div > p:last-child { max-width: 780px; margin: 22px 0 0; color: var(--muted); font-size: 1.04rem; line-height: 1.65; }
.intro aside { padding: 20px 22px; background: var(--teal-pale); border-left: 3px solid var(--teal); }
.intro aside strong { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.intro aside p { margin: 8px 0 0; color: #3f5e5a; line-height: 1.5; }
.mode-switch { margin: 38px 0 18px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: rgba(255,255,255,.45); }
.mode-switch button { min-height: 72px; padding: 13px 20px; display: grid; gap: 4px; color: var(--muted); text-align: left; background: transparent; border: 0; }
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch span { font-weight: 850; }
.mode-switch small { font-size: .7rem; }
.mode-switch button.active { color: white; background: var(--teal); }
.mode-switch button.active small { color: #c5e2dc; }
.workspace { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); align-items: start; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.control-panel { border-right: 1px solid var(--line); }
.panel-section { padding: 27px 24px; display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 10px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.step { margin: 3px 0 0; color: var(--orange); font-size: .7rem; font-weight: 900; }
h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.4rem; font-weight: 500; }
.help { margin: 7px 0 16px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
label { display: grid; gap: 6px; margin-top: 12px; color: #41504f; font-size: .73rem; font-weight: 750; }
select, input[type="text"], input[type="number"] { width: 100%; min-height: 39px; padding: 8px 9px; color: var(--ink); background: white; border: 1px solid #c6d1cc; border-radius: 0; }
select:focus, input:focus, button:focus-visible { outline: 2px solid rgba(18,109,103,.28); outline-offset: 2px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--teal); }
.primary { color: white; background: var(--teal); border-color: var(--teal) !important; }
.wide { width: 100%; min-height: 42px; margin-top: 16px; border: 1px solid var(--teal); font-weight: 800; }
.challenge-id, .peak-answer { margin-top: 14px; padding: 10px 11px; display: grid; gap: 4px; background: #f1f4ef; border-left: 3px solid var(--teal); }
.challenge-id span, .peak-answer span { color: var(--muted); font-size: .65rem; }
.challenge-id strong, .peak-answer strong { overflow-wrap: anywhere; font-size: .76rem; }
.progress-note { margin: 10px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.sweep-nav { margin-top: 14px; display: grid; grid-template-columns: 42px 1fr 42px; min-height: 42px; border: 1px solid #c6d1cc; }
.sweep-nav button { color: var(--teal); background: #f4f7f3; border: 0; font-weight: 900; }
.sweep-nav button:first-child { border-right: 1px solid var(--line); }
.sweep-nav button:last-child { border-left: 1px solid var(--line); }
.sweep-nav button:disabled { color: #a9b3b0; cursor: default; }
.sweep-nav output { display: grid; place-items: center; font-size: .76rem; font-weight: 800; }
.worksheet-actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.worksheet-actions button, .toolbar-actions button { min-height: 38px; padding: 8px 12px; border: 1px solid #b9c8c3; background: white; font-size: .74rem; font-weight: 800; }
.worksheet-actions button.primary { color: white; background: var(--teal); }
.hint { min-height: 52px; margin: 12px 0 0; padding: 10px; color: #6e503e; background: #f8eee5; border-left: 3px solid var(--orange); font-size: .7rem; line-height: 1.45; }
.results-panel { min-width: 0; padding: 30px; }
.results-toolbar { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.results-toolbar h2 { font-size: 1.65rem; }
.results-toolbar > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .76rem; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { padding: 7px 9px; color: #76523c; background: #f6e8dc; font-size: .68rem; font-weight: 850; }
.status-pill.pass { color: #285d52; background: #e1efe9; }
.status-pill.review { color: #76523c; background: #f6e8dc; }
.status-pill.exclude { color: #823b3b; background: #f6e2df; }
.plot-card { margin-top: 20px; border: 1px solid var(--line); background: #fbfaf5; }
.plot-legend { min-height: 44px; padding: 10px 15px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 20px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: .68rem; }
.plot-legend span::before { width: 18px; height: 2px; margin-right: 6px; display: inline-block; vertical-align: middle; background: var(--teal); content: ""; }
.plot-legend .artifact-key::before { background: var(--orange); }
.plot-legend .analysis-key::before { height: 7px; background: linear-gradient(90deg,#2b8a64 0 33%,#b64b4b 33% 66%,#7b6aa5 66%); }
.plot-legend .student-key::before { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
#psp-canvas { width: 100%; height: clamp(330px, 42vw, 570px); display: block; cursor: crosshair; touch-action: manipulation; }
.feedback-card, .truth-card, .quality-card { margin-top: 16px; padding: 20px; display: grid; grid-template-columns: minmax(170px,.35fr) 1fr; gap: 24px; border: 1px solid var(--line); }
.feedback-card { background: #f2f7f3; border-left: 4px solid var(--teal); }
.feedback-card[data-score="low"] { background: #fbf0e8; border-left-color: var(--orange); }
#feedback-content { color: #405350; font-size: .79rem; line-height: 1.55; }
#feedback-content p { margin: 0 0 8px; }
#feedback-content p:last-child { margin-bottom: 0; }
.truth-card { background: #10282a; color: white; border-color: #10282a; }
.truth-card .eyebrow { color: #8bc2b4; }
.truth-card dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.truth-card dl div { padding: 9px 10px; background: rgba(255,255,255,.07); }
.truth-card dt { color: #a8c2bc; font-size: .65rem; }
.truth-card dd { margin: 5px 0 0; font-size: .78rem; font-weight: 750; }
.metric-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); }
.metric-grid article { min-width: 0; padding: 14px 11px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span { color: var(--muted); font-size: .64rem; line-height: 1.3; }
.metric-grid strong { margin-top: 6px; display: block; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: .98rem; font-weight: 500; text-overflow: ellipsis; }
.quality-card ul { margin: 0; padding: 0; display: grid; gap: 7px; list-style: none; }
.quality-card li { padding: 9px 11px; color: #41504f; background: #f1f4ef; border-left: 3px solid #77919a; font-size: .72rem; line-height: 1.4; }
.quality-card li.review { color: #74503b; background: #f7ece3; border-color: var(--orange); }
.quality-card li.exclude { color: #7d3636; background: #f7e5e3; border-color: var(--red); }
.quality-card li.pass { color: #285d52; background: #e7f1ec; border-color: var(--teal); }
.method-card { margin-top: 16px; padding: 18px 20px; color: #d6e5e1; background: var(--ink); }
.method-card strong { color: white; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.method-card p { margin: 8px 0 0; font-size: .76rem; line-height: 1.55; }
.method-card code { color: #f3c690; }
footer { padding: 22px clamp(18px,4vw,64px); display: flex; justify-content: space-between; gap: 20px; color: #a9bfbb; background: var(--ink); font-size: .72rem; }

@media (max-width: 1080px) {
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .intro aside { max-width: 620px; }
  .workspace { grid-template-columns: 330px minmax(0,1fr); }
  .metric-grid { grid-template-columns: repeat(3,1fr); }
  .metric-grid article:nth-child(3) { border-right: 0; }
  .metric-grid article:nth-child(n+4) { border-top: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .header-actions span, .header-actions a:first-of-type { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .results-toolbar { flex-direction: column; }
  .feedback-card, .truth-card, .quality-card { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app-header { min-height: 64px; }
  .brand img { width: 34px; height: 34px; }
  .header-actions > a { display: none; }
  .app-shell { padding-top: 34px; }
  .intro h1 { font-size: 2.55rem; }
  .mode-switch button { padding: 10px; }
  .panel-section { padding: 22px 15px; grid-template-columns: 24px minmax(0,1fr); }
  .results-panel { padding: 18px 11px; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
  #psp-canvas { height: 340px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article, .metric-grid article:nth-child(3) { border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
  .metric-grid article:nth-child(-n+2) { border-top: 0; }
  .metric-grid article:nth-child(even) { border-right: 0; }
  .truth-card dl { grid-template-columns: 1fr 1fr; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
