/* ==========================================================
   DiDracin – mobile-first UI. Dark by default, light optional.
   ========================================================== */

:root {
  --bg: #0a0a0f;
  --bg-2: #101017;
  --surface: #15151e;
  --surface-2: #1e1e2a;
  --border: rgba(255, 255, 255, .08);
  --text: #f6f6f9;
  --muted: #9b9bb0;
  --accent: #ff5e7e;
  --accent-2: #ff9a4d;
  --grad: linear-gradient(135deg, #ff5e7e 0%, #ff9a4d 100%);
  --accent-soft: rgba(255, 94, 126, .14);
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --glass: rgba(20, 20, 30, .72);
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
  --r: 16px;
  --r-sm: 12px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gutter: 16px;
  --maxw: 1200px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f5f5f8;
  --bg-2: #ececf2;
  --surface: #ffffff;
  --surface-2: #ececf3;
  --border: rgba(20, 20, 40, .09);
  --text: #16161f;
  --muted: #6d6d82;
  --accent: #f2325f;
  --accent-2: #f27a1a;
  --grad: linear-gradient(135deg, #f2325f 0%, #f27a1a 100%);
  --accent-soft: rgba(242, 50, 95, .1);
  --glass: rgba(255, 255, 255, .8);
  --shadow: 0 14px 36px rgba(30, 30, 60, .14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 28px);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.ico { width: 1.3em; height: 1.3em; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ico.fill { fill: currentColor; stroke-width: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

main { max-width: var(--maxw); margin: 0 auto; padding: 8px var(--gutter) 0; }
main.detail-page { padding: 0; max-width: 900px; }
main.narrow-page { max-width: 640px; }

/* ---------------- Loader / spinner ---------------- */
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .18); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; pointer-events: none;
  background: var(--grad); transform: scaleX(0); transform-origin: left; opacity: 0;
}
.page-loader .spinner { display: none; }
.page-loader.show { opacity: 1; transform: scaleX(.85); transition: transform 6s cubic-bezier(.1, .8, .2, 1); }
.sentinel-loader { display: flex; justify-content: center; padding: 28px 0; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--border); }
.header-inner { max-width: var(--maxw); margin: 0 auto; height: 56px; padding: 0 var(--gutter); display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 9px; margin-right: auto; }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(255, 94, 126, .35); }
.logo-mark .ico { width: 16px; height: 16px; fill: #fff; stroke: #fff; stroke-width: 1; margin-left: 2px; }
.logo-text { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: -.03em; }
.beta-badge { align-self: flex-start; margin: 2px 0 0 -4px; padding: 2px 6px; border-radius: 6px; background: var(--grad); color: #fff; font: 800 9px/1.2 'Plus Jakarta Sans', sans-serif; letter-spacing: .08em; -webkit-text-fill-color: #fff; }
.logo-text span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-nav, .search-wrap, .donate-pill { display: none; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text); transition: background .15s; }
.icon-btn:hover, .icon-btn:active { background: var(--surface-2); }

/* ---------------- Bottom nav (mobile) ---------------- */
.bottom-nav {
  position: fixed; z-index: 70; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  max-width: 460px; margin: 0 auto; height: var(--nav-h);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 6px;
  background: var(--glass); backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
}
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 16px; color: var(--muted); font-size: 11px; font-weight: 700; transition: color .15s, background .15s; }
.nav-item .ico { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }
body:has(.detail-page) .bottom-nav { display: none; }

/* ---------------- Buttons ---------------- */
.btn-fill, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 999px; font-weight: 800; font-size: 15px;
  transition: transform .12s, filter .15s;
}
.btn-fill { background: var(--grad); color: #fff; box-shadow: 0 10px 26px rgba(255, 94, 126, .32); }
.btn-fill:active, .btn-ghost:active { transform: scale(.97); }
.btn-fill.big { height: 54px; font-size: 16px; width: 100%; }
.btn-fill.block { width: 100%; }
.btn-fill .ico { width: 18px; height: 18px; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ---------------- Sections ---------------- */
.page-head { padding: 14px 0 12px; }
.page-head h1 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-head h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.section-head a { color: var(--muted); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.section-head a .ico { width: 15px; height: 15px; }
.section-note { color: var(--muted); font-size: 13px; font-weight: 600; }
.state-msg { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 36px 12px; font-size: 14px; }
.more-wrap { display: flex; justify-content: center; margin-top: 22px; }

.empty-state { text-align: center; padding: 56px 20px; display: grid; justify-items: center; gap: 10px; }
.empty-state h3 { font-size: 18px; font-weight: 800; }
.empty-state p { color: var(--muted); max-width: 320px; font-size: 14px; margin-bottom: 8px; }
.library-empty-icon { width: 68px; height: 68px; border-radius: 22px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.library-empty-icon .ico { width: 30px; height: 30px; }

/* ---------------- Poster cards ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 16px 10px; }
.card { display: block; min-width: 0; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); }
.poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .poster img { transform: scale(1.05); }
.poster::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .55)); pointer-events: none; }
.poster-ep { position: absolute; z-index: 2; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.poster-play { position: absolute; z-index: 2; right: 6px; bottom: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; opacity: 0; transform: scale(.7); transition: .2s; }
.poster-play .ico { width: 13px; height: 13px; margin-left: 1px; }
.card:hover .poster-play, .card:focus-visible .poster-play, .history-cover .poster-play { opacity: 1; transform: none; }
@media (hover: none) { .poster-play { opacity: 1; transform: none; } }
.card-title { margin-top: 8px; font-size: 13px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-anim { animation: pop .35s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.skeleton-shimmer, .skeleton-line { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.skeleton-line { height: 12px; border-radius: 6px; margin-top: 10px; width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Horizontal rails */
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 6px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; flex: 0 0 auto; }
.continue-card { width: 132px; }
.progress-bar { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.progress-fill { height: 100%; background: var(--grad); border-radius: 0 4px 4px 0; }
.top-item { position: relative; display: flex; align-items: flex-end; width: 150px; padding-left: 26px; }
.top-item .card { width: 118px; position: relative; z-index: 1; }
.top-num { position: absolute; left: -2px; bottom: 26px; z-index: 0; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 86px; line-height: .8; letter-spacing: -.06em; color: transparent; -webkit-text-stroke: 2px var(--accent); opacity: .85; }

/* ---------------- Hero ---------------- */
.hero-wrap { margin: 4px calc(var(--gutter) * -1) 0; }
.hero-carousel { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 var(--gutter); scroll-padding: 0 var(--gutter); scrollbar-width: none; }
.hero-carousel::-webkit-scrollbar { display: none; }
.hero-slide { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; min-width: 0; }
.hero { position: relative; display: block; height: 232px; border-radius: 24px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); isolation: isolate; }
.hero-bg { position: absolute; inset: -20px; width: calc(100% + 40px); height: calc(100% + 40px); object-fit: cover; filter: blur(22px) saturate(1.3) brightness(.7); z-index: -2; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(10, 10, 15, .88) 0%, rgba(10, 10, 15, .45) 60%, rgba(10, 10, 15, .1) 100%); }
.hero-cover { position: absolute; right: 16px; top: 50%; transform: translateY(-50%) rotate(3deg); width: 112px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 14px; box-shadow: 0 18px 40px rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .18); }
.hero-overlay { position: absolute; inset: 0; padding: 20px; padding-right: 140px; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; color: #fff; }
.hero-tag { display: inline-flex; align-self: flex-start; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.hero-tag .ico { width: 13px; height: 13px; }
.hero-title { font-family: 'Bricolage Grotesque', sans-serif; font-size: 25px; font-weight: 800; line-height: 1.08; letter-spacing: -.02em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { display: flex; gap: 8px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .78); }
.hero-meta span + span::before { content: '•'; margin-right: 8px; }
.hero-cta { display: inline-flex; align-self: flex-start; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 999px; background: #fff; color: #111; font-weight: 800; font-size: 13px; }
.hero-cta .ico { width: 13px; height: 13px; }
.hero-dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.hero-dots button { width: 6px; height: 6px; border-radius: 99px; background: var(--border); transition: .25s; padding: 0; }
.hero-dots button.active { width: 20px; background: var(--grad); }

.quick-row { display: flex; gap: 8px; overflow-x: auto; margin: 18px calc(var(--gutter) * -1) 0; padding: 0 var(--gutter); scrollbar-width: none; }
.quick-row::-webkit-scrollbar { display: none; }
.quick-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.quick-chip .ico { width: 17px; height: 17px; }
.quick-chip.accent { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 20px rgba(255, 94, 126, .28); }

/* ---------------- Explore ---------------- */
.explore-head { position: sticky; top: calc(56px + var(--safe-t)); z-index: 40; margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter) 12px; background: linear-gradient(var(--bg) 78%, transparent); }
.explore-head h1 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.explore-search { position: relative; display: flex; align-items: center; }
.explore-search > .ico { position: absolute; left: 14px; color: var(--muted); }
.explore-search input { width: 100%; height: 48px; padding: 0 44px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); font-size: 15px; outline: 0; -webkit-appearance: none; appearance: none; }
.explore-search input::-webkit-search-cancel-button { display: none; }
.explore-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.clear-btn { position: absolute; right: 8px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.clear-btn .ico { width: 17px; height: 17px; }
.end-msg { grid-column: 1 / -1; }

/* ---------------- Library ---------------- */
.seg-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.seg-tab { height: 40px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--muted); transition: .2s; }
.seg-tab b { margin-left: 4px; font-size: 12px; opacity: .8; }
.seg-tab.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(255, 94, 126, .3); }
.bm-item { position: relative; }
.bm-remove { position: absolute; z-index: 5; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.bm-remove .ico { width: 14px; height: 14px; }
.history-list { display: grid; gap: 10px; }
.history-item { display: flex; align-items: center; gap: 14px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.history-cover { position: relative; flex: 0 0 64px; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.history-cover img { width: 100%; height: 100%; object-fit: cover; }
.history-cover .poster-play { right: auto; bottom: auto; left: 50%; top: 50%; margin: -14px 0 0 -14px; }
.history-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.history-info strong { font-size: 14px; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-info span, .history-time { font-size: 12px; color: var(--muted); }
.history-info .progress-bar { position: relative; border-radius: 4px; margin: 4px 0; height: 4px; background: var(--surface-2); }
.history-go { color: var(--muted); }

/* ---------------- Detail ---------------- */
.detail-hero { position: relative; padding: calc(var(--safe-t) + 12px) var(--gutter) 22px; overflow: hidden; isolation: isolate; }
.detail-bg { position: absolute; inset: -30px; width: calc(100% + 60px); height: calc(100% + 60px); object-fit: cover; filter: blur(34px) saturate(1.4) brightness(.55); z-index: -2; }
html[data-theme="light"] .detail-bg { filter: blur(34px) saturate(1.3) brightness(.9); }
.detail-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 10, 15, .1) 0%, var(--bg) 100%); }
.detail-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.reels-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .42); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bookmark-toggle { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 16px; border-radius: 999px; background: rgba(0, 0, 0, .42); color: #fff; font-weight: 700; font-size: 13px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bookmark-toggle .ico { width: 17px; height: 17px; }
.bookmark-toggle.saved { background: var(--grad); }
.bookmark-toggle.saved .ico { fill: currentColor; }
.detail-head { display: flex; gap: 16px; align-items: flex-end; }
.detail-cover { flex: 0 0 118px; width: 118px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; box-shadow: 0 20px 44px rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .14); }
.detail-meta { min-width: 0; display: grid; gap: 8px; padding-bottom: 4px; }
.detail-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2); }
.detail-title { font-family: 'Bricolage Grotesque', sans-serif; font-size: 25px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.detail-stats > span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.detail-stats .ico { width: 14px; height: 14px; }
.detail-body { padding: 4px var(--gutter) calc(110px + var(--safe-b)); display: grid; gap: 26px; }
.block-title { font-family: 'Bricolage Grotesque', sans-serif; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.block-title small { margin-left: 6px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 2px; }
.block-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.syn { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.syn.open { display: block; }
.link-btn { margin-top: 6px; color: var(--accent); font-weight: 800; font-size: 13px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 700; }
.chip-btn .ico { width: 15px; height: 15px; }
.ep-search { width: 100%; height: 44px; padding: 0 16px; margin-bottom: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); outline: 0; }
.ep-search:focus { border-color: var(--accent); }
.ep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.ep-chip { height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); font-weight: 800; font-size: 14px; transition: transform .1s; }
.ep-chip:active { transform: scale(.94); }
.ep-chip.watched { color: var(--muted); background: var(--bg-2); }
.ep-chip.current { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(255, 94, 126, .32); }
.cta-bar { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; padding: 14px var(--gutter) calc(14px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 40%); }
.cta-bar .btn-fill { max-width: 560px; margin: 0 auto; display: flex; }

/* ---------------- Settings / auth ---------------- */
.settings-group { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; margin-bottom: 14px; overflow: hidden; }
.settings-row { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; font-weight: 700; text-align: left; font-size: 15px; }
.settings-row + .settings-row, form + .settings-row, .settings-row + form .settings-row { border-top: 1px solid var(--border); }
.settings-group form .settings-row { border-top: 1px solid var(--border); }
.settings-row .val { color: var(--muted); font-size: 13px; font-weight: 600; }
.settings-row.danger { color: var(--danger); }
.profile-form { padding: 20px; }
.profile-preview { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 18px; overflow: hidden; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 34px; font-weight: 800; }
.profile-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-field { display: grid; gap: 6px; margin-bottom: 16px; font-size: 13px; font-weight: 700; }
.profile-field input { width: 100%; height: 46px; padding: 0 14px; border-radius: 13px; background: var(--bg-2); border: 1px solid var(--border); outline: 0; font-size: 15px; }
.profile-field input[type="file"] { padding: 9px; height: auto; }
.profile-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.profile-field input:disabled { color: var(--muted); }
.profile-field small { color: var(--muted); font-size: 12px; font-weight: 500; }
.profile-remove { display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; color: var(--muted); font-size: 13px; }
.profile-remove input { accent-color: var(--accent); }
.profile-message { margin-bottom: 14px; padding: 13px 16px; border-radius: 14px; font-size: 13px; font-weight: 600; }
.profile-message.error { color: var(--danger); background: rgba(255, 107, 107, .12); }
.profile-message.success { color: var(--ok); background: rgba(61, 220, 151, .12); }
.profile-login { padding: 28px 20px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.profile-login h3 { font-size: 18px; font-weight: 800; }
.profile-login p { color: var(--muted); font-size: 14px; max-width: 300px; margin-bottom: 6px; }
.login-art { width: 64px; height: 64px; border-radius: 22px; background: var(--grad); color: #fff; display: grid; place-items: center; }
.login-art .ico { width: 28px; height: 28px; }
.social-links { display: grid; gap: 10px; margin-bottom: 18px; }
.social-link { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.social-mark { width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.social-copy { flex: 1; display: grid; line-height: 1.3; }
.social-copy strong { font-size: 14px; }
.social-copy span { color: var(--muted); font-size: 13px; }
.social-external { color: var(--muted); width: 18px; height: 18px; }
.about-box { text-align: center; padding: 28px 16px; display: grid; justify-items: center; gap: 6px; }
.about-box .app-name { font-family: 'Bricolage Grotesque', sans-serif; font-size: 28px; font-weight: 800; letter-spacing: -.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.about-box p { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.donate-btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 22px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 14px; }
.auth-panel { text-align: center; padding: 60px 20px; display: grid; justify-items: center; gap: 12px; }
.auth-panel p { color: var(--muted); max-width: 340px; }

/* ==========================================================
   Reels – vertical TikTok-style episode feed
   ========================================================== */
body.watch-mode { padding: 0; overflow: hidden; background: #000; overscroll-behavior: none; }
.reels { position: fixed; inset: 0; background: #000; display: flex; justify-content: center; color: #fff; }
.reels-backdrop { position: absolute; inset: 0; overflow: hidden; }
.reels-backdrop img { width: 100%; height: 100%; object-fit: cover; filter: blur(46px) brightness(.32) saturate(1.4); transform: scale(1.3); }
.reels-stage { position: relative; width: 100%; max-width: calc(100vh * 9 / 16); max-width: calc(100dvh * 9 / 16); height: 100%; background: #000; overflow: hidden; }
.reels-feed { position: absolute; inset: 0; overflow-y: scroll; overflow-x: hidden; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; outline: 0; -webkit-overflow-scrolling: touch; }
.reels-feed::-webkit-scrollbar { display: none; }
.reel { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; background: #000; }
.reel-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(18px) brightness(.55); transform: scale(1.12); transition: opacity .35s; }
.reel.ready .reel-poster { opacity: .7; }
.reel-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.reel-status { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; }
.reel.loading .reel-status, .reel.buffering .reel-status { display: grid; }
.reel-status .spinner { width: 44px; height: 44px; border-width: 4px; }
.reel-epbadge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 54px; letter-spacing: -.04em; color: rgba(255, 255, 255, .0); pointer-events: none; }
.reel:not(.ready):not(.failed) .reel-epbadge { color: rgba(255, 255, 255, .12); }
.reel-flash { position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 50%; background: rgba(0, 0, 0, .5); display: grid; place-items: center; opacity: 0; pointer-events: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.reel-flash .ico { width: 38px; height: 38px; fill: #fff; stroke: #fff; }
.reel-flash.go { animation: flash .7s ease-out forwards; }
.reel-flash.hold { animation: none; opacity: 1; }
@keyframes flash { 0% { opacity: 0; transform: scale(.7); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.2); } }
.reel-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 28px; text-align: center; background: rgba(0, 0, 0, .72); z-index: 4; }
.reel-error p { font-weight: 600; max-width: 260px; }
.reel-error > div { display: flex; gap: 10px; }
.reel-error .btn-fill, .reel-error .btn-ghost { height: 42px; padding: 0 18px; font-size: 14px; }
.reel-error .btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: transparent; }

.reels-top { position: absolute; z-index: 10; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t) + 12px) 14px 34px; background: linear-gradient(rgba(0, 0, 0, .65), transparent); pointer-events: none; }
.reels-top > * { pointer-events: auto; }
.reels-heading { min-width: 0; display: grid; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.reels-heading strong { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reels-heading span { font-size: 12px; font-weight: 700; opacity: .85; }

.reels-rail { position: absolute; z-index: 10; right: 8px; bottom: calc(var(--safe-b) + 92px); display: grid; gap: 14px; pointer-events: none; }
.rail-btn { pointer-events: auto; width: 56px; display: grid; justify-items: center; gap: 3px; color: #fff; font-size: 11px; font-weight: 700; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); }
.rail-btn .ico { width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: rgba(0, 0, 0, .42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: transform .12s, background .15s; }
.rail-btn:active .ico { transform: scale(.88); }
.rail-btn.off .ico { background: rgba(255, 255, 255, .22); }
.rail-btn.on .ico { background: var(--grad); fill: #fff; }

.reels-info { position: absolute; z-index: 9; left: 0; right: 0; bottom: 0; padding: 70px 78px calc(var(--safe-b) + 36px) 16px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); pointer-events: none; display: grid; gap: 8px; }
.reels-syn { font-size: 13px; line-height: 1.4; opacity: .92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); }
.reels-hint { display: inline-flex; align-items: center; gap: 4px; justify-self: start; padding: 4px 11px 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, .16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 11px; font-weight: 700; transition: opacity .6s .8s; }
.reels-hint .ico { width: 14px; height: 14px; animation: nudge 1.4s infinite; }
.reels-hint.seen { opacity: 0; }
@keyframes nudge { 50% { transform: translateY(-3px); } }

.reels-progress { position: absolute; z-index: 12; left: 0; right: 0; bottom: calc(var(--safe-b) + 6px); height: 30px; display: flex; align-items: center; }
.reels-time { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; font-size: 13px; font-weight: 800; opacity: 0; transition: opacity .15s; text-shadow: 0 1px 8px #000; pointer-events: none; }
.reels-progress.scrub .reels-time { opacity: 1; }
#seek { --p: 0%; width: 100%; height: 30px; margin: 0; padding: 0; background: transparent; -webkit-appearance: none; appearance: none; touch-action: none; cursor: pointer; }
#seek::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, #fff var(--p), rgba(255, 255, 255, .28) var(--p)); transition: height .15s; }
#seek::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .28); }
#seek::-moz-range-progress { height: 3px; background: #fff; border-radius: 3px; }
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 0; height: 0; margin-top: 1.5px; border-radius: 50%; background: #fff; transition: .15s; }
#seek::-moz-range-thumb { width: 0; height: 0; border: 0; background: #fff; }
.reels-progress.scrub #seek::-webkit-slider-runnable-track, #seek:hover::-webkit-slider-runnable-track { height: 6px; }
.reels-progress.scrub #seek::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -4px; }
.reels-progress.scrub #seek::-moz-range-thumb { width: 14px; height: 14px; }

/* Immersive mode: after 3s of playback every overlay fades out. Tap/touch brings them back. */
.reels-top, .reels-rail, .reels-info, .reels-progress, .reels-side { transition: opacity .4s ease; }
.reels.ui-hidden .reels-top, .reels.ui-hidden .reels-rail, .reels.ui-hidden .reels-info,
.reels.ui-hidden .reels-progress, .reels.ui-hidden .reels-side { opacity: 0; pointer-events: none; }
.reels.ui-hidden .reels-top > *, .reels.ui-hidden .rail-btn, .reels.ui-hidden .reels-side button { pointer-events: none; }
/* Press-and-hold anywhere on the video = temporary 2x speed */
.reels { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.speed-boost { position: absolute; z-index: 15; left: 50%; top: calc(var(--safe-t) + 22px); transform: translate(-50%, -6px); padding: 7px 16px; border-radius: 999px; background: rgba(0, 0, 0, .62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; font-weight: 800; letter-spacing: .02em; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.speed-boost.show { opacity: 1; transform: translate(-50%, 0); }
.reels-toast { position: absolute; z-index: 20; left: 50%; top: calc(var(--safe-t) + 76px); transform: translate(-50%, -8px); padding: 9px 16px; border-radius: 999px; background: rgba(0, 0, 0, .74); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; font-weight: 700; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; opacity: 0; pointer-events: none; transition: .25s; }
.reels-toast.show { opacity: 1; transform: translate(-50%, 0); }

.reels-side { display: none; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .22s; }
.sheet.open .sheet-scrim { opacity: 1; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; max-height: 78dvh; display: flex; flex-direction: column; padding: 8px 16px calc(var(--safe-b) + 16px); background: var(--bg-2); color: var(--text); border-radius: 26px 26px 0 0; border: 1px solid var(--border); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.sheet.open .sheet-panel { transform: none; }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 6px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 20px; font-weight: 800; }
.sheet-options { display: grid; gap: 12px; padding: 10px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; flex: 0 0 46px; height: 28px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); transition: .2s; order: 2; margin-left: auto; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); transition: .2s; }
.switch input:checked + span { background: var(--grad); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(18px); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.seg button { height: 36px; border-radius: 11px; font-size: 13px; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--grad); color: #fff; }
.ep-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; overflow-y: auto; padding-bottom: 4px; position: relative; }
.ep-grid button { height: 46px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); font-weight: 800; font-size: 14px; }
.ep-grid button.current { background: var(--grad); color: #fff; border-color: transparent; }
.watch-fail { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; background: var(--bg); color: var(--text); }
.watch-fail p { color: var(--muted); }
body.watch-mode:has(.watch-fail) { overflow: auto; }

/* ==========================================================
   Larger screens
   ========================================================== */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; }
  .card-title { font-size: 14px; }
  .hero-slide { flex-basis: min(520px, 86%); }
  .hero { height: 260px; }
  .hero-cover { width: 130px; }
  .hero-overlay { padding-right: 170px; }
  .hero-wrap { margin: 4px 0 0; }
  .hero-carousel { padding: 0; scroll-padding: 0; }
  .continue-card { width: 150px; }
}

@media (min-width: 900px) {
  body { padding-bottom: 40px; }
  .bottom-nav, body:has(.detail-page) .bottom-nav { display: none; }
  .top-nav { display: flex; gap: 4px; margin: 0 auto 0 14px; }
  .top-nav a { padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--muted); }
  .top-nav a:hover { color: var(--text); background: var(--surface); }
  .top-nav a.active { color: var(--accent); background: var(--accent-soft); }
  .logo { margin-right: 0; }
  .search-wrap { display: flex; align-items: center; position: relative; width: 280px; }
  .search-wrap .ico { position: absolute; left: 14px; color: var(--muted); width: 18px; height: 18px; }
  .search-wrap input { width: 100%; height: 42px; padding: 0 16px 0 42px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); outline: 0; -webkit-appearance: none; appearance: none; }
  .search-wrap input:focus { border-color: var(--accent); }
  .donate-pill { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; }
  .donate-pill .ico { width: 16px; height: 16px; }
  .search-link { display: none; }
  .header-actions { margin-left: 8px; }
  .explore-head { top: 56px; }
  .hero-slide { flex-basis: min(640px, 70%); }
  .hero { height: 300px; }
  .hero-title { font-size: 32px; }
  .hero-cover { width: 150px; }
  .hero-overlay { padding: 28px; padding-right: 210px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .top-item { width: 180px; }
  .top-item .card { width: 140px; }
  .top-num { font-size: 104px; bottom: 30px; }
  .detail-head { gap: 28px; }
  .detail-cover { flex-basis: 170px; width: 170px; }
  .detail-title { font-size: 38px; }
  .detail-hero { padding: 24px 32px 32px; border-radius: 0 0 28px 28px; }
  .detail-body { padding: 8px 32px 120px; }
  .reels-side { display: grid; gap: 12px; position: fixed; top: 50%; transform: translateY(-50%); right: max(20px, calc(50% - (100dvh * 9 / 32) - 76px)); }
  .reels-side button { width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: .15s; }
  .reels-side button:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
  .reels-side button:disabled { opacity: .3; cursor: default; }
  .reels-side .ico { width: 24px; height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
