/* Layout: one narrow column; a playful, sticker-like control set around one very loud result. Accent changes per section. */
:root {
  --bg: #fbfaf7;
  --dot: #e3e0d8;
  --surface: #ffffff;
  --ink: #16150f;
  --muted: #6d6a60;
  --line: #d8d5cc;
  --fig-light: #d7d4ca;
  --fig-dark: #16150f;
  --accent: #e8552f;
  --accent-soft: #fbd9cf;
  --accent-ink: #ffffff;
  --shadow: #16150f;
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-group="mind"]   { --accent: #6b5ce7; --accent-soft: #dcd7fb; }
:root[data-group="life"]   { --accent: #1f9a56; --accent-soft: #cdeedb; }
:root[data-group="habits"] { --accent: #d98c0b; --accent-soft: #fbe6bf; }
:root[data-group="money"]  { --accent: #1a9b8c; --accent-soft: #c8ebe6; }
:root[data-group="traits"] { --accent: #e0407f; --accent-soft: #f9d2e2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141310; --dot: #26241f; --surface: #1d1c18; --ink: #f2f0ea; --muted: #a09d93; --line: #3a3832;
    --fig-light: #3c3a33; --fig-dark: #ece9e1; --accent: #ff7148; --accent-soft: #4a2a20; --accent-ink: #141310; --shadow: #000000;
    color-scheme: dark;
  }
  :root:not([data-theme="light"])[data-group="mind"]   { --accent: #9b8dff; --accent-soft: #2f2a55; }
  :root:not([data-theme="light"])[data-group="life"]   { --accent: #3fcf7c; --accent-soft: #1d3f2c; }
  :root:not([data-theme="light"])[data-group="habits"] { --accent: #f2b43a; --accent-soft: #4a3a16; }
  :root:not([data-theme="light"])[data-group="money"]  { --accent: #35cdbb; --accent-soft: #163f3a; }
  :root:not([data-theme="light"])[data-group="traits"] { --accent: #ff6ba3; --accent-soft: #4b2033; }
}
:root[data-theme="dark"] {
  --bg: #141310; --dot: #26241f; --surface: #1d1c18; --ink: #f2f0ea; --muted: #a09d93; --line: #3a3832;
  --fig-light: #3c3a33; --fig-dark: #ece9e1; --accent: #ff7148; --accent-soft: #4a2a20; --accent-ink: #141310; --shadow: #000000;
  color-scheme: dark;
}
:root[data-theme="dark"][data-group="mind"]   { --accent: #9b8dff; --accent-soft: #2f2a55; }
:root[data-theme="dark"][data-group="life"]   { --accent: #3fcf7c; --accent-soft: #1d3f2c; }
:root[data-theme="dark"][data-group="habits"] { --accent: #f2b43a; --accent-soft: #4a3a16; }
:root[data-theme="dark"][data-group="money"]  { --accent: #35cdbb; --accent-soft: #163f3a; }
:root[data-theme="dark"][data-group="traits"] { --accent: #ff6ba3; --accent-soft: #4b2033; }
:root[data-theme="dark"][data-group="records"], :root:not([data-theme="light"])[data-group="records"] { --accent: #ff6a4a; --accent-soft: #4a2a20; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 40px;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.top, main, .foot { max-width: 700px; margin-inline: auto; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px 6px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: inherit; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.brand .mark { width: 12px; height: 28px; fill: var(--accent); align-self: center; }
.brand small { font-family: var(--body); font-weight: 500; font-size: 13px; color: var(--muted); letter-spacing: 0; }
.top-actions { display: flex; gap: 6px; }

/* buttons: flat with a hard little shadow, like a sticker you can press */
.btn {
  border: 2px solid var(--ink); background: var(--surface); color: var(--ink); border-radius: 12px;
  padding: 8px 14px; min-height: 38px; line-height: 1; font-weight: 600;
  box-shadow: 2px 2px 0 var(--shadow); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.solid { background: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 11px; min-height: 32px; font-size: 14px; border-radius: 10px; }

/* section tabs */
.groups-nav { margin-top: 16px; }
.group-tabs { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-right: 24px; }
.group-tabs::-webkit-scrollbar { display: none; }
.gtab { flex: 0 0 auto; white-space: nowrap; }
.gtab {
  border: 2px solid transparent; background: transparent; border-radius: 999px; padding: 7px 11px; min-height: 38px;
  font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--muted); letter-spacing: -0.01em;
}
.gtab:hover { color: var(--ink); }
.gtab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.gtab-link { text-decoration: none; display: inline-flex; align-items: center; color: var(--accent); }
.gtab-link:hover { color: var(--ink); }

/* category strip */
.cats { margin-top: 10px; margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px))) calc(-1 * max(16px, env(safe-area-inset-right, 0px))); }
.tablist {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); padding-block: 6px 12px; -webkit-overflow-scrolling: touch;
}
.tablist::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap;
  border: 2px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 14px; min-height: 44px; font-weight: 600; font-size: 16px; color: var(--ink);
  transition: border-color .12s, background-color .12s, transform .08s, box-shadow .08s;
}
.tab:hover { border-color: var(--ink); }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--ink); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--shadow); transform: translate(-1px, -1px); }

/* comparison group */
.groups { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 2px; min-height: 36px; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; min-height: 30px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chips { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: 0 0 auto; border: 2px solid transparent; background: transparent; border-radius: 999px; padding: 6px 9px; min-height: 32px; font-size: 14px; font-weight: 500; color: var(--muted); }
.chips button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }

/* the measurement */
.measure { margin-top: 26px; }
.value-row { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; }
.big-value { font-family: var(--display); font-weight: 700; font-size: clamp(42px, 11vw, 68px); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: block; min-width: 0; }
.big-value small { font-size: 0.4em; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 0.2em; font-family: var(--body); }
.value-tools { display: flex; align-items: center; gap: 8px; padding-bottom: 4px; }

.edit { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.edit-fields { display: flex; gap: 8px; }
.edit label { display: inline-flex; align-items: baseline; gap: 6px; font-size: 14px; color: var(--muted); }
.edit input { width: 9ch; font: inherit; font-size: 18px; padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums; }

/* slider */
.slider-wrap { position: relative; margin-top: 20px; padding-bottom: 20px; --fill: 50%; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 48px; margin: 0; background: transparent; display: block; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; border: 2px solid var(--ink); background: linear-gradient(to right, var(--accent) 0 var(--fill), var(--surface) var(--fill) 100%); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 5px; border: 2px solid var(--ink); background: var(--surface); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 5px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 32px; height: 32px; border-radius: 50%; margin-top: -13px; background: var(--surface); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--shadow); transition: transform .12s; }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--shadow); }
input[type="range"]:active::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { transform: scale(1.1); }
.ticks { position: absolute; left: 16px; right: 16px; top: 32px; height: 18px; pointer-events: none; }
.tick { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tick::before { content: ""; width: 2px; height: 6px; background: var(--muted); opacity: .6; border-radius: 1px; }
.tick span { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; white-space: nowrap; }
.scale-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* result */
.result { margin-top: 18px; }
.pct { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.04em; line-height: 0.95; font-size: clamp(84px, 24vw, 160px); font-variant-numeric: tabular-nums; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 0.12em; color: var(--ink); }
.pct .pre { font-size: 0.26em; font-weight: 600; color: var(--muted); letter-spacing: 0; align-self: center; font-family: var(--body); }
.pct .pre:empty { display: none; }
.pct .num { color: var(--accent); transition: color .25s; display: inline-block; }
.pct .num.pop { animation: pop .28s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { 0% { transform: scale(.96); } 60% { transform: scale(1.035); } 100% { transform: scale(1); } }
.pct .suf { font-size: 0.32em; font-weight: 600; letter-spacing: -0.01em; color: var(--accent); }
.pct .word { font-size: 0.2em; font-weight: 500; color: var(--muted); letter-spacing: 0.01em; font-family: var(--body); margin-left: 0.3em; }
.trait-pct { font-size: clamp(64px, 18vw, 128px); }
.trait-pct .word { font-size: 0.24em; }
.meaning { margin: 12px 0 0; font-size: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.meaning .ref { color: var(--muted); }
.meaning .ref::before { content: "·"; margin-right: 10px; }
.kind { border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-height: 24px; }
.kind.modeled, .kind.estimate { border-color: var(--accent); color: var(--accent); }
.kind.record { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.pct.words { font-size: clamp(40px, 10vw, 72px); letter-spacing: -0.02em; line-height: 1.05; }
.pct.words .pre { font-size: 0.42em; align-self: baseline; }
:root[data-group="records"] { --accent: #c8361f; --accent-soft: #f6d3cb; }

/* crowd */
.crowd { margin: 26px 0 0; }
.crowd svg { display: block; width: 100%; height: auto; max-width: 100%; }
.crowd .fig { fill: var(--fig-light); transition: fill .14s; }
.crowd .fig.below { fill: var(--fig-dark); }
.crowd .fig.same { fill: var(--accent); opacity: .45; }
.crowd .fig.you { fill: var(--accent); }
.crowd-note { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* traits */
.traits { margin-top: 16px; }
.trait-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 196px; overflow-y: auto; padding: 4px; margin: 0 -4px; scrollbar-width: thin; }
.tchip { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 10px; min-height: 40px; font-size: 14px; font-weight: 600; color: var(--ink); transition: border-color .12s, background-color .12s; }
.tchip b { font-family: var(--display); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.tchip:hover { border-color: var(--ink); }
.tchip[aria-selected="true"] { background: var(--accent); border-color: var(--ink); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--shadow); }
.tchip[aria-selected="true"] b { color: var(--accent-ink); }
.traits .result { margin-top: 22px; }

.foot { margin-top: 40px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0; }

/* info dialog */
dialog#info { width: min(100% - 32px, 620px); max-height: min(85vh, 85dvh); border: 2px solid var(--ink); border-radius: 18px; padding: 20px 22px 26px; background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.5; box-shadow: 6px 6px 0 var(--shadow); }
dialog#info::backdrop { background: rgba(0,0,0,.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
dialog h2 { font-family: var(--display); font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
dialog h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 0 6px; }
dialog p { margin: 6px 0; }
dialog dl { margin: 8px 0 0; display: grid; grid-template-columns: minmax(7em, max-content) 1fr; gap: 6px 14px; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; min-width: 0; }
dialog a { color: inherit; text-decoration-color: var(--accent); }

@media (min-width: 560px) { .pct { font-size: clamp(120px, 20vw, 172px); } .trait-pct { font-size: clamp(96px, 15vw, 140px); } }

/* ---------- home: the question, then big boxes ---------- */
.home { margin-top: 18px; }
.home h1 { font-family: var(--display); font-weight: 700; font-size: clamp(40px, 9vw, 72px); letter-spacing: -0.035em; line-height: 0.95; margin: 0; }
.home p { margin: 10px 0 0; color: var(--muted); font-size: 18px; max-width: 44ch; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; text-decoration: none; color: var(--ink); font: inherit;
  border: 2px solid var(--ink); background: var(--surface); border-radius: 18px; padding: 16px 16px 14px; min-height: 150px;
  box-shadow: 3px 3px 0 var(--shadow); cursor: pointer; transition: transform .08s, box-shadow .08s, background-color .12s;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shadow); }
.tile:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.tile-emoji { font-size: 40px; line-height: 1; }
.tile-name { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; margin-top: auto; }
.tile-sub { font-size: 13px; color: var(--muted); line-height: 1.35; }
.link-tile { background: color-mix(in oklch, var(--surface), var(--ink) 4%); }
.group-tile:nth-child(1) { --accent: #e8552f; } .group-tile:nth-child(2) { --accent: #1f9a56; } .group-tile:nth-child(3) { --accent: #1a9b8c; }
.group-tile:nth-child(4) { --accent: #6b5ce7; } .group-tile:nth-child(5) { --accent: #d98c0b; } .group-tile:nth-child(6) { --accent: #c8361f; } .group-tile:nth-child(7) { --accent: #e0407f; }
.group-tile:hover, .group-tile:focus-visible { background: color-mix(in oklch, var(--surface), var(--accent) 14%); border-color: var(--ink); }

/* picker: the section's own boxes, smaller */
.picker { margin-top: 14px; }
.picker h2 { font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -0.02em; margin: 0; }
.cat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.cat-tile { min-height: 112px; padding: 12px 12px 10px; border-radius: 14px; }
.cat-tile .tile-emoji { font-size: 30px; }
.cat-tile .tile-name { font-size: 17px; }
.cat-tile .tile-sub { font-size: 12px; }
.cat-tile:hover, .cat-tile:focus-visible { background: color-mix(in oklch, var(--surface), var(--accent) 14%); }
.gtab-home { color: var(--muted); }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .top, main, .foot { max-width: 1040px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .tile { min-height: 170px; }
  .cat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* the measurement fits one screen: controls and result on the left, the crowd on the right */
  .measure { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 40px; align-items: start; margin-top: 18px; }
  .measure .value-row, .measure .edit, .measure .slider-wrap, .measure .result { grid-column: 1; }
  .measure .crowd { grid-column: 2; grid-row: 1 / span 4; margin: 6px 0 0; align-self: center; }
  .big-value { font-size: clamp(40px, 4.6vw, 56px); }
  .pct { font-size: clamp(80px, 8.5vw, 112px); }
  .result { margin-top: 10px; }
  .meaning { font-size: 16px; }
  .crowd svg { max-height: 420px; width: 100%; }
  .traits .result .pct { font-size: clamp(72px, 8vw, 112px); }
}
