/* p(doom) among friends — dark-only by design; steps taken from the dark column
   of the reference palette and validated against the #12120f surface. */
:root {
  color-scheme: dark;

  --surface-0: #0c0c0a;
  --surface-1: #12120f;
  --surface-2: #1a1a17;
  --surface-3: #232320;
  --border:    #2e2e29;
  --border-strong: #454540;

  --text-primary:   #f3f2ed;
  --text-secondary: #b6b5ab;
  --text-muted:     #7e7d74;

  --agi:  #3987e5;  /* categorical slot 1 */
  --rsi:  #d95926;  /* categorical slot 2 */
  --doom: #199e70;  /* categorical slot 3 */
  --pdoom: #e66767; /* lone-series accent for the P(doom) bars */

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 16px 96px;
}

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 28px; }
h2 { font-size: 17px; }
a { color: inherit; }

.muted { color: var(--text-muted); }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

/* ---------------------------------------------------------- header */

.masthead { margin-bottom: 28px; }
.masthead .eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.masthead p.lede { color: var(--text-secondary); margin: 10px 0 0; max-width: 56ch; }

/* ---------------------------------------------------------- controls */

button, .btn {
  font: inherit;
  font-weight: 550;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-primary);
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms ease, border-color 120ms ease;
}
button:hover, .btn:hover { background: var(--border); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--surface-0);
}
button.primary:hover { background: #ffffff; }

input[type="text"], input[type="email"] {
  font: inherit;
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-0);
  color: var(--text-primary);
}
input::placeholder { color: var(--text-muted); }
input:focus-visible, button:focus-visible, a:focus-visible, input[type="range"]:focus-visible {
  outline: 2px solid var(--agi);
  outline-offset: 2px;
}

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 200px; }

.error {
  color: #e66767;
  font-size: 14px;
  margin: 10px 0 0;
  min-height: 1em;
}

/* ---------------------------------------------------------- sliders */

.slider { margin-bottom: 22px; }
.slider:last-of-type { margin-bottom: 8px; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 2px;
}
.slider-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.slider-value { font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; }
.slider-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }

.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right,
    var(--accent, var(--text-primary)) 0 var(--pct, 0%),
    var(--surface-3) var(--pct, 0%) 100%);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right,
    var(--accent, var(--text-primary)) 0 var(--pct, 0%),
    var(--surface-3) var(--pct, 0%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%;
  background: var(--accent, var(--text-primary));
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--accent, var(--text-primary));
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent, var(--text-primary));
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--accent, var(--text-primary));
}

/* ---------------------------------------------------------- charts */

figure { margin: 0; }
figcaption { font-size: 13px; color: var(--text-muted); margin-top: 12px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(64px, 108px) 1fr auto; gap: 12px; align-items: center; }
.bar-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--pdoom); border-radius: 0 4px 4px 0; min-width: 2px; transition: width 240ms ease; }
.bar-value { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

.strip-row { display: grid; grid-template-columns: minmax(64px, 108px) 1fr; gap: 12px; align-items: center; margin-bottom: 4px; }
.strip {
  position: relative;
  height: 34px;
  border-bottom: 1px solid var(--border);
}
.strip-dot.never { background: transparent !important; border: 2px solid; }
.strip-dot {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  /* 2px surface ring so overlapping milestones stay readable */
  box-shadow: 0 0 0 2px var(--surface-1);
}
.axis { position: relative; height: 20px; }
.axis-tick { position: absolute; transform: translateX(-50%); font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.axis-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }

.tip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 90ms ease;
  max-width: 240px;
}
.tip[data-show="1"] { opacity: 1; }

/* ---------------------------------------------------------- feed */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 12px 0; border-top: 1px solid var(--border); font-size: 14px; }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed .who { font-weight: 600; }
.feed .when { color: var(--text-muted); font-size: 13px; }
.feed .note { color: var(--text-secondary); font-style: italic; margin-top: 4px; }

/* ---------------------------------------------------------- dialog */

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(4,4,3,0.72); backdrop-filter: blur(3px); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 50;
}
.toast[data-show="1"] { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
  h1 { font-size: 23px; }
  .bar-row, .strip-row { grid-template-columns: minmax(56px, 84px) 1fr auto; }
  .card { padding: 16px; }
}

/* ---------------------------------------------------------- slider copy */

.slider-ends {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-muted);
}
.slider-ends > span:first-child,
.slider-ends > span:last-child { flex: 0 0 auto; white-space: nowrap; }

.slider-band {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  /* Text ink, not the slider's accent: at this size the categorical steps only
     clear the 3:1 mark threshold, not the 4.5:1 one that body text needs. The
     swatch in the header carries the colour. */
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

/* ---------------------------------------------------------- stat tiles */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stat {
  background: var(--surface-1);
  padding: 15px 14px;
  min-width: 0;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.stat-value {
  font-family: var(--mono);
  font-size: 23px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 5px 0 0;
  line-height: 1.4;
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 20px; }
}

/* ---------------------------------------------------------- page footer */

.page-footer {
  text-align: center;
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.page-footer p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}
