:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #5a6478;
  --line: #dbe2ef;
  --accent: #335cff;
  --accent-dark: #173ec7;
  --soft: #edf1ff;
  --shadow: 0 14px 38px rgba(20, 31, 56, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #eef3ff 0, var(--bg) 42rem);
  line-height: 1.42;
}

.hero, main, footer {
  width: min(1760px, calc(100% - 28px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: end;
  padding: 20px 0 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 3.1rem);
  line-height: 1.0;
  letter-spacing: -0.045em;
}

.lede {
  max-width: 900px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.summary-card, .panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary-card { padding: 13px 15px; }

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}

.summary-row:last-child { border-bottom: 0; }
.summary-row span { color: var(--muted); }
.summary-row strong { text-align: right; }

main {
  display: grid;
  gap: 14px;
  padding-bottom: 26px;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(430px, 0.88fr) minmax(760px, 1.35fr);
  gap: 14px;
  align-items: start;
}

.control-stack {
  display: grid;
  gap: 12px;
}

.panel { padding: 14px; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
}

.compact-heading { display: block; }

.section-heading h2, .plot-panel h3, .explanation-panel h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

.section-heading h2 { font-size: 1.08rem; }
.plot-panel h3 { font-size: 0.98rem; }

.section-heading p, .explanation-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  max-width: 780px;
  font-size: 0.88rem;
}

.global-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 5px;
  font-weight: 650;
}

.field span, .line-label, .column-header {
  color: var(--muted);
  font-size: 0.82rem;
}

select, input[type="number"] {
  width: 100%;
  border: 1px solid #c9d2e4;
  border-radius: 10px;
  background: #fff;
  padding: 7px 9px;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}


.global-span-2 { grid-column: span 2; }

.line-hidden { display: none; }

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.checkbox-row input { accent-color: var(--accent); }

.preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 11px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(51, 92, 255, 0.20);
  transition: transform 0.12s ease, background 0.12s ease;
}

button:hover { background: var(--accent-dark); transform: translateY(-1px); }
button.secondary {
  background: var(--soft);
  color: var(--accent-dark);
  box-shadow: none;
}
button.secondary:hover { background: #dfe6ff; }

.note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.line-table {
  display: grid;
  gap: 6px;
}

.line-header {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 80px;
  gap: 7px;
  align-items: center;
  margin-bottom: 1px;
  font-weight: 750;
}

.line-header .phase-header,
.line-header .phase-number-header { display: none; }

.line-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 80px;
  grid-template-rows: repeat(2, auto);
  gap: 5px 7px;
  align-items: center;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcff;
}

.line-index {
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.86rem;
}

.line-row input[type="number"] {
  padding: 5px 7px;
  font-size: 0.84rem;
}

.phase-slider { grid-column: 2; grid-row: 2; }
.phase-number { grid-column: 3; grid-row: 2; }

.plot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.plot-panel {
  padding: 12px;
  overflow: visible;
}

.plot-panel h3 { margin-bottom: 4px; }

.plot-panel.wide { grid-column: 1 / -1; }

.plot { width: 100%; }
.plot-small { min-height: 315px; }
.plot-phasor { min-height: 370px; }
.plot-large { min-height: 385px; }

.math {
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  color: var(--ink);
}

.explanation-panel {
  padding: 14px 16px;
}

.explanation-panel p + p { margin-top: 6px; }

footer {
  color: var(--muted);
  padding: 2px 0 22px;
  text-align: center;
  font-size: 0.9rem;
}

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

@media (max-width: 1280px) {
  .app-grid { grid-template-columns: 1fr; }
  .plot-small { min-height: 340px; }
  .plot-phasor { min-height: 390px; }
  .plot-large { min-height: 430px; }
}

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .summary-card { max-width: 520px; }
  .global-grid, .preset-row, .plot-grid { grid-template-columns: 1fr; }
  .plot-panel.wide { grid-column: auto; }
}

@media (max-width: 680px) {
  .hero, main, footer { width: min(100% - 20px, 1760px); }
  .panel { padding: 12px; }
  .section-heading { display: block; }
  .line-row, .line-header {
    grid-template-columns: 30px minmax(0, 1fr) 72px;
  }
  .plot-small { min-height: 320px; }
  .plot-phasor { min-height: 360px; }
  .plot-large { min-height: 380px; }
}

/* v7 emphasis: make the preset controls and waveform output visually easy to find. */
:root {
  --preset-accent: #8a5cf6;
  --preset-soft: #f4efff;
  --waveform-accent: #0f9f8e;
  --waveform-soft: #ecfffb;
  --target-accent: #f59e0b;
  --snapshot-accent: #ef4444;
}

.focus-panel {
  position: relative;
  overflow: visible;
}

.focus-panel::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 5px;
  border-radius: 999px;
}

.focus-panel-presets {
  border-color: rgba(138, 92, 246, 0.34);
  background: linear-gradient(135deg, rgba(244, 239, 255, 0.98), rgba(255, 255, 255, 0.96) 54%);
}

.focus-panel-presets::before { background: var(--preset-accent); }

.focus-panel-waveform {
  border-color: rgba(15, 159, 142, 0.34);
  background: linear-gradient(135deg, rgba(236, 255, 251, 0.98), rgba(255, 255, 255, 0.96) 58%);
}

.focus-panel-waveform::before { background: var(--waveform-accent); }

.focus-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  border: 1px solid transparent;
}

.preset-badge { background: #eef2ff; color: #334155; border-color: #dbe2ef; }
.preset-badge.family-intensity { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.preset-badge.family-amplitude { background: #f4efff; color: #5b21b6; border-color: #ddd6fe; }
.preset-badge.family-phase { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.preset-badge.family-random { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.preset-badge.family-manual { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }

.preset-panel .note {
  border-left: 3px solid var(--preset-accent);
  padding-left: 10px;
}

.waveform-panel h3::after {
  content: "intensity |E(t)|²";
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--waveform-soft);
  color: #0f766e;
  border: 1px solid rgba(15, 159, 142, 0.28);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.explanation-panel.wide {
  grid-column: 1 / -1;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.82);
  border-style: dashed;
}

@media (max-width: 680px) {
  .global-span-2 { grid-column: auto; }
  .waveform-panel h3::after,
  .focus-badge { margin-left: 0; margin-top: 5px; }
}
