/* ---- tokens -------------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);
  --baseline: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e4eefb;
  --good: #006300;
  --danger: #d03b3b;
  --other: #b9b8b1;
  --mean-fill: #9ec5f4;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262625;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.1);
    --baseline: #383835;
    --accent: #3987e5;
    --accent-soft: #17325a;
    --good: #0ca30c;
    --danger: #e66767;
    --other: #55554f;
    --mean-fill: #1c5cab;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --shadow: none;
  }
}

/* ---- base ---------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; padding: 56px 16px; }
code.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.lede { color: var(--ink-2); max-width: 66ch; }
.empty {
  color: var(--ink-2);
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed var(--baseline);
  border-radius: var(--radius);
}
.notice {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- buttons & inputs ---------------------------------------------------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s, filter 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 1.1rem;
  line-height: 1;
}
.btn.icon:hover { background: var(--surface-2); color: var(--ink); }
.btn.icon.tiny { width: 24px; height: 24px; font-size: 0.9rem; }

input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--baseline);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  min-width: 0;
}
input[type="text"]:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
input.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.2em; text-transform: uppercase; font-weight: 700; }
.inline-input { max-width: 320px; padding: 6px 10px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .slider-field > span { font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }

/* slider */
.slider { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 6px;
  margin: 0;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--pct, 50%), var(--hairline) var(--pct, 50%));
  cursor: pointer;
  outline-offset: 6px;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  cursor: grab;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: grab;
}
.slider .score-out { min-width: 2ch; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.slider.compact { min-width: 130px; gap: 8px; }
.slider.compact input[type="range"] { height: 4px; }
.slider.compact input[type="range"]::-webkit-slider-thumb { width: 16px; height: 16px; }
.slider.unrated input[type="range"] { background: var(--hairline); }
.slider.unrated input[type="range"]::-webkit-slider-thumb { border-color: var(--baseline); background: var(--surface-2); box-shadow: none; }
.slider.unrated input[type="range"]::-moz-range-thumb { border-color: var(--baseline); background: var(--surface-2); }
.slider.unrated .score-out { color: var(--muted); font-weight: 500; }

/* ---- home ---------------------------------------------------------------------------------- */
.home { padding-top: 48px; padding-bottom: 72px; display: grid; gap: 32px; }
.hero h1 { font-size: 2.6rem; letter-spacing: -0.02em; }
.hero .lede { margin-top: 10px; font-size: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.form h2 { margin-bottom: 14px; font-size: 1.2rem; }
.options-list { display: grid; gap: 8px; }
.option-row { display: flex; gap: 6px; align-items: center; }
.recent h2, .how h2 { font-size: 1.1rem; margin-bottom: 10px; }
.recent-list { display: grid; gap: 8px; }
.recent-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; color: inherit; }
.recent-list a:hover { border-color: var(--accent); }
.how-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.how-step { padding: 14px; display: grid; gap: 6px; align-content: start; }

/* ---- shell --------------------------------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding-top: 12px; padding-bottom: 12px; }
.back-link { text-decoration: none; font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.title-block { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; flex: 1; min-width: 240px; }
.title { font-size: 1.25rem; cursor: text; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.title:hover { background: var(--surface-2); }
.share { display: flex; align-items: center; gap: 8px; }
.people { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.person { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.person.me .person-name { font-weight: 700; }
.person-stage { display: none; }
@media (min-width: 900px) { .person-stage { display: inline; } }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc, var(--accent)); display: inline-block; flex: none; }

.steps { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.steps-list { list-style: none; margin: 0; display: flex; gap: 4px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; scrollbar-width: none; }
.steps-list::-webkit-scrollbar { display: none; }
.step-btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.step-btn:hover { background: var(--surface-2); }
.step-btn.current { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink-2);
  flex: none;
}
.step-btn.current .step-num { background: var(--accent); color: var(--accent-ink); }
.step-btn.done .step-num { background: var(--good); color: #fff; }
.badge { background: var(--series-2); color: #fff; font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.step { padding-top: 28px; padding-bottom: 72px; }
.step-body { display: grid; gap: 18px; }
.step-header { display: grid; gap: 8px; }
.step-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.footer-next { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- rows (reasons) ------------------------------------------------------------------------ */
.add-form { display: grid; gap: 12px; }
.add-main { display: flex; gap: 8px; }
.slider-field { display: flex; align-items: center; gap: 12px; }
.slider-field .slider { flex: 1; max-width: 440px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) minmax(200px, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
@media (max-width: 720px) {
  .row { grid-template-columns: 1fr auto; }
  .row .slider { grid-column: 1 / -1; }
}
.row-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.row-name { font-weight: 600; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }
.row-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.row-actions.confirm { gap: 8px; flex-wrap: wrap; }
.ignored summary { cursor: pointer; }

/* ---- links / the bucket of soap bubbles ---------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.toolbar.linking { display: grid; gap: 12px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 4px 8px 4px 12px; font-size: 0.9rem; font-weight: 600; }
.chip.confirm { padding-right: 12px; gap: 8px; font-weight: 500; }
.overlap-label { display: grid; gap: 6px; }
.overlap-label .slider { max-width: 520px; }
.overlap-label .score-out { min-width: 4.5ch; }
.canvas-wrap { border-radius: var(--radius); }

/* The bucket is always deep and dark so the bubbles read as glass in both colour schemes. */
.bucket {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 900 / 560;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(90% 70% at 50% 115%, rgba(64, 96, 170, 0.38), transparent 62%),
    radial-gradient(60% 55% at 12% -5%, rgba(128, 84, 180, 0.22), transparent 60%),
    linear-gradient(180deg, #0d1324 0%, #070a15 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.bucket-lines, .bucket-pills { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.bucket-lines { z-index: 1; }
.bucket-pills { z-index: 3; }
.bucket-pills .link { pointer-events: auto; cursor: pointer; outline: none; }

.bubble {
  position: absolute;
  z-index: 2;
  left: calc(var(--r) * -1);
  top: calc(var(--r) * -1);
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  will-change: transform;
  transition: width 0.35s ease, height 0.35s ease, left 0.35s ease, top 0.35s ease;
}
.bubble-inner { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 1px; border-radius: 50%; }
.bubble.new .bubble-inner { animation: bubble-inflate 0.75s cubic-bezier(0.2, 0.8, 0.3, 1.15) both; }
.bubble.dragging { cursor: grabbing; z-index: 4; }
.bubble.dragging .bubble-skin { transform: scale(1.04); animation: none; }

/* Soap film: transparent body, two specular highlights, a thin bright edge and a soft inner glow. */
.bubble-skin {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 27%, rgba(255, 255, 255, 0.9) 0, rgba(255, 255, 255, 0.5) 4%, rgba(255, 255, 255, 0) 19%),
    radial-gradient(circle at 71% 77%, rgba(255, 255, 255, 0.42) 0, rgba(255, 255, 255, 0) 13%),
    radial-gradient(circle closest-side, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.04) 72%, rgba(255, 255, 255, 0.18) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.34),
    inset 0 0 calc(var(--r) * 0.45) rgba(255, 255, 255, 0.14),
    0 0 calc(var(--r) * 0.55) color-mix(in oklab, var(--pc) 28%, transparent),
    0 10px 30px rgba(0, 0, 0, 0.4);
  animation: bubble-wobble 6s ease-in-out infinite;
  animation-delay: var(--wobble-delay, 0s);
  transition: box-shadow 0.2s;
}
/* Iridescent rim: a conic rainbow masked to a ring, turning slowly. */
.bubble-skin::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #f3a6cc, #f8d08f, #eeeaa6, #a9e9c6, #9ccdf5, #c2b5f3, #f3a6cc);
  -webkit-mask: radial-gradient(circle closest-side, transparent 72%, #000 87%, #000 96%, transparent 100%);
  mask: radial-gradient(circle closest-side, transparent 72%, #000 87%, #000 96%, transparent 100%);
  opacity: 0.55;
  mix-blend-mode: screen;
  filter: saturate(0.95) blur(0.5px);
  animation: bubble-spin 16s linear infinite;
  animation-delay: var(--spin-delay, 0s);
}
/* Soft colour bloom just inside the rim. */
.bubble-skin::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 180deg, rgba(255, 111, 177, 0.4), rgba(79, 200, 255, 0.34), rgba(246, 243, 107, 0.26), rgba(154, 124, 255, 0.4), rgba(255, 111, 177, 0.4));
  -webkit-mask: radial-gradient(circle closest-side, transparent 34%, #000 82%, transparent 100%);
  mask: radial-gradient(circle closest-side, transparent 34%, #000 82%, transparent 100%);
  opacity: 0.28;
  mix-blend-mode: screen;
  filter: blur(calc(var(--r) * 0.14));
  animation: bubble-spin 16s linear infinite reverse;
  animation-delay: var(--spin-delay, 0s);
}
.bubble:hover .bubble-skin { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), inset 0 0 calc(var(--r) * 0.45) rgba(255, 255, 255, 0.2), 0 0 calc(var(--r) * 0.6) color-mix(in oklab, var(--pc) 40%, transparent), 0 10px 30px rgba(0, 0, 0, 0.4); }
.bubble.selected .bubble-skin {
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.75),
    inset 0 0 calc(var(--r) * 0.5) rgba(255, 255, 255, 0.26),
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 calc(var(--r) * 0.8) rgba(255, 255, 255, 0.45);
}
.bubble.selected .bubble-skin::before { opacity: 0.85; }
.bubble:focus-visible .bubble-skin { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 0 3px var(--accent), 0 0 calc(var(--r) * 0.6) rgba(57, 135, 229, 0.5); }

.bubble-name {
  position: relative;
  z-index: 1;
  max-width: 76%;
  color: #fff;
  font-weight: 600;
  font-size: clamp(9px, var(--name-size, 1.5cqw), 14px);
  line-height: 1.15;
  hyphens: auto;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  pointer-events: none;
}
.bubble.small .bubble-name {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
  max-width: none;
  white-space: nowrap;
  display: block;
  font-size: clamp(10px, 1.3cqw, 12px);
}
.bubble-weight {
  position: absolute;
  z-index: 1;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pc);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px rgba(5, 8, 18, 0.75);
  pointer-events: none;
}

.bucket .link-line { stroke: rgba(255, 255, 255, 0.38); stroke-linecap: round; }
.bucket .link-line.active { stroke: rgba(255, 255, 255, 0.85); }
.bucket .link-pill { fill: rgba(8, 12, 24, 0.78); stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.2; }
.bucket .link:hover .link-pill, .bucket .link.active .link-pill, .bucket .link:focus-visible .link-pill { stroke: #fff; stroke-width: 2; }
.bucket .link-pill-text { fill: #fff; font-size: 12px; font-weight: 700; pointer-events: none; user-select: none; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.link-list li { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* What matters: form and list beside the bucket */
.matters-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  grid-template-areas: "form bucket" "list bucket";
  grid-template-rows: auto 1fr;
  gap: 16px 20px;
  align-items: start;
}
.matters-form { grid-area: form; }
.matters-list { grid-area: list; display: grid; gap: 10px; }
.matters-bucket { grid-area: bucket; display: grid; gap: 12px; min-width: 0; }
@media (max-width: 900px) {
  .matters-grid { grid-template-columns: 1fr; grid-template-areas: "form" "bucket" "list"; grid-template-rows: auto; }
}
.rows.compact .row { grid-template-columns: 1fr auto; gap: 8px 10px; padding: 10px 12px; }
.rows.compact .row .slider { grid-column: 1 / -1; }

/* Rate options: one bucket per option */
.buckets-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.option-bucket { display: grid; gap: 8px; min-width: 0; }
.option-head { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.option-head .dot { width: 12px; height: 12px; }
.option-name { font-size: 1.1rem; }
.option-actions { display: inline-flex; gap: 2px; }
.option-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add-option { display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px dashed var(--baseline); border-radius: var(--radius); }
.bucket.rating .bubble { cursor: ns-resize; }
.bubble-liquid-clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.bubble-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--level, 0%);
  background: linear-gradient(180deg, color-mix(in oklab, var(--pc) 72%, white) 0%, var(--pc) 55%, color-mix(in oklab, var(--pc) 80%, black) 100%);
  opacity: 0.82;
  transition: height 0.25s ease;
}
.bubble-liquid::before {
  content: ;
  position: absolute;
  left: -50%;
  top: calc(var(--r) * -0.42);
  width: 200%;
  height: calc(var(--r) * 0.84);
  border-radius: 42%;
  background: color-mix(in oklab, var(--pc) 78%, white);
  opacity: 0.9;
  animation: liquid-wave 7s linear infinite;
}
.bubble.rate .bubble-skin { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34), inset 0 0 calc(var(--r) * 0.45) rgba(255, 255, 255, 0.12), 0 0 calc(var(--r) * 0.4) color-mix(in oklab, var(--pc) 30%, transparent), 0 10px 30px rgba(0, 0, 0, 0.4); }
.bubble.rate.unrated .bubble-skin { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24), inset 0 0 calc(var(--r) * 0.45) rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.35); }
.bubble.rate.unrated .bubble-skin::before { opacity: 0.3; }
.bubble.rate .bubble-name { font-size: clamp(9px, var(--name-size, 1.4cqw), 12px); font-weight: 500; opacity: 0.9; }
.bubble-value { position: relative; z-index: 1; color: #fff; font-weight: 700; font-size: clamp(13px, 3cqw, 26px); line-height: 1; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); pointer-events: none; }
.bubble.rate.unrated .bubble-value { opacity: 0.55; font-weight: 500; }
.bubble.rate:focus-visible .bubble-skin { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 0 3px var(--accent); }

@keyframes bubble-wobble {
  0%, 100% { transform: scale(1, 1); }
  25% { transform: scale(1.025, 0.975); }
  50% { transform: scale(0.985, 1.02); }
  75% { transform: scale(1.015, 0.99); }
}
@keyframes bubble-spin { to { transform: rotate(360deg); } }
@keyframes bubble-inflate { from { transform: scale(0.15); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); opacity: 1; } }
@keyframes liquid-wave { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .bubble-skin, .bubble-skin::before, .bubble-skin::after, .bubble-inner, .bubble-liquid::before { animation: none; }
}

/* ---- evaluate ------------------------------------------------------------------------------ */
.options-editor { display: grid; gap: 8px; }
.inline-form { display: inline-flex; gap: 6px; }
.inline-form input { width: 170px; padding: 6px 10px; }
.matrix-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 560px; }
.matrix th, .matrix td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); text-align: left; vertical-align: middle; }
.matrix thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); background: var(--surface-2); }
.matrix tbody tr:last-child td, .matrix tbody tr:last-child th { border-bottom: none; }
.matrix th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 600; min-width: 170px; }
.matrix thead th.sticky { background: var(--surface-2); }
.matrix th.sticky .tag { margin-left: 6px; }
.matrix .cell { min-width: 160px; }
.pill { background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-wrap { display: grid; gap: 6px; }
.progress { height: 6px; border-radius: 3px; background: var(--hairline); overflow: hidden; }
.progress-bar { height: 100%; width: var(--pct); background: var(--accent); border-radius: 3px; transition: width 0.2s; }

/* ---- results ------------------------------------------------------------------------------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; justify-self: start; }
.segmented button {
  font: inherit;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.results { display: grid; gap: 16px; }
.headline-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin: 4px 0; }
.headline h3 { font-size: 1.6rem; }
.hero-score { font-size: 2.2rem; font-weight: 600; line-height: 1; }
.hero-unit { font-size: 1rem; font-weight: 500; }
.chart-title { margin-bottom: 4px; }
.chart-sub { margin-bottom: 12px; }
.chart { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.grid-line { stroke: var(--hairline); stroke-width: 1; }
.axis-line { stroke: var(--baseline); stroke-width: 1; }
.tick { font-size: 11px; fill: var(--muted); }
.row-label { font-size: 13px; font-weight: 600; fill: var(--ink); }
.value-label { font-size: 13px; font-weight: 700; fill: var(--ink); }
.muted-label { font-size: 11px; fill: var(--muted); }
.seg { outline: none; }
.seg:hover, .seg:focus-visible { filter: brightness(1.12); }
.mean-bar { fill: var(--mean-fill); outline: none; }
.mean-bar:hover, .mean-bar:focus-visible { filter: brightness(1.06); }
.dot-mark { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.dot-hit { fill: transparent; outline: none; }
.dot-group:hover .dot-mark, .dot-hit:focus-visible + .dot-mark { stroke: var(--ink); }
.tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre-line;
  max-width: 280px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.tip[hidden] { display: none; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.swatch.round { border-radius: 50%; }
.plain-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.plain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.details summary { cursor: pointer; font-weight: 600; }
.details .matrix-scroll { margin-top: 12px; border: none; }
.details-table { border-collapse: collapse; width: 100%; min-width: 480px; }
.details-table th, .details-table td { padding: 8px 10px; border-bottom: 1px solid var(--hairline); text-align: left; }
.details-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.details-table tfoot td, .details-table tfoot th { font-weight: 700; border-bottom: none; }

/* ---- toast --------------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- small screens ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .toolbar .grow { flex-basis: 100%; order: 3; }
  .canvas-wrap { overflow-x: auto; }
  .bucket { min-width: 640px; }
  .hero h1 { font-size: 2.1rem; }
  .step-footer { flex-wrap: wrap; }
}

/* ---- rating bubbles: need ring, ghost state, active state, slider panel ------------------------ */
.bubble-need {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--need, var(--r)) * 2);
  height: calc(var(--need, var(--r)) * 2);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.5);
  pointer-events: none;
  transition: width 0.35s ease, height 0.35s ease;
}
.bubble.rate.unrated .bubble-skin { opacity: 0.45; }
.bubble.rate.unrated .bubble-liquid { opacity: 0; }
.bubble.rate.unrated .bubble-need { border-color: rgba(255, 255, 255, 0.7); }
.bubble.rate.unrated .bubble-value { opacity: 0.8; font-weight: 600; }
.bubble.rate.active .bubble-skin {
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.75),
    inset 0 0 calc(var(--r) * 0.5) rgba(255, 255, 255, 0.22),
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 calc(var(--r) * 0.8) rgba(255, 255, 255, 0.45);
}
.bubble.rate.adjusting { z-index: 4; }
.bucket.readonly .bubble { cursor: default; }
.rate-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 28, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.rate-panel.at-bottom { bottom: 10px; }
.rate-panel.at-top { top: 10px; }
.rate-panel .muted { color: rgba(255, 255, 255, 0.72); }
.rate-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.rate-panel .slider { max-width: none; }
.rate-panel .slider input[type="range"] { background: linear-gradient(to right, #5aa6ff var(--pct, 50%), rgba(255, 255, 255, 0.22) var(--pct, 50%)); }
.rate-panel .slider input[type="range"]::-webkit-slider-thumb { background: #fff; border-color: #5aa6ff; }
.rate-panel .btn.ghost { color: #9ccdf5; }
.rate-panel .btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.add-option { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }

/* ---- sign-in, account menu ------------------------------------------------------------------- */
.home-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.signin { align-content: start; }
.signin-card { max-width: 440px; display: grid; gap: 14px; }
.signin-card h2 { font-size: 1.2rem; }
.btn.google { display: inline-flex; align-items: center; gap: 10px; justify-content: center; }
.btn.google .g { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #1a73e8; font-weight: 800; font-size: 0.85rem; }
.dev-login { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.account summary::-webkit-details-marker { display: none; }
.account.compact summary { font-size: 0.85rem; padding: 4px 10px; }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; display: grid; gap: 8px; justify-items: start; padding: 12px 14px; }
