/* ==========================================================================
   The Bard's Grimoire — styles
   ========================================================================== */

:root {
  --ink: #0f0b12;
  --ink-2: #17111b;
  --panel: #1d1622;
  --panel-2: #251c2b;
  --line: rgba(217, 164, 65, 0.18);
  --line-strong: rgba(217, 164, 65, 0.45);
  --gold: #d9a441;
  --gold-hi: #f3cf7a;
  --ember: #e2683c;
  --parchment: #f1e6cf;
  --muted: #b3a38c;
  --faint: #7d6f60;

  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 4.5rem;
  --dock-h: 0px;
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1500px;

  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-deco: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --focus: 0 0 0 3px var(--ink), 0 0 0 6px var(--gold-hi), 0 0 28px 6px rgba(243, 207, 122, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: var(--dock-h);
}
body.has-dock { --dock-h: 5.5rem; }
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }
kbd {
  font-family: var(--font-body); font-size: .85em;
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 6px; padding: 0 .4em; color: var(--gold-hi);
}
[hidden] { display: none !important; }

/* focus — mouse users get a subtle ring, keyboard/remote users get a big glow */
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); }
body.keys :focus { box-shadow: var(--focus); }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(226, 104, 60, .16), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(120, 70, 170, .18), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(217, 164, 65, .08), transparent 60%),
    linear-gradient(180deg, #120d16 0%, var(--ink) 60%);
}
.bg::after { /* parchment grain */
  content: ""; position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .4 0 0 0 0 .3 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.bg-glow {
  position: absolute; width: 60vmax; height: 60vmax; left: 50%; top: -30vmax; translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle, hsla(var(--theme-hue, 38), 80%, 55%, .16), transparent 65%);
  transition: background 1.2s ease;
}
.bg-embers { position: absolute; inset: 0; }
.bg-embers i {
  position: absolute; bottom: -10px; width: 3px; height: 3px; border-radius: 50%;
  background: var(--gold-hi); box-shadow: 0 0 8px 2px rgba(243, 160, 70, .7);
  opacity: 0; animation: ember linear infinite;
}
@keyframes ember {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: .9; }
  100% { transform: translate(var(--drift, 40px), -105vh); opacity: 0; }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0 var(--gutter);
  background: linear-gradient(180deg, rgba(15, 11, 18, .96), rgba(15, 11, 18, .82));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: .7rem; text-decoration: none; flex-shrink: 0;
  border-radius: var(--radius-sm); padding: .3rem .4rem;
}
.brand-die { width: 2.3rem; height: 2.3rem; color: var(--gold); filter: drop-shadow(0 0 10px rgba(217, 164, 65, .45)); transition: transform .8s cubic-bezier(.2, .9, .2, 1.2); }
.brand:hover .brand-die { transform: rotate(180deg); }
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: .04em; white-space: nowrap; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; }
/* ✎ next to the site name: rename it for this browser */
.brand-edit {
  flex-shrink: 0; width: 1.9rem; height: 1.9rem; margin-left: -.9rem; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer; background: none; color: var(--faint); opacity: 0; transition: opacity .2s, color .2s;
}
.brand-edit svg { width: .95rem; height: .95rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topbar:hover .brand-edit, .brand-edit:focus-visible { opacity: 1; }
.brand-edit:hover { color: var(--gold-hi); background: rgba(255, 255, 255, .06); }
@media (hover: none) { .brand-edit { opacity: .6; } }
.brand-text em { font-family: var(--font-deco); font-style: normal; color: var(--gold-hi); }

.search {
  flex: 1; min-width: 0; max-width: 34rem; margin-left: auto;
  display: flex; align-items: center; gap: .6rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0 1rem; height: 2.75rem;
  transition: border-color .2s, background .2s;
}
.search:focus-within { border-color: var(--gold); background: rgba(255, 255, 255, .07); }
.search svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0; height: 100%; background: none; border: 0; color: var(--parchment);
  font: inherit; font-size: 1rem;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { box-shadow: none; }
body.keys .search:focus-within { box-shadow: var(--focus); }

.top-actions { display: flex; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  height: 2.75rem; padding: 0 1rem;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03); cursor: pointer;
  text-decoration: none; font-weight: 500; white-space: nowrap;
  transition: border-color .2s, background .2s, color .2s;
}
.chip svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chip:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .07); }
.chip[aria-pressed="true"], .chip.active { color: var(--gold-hi); border-color: var(--gold); background: rgba(217, 164, 65, .12); }
/* hover-sounds toggle: speaker with waves + a sparkle when on, a cross when off */
.chip-icon { width: 2.75rem; padding: 0; justify-content: center; }
.chip-icon .sfx-off { display: none; }
.chip-icon[aria-pressed="false"] .sfx-on { display: none; }
.chip-icon[aria-pressed="false"] .sfx-off { display: inline; }
.chip-icon[aria-pressed="false"] { color: var(--faint); border-color: var(--line); background: rgba(255, 255, 255, .03); }

/* play-mode switch: integrated player vs. open on YouTube */
.segmented {
  display: flex; height: 2.75rem; padding: 3px; gap: 2px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
}
.segmented button {
  display: inline-flex; align-items: center; gap: .4rem; padding: 0 .85rem;
  border: 0; border-radius: 999px; background: none; cursor: pointer;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  transition: background .2s, color .2s;
}
.segmented button:hover { color: var(--parchment); }
.segmented button[aria-pressed="true"] {
  color: #1b1206; background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.segmented svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.segmented svg .fill { fill: currentColor; stroke: none; }

/* in YouTube mode the card hover hint shows an "open externally" arrow */
.play-hint .i-ext { display: none; }
body.mode-yt .play-hint .i-play { display: none; }
body.mode-yt .play-hint .i-ext { display: block; margin-left: 0; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) 3rem; outline: none; }
main.enter { animation: pageIn .45s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- hero ---------- */
.hero {
  position: relative; text-align: center;
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(1.5rem, 4vw, 3rem);
}
.hero-circle {
  position: absolute; left: 50%; top: 50%; width: min(620px, 92vw); aspect-ratio: 1;
  translate: -50% -52%; z-index: -1; opacity: .22; color: var(--gold);
  animation: spin 160s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
.eyebrow {
  font-family: var(--font-display); letter-spacing: .32em; text-transform: uppercase;
  font-size: .8rem; color: var(--gold); margin: 0 0 .9rem;
}
.hero h1 {
  font-family: var(--font-deco); font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 4.8rem); line-height: 1.05; margin: 0;
  background: linear-gradient(180deg, #fff3d6 10%, var(--gold) 70%, #a8702a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(217, 164, 65, .15);
}
.hero p.lede { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.3rem); max-width: 40rem; margin: 1rem auto 1.8rem; }
.hero-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  height: 3.1rem; padding: 0 1.5rem; border-radius: 999px;
  font-family: var(--font-display); font-weight: 600; letter-spacing: .06em; font-size: .95rem;
  text-decoration: none; cursor: pointer; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .04); transition: transform .15s, background .2s, border-color .2s, box-shadow .2s;
}
.btn svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.btn:hover { background: rgba(255, 255, 255, .09); border-color: var(--gold); }
.btn:active { transform: scale(.97); }
.btn-gold {
  color: #1b1206; border-color: transparent;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #b27b2c);
  box-shadow: 0 6px 24px -6px rgba(217, 164, 65, .6), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-gold:hover { background: linear-gradient(180deg, #ffe39c, var(--gold-hi) 55%, var(--gold)); }
.btn.rolling svg { animation: roll .8s cubic-bezier(.2, .8, .3, 1); }
@keyframes roll { to { transform: rotate(720deg) scale(1); } 50% { transform: rotate(360deg) scale(1.35); } }

/* ---------- big home search + hashtag chips ---------- */
body.on-home .topbar .search { display: none; }
.top-actions { margin-left: auto; }

.hero-search { max-width: 48rem; margin: 0 auto 1.8rem; }
.big-search {
  display: flex; align-items: center; gap: .8rem;
  height: 3.9rem; padding: 0 .6rem 0 1.4rem; border-radius: 999px;
  background: rgba(15, 11, 18, .72);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px -20px #000, inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: border-color .2s, box-shadow .2s;
}
.big-search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(217, 164, 65, .18), 0 16px 40px -20px #000; }
.big-search svg { width: 1.45rem; height: 1.45rem; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.big-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--parchment);
  font: inherit; font-size: 1.15rem;
}
.big-search input::placeholder { color: var(--faint); }
.big-search input:focus { box-shadow: none; }
.big-search input::-webkit-search-cancel-button { display: none; }
.clear-search {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; cursor: pointer; flex-shrink: 0;
  background: rgba(255, 255, 255, .06); color: var(--muted); font-size: 1rem;
}
.clear-search:hover { background: rgba(255, 255, 255, .12); color: var(--parchment); }

.tag-cloud, .related { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; margin-top: 1rem; }
.related { justify-content: flex-start; align-items: center; margin: -.2rem 0 1.4rem; }
.related > span { color: var(--faint); font-style: italic; margin-right: .2rem; }
.tag-chip {
  height: 2.1rem; padding: 0 .85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  color: var(--muted); font: inherit; font-size: .92rem; font-weight: 500;
  transition: color .15s, background .15s, border-color .15s, transform .15s;
}
.tag-chip:hover, .tag-chip:focus { color: var(--gold-hi); border-color: var(--gold); background: rgba(217, 164, 65, .1); }
.tag-chip[aria-pressed="true"] { color: #1b1206; border-color: transparent; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); }
.tag-chip.more { border-style: dashed; color: var(--faint); }

/* while searching, fold the hero down so results sit right under the box */
.hero.searching { padding-top: 1.6rem; padding-bottom: 0; }
.hero.searching .hero-circle, .hero.searching .eyebrow, .hero.searching h1,
.hero.searching .lede, .hero.searching .hero-actions { display: none; }
.hero.searching .hero-search { margin-bottom: 0; }
.results { margin-top: 1.6rem; }
.results-actions { justify-content: flex-start; margin: -.2rem 0 1.1rem; }

/* hashtags under each video card */
.card-tags { display: flex; flex-wrap: wrap; gap: .15rem .55rem; margin: .3rem .15rem 0; font-size: .82rem; color: hsla(38, 60%, 62%, .8); }

/* ---------- sections ---------- */
.section { margin-top: clamp(2rem, 5vw, 3.5rem); }
.section-head { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1.1rem; }
.section-head h2 {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  margin: 0; letter-spacing: .03em; color: var(--parchment);
}
.section-head p { margin: 0 0 .15rem; color: var(--faint); font-style: italic; }
.section-head::after {
  content: ""; flex: 1; height: 1px; margin-bottom: .55rem;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

/* ---------- theme cards ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 1rem; }
.theme-card {
  --h: 38; --c: hsl(var(--h) 75% 62%); --c-soft: hsla(var(--h), 75%, 55%, .16);
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1rem;
  padding: 1.1rem 1.15rem; min-height: 6.4rem;
  text-decoration: none; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-2), var(--panel) 60%);
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px -18px #000;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1.2), border-color .22s, box-shadow .22s;
}
.theme-card::before { /* colored wash */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 140% at 0% 50%, var(--c-soft), transparent 55%);
  transition: opacity .3s; opacity: .8;
}
.theme-card::after { /* inner gilded border */
  content: ""; position: absolute; inset: 5px; border-radius: calc(var(--radius) - 5px);
  border: 1px solid transparent; transition: border-color .25s; pointer-events: none;
}
.theme-card:hover, .theme-card:focus { transform: translateY(-3px); border-color: hsla(var(--h), 70%, 60%, .5); }
.theme-card:hover::before, .theme-card:focus::before { opacity: 1.4; }
.theme-card:hover::after, .theme-card:focus::after { border-color: hsla(var(--h), 70%, 70%, .25); }
.theme-card:hover .sigil svg, .theme-card:focus .sigil svg { transform: scale(1.1) rotate(-6deg); }
.sigil {
  width: 3.6rem; height: 3.6rem; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, hsla(var(--h), 70%, 60%, .3), hsla(var(--h), 60%, 20%, .35));
  border: 1px solid hsla(var(--h), 70%, 60%, .35);
  box-shadow: 0 0 22px -4px hsla(var(--h), 80%, 55%, .5);
  color: var(--c);
}
.sigil svg { width: 62%; height: 62%; transition: transform .35s cubic-bezier(.2, .8, .3, 1.4); filter: drop-shadow(0 0 6px hsla(var(--h), 80%, 60%, .6)); }
.theme-card h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.12rem; letter-spacing: .02em; line-height: 1.2; }
.theme-card p { margin: .2rem 0 0; color: var(--muted); font-size: .93rem; line-height: 1.3; }
.theme-card .count { font-size: .78rem; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-top: .35rem; }

/* ---------- theme page header ---------- */
.theme-hero {
  --h: 38;
  display: grid; grid-template-columns: auto 1fr; gap: clamp(1rem, 3vw, 2rem); align-items: center;
  padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem;
}
.theme-hero .sigil { width: clamp(5rem, 11vw, 7.5rem); height: clamp(5rem, 11vw, 7.5rem); color: hsl(var(--h) 75% 64%); }
.crumb { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); text-decoration: none; font-size: .95rem; padding: .2rem .5rem; margin-left: -.5rem; border-radius: 8px; }
.crumb:hover { color: var(--gold-hi); }
.theme-hero h1 { margin: .25rem 0 .2rem; font-family: var(--font-deco); font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; color: #fff4dc; }
.theme-hero .tagline { margin: 0 0 1.2rem; color: var(--muted); font-size: 1.15rem; font-style: italic; }
.theme-hero .hero-actions { justify-content: flex-start; }

/* ---------- video cards ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr)); gap: 1.4rem 1.1rem; }
.video-card {
  display: block; text-align: left; padding: 0; margin: 0; border: 0; background: none; cursor: pointer;
  border-radius: var(--radius); position: relative;
  transition: transform .2s cubic-bezier(.2, .8, .3, 1.2);
}
.video-card:hover, .video-card:focus { transform: translateY(-4px); }
.thumb {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden;
  background: var(--panel) center/cover no-repeat;
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 14px 30px -18px #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s, filter .3s; filter: saturate(.92) brightness(.92); }
.video-card:hover .thumb img, .video-card:focus .thumb img { transform: scale(1.05); filter: saturate(1.05) brightness(1); }
.thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .55)); }
.badge {
  position: absolute; right: .55rem; bottom: .55rem; z-index: 1;
  font-size: .8rem; font-weight: 700; letter-spacing: .03em;
  padding: .1rem .45rem; border-radius: 6px; background: rgba(10, 7, 12, .82); color: var(--parchment);
}
/* chart position on the Most Popular page */
.rank {
  position: absolute; left: .55rem; top: .55rem; z-index: 2;
  min-width: 2.1rem; height: 2.1rem; padding: 0 .45rem; border-radius: 999px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: #1b1206;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .8);
}
.play-hint {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; opacity: 0; transition: opacity .2s;
}
.play-hint span {
  width: 3.6rem; height: 3.6rem; border-radius: 50%; display: grid; place-items: center;
  background: rgba(217, 164, 65, .92); color: #1b1206; box-shadow: 0 0 30px rgba(217, 164, 65, .6);
}
.play-hint svg { width: 1.6rem; height: 1.6rem; fill: currentColor; margin-left: 3px; }
.video-card:hover .play-hint, .video-card:focus .play-hint { opacity: 1; }
.video-card h3 {
  margin: .7rem .15rem .15rem; font-family: var(--font-body); font-weight: 700; font-size: 1.02rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-card .meta { margin: 0 .15rem; color: var(--faint); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-card .meta .tag { color: var(--gold); }

/* now playing state on a card */
.eq { display: none; position: absolute; left: .6rem; bottom: .6rem; z-index: 2; gap: 3px; align-items: flex-end; height: 1.1rem; padding: .25rem .4rem; border-radius: 6px; background: rgba(10, 7, 12, .8); box-sizing: content-box; }
.eq i { width: 3px; background: var(--gold-hi); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; } .eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
.video-card.is-playing .eq { display: flex; }
.video-card.is-playing .thumb { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 26px -4px rgba(217, 164, 65, .55); }
body.paused .eq i { animation-play-state: paused; }

/* horizontal shelf (recently played) */
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(15rem, 17rem); gap: 1.1rem; overflow-x: auto; padding: .6rem .6rem 1rem; margin: -.6rem -.6rem 0; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.shelf > * { scroll-snap-align: start; }

.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty h2 { font-family: var(--font-display); color: var(--parchment); }

/* ---------- footer ---------- */
.site-footer { max-width: var(--maxw); margin: 0 auto; padding: 2rem var(--gutter) 3rem; color: var(--faint); font-size: .9rem; text-align: center; border-top: 1px solid var(--line); }
.site-footer p { margin: .35rem 0; }
.site-footer a { color: var(--muted); }
.remote-hint { display: none; }
body.tv .remote-hint, body.keys .remote-hint { display: block; color: var(--muted); }

/* ---------- stage (video) ---------- */
.stage {
  position: fixed; z-index: 45; right: var(--gutter); bottom: calc(var(--dock-h) + 1rem);
  width: 20rem; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden;
  background: #000; border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -10px #000, 0 0 0 1px rgba(0, 0, 0, .6);
  transition: all .45s cubic-bezier(.2, .8, .2, 1);
  opacity: 0; transform: translateY(20px) scale(.96); pointer-events: none;
}
body.has-dock .stage { opacity: 1; transform: none; pointer-events: auto; }
body.stage-hidden .stage { opacity: 0; transform: translateY(20px) scale(.96); pointer-events: none; }
.stage-frame, .stage-frame iframe, #yt { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage-expand {
  position: absolute; top: .5rem; right: .5rem; z-index: 2; width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(10, 7, 12, .75); color: var(--parchment); opacity: 0; transition: opacity .2s;
}
.stage:hover .stage-expand { opacity: 1; }
.stage-expand svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

body.theater { overflow: hidden; }
body.theater .stage { inset: 0; right: 0; bottom: 0; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; border: 0; z-index: 60; opacity: 1; transform: none; pointer-events: auto; }
body.theater .stage-expand { display: none; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: var(--dock-h);
  background: linear-gradient(180deg, rgba(29, 22, 34, .94), rgba(15, 11, 18, .98));
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -20px 40px -20px #000;
  animation: dockIn .45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes dockIn { from { transform: translateY(100%); } }
body.theater .dock { z-index: 70; background: linear-gradient(180deg, rgba(15, 11, 18, .55), rgba(15, 11, 18, .92)); border-top-color: transparent; transition: transform .4s, opacity .4s; }
body.theater.idle .dock { transform: translateY(100%); opacity: 0; }
body.theater.idle { cursor: none; }

.dock-progress { position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: rgba(255, 255, 255, .06); cursor: pointer; }
.dock-progress:hover { height: 6px; top: -3px; }
.dock-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--ember), var(--gold-hi)); box-shadow: 0 0 10px rgba(243, 207, 122, .6); }

.dock-inner {
  height: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1rem;
}
.dock-meta { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.dock-sigil { --h: 38; flex-shrink: 0; }
.dock-sigil .sigil { width: 3rem; height: 3rem; }
.dock-text { min-width: 0; }
.dock-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub .dot { margin: 0 .4rem; color: var(--faint); }
.dock-controls, .dock-extra { display: flex; align-items: center; gap: .35rem; }
.dock-extra { justify-content: flex-end; }

.ctl {
  width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 1px solid transparent; background: none;
  display: grid; place-items: center; cursor: pointer; color: var(--muted);
  transition: color .2s, background .2s, transform .12s, border-color .2s;
}
.ctl:hover { color: var(--parchment); background: rgba(255, 255, 255, .07); }
.ctl:active { transform: scale(.92); }
.ctl svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctl svg .fill { fill: currentColor; stroke: none; }
.ctl svg text { fill: currentColor; stroke: none; font-family: var(--font-body); font-weight: 700; }
.ctl[aria-pressed="true"] { color: var(--gold-hi); }
.ctl[aria-pressed="true"]::after { content: ""; position: absolute; }
#btnFav[aria-pressed="true"] svg { fill: var(--ember); stroke: var(--ember); }
#btnLoop .loop-1 { opacity: 0; }
#btnLoop[aria-pressed="true"] .loop-1 { opacity: 1; }
/* auto-change timer: grows into a pill showing the countdown when on */
.ctl-timer { display: flex; align-items: center; justify-content: center; gap: .3rem; width: auto; min-width: 2.8rem; padding: 0 .7rem; border-radius: 999px; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ctl-timer[aria-pressed="true"] { border-color: rgba(217, 164, 65, .45); background: rgba(217, 164, 65, .1); }
#timerLabel:empty { display: none; }
.ctl-main {
  width: 3.4rem; height: 3.4rem; color: #1b1206;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); box-shadow: 0 4px 18px -4px rgba(217, 164, 65, .7);
}
.ctl-main:hover { color: #1b1206; background: linear-gradient(180deg, #ffe39c, var(--gold-hi)); }
.ctl-main svg { width: 1.5rem; height: 1.5rem; }
.ctl-main .i-pause { display: none; }
body.playing .ctl-main .i-play { display: none; }
body.playing .ctl-main .i-pause { display: block; }

.vol { width: 6rem; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); cursor: pointer; position: relative; }
.vol::before { content: ""; position: absolute; inset: -10px 0; }
.vol-fill { height: 100%; width: 60%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-hi)); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--header-h) + 1rem); z-index: 90;
  translate: -50% -20px; opacity: 0; pointer-events: none;
  padding: .7rem 1.2rem; border-radius: 999px;
  background: rgba(29, 22, 34, .96); border: 1px solid var(--line-strong);
  box-shadow: 0 12px 30px -10px #000; font-weight: 500;
  transition: opacity .25s, translate .25s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ==========================================================================
   Editing lists, the queue, and dialogs
   ========================================================================== */
.btn svg[fill="none"] { fill: none; }
.btn-queue svg { fill: none; }

/* card wrapper + its tool buttons (drag handle, add to queue, remove) */
.vc { position: relative; }
.card-tools {
  position: absolute; top: .5rem; right: .5rem; z-index: 3;
  display: flex; gap: .3rem; opacity: 0; transition: opacity .15s;
}
.vc:hover .card-tools, .vc:focus-within .card-tools, .editing .card-tools, .dragging .drag-chosen .card-tools { opacity: 1; }
.tool {
  width: 2.1rem; height: 2.1rem; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .14);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  background: rgba(12, 9, 14, .82); color: var(--parchment); backdrop-filter: blur(4px);
  transition: background .15s, color .15s, border-color .15s;
}
.tool svg { width: 1.15rem; height: 1.15rem; }
.tool:hover { background: rgba(217, 164, 65, .95); color: #1b1206; border-color: transparent; }
.drag-handle { cursor: grab; touch-action: none; }
/* touch screens have no hover: keep "add to queue" visible, show drag handles in edit mode */
@media (hover: none) {
  .card-tools { opacity: 1; }
  .card-tools .drag-handle { display: none; }
  .editing .card-tools .drag-handle { display: grid; }
}
.dragging, .dragging * { cursor: grabbing !important; }
.tool-remove { font-size: .95rem; font-weight: 700; }
.tool-remove:hover { background: #c4452f; color: #fff; }
.card-tools .tool-remove { display: none; }
.editing .card-tools .tool-remove { display: grid; }
.editing .vc { animation: wiggle .5s ease; }
@keyframes wiggle { 30% { transform: rotate(-.6deg); } 60% { transform: rotate(.6deg); } }
.drag-ghost { opacity: .35; }
.drag-ghost .thumb { outline: 2px dashed var(--gold); outline-offset: 2px; }
.drag-active { transform: rotate(2deg) scale(1.03); box-shadow: 0 30px 60px -20px #000; opacity: .95 !important; z-index: 100; }
body.mode-yt .tool-queue, body.mode-yt .btn-queue, body.mode-yt .ctl-queue { display: none; }

/* "New theme" / "Add YouTube links" cards */
.add-card { font: inherit; color: inherit; text-align: left; cursor: pointer; border-style: dashed; border-color: var(--line-strong); background: rgba(255, 255, 255, .02); }
.add-card .sigil svg { fill: none; }

.edit-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-top: 1rem;
  padding: .6rem .9rem; border-radius: var(--radius-sm); border: 1px dashed var(--line-strong);
  color: var(--muted); font-size: .92rem; background: rgba(217, 164, 65, .05);
}
.edit-bar svg { width: 1rem; height: 1rem; display: inline-block; vertical-align: -3px; color: var(--gold); }
.link-btn {
  border: 0; background: none; padding: .25rem .4rem; border-radius: 6px; cursor: pointer;
  color: var(--gold-hi); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { background: rgba(217, 164, 65, .12); }
.link-btn.danger { color: #f08a72; }

/* queue button in the player bar */
.ctl-queue { position: relative; }
.q-badge {
  position: absolute; top: 2px; right: 0; min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem;
  border-radius: 999px; background: var(--ember); color: #fff; font-size: .7rem; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.q-badge:empty { display: none; }

/* queue panel */
.queue-panel {
  position: fixed; right: 0; top: 0; bottom: var(--dock-h); z-index: 55;
  width: min(27rem, 100vw); display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(29, 22, 34, .98), rgba(15, 11, 18, .99));
  border-left: 1px solid var(--line-strong); box-shadow: -30px 0 60px -30px #000;
  transform: translateX(105%); transition: transform .35s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
body.queue-open .queue-panel { transform: none; visibility: visible; }
body.queue-open .stage { right: calc(min(27rem, 100vw) + 1rem); } /* keep the video visible beside the panel */
.queue-head { display: flex; align-items: center; gap: .3rem; padding: 1rem 1rem .6rem 1.25rem; border-bottom: 1px solid var(--line); }
.queue-head h2 { margin: 0 auto 0 0; font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .04em; }
.queue-body { overflow-y: auto; padding: .4rem .8rem 1.4rem; flex: 1; }
.queue-body h3 {
  margin: 1.1rem .45rem .45rem; font-family: var(--font-display); font-size: .82rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold);
}
.queue-body h3 span { color: var(--faint); margin-left: .3rem; }
.q-row { display: flex; align-items: center; gap: .3rem; border-radius: var(--radius-sm); }
.q-row .tool { flex-shrink: 0; opacity: .75; }
.q-row:hover .tool, .q-row:focus-within .tool { opacity: 1; }
.q-play {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; padding: .4rem .45rem;
  border: 0; border-radius: var(--radius-sm); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.q-play:hover { background: rgba(255, 255, 255, .06); }
.q-play:disabled { cursor: default; background: rgba(217, 164, 65, .1); }
.q-play img { width: 4.2rem; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.q-text { min-width: 0; display: flex; flex-direction: column; }
.q-text b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-text small { color: var(--faint); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-empty { color: var(--muted); font-size: .92rem; margin: .3rem .45rem; }
.q-empty svg { width: 1.05rem; height: 1.05rem; display: inline-block; vertical-align: -3px; }

/* dialogs */
.modal {
  position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 4, 8, .72); backdrop-filter: blur(6px); animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  width: min(40rem, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 1.6rem 1.6rem 1.3rem; border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong); box-shadow: 0 40px 80px -30px #000;
  animation: popIn .25s cubic-bezier(.2, .8, .2, 1.2);
}
@keyframes popIn { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-card h2 { margin: 0 0 1rem; font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .03em; }
.muted { color: var(--muted); margin: -.4rem 0 1rem; }
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 700; margin-bottom: .35rem; }
.field > span em { font-weight: 400; color: var(--faint); }
.field small { display: block; margin-top: .35rem; color: var(--faint); }
.field input, .field textarea, .field select {
  width: 100%; font: inherit; color: var(--parchment);
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line-strong); border-radius: 10px; padding: .65rem .8rem;
}
.field textarea { resize: vertical; min-height: 6rem; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.field select option, .field select optgroup { background: var(--panel); color: var(--parchment); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 164, 65, .2); }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: .35rem; max-height: 9.5rem; overflow-y: auto; padding: 2px; }
.pick-icon {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.pick-icon svg { width: 62%; height: 62%; }
.pick-icon:hover { color: var(--parchment); }
.pick-icon[aria-pressed="true"] { color: hsl(var(--h) 75% 64%); border-color: hsl(var(--h) 70% 55%); background: hsla(var(--h), 70%, 50%, .15); }
.hue-pick { display: flex; flex-wrap: wrap; gap: .45rem; }
.pick-hue {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
  background: radial-gradient(circle at 35% 30%, hsl(var(--h) 80% 70%), hsl(var(--h) 65% 42%));
}
.pick-hue[aria-pressed="true"] { border-color: var(--parchment); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px hsl(var(--h) 70% 60%); }
.form-status { min-height: 1.4em; color: var(--gold-hi); margin: .2rem 0 .8rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.modal-actions .btn:disabled { opacity: .6; cursor: progress; }

/* ---------- safe deleting: undo, confirmations, ownership, Recently deleted ---------- */
.toast { display: flex; align-items: center; gap: .8rem; max-width: calc(100vw - 32px); }
.toast.has-action { pointer-events: auto; padding-right: .5rem; }
.toast-btn {
  flex-shrink: 0; border: 0; border-radius: 999px; padding: .35rem .95rem; cursor: pointer;
  font: inherit; font-weight: 700; color: #1b1206; background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.btn-danger { color: #fff; border-color: transparent; background: linear-gradient(180deg, #d8573d, #a93a26); }
.btn-danger:hover { background: linear-gradient(180deg, #e8674c, #bb4630); border-color: transparent; }
.confirm-text { margin: 0 0 1.3rem; line-height: 1.5; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.section-head::after { order: 2; }
.section-link { order: 3; margin-bottom: .2rem; color: var(--gold); font-size: .92rem; white-space: nowrap; text-underline-offset: 3px; }
.lock-note {
  margin: 1rem 0 0; padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .95rem;
  color: var(--muted); background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
}
.check { display: flex; gap: .7rem; align-items: flex-start; margin: .2rem 0 1rem; cursor: pointer; line-height: 1.4; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; accent-color: var(--gold); flex-shrink: 0; }
.check small { display: block; color: var(--faint); margin-top: .2rem; }

.trash-list { display: flex; flex-direction: column; gap: .6rem; max-width: 60rem; }
.trash-row {
  display: flex; align-items: center; gap: 1rem; padding: .7rem .9rem; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-2), var(--panel)); border: 1px solid rgba(255, 255, 255, .06);
}
.trash-art { flex-shrink: 0; width: 7rem; display: grid; place-items: center; }
.trash-art img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.trash-art .sigil { width: 3.4rem; height: 3.4rem; }
.trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trash-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-text small { color: var(--faint); }
@media (max-width: 520px) { .trash-art { width: 4.5rem; } .trash-row { gap: .6rem; } }

/* ---------- scene effects (js/effects.js) ---------- */
/* above the page but below the header, player and dialogs; never catches clicks */
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 30; pointer-events: none; opacity: 0; transition: opacity .5s ease; }
body.theater .fx { z-index: 65; } /* over the full-screen video too */
.chip-icon .fx-off { display: none; }
.chip-icon[aria-pressed="false"] .fx-on { display: none; }
.chip-icon[aria-pressed="false"] .fx-off { display: inline; }
#fxToggle svg path { fill: currentColor; stroke: none; }
#fxToggle svg .fx-off { fill: none; stroke: currentColor; stroke-width: 1.6; }

/* critical hit: golden stars and dice fly out of the roll button */
.crit-p { position: absolute; margin: -6px 0 0 -6px; pointer-events: none; animation: crit 1.1s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes crit {
  0% { transform: translate(0, 0) scale(.4) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) scale(1) rotate(var(--rot)); opacity: 0; }
}
.crit-star { width: 12px; height: 12px; background: #ffe39c; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); filter: drop-shadow(0 0 6px #ffd76a); }
.crit-die { font-size: 16px; line-height: 1; color: #d9a441; text-shadow: 0 0 8px rgba(255, 215, 106, .9); }
.crit-text, .fumble-text {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-family: var(--font-deco); font-weight: 700; letter-spacing: .06em;
}
.crit-text { font-size: 2.4rem; color: #ffe39c; text-shadow: 0 0 18px rgba(255, 200, 80, .9), 0 3px 0 #7a4a10; animation: critText 1.6s ease-out forwards; }
@keyframes critText { 0% { transform: translate(-50%, -30%) scale(.3); opacity: 0; } 20% { transform: translate(-50%, -120%) scale(1.15); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }
.fumble-text { font-size: 1.5rem; color: #b8aca0; text-shadow: 0 2px 0 #000; animation: fumbleText 1.6s ease-in forwards; }
@keyframes fumbleText { 0% { transform: translate(-50%, -150%); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, 60%) rotate(8deg); opacity: 0; } }
/* critical fumble: the button slips and the page shudders */
.fumbling { animation: fumble .9s cubic-bezier(.3, .1, .3, 1); }
@keyframes fumble { 20% { transform: translateY(6px) rotate(-6deg); } 40% { transform: translateY(2px) rotate(5deg); } 60% { transform: translateY(5px) rotate(-3deg); } 80% { transform: rotate(1deg); } }
.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }

/* page turn: a copy of the old page swings away on its spine */
.page-turn {
  position: fixed; z-index: 35; overflow: hidden; pointer-events: none;
  background: linear-gradient(180deg, #16101a, var(--ink));
  box-shadow: 0 0 40px rgba(0, 0, 0, .6);
  animation: turnFwd .65s cubic-bezier(.5, .05, .6, .95) forwards;
  transform-origin: left center; backface-visibility: hidden;
}
.page-turn::after { /* the page darkens as it turns away from the light */
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .55));
  animation: turnShade .65s ease-in forwards;
}
.page-turn.turn-back { transform-origin: right center; animation-name: turnBack; }
.page-turn.turn-back::after { background: linear-gradient(270deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .55)); }
@keyframes turnFwd { from { transform: perspective(1800px) rotateY(0); } to { transform: perspective(1800px) rotateY(-96deg); opacity: .6; } }
@keyframes turnBack { from { transform: perspective(1800px) rotateY(0); } to { transform: perspective(1800px) rotateY(96deg); opacity: .6; } }
@keyframes turnShade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- easter egg: Bag of Tricks ---------- */
.brand.rolling .brand-die { animation: roll .8s cubic-bezier(.2, .8, .3, 1); }
.trick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .6rem; margin-bottom: 1.1rem; }
.trick {
  display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .9rem .5rem;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.trick img { width: 2.6rem; height: 2.6rem; image-rendering: auto; }
.trick-arrow { font-size: 1.8rem; line-height: 2.6rem; color: var(--parchment); }
.trick:hover { border-color: var(--line-strong); color: var(--parchment); }
.trick[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-hi); background: rgba(217, 164, 65, .12); box-shadow: 0 0 22px -6px rgba(217, 164, 65, .6); }

/* the magical trail: particles spawned at the cursor that drift and fade */
.trail { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.trail-p { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; animation: trail .8s ease-out forwards; }
@keyframes trail { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.trail-sparkle { width: 7px; height: 7px; border-radius: 0; background: #ffe39c; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); filter: drop-shadow(0 0 4px #ffd76a); animation-duration: .9s; }
.trail-ember { background: #ff9d2e; box-shadow: 0 0 8px 2px rgba(255, 140, 40, .75); animation-duration: 1s; }
.trail-glint { width: 10px; height: 2px; border-radius: 2px; background: #eef0f6; box-shadow: 0 0 6px #fff; transform: rotate(45deg); animation-duration: .5s; }
.trail-ink { background: #2a3a6a; width: 5px; height: 7px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; animation-duration: .9s; }
.trail-pips { width: auto; height: auto; background: none; font-size: 13px; color: #f3cf7a; text-shadow: 0 0 6px rgba(217, 164, 65, .8); animation-duration: .9s; }

/* ---------- browsing a big library ---------- */
.browse-chips, .tag-wall { display: flex; flex-wrap: wrap; gap: .5rem; }
.browse-chips .tag-chip, .tag-wall .tag-chip { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; }
.browse-chips .tag-chip { height: 2.5rem; padding: 0 1rem; font-size: .98rem; color: var(--parchment); }
.chip-count {
  min-width: 1.5rem; padding: 0 .4rem; border-radius: 999px; font-size: .75rem; font-weight: 700; text-align: center;
  background: rgba(255, 255, 255, .08); color: var(--muted);
}
.tag-chip[aria-pressed="true"] .chip-count { background: rgba(0, 0, 0, .15); color: #1b1206; }
.see-all { border-style: dashed; border-color: var(--line-strong); background: rgba(217, 164, 65, .04); }
.see-all .sigil svg { fill: none; }
.tag-chip.more { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------- share & move ---------- */
.section-links { order: 3; display: flex; gap: 1rem; flex-wrap: wrap; }
.copy-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.copy-row input {
  flex: 1; min-width: 0; font: inherit; font-size: .88rem; color: var(--muted);
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line-strong); border-radius: 10px; padding: .6rem .8rem;
}
.share-grid { display: grid; grid-template-columns: auto 1fr; gap: 1.2rem; align-items: start; margin-bottom: 1rem; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: .4rem; width: 11rem; }
.qr-box small { color: var(--faint); text-align: center; font-size: .8rem; }
.qr { width: 11rem; min-height: 11rem; display: grid; place-items: center; text-align: center; font-size: .85rem; color: var(--ink);
  background: #fff; border-radius: 12px; padding: .5rem; }
.qr svg { width: 100%; height: auto; }
.steps { font-size: .95rem; color: var(--muted); }
.steps b { color: var(--parchment); }
.steps ol { margin: .5rem 0; padding-left: 1.2rem; }
.steps li { margin: .25rem 0; }
.steps small { color: var(--faint); }
@media (max-width: 560px) { .share-grid { grid-template-columns: 1fr; justify-items: center; } }

.import-eyebrow { margin: .6rem 0 0; text-align: left; }
.import-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; opacity: .85; }
.import-strip img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; }
.import-list { margin: 0 0 1rem; padding-left: 1.3rem; color: var(--parchment); }
.import-list li { margin: .25rem 0; }

.transfer { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1.1rem; }
.t-card {
  padding: 1.3rem 1.4rem; border-radius: var(--radius); border: 1px solid rgba(255, 255, 255, .07);
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
}
.t-wide { grid-column: 1 / -1; }
.t-card h2 { margin: 0 0 .5rem; font-family: var(--font-display); font-size: 1.2rem; display: flex; align-items: center; gap: .6rem; }
.t-card h2 em { font-family: var(--font-body); font-style: normal; font-size: .85rem; color: var(--faint); }
.t-card p { color: var(--muted); margin: 0 0 .8rem; }
.t-card p b { color: var(--parchment); }
.t-num {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-size: .95rem; color: #1b1206; background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.t-steps { margin: 0 0 1rem; padding-left: 1.3rem; }
.t-steps li { margin: .3rem 0; }
.t-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.t-buttons .btn { height: 2.7rem; padding: 0 1.1rem; font-size: .85rem; }
.t-note { font-size: .88rem; color: var(--faint) !important; margin: .4rem 0 0 !important; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.key-row code {
  font-family: ui-monospace, Consolas, monospace; font-size: .95rem; letter-spacing: .04em; color: var(--gold-hi);
  padding: .55rem .8rem; border-radius: 8px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line);
}
@media (max-width: 520px) { .transfer { grid-template-columns: 1fr; } .t-card { padding: 1.1rem; } }

/* ==========================================================================
   TV mode — bigger type, overscan-safe margins, lighter effects
   ========================================================================== */
body.tv { --gutter: 5vw; --header-h: 5rem; }
html.tv { font-size: clamp(16px, 1.2vw, 30px); }
body.tv .bg::after, body.tv .bg-embers { display: none; }
body.tv .topbar, body.tv .dock { backdrop-filter: none; background: rgba(15, 11, 18, .97); }
body.tv .hero-circle { animation: none; }
body.tv .theme-grid { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
body.tv .video-grid { grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
body.tv .theme-card:focus, body.tv .video-card:focus { transform: scale(1.05); z-index: 2; }
body.tv .search { max-width: 26rem; }
body.tv .tag-chip:focus { transform: scale(1.08); }
body.tv .stage { width: 16rem; }
body.tv .site-footer { padding-bottom: 5rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .dock-extra .vol { display: none; }
}
@media (max-width: 860px) {
  .brand-text, .brand-edit { display: none; } /* phones rename via the footer link */
  .top-actions .chip span, .segmented span { display: none; }
  .segmented button { padding: 0 .7rem; }
  .top-actions .chip { padding: 0; width: 2.75rem; justify-content: center; }
  .dock-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .dock-extra { display: none; }
  #btnShuffle, #btnLoop { display: none; }
  .stage { width: 12rem; right: 12px; }
  .theme-hero { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  :root { --header-h: 4rem; }
  .topbar { gap: .6rem; }
  .search { height: 2.5rem; padding: 0 .8rem; }
  .chip, .segmented { height: 2.5rem; }
  .big-search { height: 3.3rem; padding-left: 1rem; }
  .big-search input { font-size: 1rem; }
  .tag-chip { height: 2rem; padding: 0 .7rem; font-size: .88rem; }
  .top-actions .chip { width: 2.5rem; }
  #tvToggle { display: none; }
  .theme-grid { grid-template-columns: 1fr; gap: .7rem; }
  .theme-card { min-height: 5.4rem; padding: .85rem 1rem; }
  .video-grid { grid-template-columns: 1fr; }
  .dock-sigil { display: none; }
  #btnPrev { display: none; }
  .stage { width: 9.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bg-embers { display: none; }
}
