:root {
  --ink: #20242a;
  --muted: #59636f;
  --page: #f6f8fb;
  --panel: #ffffff;
  --line: #d8dee8;
  --blue: #276fbf;
  --blue-soft: #d9ebff;
  --orange: #c2410c;
  --green: #247a5a;
  --shadow: 0 8px 24px rgba(32, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Verdana, Geneva, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.app-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

h1 {
  margin: 0 0 6px;
  color: #5d6670;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0;
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.controls,
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.controls {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.results {
  min-width: 0;
  padding: 16px;
}

.control-group {
  margin-bottom: 14px;
}

label,
.metric-label,
figcaption {
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 650;
}

select,
input[type="number"] {
  width: 100%;
  height: 38px;
  border: 1px solid #cbd3df;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 6px 8px;
}

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

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-grid label {
  min-height: 38px;
  display: flex;
  align-items: flex-end;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.range-label label {
  margin: 0;
}

output {
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--ink);
  font-weight: 400;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

button {
  border: 1px solid #1f5f9f;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

button:hover,
button:focus-visible {
  background: #1f5f9f;
}

#new-sample {
  width: 100%;
  min-height: 40px;
  margin: 6px 0 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 10px;
}

.tab {
  background: #f1f5fa;
  border-color: #cbd3df;
  color: var(--ink);
  min-height: 36px;
  padding: 0 14px;
}

.tab:hover,
.tab:focus-visible {
  background: #e5edf7;
}

.tab.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  padding: 10px 12px;
}

.metric-value {
  margin-top: 2px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.plot-stack {
  display: grid;
  gap: 14px;
}

.plot-frame {
  margin: 0;
}

figcaption {
  margin-bottom: 6px;
  font-weight: 650;
}

svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

#hist-plot {
  min-height: 230px;
}

#pvalue-plot {
  min-height: 300px;
}

.repeat-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.help-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  padding: 14px 16px;
}

.help-item h2 {
  margin: 0 0 8px;
  color: #4f5965;
  font-size: 18px;
  letter-spacing: 0;
}

.help-item p {
  margin: 8px 0 0;
  color: var(--ink);
}

.axis {
  stroke: #5e6875;
  stroke-width: 1;
}

.grid-line {
  stroke: #e5e9ef;
  stroke-width: 1;
}

.axis text,
.plot-label,
.legend text {
  fill: var(--muted);
  font-size: 13px;
}

.point {
  fill: var(--blue);
  opacity: 0.88;
}

.band {
  fill: #9ecae1;
  opacity: 0.35;
}

.qq-line,
.normal-curve,
.alpha-line {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2.5;
}

.hist-bar,
.p-bar {
  fill: var(--blue-soft);
  stroke: #7aa7d9;
}

.rug-line {
  stroke: var(--green);
  stroke-width: 1;
}

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

  .controls {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .metric-row,
  .repeat-controls,
  .input-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-direction: column;
  }

  .tab {
    width: 100%;
  }
}
