:root {
  --bg: #f5f5f2;
  --card: #ffffff;
  --ink: #16161a;
  --muted: #6a6a73;
  --faint: #9b9ba3;
  --line: #e3e3de;
  --tile: #ffffff;
  --tile-hover: #f0f0ec;
  --accent: #3d5afe;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --track: #ebebe6;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --card: #17171b;
    --ink: #f2f2f4;
    --muted: #a0a0aa;
    --faint: #6c6c76;
    --line: #2a2a31;
    --tile: #1c1c21;
    --tile-hover: #24242a;
    --accent: #8c9eff;
    --accent-ink: #0e0e11;
    --accent-soft: #1f2340;
    --track: #2a2a31;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font:
    16px/1.45 ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Logos (monochrome via mask, so they follow the theme) ---------- */
.logo {
  flex: none;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--src) center / contain no-repeat;
  mask: var(--src) center / contain no-repeat;
}
.logo.mono {
  background: none;
  -webkit-mask: none;
  mask: none;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
  border: 1.5px solid currentColor;
  border-radius: 6px;
}

/* ---------- Survey shell ---------- */
.shell {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress {
  flex: 1;
  height: 4px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main.q {
  flex: 1;
  padding: 12px 0 24px;
}
.section {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
h1 {
  margin: 0 0 6px;
  font-size: clamp(22px, 5.5vw, 28px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15px;
}

.nav {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 13px 20px;
  font-weight: 600;
  min-height: 48px;
}
.btn.primary {
  flex: 1;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}
.btn.ghost {
  background: transparent;
}
.btn.ghost[hidden] {
  display: none;
}

/* ---------- Intro / done ---------- */
.intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}
.intro h1 {
  font-size: clamp(30px, 8vw, 40px);
  margin-bottom: 10px;
}
.intro .lede {
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 28px;
}
.points {
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
  display: grid;
  gap: 12px;
}
.points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.points .logo {
  color: var(--accent);
  margin-top: 1px;
}
.points b {
  display: block;
}
.points span {
  color: var(--muted);
  font-size: 15px;
}
.intro .btn.primary {
  flex: none;
  width: 100%;
  font-size: 17px;
}
.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  padding: 12px;
  margin-top: 8px;
  font-size: 14px;
}
.error {
  color: #d93025;
  font-size: 14px;
  margin: 8px 0 0;
}

/* ---------- Tiles ---------- */
.group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 0 8px;
}
.group-label:first-child {
  margin-top: 0;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 520px) {
  .tiles.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .tiles.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  min-height: 56px;
  padding: 10px 12px;
  background: var(--tile);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.tiles.cols-4 .tile {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 12px 8px;
  min-height: 84px;
}
.tiles.cols-4 .tile .logo {
  width: 26px;
  height: 26px;
}
.tile:hover {
  background: var(--tile-hover);
}
.tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tile[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.tile .txt {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.tile .sub {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.tile .logo {
  color: var(--ink);
}
.tile.dim {
  opacity: 0.55;
}

.other-input {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
}
.other-input:focus {
  border-color: var(--accent);
  outline: none;
}

/* ---------- Split panel ---------- */
.split {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.split-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.split-head b {
  font-size: 14px;
}
.split-head .total {
  font-size: 13px;
  color: var(--muted);
}
.split-head button {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 0;
}
.split-empty {
  color: var(--faint);
  font-size: 14px;
  margin: 6px 0 2px;
}
.srow {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 48px;
  align-items: center;
  column-gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.srow:first-of-type {
  border-top: 0;
}
.srow .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.srow .val {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.srow input[type="range"] {
  grid-column: 1 / -1;
  margin-top: 6px;
}
.srow .other-input {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 9px 12px;
  font-size: 14px;
}

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

/* ---------- Chips (single / pair) ---------- */
.chips {
  display: grid;
  gap: 8px;
}
.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 12px 16px;
  background: var(--tile);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
  text-align: left;
}
.chip:hover {
  background: var(--tile-hover);
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.chip[aria-pressed="true"]::after {
  content: "✓";
  color: var(--accent);
}
.pair-row + .pair-row {
  margin-top: 22px;
}
.pair-row .group-label {
  margin-top: 0;
}
.chips.inline {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.chips.inline .chip {
  justify-content: center;
  padding: 12px 4px;
}
.chips.inline .chip[aria-pressed="true"]::after {
  content: none;
}

/* ---------- Slider question ---------- */
.big-slider {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 16px;
}
.big-slider .readout {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin-bottom: 12px;
}
.big-slider .readout b {
  font-size: 26px;
  display: block;
  font-variant-numeric: tabular-nums;
}
.big-slider .readout div:last-child {
  text-align: right;
}
.big-slider .ends {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.big-slider.untouched .readout {
  opacity: 0.4;
}
.nudge {
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  margin-top: 10px;
}

textarea {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--card);
  resize: vertical;
}
textarea:focus {
  border-color: var(--accent);
  outline: none;
}

/* Sliders sit directly under their group's tiles */
.tiles + .split { margin-top: 10px; }
.split + .group-label { margin-top: 26px; }
.split-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding: 10px 2px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.split-foot button { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 13px; padding: 6px 0; }
