:root {
  --ink: #eaf7ff;
  --muted: #9cb8c8;
  --panel: rgba(7, 20, 32, 0.92);
  --panel-2: rgba(12, 31, 48, 0.92);
  --line: rgba(163, 220, 239, 0.18);
  --cyan: #55d6e8;
  --cyan-deep: #1599b5;
  --violet: #a78bfa;
  --amber: #f6c85f;
  --success: #67e8a5;
  --warning: #ffc86b;
  --danger: #ff8b8b;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #020812; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(85, 214, 232, 0.12), transparent 28rem),
    radial-gradient(circle at 84% 18%, rgba(167, 139, 250, 0.13), transparent 32rem),
    linear-gradient(180deg, #020713 0%, #06111d 45%, #020812 100%);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.48;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.75) 0 1px, transparent 1.2px),
    radial-gradient(circle, rgba(85,214,232,.65) 0 1px, transparent 1.2px);
  background-position: 0 0, 37px 29px;
  background-size: 91px 91px, 137px 137px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
button, select, input, textarea { font: inherit; }
button, select, input[type="range"], input[type="checkbox"] { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(85, 214, 232, .8);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .48; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(3, 12, 21, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 12px; width: max-content; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--cyan), #197893 56%, #694fc3);
  box-shadow: 0 10px 28px rgba(44, 186, 214, .26);
  position: relative; overflow: hidden; font-weight: 900; letter-spacing: -5px; padding-right: 5px;
}
.brand-mark::after { content: ""; position: absolute; inset: 3px; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; }
.brand-mark span:last-child { opacity: .65; }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 1.02rem; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-size: .72rem; }
.header-title { text-align: center; }
.header-title h1 { margin: 2px 0 0; font-size: clamp(1.1rem, 2vw, 1.55rem); letter-spacing: -.02em; }
.eyebrow, .panel-kicker { color: var(--cyan); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.header-actions { display: flex; justify-content: flex-end; gap: 9px; }

.ghost-button, .secondary-button, .primary-button, .icon-button, .text-button {
  border: 0; border-radius: 11px; min-height: 42px; font-weight: 800; transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.ghost-button, .secondary-button { color: var(--ink); background: rgba(122, 177, 204, .08); border: 1px solid rgba(139, 211, 235, .22); padding: 10px 14px; }
.ghost-button:hover, .secondary-button:hover { background: rgba(85, 214, 232, .13); border-color: rgba(85,214,232,.46); transform: translateY(-1px); }
.primary-button { color: #03131a; background: linear-gradient(135deg, #75e7f5, #4fcbdc); padding: 11px 16px; box-shadow: 0 10px 24px rgba(85,214,232,.18); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.icon-button { width: 42px; padding: 0; color: var(--ink); background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: 1.2rem; }
.full-width { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.app-shell {
  position: relative; z-index: 1; display: grid; grid-template-columns: 288px minmax(640px, 1fr) 290px; align-items: start; gap: 16px; max-width: 1920px; margin: 0 auto; padding: 16px;
}
.panel, .display-card {
  border: 1px solid var(--line); background: linear-gradient(180deg, rgba(13, 31, 47, .92), rgba(5, 17, 29, .94)); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.panel { border-radius: 18px; overflow: hidden; }
.controls-panel, .notebook-panel { position: sticky; top: 94px; max-height: calc(100vh - 110px); overflow: auto; }
.panel-heading, .card-heading, .section-title-row, .workspace-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-heading { padding: 18px; border-bottom: 1px solid var(--line); }
h2, h3, p { margin-top: 0; }
.panel-heading h2, .workspace-toolbar h2, .card-heading h3 { margin: 3px 0 0; }
.panel-heading h2 { font-size: 1.12rem; }
.control-section { padding: 17px 18px; border-bottom: 1px solid var(--line); }
.control-section h3 { margin-bottom: 11px; font-size: .94rem; }
.compact-section p { margin-bottom: 0; }
.standards-card { background: linear-gradient(135deg, rgba(85,214,232,.09), rgba(167,139,250,.08)); }
.standards-card p { color: var(--muted); line-height: 1.52; font-size: .82rem; margin-bottom: 0; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); }
.switch-row span { display: grid; }
.switch-row small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.switch-row input { appearance: none; width: 48px; height: 26px; border-radius: 999px; background: #243748; border: 1px solid var(--line); position: relative; flex: 0 0 auto; }
.switch-row input::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; top: 3px; left: 4px; background: #dcecf2; transition: left .16s ease, background .16s ease; }
.switch-row input:checked { background: rgba(85,214,232,.35); border-color: var(--cyan); }
.switch-row input:checked::after { left: 24px; background: var(--cyan); }
.info-dot { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(85,214,232,.35); color: var(--cyan); background: rgba(85,214,232,.08); font-weight: 900; }

.mode-list { display: grid; padding: 10px; gap: 8px; }
.mode-button {
  width: 100%; display: grid; grid-template-columns: 34px 1fr 24px; align-items: center; gap: 10px; padding: 11px; text-align: left; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 13px;
}
.mode-button:hover { background: rgba(255,255,255,.035); }
.mode-button.active { background: linear-gradient(135deg, rgba(85,214,232,.14), rgba(167,139,250,.08)); border-color: rgba(85,214,232,.35); }
.mode-button span:nth-child(2) { display: grid; }
.mode-button small { color: var(--muted); margin-top: 3px; line-height: 1.25; }
.step-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: var(--cyan); background: rgba(85,214,232,.1); font-weight: 900; }
.step-check { color: var(--muted); font-size: 1.1rem; }
.step-check.complete { color: var(--success); }
.progress-track { height: 9px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .3s ease; }
.progress-copy { margin-top: 10px; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.workspace { min-width: 0; }
.workspace-toolbar { min-height: 74px; padding: 15px 18px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(7,20,32,.84); box-shadow: var(--shadow); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 8px 12px; color: var(--muted); background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: .78rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }
.mode-panel { animation: panelIn .22s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(5px); } }
.instruction-banner { margin-bottom: 14px; padding: 14px 16px; border-radius: 14px; color: #dff9ff; line-height: 1.5; background: linear-gradient(90deg, rgba(85,214,232,.12), rgba(167,139,250,.1)); border: 1px solid rgba(85,214,232,.25); }
.two-column-stage { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 14px; align-items: stretch; }
.display-card { border-radius: 18px; overflow: hidden; }
.card-heading { min-height: 76px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-heading h3 { font-size: 1rem; }
.compact-select { display: grid; gap: 5px; color: var(--muted); font-size: .71rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
select, textarea {
  color: var(--ink); background: #091a29; border: 1px solid rgba(151,207,227,.24); border-radius: 10px; padding: 10px 11px;
}
select option { background: #091a29; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
canvas { display: block; width: 100%; height: auto; background: #04101c; }
.instrument-card canvas { border-bottom: 1px solid var(--line); }
.measurement-controls { padding: 16px 18px 18px; }
.range-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .8rem; font-weight: 800; }
.range-label output { color: var(--cyan); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--cyan); margin: 12px 0 15px; }
.feedback-message { min-height: 40px; margin: 12px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.feedback-message.success { color: var(--success); }
.feedback-message.warning { color: var(--warning); }
.feedback-message.error { color: var(--danger); }
.metric-chip { display: grid; gap: 2px; min-width: 86px; padding: 8px 10px; text-align: right; border-radius: 10px; background: rgba(85,214,232,.08); border: 1px solid rgba(85,214,232,.18); }
.metric-chip span { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-chip strong { color: var(--cyan); font-size: .9rem; }
.graph-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.graph-readouts div { display: grid; gap: 5px; padding: 14px 16px; background: rgba(5,17,29,.94); }
.graph-readouts span { color: var(--muted); font-size: .72rem; }
.graph-readouts strong { font-size: .86rem; }
.expansion-card { margin-top: 14px; }
.expansion-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; }
.expansion-controls { padding: 18px; border-left: 1px solid var(--line); }
.concept-card { margin-top: 14px; padding: 13px; border-radius: 12px; background: rgba(167,139,250,.08); border: 1px solid rgba(167,139,250,.2); }
.concept-card p { color: var(--muted); margin: 6px 0 0; font-size: .82rem; line-height: 1.5; }

.table-wrap { max-height: 390px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .81rem; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #091a29; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.empty-cell { color: var(--muted); text-align: center; padding: 28px; }
.evidence-question { padding: 16px 18px 18px; }
.evidence-question label { display: block; margin-bottom: 8px; font-weight: 800; line-height: 1.4; }
.evidence-question select { width: 100%; margin-bottom: 10px; }
.sample-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 16px 18px; }
.sample-button { min-height: 118px; display: grid; place-items: center; gap: 2px; padding: 10px; color: var(--ink); border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.025); }
.sample-button:hover, .sample-button.active { border-color: rgba(85,214,232,.5); background: rgba(85,214,232,.08); }
.sample-button.measured::after { content: "✓ analyzed"; color: var(--success); font-size: .68rem; }
.sample-button small { color: var(--muted); }
.sample-orb { width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, white, #8be5f0 8%, #5c72d8 35%, #261746 75%); box-shadow: 0 0 22px rgba(85,214,232,.35); }

.model-comparison-card { margin-bottom: 14px; }
.explanation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px; }
.explanation-card { min-height: 190px; padding: 16px; text-align: left; color: var(--ink); background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 15px; }
.explanation-card:hover { border-color: rgba(85,214,232,.4); }
.explanation-card.selected { background: linear-gradient(145deg, rgba(85,214,232,.13), rgba(167,139,250,.1)); border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(85,214,232,.08); }
.explanation-card p { color: var(--muted); line-height: 1.48; margin-bottom: 0; font-size: .82rem; }
.model-icon { display: block; width: 72px; height: 54px; margin-bottom: 12px; border-radius: 13px; position: relative; background: #06131f; border: 1px solid var(--line); overflow: hidden; }
.static-icon::before { content: ""; position: absolute; inset: 10px; background: radial-gradient(circle at 20% 30%, white 0 2px, transparent 3px), radial-gradient(circle at 70% 65%, #8ce8f2 0 2px, transparent 3px), radial-gradient(circle at 50% 20%, #b69cff 0 2px, transparent 3px); }
.explosion-icon::before { content: ""; position: absolute; left: 34px; top: 26px; width: 4px; height: 4px; border-radius: 50%; background: var(--amber); box-shadow: -22px -10px 0 var(--cyan), 22px 10px 0 var(--violet), 14px -18px 0 white, -14px 18px 0 #ff8c78; }
.explosion-icon::after { content: ""; position: absolute; inset: 9px; border: 1px dashed rgba(246,200,95,.5); border-radius: 50%; }
.expanding-icon { background-image: linear-gradient(rgba(85,214,232,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(85,214,232,.13) 1px, transparent 1px); background-size: 14px 14px; }
.expanding-icon::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(167,139,250,.7); border-radius: 8px; }
.synthesis-layout { grid-template-columns: .85fr 1.15fr; }
.evidence-selector-card { padding-bottom: 8px; }
.evidence-choice { display: flex; gap: 11px; margin: 10px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.evidence-choice input { width: 19px; height: 19px; accent-color: var(--cyan); flex: 0 0 auto; }
.evidence-choice span { display: grid; gap: 4px; }
.evidence-choice small { color: var(--muted); line-height: 1.35; }
.claim-card { padding-bottom: 18px; }
.claim-card > label, .claim-card > textarea, .claim-card > button, .claim-card > p { width: calc(100% - 36px); margin-left: 18px; margin-right: 18px; }
.claim-card > label { display: block; margin-top: 16px; margin-bottom: 9px; font-weight: 800; line-height: 1.45; }
.claim-card > textarea { width: calc(100% - 36px); }
.claim-card > button { margin-top: 12px; }
.limitation-card { margin-top: 14px; padding: 18px; }
.limitation-card h3 { margin: 4px 0 14px; }
.limitation-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.limitation-grid p { margin: 0; padding: 12px; color: var(--muted); background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 12px; line-height: 1.5; font-size: .82rem; }

.notebook-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.notebook-section h3 { font-size: .91rem; margin-bottom: 11px; }
.notebook-section p { color: var(--muted); font-size: .8rem; line-height: 1.46; margin: 10px 0 0; }
.notebook-metric { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed rgba(151,207,227,.15); font-size: .8rem; }
.notebook-metric span { color: var(--muted); }
.notebook-metric strong { color: var(--cyan); text-align: right; }
.vocabulary-card dl { margin: 0; }
.vocabulary-card dt { font-weight: 850; color: var(--ink); margin-top: 9px; }
.vocabulary-card dd { margin: 2px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }

.help-dialog { width: min(720px, calc(100vw - 28px)); color: var(--ink); background: #071725; border: 1px solid rgba(85,214,232,.34); border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.help-dialog::backdrop { background: rgba(0, 5, 12, .78); backdrop-filter: blur(5px); }
.help-dialog form { margin: 0; }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.dialog-heading h2 { margin: 4px 0 0; }
.guide-steps { padding-left: 22px; color: var(--muted); line-height: 1.58; }
.guide-steps li { margin: 10px 0; padding-left: 5px; }
.guide-steps strong { color: var(--ink); }
.guide-note { margin: 18px 0; padding: 14px; border-radius: 12px; background: rgba(85,214,232,.09); border: 1px solid rgba(85,214,232,.18); line-height: 1.5; }
.tooltip { position: fixed; z-index: 100; max-width: 300px; padding: 10px 12px; color: var(--ink); background: #071725; border: 1px solid rgba(85,214,232,.35); border-radius: 10px; box-shadow: var(--shadow); font-size: .78rem; line-height: 1.45; pointer-events: none; }

@media (max-width: 1400px) {
  .app-shell { grid-template-columns: 260px minmax(590px, 1fr); }
  .notebook-panel { position: static; grid-column: 1 / -1; max-height: none; display: grid; grid-template-columns: repeat(4, 1fr); }
  .notebook-panel .panel-heading { grid-column: 1 / -1; }
  .notebook-section { border-right: 1px solid var(--line); }
}
@media (max-width: 1050px) {
  .site-header { grid-template-columns: 1fr auto; }
  .header-title { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .controls-panel { position: static; max-height: none; }
  .mode-list { grid-template-columns: repeat(4, minmax(170px, 1fr)); overflow-x: auto; }
  .mode-button { min-width: 190px; }
  .two-column-stage, .synthesis-layout { grid-template-columns: 1fr; }
  .expansion-layout { grid-template-columns: 1fr; }
  .expansion-controls { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .site-header { padding: 10px 12px; }
  .brand-copy small { display: none; }
  .header-actions .ghost-button:first-child { display: none; }
  .app-shell { padding: 10px; gap: 10px; }
  .workspace-toolbar { align-items: flex-start; }
  .status-pill { display: none; }
  .button-row, .graph-readouts, .limitation-grid { grid-template-columns: 1fr; }
  .sample-grid, .explanation-grid { grid-template-columns: repeat(2, 1fr); }
  .notebook-panel { display: block; }
  .card-heading { align-items: flex-start; flex-wrap: wrap; }
}
@media (max-width: 500px) {
  .brand-mark { width: 40px; height: 40px; }
  .brand-copy strong { font-size: .9rem; }
  .header-actions .ghost-button { padding: 9px 10px; font-size: .78rem; }
  .sample-grid, .explanation-grid { grid-template-columns: 1fr; }
  .mode-list { grid-template-columns: repeat(4, 180px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
