/* Joel's Room — Frutiger Aero by day, Midnight Gospel by night. */

@font-face {
  font-family: "Fredoka";
  src: url("../assets/fonts/fredoka-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --font-display: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Day: Frutiger Aero */
  --bg: #bfeaff;
  --bg-2: #e9fbff;
  --ink: #0b2a45;
  --ink-soft: #1f4262;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-edge: rgba(15, 110, 180, 0.18);
  --gloss: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.25) 48%, rgba(255, 255, 255, 0) 52%);
  --accent: #0a9ce6;
  --accent-ink: #ffffff;
  --accent-grad: linear-gradient(180deg, #7fe2ff 0%, #22b4f2 48%, #0a86d6 52%, #36c3ff 100%);
  --accent-2: #2fc46a;
  --accent-3: #ff4fa3;
  --chip: rgba(10, 156, 230, 0.12);
  --chip-ink: #075a8f;
  --shadow: 0 24px 60px rgba(8, 60, 110, 0.28), 0 2px 6px rgba(8, 60, 110, 0.12);
  --focus: #ff4fa3;
  --hot-core: radial-gradient(circle at 35% 30%, #ffffff 0 18%, #9feaff 32%, #1aa8ee 70%, #0b74c4 100%);
  --hot-ring: rgba(255, 255, 255, 0.95);
  --radius: 22px;
  --gutter: 16px;
  --panel-w: min(440px, 42vw);
}

:root[data-theme="night"] {
  /* Night: Midnight Gospel */
  --bg: #160a33;
  --bg-2: #2a0f52;
  --ink: #fbf1ff;
  --ink-soft: #cdb9f2;
  --glass: rgba(30, 12, 66, 0.66);
  --glass-strong: rgba(36, 14, 78, 0.86);
  --glass-border: rgba(255, 140, 230, 0.5);
  --glass-edge: rgba(63, 245, 255, 0.35);
  --gloss: linear-gradient(180deg, rgba(255, 170, 255, 0.28) 0%, rgba(255, 255, 255, 0.04) 48%, rgba(255, 255, 255, 0) 52%);
  --accent: #3ff5ff;
  --accent-ink: #1a0838;
  --accent-grad: linear-gradient(180deg, #a6ffff 0%, #3ff5ff 48%, #19c9e0 52%, #6bfbff 100%);
  --accent-2: #b6ff4a;
  --accent-3: #ff4fd8;
  --chip: rgba(255, 79, 216, 0.18);
  --chip-ink: #ffb3f2;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 79, 216, 0.12), 0 0 40px rgba(255, 79, 216, 0.18);
  --focus: #b6ff4a;
  --hot-core: radial-gradient(circle at 35% 30%, #ffffff 0 16%, #ffb3f2 30%, #ff4fd8 64%, #7b2ff7 100%);
  --hot-ring: rgba(63, 245, 255, 0.95);
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }
html.no-webgl #list-toggle { display: none; }
html.no-webgl #music-toggle { display: none; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.8s ease, color 0.8s ease;
}

html.no-webgl { background: linear-gradient(180deg, var(--bg-2), var(--bg)) fixed; }
html.no-webgl body { overflow: auto; background: transparent; }

button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: var(--gutter); top: -80px; z-index: 100;
  padding: 10px 16px; border-radius: 999px;
  background: var(--glass-strong); color: var(--ink); font-weight: 800; text-decoration: none;
  box-shadow: var(--shadow);
}
.skip-link:focus { top: var(--gutter); }

/* ---------- Stage ---------- */

#stage { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
html.no-webgl #stage, html.no-webgl #hotspots, html.no-webgl #tooltip, html.no-webgl #hint { display: none; }

#fade {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: var(--bg); opacity: 0; transition: opacity 0.25s ease;
}
#fade.on { opacity: 1; }

/* ---------- Top bar ---------- */

.topbar {
  position: fixed; z-index: 30;
  top: calc(var(--gutter) + env(safe-area-inset-top));
  left: calc(var(--gutter) + env(safe-area-inset-left));
  right: calc(var(--gutter) + env(safe-area-inset-right));
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.topbar-left > * { pointer-events: auto; }
.pill.pill-sub { min-height: 40px; padding: 6px 14px 6px 12px; font-size: 14px; gap: 7px; }

.brand {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 10px; border-radius: 999px; text-decoration: none;
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(1.6); -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow); overflow: hidden;
}
.brand::before { content: ""; position: absolute; inset: 0 0 50% 0; background: var(--gloss); opacity: 0.75; pointer-events: none; border-radius: inherit; }
.brand-text {
  position: relative; font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: 0.2px;
  background: linear-gradient(90deg, #0a86d6, #1fb36a 55%, #0a9ce6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="night"] .brand-text { background-image: linear-gradient(90deg, #ff4fd8, #3ff5ff 55%, #b6ff4a); }
.brand-bubble {
  position: relative; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--hot-core);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.brand-bubble::after { content: ""; position: absolute; left: 6px; top: 4px; width: 11px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); filter: blur(0.4px); }

.topbar-actions { display: flex; gap: 8px; }

.pill {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--ink);
  backdrop-filter: blur(16px) saturate(1.6); -webkit-backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow); font-weight: 800; font-size: 15px; overflow: hidden;
  transition: transform 0.2s ease, background-color 0.3s ease;
}
.pill::before { content: ""; position: absolute; inset: 0 0 50% 0; background: var(--gloss); opacity: 0.7; pointer-events: none; }
.pill:hover { transform: translateY(-1px); background: var(--glass-strong); }
.pill:active { transform: translateY(1px) scale(0.98); }
.pill-icon { position: relative; display: inline-flex; }
.pill-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill-text { position: relative; }
#music-toggle .i-eq { display: none; width: 18px; height: 18px; align-items: flex-end; justify-content: center; gap: 2px; }
#music-toggle .i-eq i { display: block; width: 3px; height: 40%; border-radius: 2px; background: currentColor; animation: eq 0.9s ease-in-out infinite alternate; }
#music-toggle .i-eq i:nth-child(2) { animation-delay: -0.35s; }
#music-toggle .i-eq i:nth-child(3) { animation-delay: -0.6s; }
#music-toggle.on .i-note { display: none; }
#music-toggle.on .i-eq { display: inline-flex; }
@keyframes eq { from { height: 25%; } to { height: 95%; } }
#theme-toggle .i-moon { display: none; }
:root[data-theme="night"] #theme-toggle .i-moon { display: inline; }
:root[data-theme="night"] #theme-toggle .i-sun { display: none; }

@media (max-width: 520px) {
  .pill { padding: 8px 12px; }
  .pill-text { font-size: 14px; }
  #theme-toggle .pill-text, #music-toggle .pill-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pill.pill-sub { min-height: 40px; }
  .brand-text { font-size: 18px; white-space: nowrap; }
}
@media (max-width: 360px) { .brand-text { font-size: 16px; } .brand { padding-right: 14px; } }

/* ---------- Hotspots ---------- */

#hotspots { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hotspot {
  position: absolute; left: 0; top: 0;
  display: block; width: 44px; height: 44px;
  padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto; will-change: transform;
  transition: opacity 0.35s ease;
}
.hotspot[data-hidden="true"] { opacity: 0; pointer-events: none; }
.hotspot .dot {
  display: block; position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%;
  margin: 11px; background: var(--hot-core);
  box-shadow: 0 0 0 2px var(--hot-ring), 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1);
}
.hotspot .dot::before {
  content: ""; position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid var(--hot-ring); opacity: 0.0;
  animation: ping 2.6s ease-out infinite;
}
.hotspot .dot::after { content: ""; position: absolute; left: 4px; top: 3px; width: 8px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); }
.hotspot .label {
  font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap;
  position: absolute; left: 34px; top: 50%; translate: 0 -50%;
  padding: 6px 12px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--glass-border); color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateX(-6px) scale(0.96); transform-origin: left center;
  transition: opacity 0.2s ease, transform 0.25s ease;
  pointer-events: none;
}
.kbd .hotspot:focus-visible .dot, .hotspot.is-active .dot { transform: scale(1.25); }
.kbd .hotspot:focus-visible .label, .hotspot.is-active .label { opacity: 1; transform: none; }
/* :hover only on devices that really hover (on touch screens it sticks to wherever the finger lifted) */
@media (hover: hover) {
  .hotspot:hover .dot { transform: scale(1.25); }
  .hotspot:hover .label { opacity: 1; transform: none; }
}
.kbd .hotspot:focus-visible, .hotspot.quiet:focus-visible { outline: none; }
.kbd .hotspot:focus-visible .dot { box-shadow: 0 0 0 3px var(--focus), 0 0 0 6px rgba(255, 255, 255, 0.6); }
/* On a mouse or trackpad the dots are invisible: you point at the 3D objects themselves. The buttons stay
   for keyboard and screen-reader users, and show up again as soon as someone tabs. */
@media (hover: hover) and (pointer: fine) {
  .hotspot { pointer-events: none; }
  .hotspot .dot { width: 14px; height: 14px; margin: 15px; opacity: 0; }
  .hotspot .dot::before { animation: none; }
  .hotspot .dot::after { left: 3px; top: 2px; width: 6px; height: 4px; }
  .kbd .hotspot { pointer-events: auto; }
  .kbd .hotspot .dot { opacity: 0.85; }
  .kbd .hotspot:focus-visible .dot { opacity: 1; }
  .hotspot.is-active .label { opacity: 0; }
  .kbd .hotspot:focus-visible .label { opacity: 1; }
}
/* Touch screens: clear soap bubbles that breathe in and out, each on its own beat. */
@media (hover: none), (pointer: coarse) {
  .hotspot { touch-action: none; } /* our own drag-to-look-around, not the browser's */
  .hotspot .dot {
    width: 24px; height: 24px; margin: 10px;
    background:
      radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.95) 0 9%, rgba(255, 255, 255, 0) 17%),
      radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0 50%, rgba(190, 240, 255, 0.28) 66%, rgba(255, 255, 255, 0.85) 84%, rgba(255, 255, 255, 0.35) 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55), 0 3px 10px rgba(0, 40, 80, 0.16);
    animation: bubble-breathe 3.8s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * -0.7s);
  }
  .hotspot .dot::after { display: none; }
  .hotspot .dot::before {
    inset: 1px; border: 0; opacity: 0.75; animation: none;
    background: conic-gradient(from 20deg, rgba(255, 120, 220, 0.55), rgba(120, 220, 255, 0.55), rgba(180, 255, 150, 0.5), rgba(255, 220, 120, 0.55), rgba(255, 120, 220, 0.55));
    -webkit-mask: radial-gradient(circle, transparent 0 58%, #000 72%, transparent 100%);
    mask: radial-gradient(circle, transparent 0 58%, #000 72%, transparent 100%);
  }
  :root[data-theme="night"] .hotspot .dot { box-shadow: 0 0 0 1px rgba(255, 179, 242, 0.6), 0 0 14px rgba(255, 79, 216, 0.35); }
  .hotspot.is-active .dot { animation: none; opacity: 1; scale: 1.15; }
}
@keyframes bubble-breathe {
  0%, 100% { opacity: 0.3; scale: 0.88; }
  50% { opacity: 0.95; scale: 1; }
}
body.panel-open .hotspot { opacity: 0; pointer-events: none; }
.hotspot.flip .label { left: auto; right: 34px; transform-origin: right center; }

@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  70%, 100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- Tooltip (follows hovered 3D object) ---------- */

#tooltip {
  position: fixed; left: 0; top: 0; z-index: 12; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px 9px; border-radius: 18px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(1.6); -webkit-backdrop-filter: blur(14px) saturate(1.6);
  box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, -100%) translateY(6px) scale(0.95);
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(.3, 1.4, .5, 1);
  will-change: transform;
}
#tooltip.show { opacity: 1; }
#tooltip.below { transform: translate(-50%, 0) scale(0.95); }
.tt-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.tt-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 1.2; }

/* ---------- Hint ---------- */

.hint {
  position: fixed; z-index: 9; left: var(--gutter); right: var(--gutter); bottom: calc(22px + env(safe-area-inset-bottom));
  width: fit-content; max-width: 640px; margin: 0 auto;
  padding: 10px 18px; border-radius: 999px; text-align: center;
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(1.6); -webkit-backdrop-filter: blur(14px) saturate(1.6);
  box-shadow: var(--shadow); font-weight: 700; font-size: 14px;
  opacity: 0; transition: opacity 0.6s ease;
  pointer-events: none;
}
.hint.show { opacity: 1; }
/* (no :empty rule: the hint is a live region and is invisible until .show anyway) */

/* the first-visit hint sits up by the window on wide screens, so it never covers the journal */
@media (min-width: 761px) and (min-height: 600px) {
  .hint { bottom: auto; top: calc(var(--gutter) + 120px + env(safe-area-inset-top)); }
}
@media (min-width: 1000px) and (min-height: 600px) {
  /* over the empty sky of the left pane, clear of the ringed planet */
  .hint { top: calc(var(--gutter) + 72px + env(safe-area-inset-top)); left: 26vw; right: auto; margin: 0; max-width: 24vw; border-radius: 22px; }
}

/* ---------- Loader ---------- */

#loader {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(120% 90% at 50% 100%, #e8fbff 0%, #8fdcff 45%, #2a8fe6 100%);
  color: #ffffff; text-align: center;
  transition: opacity 0.9s ease, visibility 0.9s;
}
:root[data-theme="night"] #loader { background: radial-gradient(120% 90% at 50% 100%, #ff4fa3 0%, #6a1fb8 40%, #12052b 100%); }
#loader.done { opacity: 0; visibility: hidden; }
.loader-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(36px, 8vw, 64px); text-shadow: 0 4px 24px rgba(0, 40, 90, 0.35); }
.loader-sub { margin: 0 0 14px; font-weight: 700; opacity: 0.9; }
.loader-bar { width: min(260px, 60vw); height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.3); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); }
.loader-bar span { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(180deg, #ffffff, #c9f3ff); transition: width 0.3s ease; }
.loader-bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.loader-bubbles i {
  position: absolute; bottom: -80px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.9) 0 10%, rgba(255, 255, 255, 0.08) 28%, rgba(160, 230, 255, 0.15) 70%, rgba(255, 255, 255, 0.35) 100%);
  animation: rise 6s linear infinite;
}
.loader-bubbles i:nth-child(1) { left: 12%; width: 46px; height: 46px; animation-delay: 0s; }
.loader-bubbles i:nth-child(2) { left: 30%; width: 22px; height: 22px; animation-delay: 1.2s; animation-duration: 5s; }
.loader-bubbles i:nth-child(3) { left: 52%; width: 64px; height: 64px; animation-delay: 2.1s; animation-duration: 7s; }
.loader-bubbles i:nth-child(4) { left: 70%; width: 30px; height: 30px; animation-delay: 0.6s; }
.loader-bubbles i:nth-child(5) { left: 84%; width: 52px; height: 52px; animation-delay: 3s; animation-duration: 6.5s; }
.loader-bubbles i:nth-child(6) { left: 42%; width: 16px; height: 16px; animation-delay: 4s; animation-duration: 4.5s; }
@keyframes rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translateY(-55vh) translateX(18px); }
  100% { transform: translateY(-115vh) translateX(-10px); opacity: 0.2; }
}

/* ---------- Panels (dialogs) ---------- */

.panel {
  position: fixed; margin: 0; padding: 0;
  inset: calc(var(--gutter) + 64px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--gutter) + env(safe-area-inset-bottom)) auto;
  width: var(--panel-w); max-width: none; height: auto; max-height: none;
  color: var(--ink); background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 26px;
  backdrop-filter: blur(22px) saturate(1.7); -webkit-backdrop-filter: blur(22px) saturate(1.7);
  box-shadow: var(--shadow);
  overflow: hidden; display: none; flex-direction: column;
}
.panel[open] { display: flex; animation: panel-in 0.5s cubic-bezier(.2, .9, .25, 1.1) both; }
.panel.closing { animation: panel-out 0.2s ease both; }
.panel::backdrop { background: transparent; }
.panel.room-hot::backdrop { cursor: pointer; }
.panel-wide::backdrop { background: rgba(10, 30, 60, 0.25); backdrop-filter: blur(4px); }
:root[data-theme="night"] .panel { border-image: none; }
:root[data-theme="night"] .panel::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: linear-gradient(140deg, #ff4fd8, #3ff5ff 45%, #b6ff4a);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.panel-gloss { position: absolute; inset: 0 0 auto 0; height: 120px; background: var(--gloss); opacity: 0.55; pointer-events: none; border-radius: 26px 26px 0 0; }

.panel-wide {
  inset: calc(var(--gutter) + 64px + env(safe-area-inset-top)) 0 calc(var(--gutter) + env(safe-area-inset-bottom)) 0;
  margin: 0 auto; width: min(900px, calc(100% - 2 * var(--gutter)));
}

.panel-head { position: relative; padding: 22px 64px 8px 24px; }
.panel-kicker { margin: 0 0 2px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.panel-title:focus { outline: none; }
.kbd .panel-title:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
.panel-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(28px, 3.2vw, 36px); line-height: 1.1; }
.close-btn {
  position: absolute; right: 14px; top: 14px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}
.close-btn:hover { transform: rotate(90deg); }
.close-btn svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.panel-body { position: relative; padding: 8px 24px 26px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.panel-body > p { margin: 0 0 14px; color: var(--ink-soft); font-size: 16.5px; }
.panel-body h3 { font-family: var(--font-display); font-weight: 600; font-size: 19px; margin: 18px 0 8px; }

.card-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.card {
  position: relative; display: block; padding: 14px 16px; border-radius: 18px; text-decoration: none;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
a.card:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.14); }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-body); font-weight: 800; font-size: 16.5px; line-height: 1.3; }
.card-title .arrow { margin-left: auto; opacity: 0.6; transition: transform 0.2s ease; }
a.card:hover .arrow { transform: translateX(3px); opacity: 1; }
.panel-body .card-title { margin: 0; }
.card-desc { margin: 4px 0 0; color: var(--ink-soft); font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chip { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--chip-ink); }
.chip.placeholder { background: rgba(255, 170, 0, 0.18); color: #7a4700; }
:root[data-theme="night"] .chip.placeholder { color: #ffd27a; }

.aqua-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 10px 20px; border-radius: 999px; border: 1px solid rgba(0, 80, 140, 0.35);
  background: var(--accent-grad); color: var(--accent-ink); font-weight: 900; cursor: pointer;
  box-shadow: 0 6px 16px rgba(10, 120, 200, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); text-decoration: none;
  transition: transform 0.15s ease, filter 0.2s ease;
}
:root:not([data-theme="night"]) .aqua-btn {
  color: #0b2a45; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #d4f6ff 0%, #8fe0ff 48%, #5cc8f5 52%, #a8eaff 100%);
}
:root[data-theme="night"] .aqua-btn { text-shadow: none; box-shadow: 0 0 22px rgba(63, 245, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7); border-color: rgba(63, 245, 255, 0.6); }
.aqua-btn:hover { filter: brightness(1.06) saturate(1.1); transform: translateY(-1px); }
.aqua-btn:active { transform: translateY(1px); }
.aqua-btn[aria-pressed="true"], .aqua-btn.on { filter: hue-rotate(140deg) saturate(1.2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }

.small-note { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; }
/* live regions stay in the page while empty, or screen readers may not announce what arrives */
.small-note:empty:not([role=status]):not([aria-live]) { display: none; }
.small-note[role=status]:empty, .small-note[aria-live]:empty { margin: 0; }
.dialog-status { flex: none; margin: 0; padding: 0 24px; font-weight: 700; color: var(--ink); }
.dialog-status:not(:empty) { padding: 10px 24px 14px; border-top: 1px solid var(--glass-border); }
.credits { margin: 22px 0 0; color: var(--ink-soft); font-size: 12.5px; opacity: 0.85; }
.text-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--glass-border); color: var(--ink); font-weight: 800; text-decoration: none;
}
.text-btn:hover { background: var(--glass-strong); }
.aqua-btn.small { min-height: 40px; padding: 8px 16px; font-size: 14.5px; }

/* the laptop's desktop */
.app-grid { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.app-tile {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px 14px; cursor: pointer;
  border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  font-weight: 800; font-size: 15.5px; transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.app-tile:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.14); }
.app-icon { display: inline-grid; place-items: center; }
.app-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-tile .app-icon { width: 56px; height: 56px; border-radius: 16px; color: #ffffff; background: var(--accent-grad); box-shadow: 0 6px 14px rgba(10, 120, 200, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
:root[data-theme="night"] .app-tile .app-icon { color: var(--accent-ink); }
.app-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--glass-border); }
.app-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--glass-border); font-weight: 800; font-size: 14px;
}
.app-chip:hover { background: var(--glass-strong); }
.app-chip[aria-current="page"] { background: var(--chip); color: var(--chip-ink); border-color: transparent; cursor: default; }

/* music */
.music-block { margin: 4px 0 18px; }
.track-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.track {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; border-radius: 14px; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--glass-border); text-align: left; font-weight: 800;
}
.track:hover { transform: translateY(-1px); }
.track.current { border-color: var(--accent); }
.track .num { width: 14px; text-align: center; opacity: 0.55; font-size: 13px; }
.track[aria-current] .num { display: none; }
.track:not([aria-current]) .eq { display: none; }
.track .eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 14px; height: 14px; opacity: 0.35; }
.track .eq i { display: block; width: 3px; height: 30%; border-radius: 2px; background: currentColor; }
.track[aria-current] .eq { opacity: 1; color: var(--accent); }
.track[aria-current] .eq i { animation: eq 0.9s ease-in-out infinite alternate; }
.track[aria-current] .eq i:nth-child(2) { animation-delay: -0.35s; }
.track[aria-current] .eq i:nth-child(3) { animation-delay: -0.6s; }
.chip.svc { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.chip.svc-spotify { background: rgba(30, 215, 96, 0.18); color: #0c6b30; }
.chip.svc-apple { background: rgba(250, 45, 72, 0.14); color: #a3142a; }
.chip.svc-soundcloud { background: rgba(255, 85, 0, 0.15); color: #9a3300; }
.chip.svc-youtube { background: rgba(255, 0, 0, 0.12); color: #a30000; }
:root[data-theme="night"] .chip.svc { color: #ffffff; }
.card.playlist .btn-row { margin: 10px 0 0; }
.embed-slot:empty { display: none; }
.embed-slot { margin-top: 12px; }
.embed-slot iframe { display: block; width: 100%; border: 0; border-radius: 14px; background: rgba(0, 0, 0, 0.06); }

.section-block + .section-block { margin-top: 26px; }
.section-block h3 { display: flex; align-items: center; gap: 10px; }
.section-emoji { font-size: 22px; }

/* ---------- Everything (fallback page + dialog) ---------- */

.everything { display: none; }
html.no-webgl .everything { display: block; padding: calc(96px + env(safe-area-inset-top)) var(--gutter) 48px; }
.everything-inner { max-width: 900px; margin: 0 auto; }
.everything h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(32px, 5vw, 48px); margin: 0 0 6px; }
.everything-intro { color: var(--ink-soft); font-size: 18px; margin: 0 0 22px; }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card-grid .section-card {
  padding: 18px; border-radius: 22px; background: var(--glass); border: 1px solid var(--glass-border);
  box-shadow: var(--shadow); backdrop-filter: blur(16px);
}
.section-card h3 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.section-card p { margin: 0 0 10px; color: var(--ink-soft); }
.section-card ul { margin: 0; padding-left: 18px; }
.section-card li + li { margin-top: 4px; }

/* ---------- Phones: panel becomes a bottom sheet ---------- */

@media (max-width: 760px) {
  .panel {
    inset: auto 0 0 0; width: 100%; max-height: min(62dvh, 560px);
    border-radius: 26px 26px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .panel[open] { animation-name: sheet-in; }
  .panel.closing { animation-name: sheet-out; }
  .panel-wide { inset: calc(64px + env(safe-area-inset-top)) 0 0 0; width: 100%; max-height: none; }
  .panel-head { padding: 18px 60px 6px 20px; }

  .panel-body { padding: 6px 20px 22px; }
  .panel:not(.panel-wide) .panel-head { touch-action: none; } /* the drag-to-close is ours, not the browser's scroll */
  .panel-wide .panel-head::before { display: none; }
  .panel.swiped { animation: none !important; transition: transform 0.2s ease; }
  .panel[open]:not(.closing) { animation-fill-mode: backwards; } /* so the inline drag transform can move it */
  .panel-head::before { content: ""; position: absolute; left: 50%; top: 7px; width: 40px; height: 5px; border-radius: 99px; background: var(--ink-soft); opacity: 0.35; transform: translateX(-50%); }
}

/* phones in portrait: the open object fills the top of the screen, so the list button waits until the sheet closes */
@media (max-width: 760px) and (max-aspect-ratio: 13/10) {
  body.panel-open #list-toggle { opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
}

.btn-row > a { max-width: 100%; overflow-wrap: anywhere; }

/* short but wide windows (a zoomed-in laptop, a phone on its side): keep the side panel, not a sheet */
@media (max-width: 760px) and (min-aspect-ratio: 13/10) {
  .panel:not(.panel-wide) {
    inset: calc(var(--gutter) + 56px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) var(--gutter) auto;
    width: min(360px, 50vw); max-height: none; border-radius: 22px; padding-bottom: 0;
  }
  .panel:not(.panel-wide)[open] { animation-name: panel-in; }
  .panel:not(.panel-wide).closing { animation-name: panel-out; }
  .panel:not(.panel-wide) .panel-head::before { display: none; }
  .panel:not(.panel-wide) .panel-head { touch-action: auto; }
}

/* very short, narrow windows (400% zoom on a laptop): the panel takes the whole window rather than a sliver */
@media (max-height: 320px) and (max-width: 560px) { /* 400% zoom; landscape phones (≥ 568 wide) keep the side panel */
  body.panel-open .topbar, body.panel-open .hint { visibility: hidden; }
  .panel.panel-wide { inset: 8px; width: auto; margin: 0; } /* under the panel anyway; stops it showing through the glass */
  .panel:not(.panel-wide) { inset: 8px; width: auto; max-height: none; border-radius: 18px; }
  .panel-head { padding: 10px 56px 2px 14px; }
  .panel-title { font-size: 22px; }
  .close-btn { top: 6px; right: 6px; }
}

@keyframes panel-in { from { opacity: 0; transform: translateX(30px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes panel-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(24px) scale(0.98); } }
@keyframes sheet-in { from { opacity: 0.4; transform: translateY(100%); } to { opacity: 1; transform: none; } }
@keyframes sheet-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(60%); } }

@media (max-height: 420px) and (pointer: coarse) { body.panel-open #list-toggle { opacity: 0; pointer-events: none; transition: opacity 0.2s ease; } }
body:has(#everything-dialog[open]) #list-toggle { visibility: hidden; } /* under the list's corner otherwise */
/* ---------- Low-power devices: no live blur over a 60 fps canvas ---------- */

.low-power .pill, .low-power .brand, .low-power .panel, .low-power .hint, .low-power #tooltip, .low-power .hotspot .label {
  backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--glass-strong);
}
.low-power .panel-wide::backdrop { backdrop-filter: none; }
#loader.gone { display: none; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .hotspot .dot::before { display: none; }
  .loader-bubbles { display: none; }
  #fade { transition-duration: 0.1s !important; }
}
