/* Brain Massage — "Nocturne". Midnight canvas, slow aurora, one hue per sound family.
   Fonts are self-hosted (offline): Gloock for display, Hanken Grotesk for text. */
@font-face { font-family: "Gloock"; src: url("/fonts/gloock.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 400 700; font-display: swap; }

:root {
  --bg: #0a0b16; --bg-2: #11132a; --glass: rgba(255,255,255,.06); --glass-2: rgba(255,255,255,.1);
  --line: rgba(255,255,255,.1); --text: #f2efe8; --muted: #a3a6b8; --accent: #b9aefc; --accent-ink: #12102a;
  --fav: #ff9aa8; --mixed: #f2c46d; --limited: #b9aefc; --strong: #7fd6a4;
  /* category hues: [glow A, glow B] — same as scripts/make_art.py */
  --c-8d-a: #7b6cf6; --c-8d-b: #4fd1c5;
  --c-asmr-a: #f6a97b; --c-asmr-b: #e07a9b;
  --c-binaural-a: #5b6cf9; --c-binaural-b: #8fb4ff;
  --c-pulse-a: #f4b860; --c-pulse-b: #f07167;
  --c-nature-a: #3ba99c; --c-nature-b: #8dbf7a;
  --c-soundbath-a: #e9c46a; --c-soundbath-b: #b79ced;
  --c-expect-a: #ffc270; --c-expect-b: #ee7694;
  --serif: "Gloock", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 var(--sans); padding: env(safe-area-inset-top) 0 calc(110px + env(safe-area-inset-bottom));
  overflow-x: hidden; -webkit-font-smoothing: antialiased; }
main { max-width: 760px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- aurora background: slow, never flashing ---------- */
.aurora { position: fixed; inset: -20%; z-index: 0; pointer-events: none; filter: blur(60px); opacity: .55; }
.aurora i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; mix-blend-mode: screen; }
.aurora i:nth-child(1) { background: radial-gradient(circle, #5b4bd8 0%, transparent 62%); left: 0; top: -10%; animation: drift1 48s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { background: radial-gradient(circle, #1f8f8a 0%, transparent 60%); right: -10%; top: 20%; animation: drift2 61s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { background: radial-gradient(circle, #9a3f72 0%, transparent 60%); left: 10%; bottom: -20%; animation: drift3 73s ease-in-out infinite alternate; opacity: .6; }
@keyframes drift1 { to { transform: translate(18vw, 12vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vw, 18vh) scale(.9); } }
@keyframes drift3 { to { transform: translate(12vw, -14vh) scale(1.1); } }

/* ---------- header + hero ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 0; }
.wordmark { font-family: var(--serif); font-size: 19px; letter-spacing: .01em; opacity: .9; }
.icon-btn { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; width: 38px; height: 38px;
  display: grid; place-items: center; cursor: pointer; font-weight: 600; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.icon-btn.big { width: 46px; height: 46px; background: var(--text); color: var(--bg); border: 0; font-size: 15px; }
.icon-btn.huge { width: 76px; height: 76px; background: var(--text); color: var(--bg); border: 0; font-size: 24px;
  box-shadow: 0 10px 40px rgba(185,174,252,.35); }
.hero { padding: 26px 0 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 11px; color: var(--muted); margin: 0 0 6px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 11vw, 56px); line-height: 1.02; margin: 0 0 18px; letter-spacing: -.01em; }
.medi { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.medi .n { font-family: var(--serif); font-size: 26px; line-height: 1; }
.medi .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin-top: 6px; }
.medi .link { margin-left: auto; font-size: 13px; }
.begin { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 22px; cursor: pointer;
  border: 1px solid var(--line); background: linear-gradient(120deg, rgba(123,108,246,.28), rgba(79,209,197,.14));
  text-align: left; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.begin-art { width: 64px; height: 64px; border-radius: 16px; background-size: cover; background-position: center; flex: none; }
.begin-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.begin-label { font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); }
.begin-title { font-family: var(--serif); font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.begin-play { width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; flex: none; margin-right: 4px; }
.tip { background: var(--glass); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 14px; margin-top: 14px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- sections + cards ---------- */
.sec { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
.sec .swatch { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--a), var(--b)); box-shadow: 0 0 14px var(--a); }
.sec .info-btn { margin-left: auto; }
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 20px; margin: 0 -20px; padding: 2px 20px 8px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail .card { flex: 0 0 156px; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
.card { position: relative; cursor: pointer; text-align: left; min-width: 0; }
.cover { position: relative; aspect-ratio: 1; border-radius: 20px; overflow: hidden; background: var(--bg-2) center/cover no-repeat;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.08); transition: transform .25s ease; }
.card:active .cover { transform: scale(.97); }
.card.playing .cover { box-shadow: 0 0 0 2px var(--text), 0 12px 40px var(--a, rgba(185,174,252,.4)); }
.card.playing .cover::after { content: "Playing"; position: absolute; left: 10px; bottom: 10px; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: rgba(10,11,22,.65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.card .t { font-weight: 600; font-size: 15px; margin: 9px 2px 1px; line-height: 1.25; }
.card .s { color: var(--muted); font-size: 13px; margin: 0 2px; line-height: 1.3; }
.card .meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); margin: 6px 2px 0; flex-wrap: wrap; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.tag.off { border-color: rgba(127,214,164,.5); color: var(--strong); }
.fav { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0; z-index: 2; cursor: pointer;
  background: rgba(10,11,22,.45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 17px; color: #fff; }
.fav[aria-pressed="true"] { color: var(--fav); }
.info-btn { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; font: 500 12px var(--sans);
  padding: 4px 10px; color: var(--muted); cursor: pointer; }
.rating { font-size: 12px; font-weight: 600; }
.rating.Mixed { color: var(--mixed); } .rating.Limited { color: var(--limited); } .rating.Strong { color: var(--strong); }
.foot { margin: 40px 0 0; text-align: center; }

/* ---------- mini player ---------- */
.player { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; max-width: 736px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 22px; cursor: pointer; overflow: hidden;
  background: rgba(22,24,44,.72); border: 1px solid var(--line); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 14px 40px rgba(0,0,0,.45); }
.mini-art { width: 50px; height: 50px; border-radius: 14px; object-fit: cover; flex: none; }
.np { flex: 1; min-width: 0; }
.np-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mini-clock { font-variant-numeric: tabular-nums; color: var(--text); }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
#mini-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------- now playing ---------- */
.nowplaying { position: fixed; inset: 0; z-index: 40; background: var(--bg); transform: translateY(100%); transition: transform .45s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; visibility: hidden; }
.nowplaying.open { transform: none; visibility: visible; }
.np-bg { position: absolute; inset: -10%; background: center/cover no-repeat; filter: blur(50px) saturate(1.3); opacity: .55; transform: scale(1.1); }
.np-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,11,22,.2), rgba(10,11,22,.85) 70%); }
.np-inner { position: relative; max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); }
.np-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.np-top .eyebrow { margin: 0; }
.np-fav { position: static; }

.stage { position: relative; width: min(72vw, 320px); aspect-ratio: 1; margin: 26px auto 6px; --p: 10s; --d: 0s; --a: #b9aefc; }
.stage-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); }
.stage-ring.r2 { inset: 18%; border-color: rgba(255,255,255,.08); }
.head { position: absolute; inset: 37%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(255,255,255,.22), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.25); }
.head .nose { position: absolute; left: 50%; top: -9px; width: 12px; height: 12px; margin-left: -6px; border-left: 1px solid rgba(255,255,255,.35);
  border-top: 1px solid rgba(255,255,255,.35); transform: rotate(45deg); }
.head .ear { position: absolute; top: 34%; width: 9px; height: 32%; border-radius: 6px; background: rgba(255,255,255,.2); }
.head .ear.l { left: -6px; } .head .ear.r { right: -6px; }
.orbit { position: absolute; inset: 0; display: none; }
.orbit .dot { position: absolute; left: 50%; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 18px 6px var(--a), 0 0 50px 14px var(--a); }
.stage.circle .orbit { display: block; animation: spin var(--p) linear infinite; animation-delay: var(--d); }
.stage.sway .orbit { display: block; animation: sway calc(var(--p) / 2) ease-in-out infinite alternate; animation-delay: var(--d); }
.stage.paused .orbit, .stage.paused .breath, .stage.paused .breath span { animation-play-state: paused; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sway { from { transform: rotate(-80deg); } to { transform: rotate(80deg); } }
.breath { position: absolute; inset: 22%; border-radius: 50%; display: none; place-items: center;
  background: radial-gradient(circle, var(--a) 0%, transparent 70%); opacity: .8; animation: breathe 10s ease-in-out infinite; }
.stage.breathe .breath { display: grid; }
.stage.breathe .head, .stage.breathe .stage-ring.r2 { display: none; }
.breath span { grid-area: 1 / 1; font-family: var(--serif); font-size: 20px; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.4); }
.breath .in { animation: say-in 10s ease-in-out infinite; } .breath .out { animation: say-out 10s ease-in-out infinite; }
@keyframes breathe { 0% { transform: scale(.72); } 40% { transform: scale(1.12); } 100% { transform: scale(.72); } }
@keyframes say-in { 0%, 34% { opacity: 1; } 40%, 100% { opacity: 0; } }
@keyframes say-out { 0%, 36% { opacity: 0; } 44%, 94% { opacity: 1; } 100% { opacity: 0; } }
.stage-caption { text-align: center; margin: 4px 0 0; min-height: 18px; }

.np-meta { text-align: center; margin-top: 16px; }
.np-big-title { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 0 0 4px; }
.np-meta p { margin: 0; }
.np-clock { text-align: center; margin: 22px 0 10px; }
#clock { font-family: var(--serif); font-size: 54px; line-height: 1; font-variant-numeric: tabular-nums; }
.progress { width: 100%; height: 3px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--text); transition: width .25s linear; }
.np-controls { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 26px 0 18px; }
.chip-btn { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 9px 14px; font-size: 14px; cursor: pointer; min-width: 84px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.chip-btn[aria-pressed="true"] { background: var(--glass-2); border-color: rgba(255,255,255,.35); }
.end { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; padding: 8px; }

/* ---------- toast, sheet, log ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; z-index: 50;
  background: rgba(242,239,232,.95); color: var(--bg); border-radius: 16px; padding: 12px 14px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
dialog { border: 1px solid var(--line); border-radius: 22px; background: #15172c; color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: 80vh; padding: 20px; }
dialog::backdrop { background: rgba(5,6,14,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0 0 10px; }
dialog p, dialog li { font-size: 14px; }
dialog a { word-break: break-word; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.primary { margin-top: 14px; width: 100%; padding: 13px; border: 0; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; cursor: pointer; }
.log-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-row .when { color: var(--muted); font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .aurora i, .breath, .breath span { animation: none !important; }
  .nowplaying { transition: none; }
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- sign-in ---------- */
body.login { padding-bottom: 40px; min-height: 100vh; }
body.login main { max-width: 420px; padding-top: 9vh; text-align: center; }
body.login h1 { margin-bottom: 10px; }
.lead { font-size: 17px; margin: 0 0 26px; }
.center { text-align: center; }
.login-mark { position: relative; width: 132px; height: 132px; margin: 0 auto 26px; }
.lm-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); }
.lm-ring.r2 { inset: 22%; border-color: rgba(255,255,255,.1); }
.lm-core { position: absolute; inset: 39%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, rgba(255,255,255,.35)); box-shadow: 0 0 30px rgba(185,174,252,.6); }
.lm-orbit { position: absolute; inset: 0; animation: spin 10s linear infinite; }
.lm-dot { position: absolute; left: 50%; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 14px 4px #7b6cf6, 0 0 36px 10px #4fd1c5; }
.primary.wide { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin: 12px 0; padding: 16px; font-size: 17px; border-radius: 18px;
  box-shadow: 0 12px 40px rgba(185,174,252,.25); }
.faceid { width: 22px; height: 22px; border: 2px solid currentColor; border-radius: 7px; position: relative; flex: none; }
.faceid::before { content: ""; position: absolute; left: 5px; right: 5px; top: 5px; height: 3px; border-left: 2px solid currentColor; border-right: 2px solid currentColor; }
.faceid::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: 4px; height: 4px; border-bottom: 2px solid currentColor; border-radius: 0 0 6px 6px; }
.panel { text-align: left; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 22px; padding: 18px; margin-top: 18px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.panel-title { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; }
.login input { width: 100%; font: inherit; font-size: 18px; letter-spacing: .06em; padding: 13px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(10,11,22,.6); color: var(--text); margin-top: 6px; }
.code-box { font: 600 19px/1.3 ui-monospace, Menlo, monospace; letter-spacing: .05em; background: rgba(10,11,22,.6);
  border: 1px dashed var(--accent); border-radius: 14px; padding: 12px; text-align: center; user-select: all; -webkit-user-select: all; }
.msg { margin-top: 16px; padding: 11px 13px; border-radius: 14px; background: rgba(255,255,255,.08); font-size: 14px; }
.msg.err { border: 1px solid var(--fav); }
@media (prefers-reduced-motion: reduce) { .lm-orbit { animation: none; } }

/* ---------- Expect ---------- */
.expect-begin { background: linear-gradient(120deg, rgba(255,194,112,.26), rgba(238,118,148,.16)); }
.expect-begin .begin-text .small { margin-top: 2px; }
.glass-card { display: block; width: 100%; text-align: left; margin-top: 14px; padding: 16px; border-radius: 22px; cursor: default;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.decl-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.decl-head .eyebrow { margin: 0; }
.decl { padding: 12px 0; border-bottom: 1px solid var(--line); }
.decl:last-child { border-bottom: 0; padding-bottom: 2px; }
.decl p { font-family: var(--serif); font-size: 20px; line-height: 1.3; margin: 0 0 9px; }
.decl-theme { margin: 18px 0 0; }
.rate { display: flex; gap: 6px; flex-wrap: wrap; }
.rate-btn { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.rate-btn.yes[aria-pressed="true"] { background: rgba(127,214,164,.18); border-color: rgba(127,214,164,.6); color: var(--strong); }
.rate-btn.mid[aria-pressed="true"] { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); color: var(--text); }
.rate-btn.no[aria-pressed="true"] { background: rgba(255,154,168,.14); border-color: rgba(255,154,168,.55); color: var(--fav); }
.rail-label { margin: 22px 0 10px; }
.scene { flex: 0 0 172px; min-height: 132px; scroll-snap-align: start; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border-radius: 20px; border: 1px solid var(--line);
  background: radial-gradient(circle at 20% 15%, rgba(255,194,112,.28), transparent 60%), radial-gradient(circle at 90% 100%, rgba(238,118,148,.22), transparent 60%), #15122a; }
.scene .eyebrow { margin: 0; }
.scene-title { font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.scene .tag { margin-top: auto; align-self: flex-start; font-size: 11px; color: var(--strong); border-color: rgba(127,214,164,.5); }
.scene.dim { opacity: .45; }
.scene-text { font-family: var(--serif); font-size: 19px; line-height: 1.5; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duo-card { cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.duo-card .eyebrow { margin: 0; }
.duo-title { font-family: var(--serif); font-size: 21px; }
.field { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
.field input, .add-row input { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px; color: var(--text); padding: 12px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(10,11,22,.6); }
.add-row { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.add-row input { margin: 0; flex: 1; }
.receipt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.receipt.arrived span:first-child { color: var(--muted); }
.last { margin-top: 14px; }
