/* Shared base (deep navy, silver, pink heat) plus three looks chosen by html[data-theme]:
   velvet = misty orb + glass capsules, candy = chrome blob + glossy buttons, horology = dial + hairlines. */
:root {
  --navy-0: #050816; --navy-1: #0b1230; --navy-2: #18244a;
  --text: #eef1f7; --muted: #8f9ab2; --silver: #d9dee8; --line: rgba(201, 209, 224, .18);
  --pink: #ff4fa3; --pink-2: #ff8cc6; --ok: #8fe3c8;
  --heat: 0; /* 0..1, driven by what the toy is doing right now */
  --serif: "Didot", "Bodoni MT", "Songti SC", serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  font: 15px/1.55 system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(60% 40% at 20% 85%, #14204a66, transparent 70%),
    radial-gradient(50% 35% at 85% 30%, #1a285a55, transparent 70%),
    radial-gradient(120% 80% at 50% 0%, var(--navy-2) 0%, var(--navy-1) 45%, var(--navy-0) 100%) fixed;
}
main { max-width: 560px; margin: 0 auto; padding: 18px 16px 110px; display: grid; gap: 14px; }
h1 { margin: 0; font-size: 21px; font-weight: 300; letter-spacing: .32em; }
h2 { margin: 0; font-size: 12px; font-weight: 500; letter-spacing: .2em; color: var(--muted); }
.eyebrow { font-size: 11px; letter-spacing: .22em; color: var(--muted); }
p.sub, .note { margin: 0; font-size: 13px; color: var(--muted); }
a { color: var(--pink-2); }

section {
  display: grid; gap: 10px; padding: 14px; border-radius: 20px;
  background: rgba(10, 16, 40, .62); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-4 button { padding: 10px 2px; font-size: 13px; letter-spacing: .04em; }

input, select {
  width: 100%; font: inherit; color: var(--text); padding: 10px 12px; border-radius: 12px;
  background: rgba(5, 8, 22, .7); border: 1px solid var(--line);
}

/* Silver-thread glass capsules; pink means warm (chosen, sent, climax, love). */
button {
  font: inherit; font-size: 14px; font-weight: 400; letter-spacing: .12em; cursor: pointer;
  padding: 10px 8px; border-radius: 999px; color: #e7ebf3;
  border: 1px solid #d9dee855; background: linear-gradient(180deg, #ffffff14, #ffffff03);
  transition: transform .12s, border-color .25s, color .25s, box-shadow .25s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: default; }
button.pink, button.on, button.sent, button.primary {
  color: var(--pink-2); border-color: color-mix(in srgb, var(--pink) 70%, transparent);
  box-shadow: inset 0 0 14px #ff4fa333, 0 0 12px #ff4fa322;
}
button.sent.sent { box-shadow: inset 0 0 18px #ff4fa366, 0 0 18px #ff4fa355; }
button.dusk, button.ghost { color: var(--silver); border-color: #d9dee82e; background: transparent; }
.icon-btn { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 18px; letter-spacing: 0; }

/* Hairline segmented row */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid #c9d1e033; border-bottom: 1px solid #c9d1e033; }
.seg button { border: 0; border-right: 1px solid #c9d1e022; border-radius: 0; background: none; box-shadow: none;
  padding: 12px 4px; font-size: 13px; letter-spacing: .2em; color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button.on, .seg button.sent { color: var(--pink-2); box-shadow: none; }
.talk { touch-action: none; user-select: none; -webkit-user-select: none; }

.readout { text-align: center; line-height: 1; }
.readout b { display: block; font-family: var(--serif); font-weight: 400; font-size: 44px; color: #f1f3f8; letter-spacing: .04em; }
.readout small { display: block; margin-top: 6px; font-size: 11px; letter-spacing: .4em; color: var(--pink-2); }
.hair { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; padding: 0; background: transparent; border: 0; }
.hair::-webkit-slider-runnable-track { height: 1px; background: linear-gradient(90deg, #c9d1e099, var(--pink)); }
.hair::-moz-range-track { height: 1px; background: linear-gradient(90deg, #c9d1e099, var(--pink)); }
.hair::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, #c7cfdf 45%, #7d879d); box-shadow: 0 0 0 1px #ff8cc6aa, 0 0 12px #ff4fa366; }
.hair::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, #c7cfdf 45%, #7d879d); box-shadow: 0 0 0 1px #ff8cc6aa, 0 0 12px #ff4fa366; }
.slider input[type=range] { padding: 0; height: 30px; background: none; border: 0; accent-color: var(--pink); }

/* Stage */
.stage { position: relative; aspect-ratio: 1; border-radius: 24px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(100% 70% at 50% 30%, #16204a 0%, #0a1028 60%, #050816 100%); }
.stage-inner { position: absolute; inset: 0; }
.fx-shake .stage-inner { animation: shake calc(150ms - var(--heat) * 70ms) linear infinite; }
@keyframes shake {
  25% { transform: translate(calc(var(--heat) * 1.8px), calc(var(--heat) * -1.2px)); }
  50% { transform: translate(calc(var(--heat) * -1.5px), calc(var(--heat) * 1.3px)); }
  75% { transform: translate(calc(var(--heat) * 1.1px), calc(var(--heat) * 1.6px)); }
}
.fog { position: absolute; inset: -20%; filter: blur(12px);
  background: radial-gradient(40% 25% at 30% 70%, #1a2a5a77, transparent 70%), radial-gradient(35% 20% at 75% 35%, #22336a66, transparent 70%); }
.backlight { position: absolute; inset: -10%; pointer-events: none; opacity: .5;
  background: radial-gradient(60% 55% at 50% 48%, color-mix(in srgb, var(--pink) calc(var(--heat) * 75%), #6f93ff) 0%,
    color-mix(in srgb, color-mix(in srgb, var(--pink) calc(var(--heat) * 60%), #3c55b8) 45%, transparent) 45%, transparent 75%); }
.fx-breathe .backlight { animation: backlight calc(6s - var(--heat) * 4s) ease-in-out infinite; }
@keyframes backlight { 0%, 100% { opacity: calc(.28 + var(--heat) * .25); transform: scale(.94); } 50% { opacity: calc(.62 + var(--heat) * .3); transform: scale(1.05); } }

.orb, .dial { position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%, -50%); transition: opacity .5s, transform .5s; cursor: pointer; }
.orb { width: 50%; height: 50%; filter: blur(1.5px);
  background: radial-gradient(circle at 42% 38%,
    rgba(255, 255, 255, .85) 0%, rgba(222, 230, 246, .5) 14%,
    color-mix(in srgb, color-mix(in srgb, var(--pink) calc(var(--heat) * 70%), #9db8ff) 30%, transparent) 40%,
    rgba(120, 145, 210, .08) 62%, transparent 71%);
  box-shadow: 0 0 calc(40px + var(--heat) * 60px) color-mix(in srgb, color-mix(in srgb, var(--pink) calc(var(--heat) * 100%), #7fa6ff) 35%, transparent); }
.fx-breathe .orb { animation: orb-breathe calc(5.2s - var(--heat) * 3.6s) ease-in-out infinite; }
@keyframes orb-breathe { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }

.dial { width: 74%; height: 74%; opacity: 0; transform: translate(-50%, -50%) scale(.85) rotate(-20deg); pointer-events: none; touch-action: none;
  background: repeating-radial-gradient(circle, #1b2650 0 1px, #0d1430 1px 4px), radial-gradient(circle, #16204a, #0a1028);
  box-shadow: 0 0 0 1px #c9d1e066, 0 0 0 7px #0b1129, 0 0 0 8px #aeb6c855, inset 0 0 40px #000c; }
.dial .ticks { position: absolute; inset: 9px; border-radius: 50%;
  background: repeating-conic-gradient(from -1.5deg, #d9dee8 0 3deg, transparent 3deg 30deg);
  -webkit-mask: radial-gradient(closest-side, transparent 86%, #000 87%); mask: radial-gradient(closest-side, transparent 86%, #000 87%); }
.dial .needle { position: absolute; left: 50%; bottom: 50%; width: 3px; height: 42%; margin-left: -1.5px; border-radius: 2px; transform-origin: 50% 100%;
  background: linear-gradient(180deg, var(--pink-2), var(--pink)); box-shadow: 0 0 12px var(--pink); transform: rotate(var(--needle, -120deg)); }
.dial .hub { position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; transform: translate(-50%, -50%); border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #20295a, #0a1028); box-shadow: 0 0 0 1px #c9d1e055; color: #f1f3f8;
  font-family: var(--serif); font-size: 22px; font-weight: 400; }
.stage.show-dial .orb { opacity: 0; transform: translate(-50%, -50%) scale(.6); pointer-events: none; animation: none; }
.stage.show-dial .dial { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.stage.busy .orb, .stage.busy .dial { opacity: .22; filter: blur(2px); pointer-events: none; animation: none; }

/* Listening ripples: rings leaving the orb while listening, brighter when something is heard. */
.ripples { position: absolute; inset: 0; pointer-events: none; }
.ripples i { position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; border-radius: 50%; transform: translate(-50%, -50%) scale(1);
  border: 1.5px solid #e7ebf3; box-shadow: 0 0 10px #ff8cc666, inset 0 0 8px #ff8cc644; opacity: 0; }
.fx-ripple .listening .ripples i { animation: ripple 3s ease-out infinite; }
.fx-ripple .listening .ripples i:nth-child(2) { animation-delay: 1s; }
.fx-ripple .listening .ripples i:nth-child(3) { animation-delay: 2s; }
@keyframes ripple { from { opacity: calc(.35 + var(--ear, 0) * .6); transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -50%) scale(2.1); } }

.dust { position: absolute; inset: 0; pointer-events: none; }
.dust i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--silver); animation: rise linear infinite; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } 20% { opacity: .55; } to { transform: translateY(-560px); opacity: 0; } }
body:not(.fx-dust) .dust { display: none; }

/* A finished drawing lingers a few seconds, then sinks back as a ghost. */
#ink, #tip { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#ink { transition: opacity 1.4s 4s; opacity: .22; }
.stage.busy #ink { transition: opacity .3s; opacity: 1; }
.stage-hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 11px; letter-spacing: .2em; color: var(--muted); pointer-events: none; }
.meter { height: 4px; border-radius: 2px; background: #ffffff14; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #9fb6ff, var(--pink)); transition: width .1s linear; }

.chips-live { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chips-live span { font-size: 12px; padding: 3px 10px; border-radius: 999px; color: var(--pink-2); border: 1px solid #ff8cc666; background: #ff4fa314; }

/* Toys */
.toy { display: grid; gap: 8px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(5, 8, 22, .45); }
.toy-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toy-name { all: unset; cursor: pointer; font-weight: 600; letter-spacing: .06em; }
.toy-head small { color: var(--muted); flex: 1 1 auto; text-align: right; }
.toy-head .rename { flex: 0 0 auto; padding: 5px 12px; font-size: 12px; }
.now { font-size: 13px; color: var(--pink-2); min-height: 1.4em; }
.slider { display: grid; grid-template-columns: 56px 1fr 40px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* Lists and settings */
ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.saved li { display: flex; align-items: center; gap: 8px; }
.saved li span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved li small { color: var(--muted); }
.saved li button { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
details summary { cursor: pointer; font-size: 12px; letter-spacing: .2em; color: var(--muted); list-style: none; }
.switches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.switches label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); font-size: 14px; }
.switches input { width: auto; accent-color: var(--pink); }

/* Stop stays within reach at the bottom */
.dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, #050816ee 40%); }
.panic { display: block; width: 100%; max-width: 528px; margin: 0 auto; padding: 14px; font-size: 16px; letter-spacing: .5em;
  color: #f1f3f8; background: rgba(10, 16, 40, .85); border: 1px solid #d9dee899;
  box-shadow: 0 0 0 1px #ff8cc644, 0 0 22px #ff4fa333, inset 0 0 16px #ff4fa31f; }

/* Relay page */
#status { font-size: 13px; color: var(--muted); }
#status[data-live="1"] { color: var(--ok); }
#log { font-size: 12px; color: var(--muted); max-height: 220px; overflow: auto; }

/* ── Candy: chrome blob and glossy buttons ── */
[data-theme="candy"] h1 { font-weight: 700; letter-spacing: .08em;
  background: linear-gradient(180deg, #fff 0%, #c3cad8 45%, #7d879d 55%, #eef1f7 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="candy"] button:not(.toy-name):not(.icon-btn) { font-weight: 600; letter-spacing: .04em; border: 0; border-radius: 16px; color: #1a2040;
  background: linear-gradient(180deg, #fff 0%, #d6dbe6 48%, #a9b2c5 52%, #e9ecf3 100%);
  box-shadow: inset 0 2px 0 #ffffffaa, inset 0 -2px 0 #0003, 0 6px 14px #0006; }
[data-theme="candy"] button.pink:not(.toy-name), [data-theme="candy"] button.on:not(.toy-name), [data-theme="candy"] button.sent:not(.toy-name), [data-theme="candy"] button.primary:not(.toy-name) {
  color: #fff; background: linear-gradient(180deg, #ffb3da 0%, #ff5fae 48%, #e8348c 52%, #ff8cc6 100%);
  box-shadow: inset 0 2px 0 #fff8, inset 0 -2px 0 #0003, 0 6px 18px #ff4fa355; }
[data-theme="candy"] button.dusk:not(.toy-name) { color: var(--silver);
  background: linear-gradient(180deg, #3a4777 0%, #1c2650 48%, #121a3d 52%, #2c3866 100%); box-shadow: inset 0 1px 0 #ffffff33, inset 0 -2px 0 #0005, 0 6px 14px #0006; }
[data-theme="candy"] .seg { gap: 8px; border: 0; }
[data-theme="candy"] .panic { font-size: 17px; letter-spacing: .3em; padding: 15px; border-radius: 20px;
  box-shadow: inset 0 2px 0 #fff, inset 0 -2px 0 #0003, 0 0 0 2px #ff8cc6aa, 0 0 22px #ff4fa366, 0 8px 20px #0008; }
[data-theme="candy"] .orb { filter: none; border-radius: 46% 54% 52% 48% / 55% 45% 55% 45%; width: 46%; height: 46%;
  background: conic-gradient(from 210deg, #f4f6fb, #9aa3b8, #fff, #c9cfdd, #ff9ccf, #eef1f7, #8d97ad, #f4f6fb);
  box-shadow: inset 0 -12px 30px #0006, inset 0 10px 24px #fff8, 0 10px calc(30px + var(--heat) * 50px) #ff4fa366; }
[data-theme="candy"] .fx-breathe .orb { animation: morph 7s ease-in-out infinite; }
@keyframes morph { 0%, 100% { transform: translate(-50%, -50%); } 50% { border-radius: 55% 45% 40% 60% / 45% 58% 42% 55%; transform: translate(-50%, -50%) rotate(18deg) scale(1.03); } }

/* ── Horology: watch dial, hairlines, serif numerals ── */
[data-theme="horology"] h1 { font-family: var(--serif); font-weight: 400; letter-spacing: .25em; }
[data-theme="horology"] section { border-radius: 4px; background: rgba(7, 11, 26, .5); }
[data-theme="horology"] .stage { border-radius: 4px; }
[data-theme="horology"] button:not(.toy-name):not(.icon-btn) { border-radius: 2px; background: none; border-color: #c9d1e033; font-size: 13px; letter-spacing: .2em; box-shadow: none; }
[data-theme="horology"] button.pink, [data-theme="horology"] button.on, [data-theme="horology"] button.sent, [data-theme="horology"] button.primary { color: var(--pink-2); border-color: #ff8cc688; }
[data-theme="horology"] .grid-4 button { font-size: 12px; letter-spacing: .08em; }
[data-theme="horology"] .readout b { font-size: 52px; }
[data-theme="horology"] button.panic:not(.toy-name):not(.icon-btn) { border-radius: 2px; font-family: var(--serif); font-size: 16px; background: rgba(7, 11, 26, .96); border-color: #d9dee866; box-shadow: 0 0 18px #ff4fa322; }

/* Low-key mode: calm and quiet, no glow, no motion */
.lowkey { --heat: 0 !important; }
.lowkey .backlight, .lowkey .dust, .lowkey .ripples { display: none; }
.lowkey .panic { box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .stage-inner, .backlight, .orb, .ripples i, .dust i { animation: none !important; } }
