:root {
  --bg: #15110e;
  --bg2: #1e1814;
  --ink: #f3ead8;
  --muted: #b5a68c;
  --line: rgba(243, 234, 216, 0.12);
  --accent: #ffb45e;
  --accent-ink: #2a1708;
  --green: #8fd694;
  --panel: rgba(24, 19, 15, 0.9);
  --text2: #e2d6bf;
  --glass: rgba(21, 17, 14, 0.72);
  --glass-strong: rgba(21, 17, 14, 0.9);
  --tint: rgba(255, 255, 255, 0.05);
  --stage-a: #3a2a1d;
  --stage-b: #221a14;
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Day theme: sunny room, light paper-coloured page */
html[data-theme='day'] {
  --bg: #f3e9d8;
  --bg2: #eadcc4;
  --ink: #2a1d12;
  --muted: #7c6750;
  --line: rgba(42, 29, 18, 0.14);
  --accent: #d9761a;
  --accent-ink: #ffffff;
  --panel: rgba(252, 246, 236, 0.94);
  --text2: #3d2d1f;
  --glass: rgba(252, 246, 236, 0.82);
  --glass-strong: rgba(252, 246, 236, 0.95);
  --tint: rgba(42, 29, 18, 0.05);
  --stage-a: #fff6e4;
  --stage-b: #f5e6cc;
}
body, #stage, #panel, .topbar, .chips, .hotspot { transition: background-color 0.8s ease, color 0.8s ease, border-color 0.8s ease; }

/* day / night toggle */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle span { position: absolute; inset: 0; display: grid; place-items: center; transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s; }
.theme-toggle .sun { transform: translateY(120%); opacity: 0; }
html[data-theme='day'] .theme-toggle .sun { transform: none; opacity: 1; }
html[data-theme='day'] .theme-toggle .moon { transform: translateY(-120%); opacity: 0; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--tint); padding: 1px 5px; border-radius: 4px; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg);
  transition: opacity 0.8s ease;
}
#loader.gone { opacity: 0; pointer-events: none; }
#loader p { color: var(--muted); letter-spacing: 0.02em; margin: 0; }
#loader .bulb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 30px 10px rgba(255, 180, 94, 0.45);
  animation: flicker 1.4s infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: 0.4; } 50% { opacity: 0.9; } 55% { opacity: 0.5; } }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 3vw, 32px);
  background: linear-gradient(var(--bg) 0%, transparent 100%);
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; }
.brand span { font-size: 0.78rem; color: var(--muted); }
.topbar nav { display: flex; align-items: center; gap: 6px; }
.link {
  background: none; border: 0; color: var(--ink); text-decoration: none;
  padding: 8px 12px; border-radius: 999px; font-size: 0.92rem;
}
.link:hover { background: var(--tint); }
.icon {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--tint); font-size: 1.05rem;
}
.icon:hover { border-color: var(--accent); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--tint);
  color: var(--ink); text-decoration: none; font-weight: 500;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ffc47d; }
.btn.small { padding: 8px 14px; font-size: 0.88rem; }

/* ---------- stage ---------- */
#stage {
  position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden;
  background:
    radial-gradient(60% 55% at 40% 55%, var(--stage-a) 0%, transparent 70%),
    radial-gradient(90% 80% at 50% 50%, var(--stage-b) 0%, var(--bg) 100%);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
#scene:active { cursor: grabbing; }

.intro {
  position: absolute; left: clamp(16px, 4vw, 56px); top: clamp(92px, 16vh, 150px);
  max-width: 420px; z-index: 5;
  text-shadow: 0 2px 18px var(--glass-strong);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; }
.intro h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.4rem, 5vw, 3.8rem); line-height: 1; margin: 0 0 14px; }
.lede { color: var(--text2); line-height: 1.55; margin: 0 0 20px; }
.lede span { color: var(--muted); }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
body.focused .intro { opacity: 0; transform: translateY(-10px); pointer-events: none; }
body.focused .chips, body.focused .hint { opacity: 0; pointer-events: none; }
.chips, .hint { transition: opacity 0.3s; }

/* hotspot labels */
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; transition: opacity 0.3s; }
body.focused #labels { opacity: 0; }
.hotspot {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  display: flex; align-items: center; gap: 7px;
  margin: -14px 0 0 -10px; padding: 4px 10px 4px 6px;
  border: 1px solid rgba(255, 180, 94, 0.35); border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(6px);
  font-size: 0.78rem; white-space: nowrap;
  transition: opacity 0.25s, background 0.2s, border-color 0.2s;
}
.hotspot i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 180, 94, 0.7); animation: ping 2.2s infinite;
}
.hotspot.hover, .hotspot:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hotspot.hover i, .hotspot:hover i { background: var(--accent-ink); }
.hotspot.hidden { opacity: 0; pointer-events: none; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,180,94,0.6); } 70%, 100% { box-shadow: 0 0 0 9px rgba(255,180,94,0); } }

#bubble {
  position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none;
  translate: -50% -100%;
  max-width: 220px; padding: 8px 12px; border-radius: 14px;
  background: #fff8ec; color: #2a1708; font-size: 0.85rem; font-weight: 500; line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0; scale: 0.85; transition: opacity 0.25s, scale 0.25s;
}
#bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; translate: -50% 0;
  border: 7px solid transparent; border-bottom: 0; border-top-color: #fff8ec;
}
#bubble.show { opacity: 1; scale: 1; }

.chips {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 6px; padding: 6px; max-width: calc(100% - 24px); overflow-x: auto;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(8px);
  scrollbar-width: none;
}
.chips button {
  border: 0; background: none; padding: 7px 13px; border-radius: 999px;
  font-size: 0.84rem; white-space: nowrap; color: var(--text2);
}
.chips button:hover { background: var(--tint); }
.chips button.on { background: var(--accent); color: var(--accent-ink); }
/* the one line under the room */
.hint {
  position: absolute; left: 50%; bottom: 26px; translate: -50% 0; margin: 0; z-index: 5;
  padding: 9px 18px; border-radius: 999px; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px);
  font-size: 0.92rem; color: var(--ink); pointer-events: none;
  animation: hintFloat 3s ease-in-out infinite;
  display: flex; align-items: center; gap: 10px;
}
.hint a { pointer-events: auto; color: var(--accent); text-decoration: none; font-weight: 600; }
.hint a:hover { text-decoration: underline; }
.hint-sep { color: var(--muted); }
@media (max-width: 520px) {
  /* phones: two short lines instead of one long one */
  .hint { flex-direction: column; gap: 2px; border-radius: 16px; padding: 8px 16px; font-size: 0.85rem; }
  .hint-sep { display: none; }
}
@keyframes hintFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- panel ---------- */
#panel {
  position: absolute; z-index: 10; top: 0; right: 0; bottom: 0;
  width: min(460px, 42vw);
  display: flex; flex-direction: column;
  padding: 84px 28px 18px;
  background: var(--panel); backdrop-filter: blur(14px);
  border-left: 1px solid var(--line);
  transform: translateX(105%); transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.kicker { margin: 0; color: var(--accent); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; }
#panel h2, .plain h2 { font-family: var(--serif); font-weight: 600; font-size: 1.9rem; line-height: 1.15; margin: 6px 0 16px; }
.close {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: none;
}
.close:hover { border-color: var(--accent); color: var(--accent); }
#panel .body { flex: 1; overflow-y: auto; padding-right: 6px; margin-right: -6px; }
#panel footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; border-top: 1px solid var(--line); margin-top: 12px;
}
#panel footer button {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--tint);
}
#panel footer button:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.count { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); }

/* shared content styles (panel + simple view) */
.body ul, .plain ul { padding-left: 18px; margin: 10px 0; }
.body li, .plain li { margin: 6px 0; line-height: 1.55; color: var(--text2); }
ul.roomy li { margin: 14px 0; }
.body p, .plain p { line-height: 1.6; color: var(--text2); }
.card {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 0 0 14px;
  background: var(--tint);
}
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.stack, .meta { margin: 0 0 6px; color: var(--muted) !important; font-size: 0.86rem; }
.links { display: flex; gap: 14px; margin-top: 8px; font-size: 0.9rem; }
.links a { text-decoration: none; }
.links a:hover { text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stats div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(255,180,94,0.05); }
.stats b { display: block; font-size: 1.15rem; color: var(--accent); }
.stats span { display: block; font-size: 0.76rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
dl.skills { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; }
dl.skills dt { font-weight: 700; color: var(--accent); font-size: 0.9rem; }
dl.skills dd { margin: 0; color: var(--text2); line-height: 1.5; }
.contact-grid { display: grid; gap: 10px; margin-top: 16px; }

/* playlist */
.pl-tag { margin: 16px 0 6px; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.playlist { list-style: none; padding: 0 !important; margin: 0; }
.playlist li { margin: 4px 0 !important; }
.song {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--tint);
}
.song { --mood: var(--accent); }
.song:hover:not(:disabled) { border-color: var(--mood); }
.song:disabled { opacity: 0.5; cursor: default; }
.song.on { background: color-mix(in srgb, var(--mood) 16%, transparent); border-color: var(--mood); }
.song .play {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--mood); color: #fff; font-size: 0.7rem;
}

/* speaker: mood picker + now playing */
.moods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 14px; }
.mood {
  --mood: var(--accent);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px 12px 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--tint);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.mood:hover { transform: translateY(-2px); border-color: var(--mood); }
.mood.on {
  border-color: var(--mood);
  background: color-mix(in srgb, var(--mood) 18%, transparent);
  box-shadow: 0 0 0 1px var(--mood) inset, 0 8px 24px color-mix(in srgb, var(--mood) 25%, transparent);
}
.mood-emoji { font-size: 1.35rem; line-height: 1; margin-bottom: 4px; }
.mood b { font-size: 0.9rem; }
.mood small { color: var(--muted); font-size: 0.72rem; line-height: 1.3; }
.now {
  --mood: var(--accent);
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: #0d0e11; color: #f3ead8; border: 1px solid #23262d;
}
.now small { display: block; color: var(--mood); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }
.now b { display: block; font-size: 1rem; }
.now span:not(.eq):not(.now-icon) { display: block; color: #9aa0aa; font-size: 0.8rem; }
.now .eq { display: flex; align-items: flex-end; gap: 3px; height: 22px; flex: none; }
.now .eq i { width: 4px; height: 6px; background: var(--mood); border-radius: 2px; }
.now.playing .eq i { animation: eq 0.9s infinite ease-in-out; }
.now.playing .eq i:nth-child(2) { animation-delay: 0.2s; }
.now.playing .eq i:nth-child(3) { animation-delay: 0.4s; }
.now-icon { font-size: 1.4rem; }
@media (max-width: 520px) {
  .moods { gap: 6px; }
  .mood { padding: 10px 8px 8px; }
  .mood small { display: none; }
}
.song b { display: block; font-weight: 500; }
.song small { display: block; color: var(--muted); font-size: 0.78rem; }

/* wide panel (terminal) */
#panel.wide { width: min(760px, 58vw); }
ol.steps { padding-left: 20px; margin: 10px 0; }
ol.steps li { margin: 6px 0; line-height: 1.55; color: var(--text2); }

/* ---------- terminal ---------- */
.term {
  display: flex; flex-direction: column; height: 100%; min-height: 420px;
  border-radius: 12px; overflow: hidden;
  background: #0d1118; border: 1px solid #263042;
  font-family: var(--mono); font-size: 13.5px; color: #d7dde8;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), inset 0 0 80px rgba(80,140,255,0.04);
}
#panel .body:has(.term) { display: flex; flex-direction: column; overflow: hidden; }
#panel .body:has(.term) .term-slot { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.term-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: #171d29; border-bottom: 1px solid #263042;
}
.term-bar .dots { display: flex; gap: 6px; }
.term-bar .dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-bar .dots i:nth-child(2) { background: #febc2e; }
.term-bar .dots i:nth-child(3) { background: #28c840; }
.term-title { color: #8a93a6; font-size: 12px; }
.term-out { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 4px; line-height: 1.6; }
.term-out .line { margin: 0 0 8px; overflow-wrap: anywhere; }
.term-out .echo { margin-bottom: 4px; }
.term-out a { color: #7cc4ff; }
.p-user { color: #7ee0a3; }
.p-path { color: #7cc4ff; }
.cmd { color: #f3ead8; }
.dim { color: #8a93a6; }
.err { color: #ff8a80; }
.boot { color: #ffb45e; }
.file { color: #7cc4ff; }
.kbd {
  display: inline-block; padding: 0 6px; border-radius: 4px;
  background: #1d2433; border: 1px solid #2c364a; color: #ffd8a8;
}
.help { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; align-items: center; }
.ls { display: grid; gap: 6px; margin: 2px 0 8px; }
.ls .dir {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: baseline;
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px;
  background: rgba(124,196,255,0.04); border: 1px solid #222b3b;
  font-family: var(--mono); font-size: 13px; color: #d7dde8;
}
.ls .dir:hover { background: rgba(126,224,163,0.1); border-color: #3c6e52; }
.ls .dir b { color: #7ee0a3; font-weight: 600; }
.ls .dir em { color: #8a93a6; font-style: normal; font-size: 11.5px; }
.inline { background: none; border: 0; padding: 0; color: #7ee0a3; font-family: var(--mono); text-decoration: underline dotted; }
.readme { border-left: 2px solid #2c364a; padding: 4px 0 4px 12px; }
.readme p, .readme li { color: #c9d1de !important; font-family: var(--sans); font-size: 14px; line-height: 1.55; }
.readme ol, .readme ul { padding-left: 20px; margin: 4px 0 8px; }
.readme li { margin: 4px 0; }
.r-head { font-size: 15px; margin-bottom: 2px; }
.r-name { color: #7ee0a3; font-weight: 700; font-size: 17px; }
.r-tag { color: #ffb45e; font-size: 12px; margin-bottom: 8px; }
.r-sec { color: #7cc4ff; margin-top: 10px; font-weight: 600; }
.r-links { display: flex; gap: 16px; margin: 10px 0 6px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chips-row span { padding: 2px 8px; border-radius: 999px; background: #1d2433; border: 1px solid #2c364a; font-size: 12px; }
.term-in {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-top: 1px solid #1d2433; background: #0d1118;
}
.term-in .prompt { white-space: nowrap; flex: none; }
.term-in input {
  flex: 1; min-width: 60px; background: none; border: 0; outline: none;
  font: inherit; color: #f3ead8; caret-color: #ffb45e;
}
.term-quick { display: flex; gap: 6px; padding: 0 14px 10px; background: #0d1118; flex-wrap: wrap; }
.term-quick button {
  font-family: var(--mono); font-size: 12px; padding: 3px 10px; border-radius: 6px;
  background: #1d2433; border: 1px solid #2c364a; color: #c9d1de;
}
.term-quick button:hover { border-color: #ffb45e; color: #ffb45e; }

.term-count { margin-left: auto; color: #ffb45e; font-size: 12px; }
.term .pending { visibility: hidden; }
.term .appear { animation: typeIn 0.28s ease-out both; }
@keyframes typeIn { from { opacity: 0; transform: translateX(-6px); clip-path: inset(0 100% 0 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
.term.busy .term-in input { color: #ffd8a8; }
.term.busy .term-in::after { content: '● typing'; color: #7ee0a3; font-size: 11px; animation: flicker 1.2s infinite; }
.term.busy .term-quick button:not(.next-btn) { opacity: 0.4; pointer-events: none; }
.term-quick .next-btn {
  background: #ffb45e; color: #2a1708; border-color: #ffb45e; font-weight: 700;
  animation: nudge 1.6s ease-in-out infinite;
}
.term-quick .next-btn:hover { background: #ffc47d; color: #2a1708; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateX(3px); } }

/* ---------- research book ---------- */
.book { perspective: 1400px; }
.book .page { transform-origin: left center; backface-visibility: hidden; }
.book .page.turn-next { animation: pageNext 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.book .page.turn-prev { animation: pagePrev 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; transform-origin: right center; }
@keyframes pageNext {
  0% { transform: rotateY(-80deg); opacity: 0; box-shadow: -30px 0 40px rgba(0,0,0,0.5); }
  100% { transform: none; opacity: 1; box-shadow: none; }
}
@keyframes pagePrev {
  0% { transform: rotateY(80deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.book-nav {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0 4px; background: linear-gradient(transparent, var(--panel) 35%);
}
.book-nav .turn {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--tint); font-size: 0.88rem;
}
.book-nav .turn.next { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.book-nav .turn:disabled { opacity: 0.35; cursor: default; }
.book-nav .dots { display: flex; gap: 6px; }
.book-nav .dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2); cursor: pointer; }
.book-nav .dots i.on { background: var(--accent); width: 20px; border-radius: 4px; }

/* ---------- skills bookshelf ---------- */
.shelf-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.shelf-tabs button {
  padding: 6px 11px; border-radius: 999px; font-size: 0.8rem;
  border: 1px solid var(--line); background: var(--tint);
}
.shelf-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.shelf-meta { margin: 0; color: var(--muted) !important; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.shelf-name { margin: 2px 0 12px; font-size: 1.25rem; }
.spines {
  display: flex; align-items: flex-end; gap: 4px; flex-wrap: nowrap;
  padding: 14px 12px 0; border-radius: 10px 10px 0 0;
  background: linear-gradient(#2a1f17, #22190f);
  border-bottom: 10px solid #9a6a44;
  box-shadow: inset 0 10px 24px rgba(0,0,0,0.45);
}
.spine {
  --c: #7c5cbf;
  writing-mode: vertical-rl; transform: rotate(180deg);
  height: var(--h); width: 44px; padding: 12px 0;
  flex: 0 1 44px; min-width: 26px; overflow: hidden; /* shrink so a whole shelf fits on one row */
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px 4px 2px 2px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.22) 0 5px, transparent 5px calc(100% - 4px), rgba(0,0,0,0.18) calc(100% - 4px)),
    linear-gradient(rgba(255,236,200,0.5), rgba(255,236,200,0.5)) 0 14px / 100% 3px no-repeat,
    linear-gradient(rgba(255,236,200,0.5), rgba(255,236,200,0.5)) 0 calc(100% - 14px) / 100% 3px no-repeat,
    color-mix(in srgb, var(--c) calc(var(--f) * 100%), black);
  color: #fff6e6; font-weight: 700; font-size: 0.82rem; letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: 0 -2px 0 rgba(255,255,255,0.08) inset;
  animation: pullBook 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d) both;
}
@keyframes pullBook { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }
.shelf-slot .book-nav { position: static; background: none; padding-top: 14px; }
@media (max-width: 820px) {
  .spine { width: 38px; font-size: 0.74rem; height: calc(var(--h) * 0.78); }
}

/* ---------- dialer ---------- */
.dialer {
  margin: 0 auto 18px; max-width: 300px; padding: 18px 18px 16px;
  border-radius: 28px; background: linear-gradient(180deg, #2a201a, #1c1612);
  border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}
.dial-screen { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 14px; text-align: center; }
.dial-status { font-size: 0.78rem; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }
.dialer.done .dial-status { color: var(--green); }
.dial-number { font-family: var(--mono); font-size: 1.6rem; min-height: 2.1rem; letter-spacing: 0.04em; color: var(--ink); }
.dial-number::after { content: '▍'; color: var(--accent); animation: flicker 1s infinite; }
.dialer.done .dial-number::after { content: ''; }
.dial-sub { font-size: 0.75rem; color: var(--muted); }
.dial-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-items: center; }
.dial-pad button {
  width: 62px; height: 62px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--tint); border: 1px solid rgba(243,234,216,0.12);
  transition: background 0.12s, transform 0.12s;
}
.dial-pad button b { font-size: 1.35rem; font-weight: 500; line-height: 1; }
.dial-pad button small { font-size: 0.55rem; letter-spacing: 0.14em; color: var(--muted); min-height: 0.7rem; }
.dial-pad button.hit, .dial-pad button:active { background: var(--accent); color: var(--accent-ink); transform: scale(0.94); }
.dial-pad button.hit small { color: var(--accent-ink); }
.dial-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.dial-call {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 999px; background: #2fbf63; color: #06210f;
  font-weight: 700; text-decoration: none;
  transition: transform 0.15s;
}
.dialer.done .dial-call { animation: ring 1.6s ease-in-out 2; }
.dial-call:hover { transform: translateY(-1px); background: #3ad172; }
.dial-call svg { width: 18px; height: 18px; fill: currentColor; }
.dial-actions .btn { padding: 9px 10px; font-size: 0.85rem; }
@keyframes ring { 0%, 100% { transform: none; } 10%, 30% { transform: rotate(-3deg); } 20%, 40% { transform: rotate(3deg); } 50% { transform: none; } }

/* ---------- simple view ---------- */
#simple { max-width: 820px; margin: 0 auto; padding: 96px 20px 40px; }
.simple-head h2 { font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 8px; }
.plain { padding: 36px 0; border-top: 1px solid var(--line); scroll-margin-top: 70px; }
.site-foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 30px 20px 50px; border-top: 1px solid var(--line); }

/* ---------- music dock ---------- */
#dock {
  position: fixed; left: 16px; bottom: 16px; z-index: 30; width: 272px;
  border: 1px solid var(--line); border-radius: 16px; padding: 10px;
  background: var(--panel); backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
#dock[hidden] { display: none; }
.dock-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dock-info div { flex: 1; min-width: 0; }
.dock-info b { display: block; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-info small { display: block; font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-info button { border: 0; background: none; width: 28px; height: 28px; border-radius: 50%; }
.dock-info button:hover { background: rgba(255,255,255,0.1); }
#dock-media iframe, #dock-media audio { display: block; width: 100%; border: 0; border-radius: 10px; }
#dock-media iframe { aspect-ratio: 16 / 9; height: auto; }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.eq i { width: 3px; background: var(--mood, var(--accent)); animation: eq 0.9s infinite ease-in-out; }
.eq i:nth-child(2) { animation-delay: 0.2s; }
.eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }

/* ---------- no WebGL: plain page only ---------- */
body.no-webgl #stage { display: none; }
body.no-webgl [data-tour], body.no-webgl #music-btn { display: none; }

/* ---------- small screens ---------- */
/* tablet landscape and small laptops: side panel, but slimmer */
@media (min-width: 821px) and (max-width: 1180px) {
  .intro { max-width: 340px; }
  .intro h1 { font-size: clamp(2.2rem, 4.4vw, 3rem); }
  .lede { font-size: 0.95rem; }
  #panel { width: min(400px, 44vw); padding: 80px 22px 16px; }
  #panel.wide { width: min(560px, 54vw); }
  #panel h2 { font-size: 1.6rem; }
  .ls .dir { grid-template-columns: 150px 1fr; }
  .ls .dir em { display: none; }
  .chips button { padding: 6px 10px; font-size: 0.8rem; }
}

/* tablet portrait and phones: panel becomes a bottom sheet */
@media (max-width: 820px) {
  .topbar nav .link { display: none; }
  .intro { top: 84px; max-width: 560px; right: 16px; }
  .intro .lede { font-size: 0.95rem; }
  #panel {
    top: auto; left: 0; width: 100%; height: 52%;
    padding: 20px 24px 14px;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
    transform: translateY(105%);
  }
  #panel.wide { width: 100%; height: 64%; }
  #panel h2 { font-size: 1.6rem; margin-bottom: 12px; }
  .term { min-height: 0; }
  .ls .dir { grid-template-columns: 150px 1fr; }
  .ls .dir em { display: none; }
  .chips { bottom: 40px; }
  .chips button { padding: 6px 10px; font-size: 0.8rem; }
  #dock { left: 8px; right: 8px; width: auto; max-width: 360px; }
  /* with a bottom sheet open, the mini player moves up out of the way */
  body.focused #dock { top: 64px; bottom: auto; }
  .dialer { max-width: 280px; }
}

/* phones */
@media (max-width: 520px) {
  .intro { top: 76px; }
  .intro h1 { font-size: 2.3rem; margin-bottom: 8px; }
  .intro .lede { font-size: 0.88rem; margin-bottom: 12px; }
  .intro .cta .btn { padding: 9px 14px; font-size: 0.88rem; }
  .hotspot { font-size: 0.7rem; padding: 3px 8px 3px 5px; }
  #panel { height: 56%; padding: 18px 20px 14px; }
  #panel.wide { height: 72%; }
  #panel h2 { font-size: 1.5rem; }
  .term { font-size: 12.5px; }
  .ls .dir { grid-template-columns: 1fr; gap: 2px; }
  .term-in .prompt .p-user { display: none; }
  .stats b { font-size: 1rem; }
  .dial-pad button { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
