:root {
  --bg: #fafaf8;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #3a5a8c;
  --track: #e3e1db;
  --card-bg: #ffffff;
  --border: #ddd9d0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --fg: #eceae4;
    --muted: #9a9890;
    --accent: #7fa4e0;
    --track: #2c2c31;
    --card-bg: #1e1e23;
    --border: #34343a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: none;
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: white;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.progress-track {
  height: 4px;
  background: var(--track);
  border-radius: 2px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.question-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.stem {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

.slider-row {
  margin-bottom: 2rem;
}

.pole-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.pole-labels span {
  flex: 1;
}

.pole-labels span:last-child {
  text-align: right;
}

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

input[type="range"].untouched {
  opacity: 0.4;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.confidence-panel {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.confidence-row,
.function-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.function-item {
  margin-bottom: 0.5rem;
}

.function-item .function-row {
  margin-bottom: 0;
  cursor: pointer;
  border-radius: 6px;
}

.function-item .function-row:hover {
  background: var(--track);
}

.function-item .function-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.function-description {
  margin: 0.35rem 0 0 calc(2.5rem + 0.75rem);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.function-label {
  width: 2.5rem;
  font-weight: 600;
}

.confidence-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.confidence-track,
.function-track {
  flex: 1;
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
}

.function-track {
  position: relative;
  overflow: visible;
}

/* Center tick marks the neutral (score = 0) point, since fill now grows
   outward from center rather than from the left edge — a bar's direction,
   not just its length, is what shows whether a function scored above or
   below the type's baseline. */
.function-track::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 1px;
  background: var(--muted);
  opacity: 0.5;
}

.confidence-fill {
  height: 100%;
}

.function-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.function-score {
  width: 3rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.intake-field {
  margin-bottom: 1.5rem;
}

.intake-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.intake-field input,
.intake-field select {
  font: inherit;
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
}

.result-type {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

#result-narrative p {
  margin-bottom: 1rem;
}

.function-chart {
  margin: 2rem 0;
}
