/* Base: reset, type, shell, and the components every page shares. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--super); color: #16130e; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--paper); padding: 8px 12px; }
.skip:focus { top: 8px; }

/* ---------- type ---------- */
.display { font-family: var(--font-display); font-weight: 800; line-height: 1.02; letter-spacing: -.03em; margin: 0; }
h1, h2, h3 { margin: 0; }
h1 { font-family: var(--font-display); font-weight: 800; line-height: 1.04; font-size: clamp(34px, 5.6vw, 62px); letter-spacing: -.03em;
}
h2 { font-family: var(--font-display); font-weight: 800; line-height: 1.12; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em;
}
h3 { font-family: var(--font-mono); font-weight: 700; letter-spacing: .1em; font-size: 11.5px; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.lead { font-size: clamp(17px, 2.2vw, 20px); line-height: 1.45; max-width: 52ch; }

/* ---------- shell ---------- */
.top {
  height: var(--top-h); display: flex; align-items: center; gap: 24px; padding: 0 var(--gutter);
  border-bottom: var(--rule); background: var(--paper); position: relative; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand__mark { width: 28px; height: 28px; flex: none; }
.brand__mark svg { width: 100%; height: 100%; }
.brand__word { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: .01em; line-height: 1; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
   font-size: 14px; letter-spacing: 0; text-decoration: none;
  padding: 18px 12px 16px; border-bottom: 4px solid transparent; margin-bottom: -2px; font-weight: 600;
}
.nav a:hover { background: var(--paper-2); }
.nav a[aria-current="page"] { border-bottom-color: var(--ink); font-weight: 500; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top__user { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0; text-decoration: none; padding: 6px 10px; border: var(--rule); font-weight: 700;
}
.top__user:hover { background: var(--ink); color: var(--paper); }
.top__user[aria-current="page"] { background: var(--ink); color: var(--paper); }

.tabbar { display: none; }
@media (max-width: 759px) {
  .nav, .top__user { display: none; }
  .top { padding: 0 var(--gutter); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    height: var(--tab-h); padding-bottom: var(--safe-b); background: var(--paper); border-top: var(--rule);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none;
    font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); position: relative;
  }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--ink); }
  .tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: -2px; left: 22%; right: 22%; height: 4px; background: var(--ink); }
}

main { padding: 0 var(--gutter); }
.page { max-width: 1040px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) 0 calc(var(--tab-h) + 48px); }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-bottom: var(--rule); padding-bottom: 14px; margin-bottom: 24px; }
.page__head p { margin: 8px 0 0; color: var(--ink-2); max-width: 56ch; }
.stat { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.stat b { font-family: var(--font-display); font-size: 40px; font-weight: 800; color: var(--ink); letter-spacing: 0; margin-right: 6px; vertical-align: -3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 10px 18px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700; letter-spacing: 0; text-decoration: none;
  background: var(--paper); color: var(--ink); border: var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background .15s;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: color-mix(in oklab, var(--accent) 88%, var(--ink)); }
.btn--danger { background: var(--dislike); color: var(--on-dislike); }
.btn--ghost { box-shadow: none; border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 4px; padding-inline: 6px; }
.btn--ghost:hover { background: var(--paper-2); }
.btn--small { min-height: 34px; padding: 6px 12px; font-size: 11px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label, .label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.input, .select {
  width: 100%; min-height: 46px; padding: 10px 12px; background: var(--paper); color: var(--ink);
  border: var(--rule); border-radius: var(--radius);
}
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field__error { color: var(--dislike); font-size: 14px; font-weight: 500; }
.field__hint { color: var(--ink-2); font-size: 13px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: var(--hair); }
.switch input { appearance: none; width: 52px; height: 28px; flex: none; border: var(--rule); background: var(--paper); position: relative; cursor: pointer; border-radius: 999px; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(24px); background: var(--on-accent); }
.range { width: 100%; accent-color: var(--accent); height: 32px; }

/* ---------- tags: soft filled chips ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag {
  font-family: var(--font-text); font-size: 12px; font-weight: 600; letter-spacing: 0; padding: 4px 10px; border: 0; border-radius: 8px;
  background: var(--paper-2); color: var(--ink-2); line-height: 1.3; white-space: nowrap;
}
.tag--primary { background: var(--ink); color: var(--paper); }
.tag--ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-3); color: var(--ink-2); }

/* ---------- controls as plain words: the current choice underlined (green for yes, red for no) ---------- */
.seg.seg--words { display: flex; flex-wrap: wrap; gap: 2px 14px; border: 0; background: none; margin: 0; }
.seg.seg--words button { background: none; border: 0; padding: 4px 0; min-height: 30px; font: inherit; font-size: 13px; color: var(--ink-2); border-radius: 0; box-shadow: none; font-weight: 500; letter-spacing: 0; }
.seg.seg--words button:hover { color: var(--ink); }
.seg.seg--words button[aria-checked="true"] { background: none; color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.seg.seg--words button[aria-checked="true"][data-mode="enjoy"], .seg.seg--words button[aria-checked="true"][data-mode="main"],
.seg.seg--words button[aria-checked="true"][data-mode="like"], .seg.seg--words button[aria-checked="true"][data-mode="love"] { text-decoration-color: var(--accent); }
.seg.seg--words button[aria-checked="true"][data-mode="avoid_dominant"], .seg.seg--words button[aria-checked="true"][data-mode="dislike"],
.seg.seg--words button[aria-checked="true"][data-mode="exclude"], .seg.seg--words button[aria-checked="true"][data-mode="block"] { text-decoration-color: var(--dislike); }

/* ---------- dots: Mélo's one way of showing "how much" (genre shares, progress). No bars anywhere. ---------- */
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dots i { width: 7px; height: 7px; border-radius: 50%; flex: none; background: color-mix(in oklab, var(--ink) 16%, transparent); }
.dots i.on { background: var(--ink); }

/* ---------- flash + toast ---------- */
.flash { margin: 16px 0; padding: 12px 14px; border: var(--rule); background: var(--paper-2); font-weight: 500; }
.flash--error { border-color: var(--dislike); }
.notice { margin: 12px 0 16px; padding: 12px 14px; border: var(--rule); border-radius: 8px; background: var(--paper-2); }
.notice p { margin: 4px 0; }
.temp-pw { font-family: var(--font-mono); font-size: 20px; letter-spacing: .04em; user-select: all; }
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + 12px); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper); padding: 12px 14px; font-size: 14px; font-weight: 500;
  border: var(--rule); box-shadow: var(--shadow-sm); animation: toast-in .25s var(--ease); display: flex; gap: 12px; align-items: center; justify-content: space-between; pointer-events: auto;
}
.toast--error { background: var(--dislike); color: var(--on-dislike); }
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; font-weight: 700; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dialogs (full-song player, notes) ---------- */
dialog {
  border: var(--rule); background: var(--paper); color: var(--ink); padding: 0; max-width: min(560px, 94vw); width: 100%;
  box-shadow: 8px 8px 0 var(--ink); border-radius: 0;
}
dialog::backdrop { background: color-mix(in oklab, var(--ink) 55%, transparent); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: var(--rule); }
.dialog__body { padding: 16px; max-height: 70dvh; overflow: auto; }
@media (max-width: 759px) {
  dialog { margin: auto 0 0; max-width: 100vw; width: 100vw; box-shadow: none; border-width: 2px 0 0; }
}

/* ---------- loader: a record that spins ---------- */
.record { width: 72px; height: 72px; border-radius: 50%; border: var(--rule); position: relative; animation: spin 2.4s linear infinite;
  background: repeating-radial-gradient(circle at center, transparent 0 5px, color-mix(in oklab, var(--ink) 18%, transparent) 5px 6px); }
.record::after { content: ""; position: absolute; inset: 40% ; background: var(--accent); border-radius: 50%; border: 2px solid var(--ink); }
.record::before { content: ""; position: absolute; left: 50%; top: 2px; width: 2px; height: 12px; background: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 56px 16px; display: grid; gap: 14px; justify-items: center; }
.empty h2 { max-width: 16ch; }
.empty p { max-width: 42ch; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .record { animation: none; }
}

/* ---------- quick light/dark switch ---------- */
.theme-toggle { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; color: var(--ink); border: 1.5px solid var(--ink); border-radius: 50%; padding: 0; }
.theme-toggle:hover { background: var(--ink); color: var(--paper); }
.theme-toggle[aria-pressed="true"] svg { transform: rotate(180deg); }
.theme-toggle svg { transition: transform .3s var(--ease); }

/* ---------- quips: short reactions on the side of the screen ---------- */
.quips { position: fixed; inset: 0; pointer-events: none; z-index: 85; overflow: hidden; }
.quip {
  position: absolute; top: 46%; max-width: min(260px, 40vw); margin: 0; padding: 11px 15px; font-size: 15px; font-weight: 600; line-height: 1.25;
  background: var(--ink); color: var(--paper); border-radius: var(--radius); animation: quip-in .32s var(--ease) both; box-shadow: var(--shadow-sm);
}
.quip--right { right: clamp(10px, 3vw, 40px); }
.quip--left { left: clamp(10px, 3vw, 40px); }
.quip--like { background: var(--accent); color: var(--on-accent); }
.quip--super { background: var(--super); color: var(--on-super); }
.quip--dislike { background: var(--dislike); color: var(--on-dislike); }
.quip.is-leaving { animation: quip-out .32s ease-in both; }
.quip--bottom { top: auto; bottom: clamp(18px, 9vh, 90px); left: 50%; translate: -50% 0; text-align: center; }
.quip--top { left: 50%; translate: -50% 0; text-align: center; }
.quip--left { --fx: -24px; } .quip--right { --fx: 24px; } .quip--bottom { --fy: 20px; } .quip--top { --fy: -20px; }
@keyframes quip-in { from { opacity: 0; transform: translate(var(--fx, 0), var(--fy, 0)); } to { opacity: 1; transform: none; } }
@keyframes quip-out { to { opacity: 0; transform: translate(var(--fx, 0), var(--fy, 0)); } }
@media (max-width: 759px) { .quip { top: calc(var(--top-h) + 14px); max-width: 44vw; font-size: 14px; }
  .quip--bottom { top: auto; bottom: calc(var(--tab-h) + 12px); max-width: 70vw; } }
@media (prefers-reduced-motion: reduce) { .quip, .quip.is-leaving { animation: none; } .quip.is-leaving { opacity: 0; } }
/* ---------- the super-like moment ---------- */
.superfill {
  position: fixed; inset: 0; z-index: 95; pointer-events: none; display: grid; place-items: center;
  background: var(--super); color: var(--on-super); clip-path: circle(0 at var(--ox, 50%) var(--oy, 85%));
  animation: superfill .95s cubic-bezier(.2, .7, .2, 1) forwards;
}
.superfill__heart { width: min(38vmin, 300px); height: min(38vmin, 300px); animation: heartpop .95s ease-out forwards; }
.superfill__text { position: absolute; bottom: 16%; margin: 0; padding: 0 var(--gutter); text-align: center; font-weight: 800; font-size: clamp(28px, 6vw, 64px); letter-spacing: -.03em; line-height: 1.05; }
@keyframes superfill {
  0% { clip-path: circle(0 at var(--ox, 50%) var(--oy, 85%)); opacity: 1; }
  30% { clip-path: circle(160vmax at var(--ox, 50%) var(--oy, 85%)); opacity: 1; }
  72% { clip-path: circle(160vmax at var(--ox, 50%) var(--oy, 85%)); opacity: 1; }
  100% { clip-path: circle(160vmax at var(--ox, 50%) var(--oy, 85%)); opacity: 0; }
}
@keyframes heartpop {
  0%, 14% { transform: scale(.4); opacity: 0; }
  36% { transform: scale(1.14); opacity: 1; }
  52% { transform: scale(1); }
  72% { opacity: 1; }
  100% { transform: scale(1.04); opacity: 0; }
}
.superfill--calm { clip-path: none; animation: superfill-calm .6s ease forwards; }
.superfill--calm .superfill__heart { animation: none; }
@keyframes superfill-calm { 0% { opacity: 0; } 30%, 65% { opacity: 1; } 100% { opacity: 0; } }
.top__user { white-space: nowrap; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; }
