/* Koinei web app — Apple-style chrome. Mobile-first; no framework. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: var(--text-md);
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
}

body[dir="rtl"] { direction: rtl; }

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

#app { height: 100%; display: flex; flex-direction: column; }

.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom));
}
.view.no-pad { padding-bottom: 0; }

/* ---------- Tab bar ---------- */
.app-tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  z-index: 900;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 0.5px solid var(--hairline);
}
.app-tabbar .tab {
  flex: 1;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 11px;
  transition: color var(--dur-fast) var(--ease-out);
}
.app-tabbar .tab svg { width: 20px; height: 20px; fill: currentColor; }
.app-tabbar .tab.active { color: var(--accent); }
.app-tabbar.hidden { display: none; }

/* Desktop: tab bar becomes a top bar */
@media (min-width: 900px) {
  #app { flex-direction: column-reverse; }
  .app-tabbar {
    position: sticky; top: 0; bottom: auto;
    height: 52px; padding-bottom: 0;
    border-top: none; border-bottom: 0.5px solid var(--hairline);
    justify-content: center; gap: var(--s-8);
  }
  .app-tabbar .tab { flex: none; flex-direction: row; gap: 8px; padding: 0 var(--s-4); font-size: var(--text-sm); }
  .app-tabbar .tab svg { width: 20px; height: 20px; }
  .view { padding-bottom: var(--s-8); }
}

/* ---------- Generic chrome ---------- */
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--s-4); }

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: var(--s-4) 0 var(--s-2);
}
.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: var(--s-6) 0 var(--s-3);
  display: flex; align-items: baseline; justify-content: space-between;
}
.section-title .see-all { font-size: var(--text-sm); color: var(--accent); font-weight: 500; }

.muted { color: var(--ink-secondary); }
.small { font-size: var(--text-sm); }
.hairline-top { border-top: 0.5px solid var(--hairline); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: var(--text-md);
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.quiet { background: var(--bg-elevated); color: var(--ink); box-shadow: var(--shadow-card); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: var(--text-sm); }
.btn.block { display: flex; width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-elevated);
  border: 0.5px solid var(--hairline);
  font-size: var(--text-sm);
  color: var(--ink);
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip.active { background: var(--ink); color: var(--bg-elevated); border-color: var(--ink); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: var(--s-2) 0; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.field { margin-bottom: var(--s-4); }
.field label { display: block; font-size: var(--text-sm); color: var(--ink-secondary); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px 14px;
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  font-size: var(--text-md);
  outline: none;
  transition: border-color var(--dur-fast);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 130px; resize: vertical; line-height: 1.45; }

.list { background: var(--bg-elevated); border-radius: var(--r-lg); overflow: hidden; }
.list .row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 14px var(--s-4);
  border-bottom: 0.5px solid var(--hairline);
  width: 100%; text-align: start;
}
.list .row:last-child { border-bottom: none; }
.list .row .grow { flex: 1; min-width: 0; }
.list .row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row .sub { font-size: var(--text-sm); color: var(--ink-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row .chev { color: var(--ink-tertiary); }

/* ---------- Content cards & carousels ---------- */
.carousel {
  margin: 0 calc(-1 * var(--s-4));
  padding: 0 var(--s-4);
  display: flex; gap: var(--s-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* keep the inset after snapping — otherwise cards pin to the screen edge */
  scroll-padding-inline: var(--s-4);
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel::after { content: ""; flex: 0 0 1px; } /* right-edge breathing room */

.content-card {
  scroll-snap-align: start;
  flex: 0 0 78vw;
  max-width: 330px;
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;   /* matches the stored preview.png card images */
  background: linear-gradient(135deg, #3a3a3c, #1c1c1e);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  color: #fff;
}
.content-card .bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.content-card .strip {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 14px;
  background: rgba(20, 20, 22, 0.45);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}
.content-card .strip .t { font-weight: 600; font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content-card .strip .s { font-size: var(--text-xs); opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content-card .lang-flag {
  position: absolute; top: 10px; left: 12px;
  height: 24px; min-width: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 9px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  line-height: 1;
  border-radius: var(--r-pill);
  background: rgba(20,20,22,0.55);
  backdrop-filter: blur(10px);
}

/* ---------- Feed ---------- */
.feed {
  height: calc(100dvh - var(--tabbar-height) - var(--safe-bottom));
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  background: #000;
}
.feed::-webkit-scrollbar { display: none; }

.feed-item {
  height: calc(100dvh - var(--tabbar-height) - var(--safe-bottom));
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  overflow: hidden;
}
.feed-item .fi-bg {
  position: absolute; inset: -20px;
  background-size: cover; background-position: center;
  filter: blur(18px) brightness(0.45);
  transform: scale(1.1);
}
.feed-item .fi-slide {
  position: relative; z-index: 2;
  width: 100%;
  padding: 0 var(--s-4);
  text-align: center;
}
.feed-item .fi-line { font-family: var(--font-display); font-weight: 700; font-size: clamp(22px, 6.2vw, 42px); line-height: 1.25; letter-spacing: -0.01em; text-shadow: 0 2px 18px rgba(0,0,0,0.55); }
.feed-item .fi-trans { margin-top: 10px; font-size: clamp(15px, 4.2vw, 22px); opacity: 0.92; text-shadow: 0 1px 12px rgba(0,0,0,0.5); }
.feed-item .fi-gloss { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.feed-item .fi-gloss .g { font-size: clamp(11px, 3vw, 14px); opacity: 0.8; display: inline-flex; flex-direction: column; align-items: center; }
.feed-item .fi-gloss .g b { font-weight: 600; opacity: 1; }

.feed-item .fi-meta {
  position: absolute; left: var(--s-4); bottom: var(--s-6); z-index: 3;
  max-width: 70%;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}
/* With the embedded reader, sit above its controls bar and read on light bg */
.feed-item:has(.reader-overlay) .fi-meta {
  bottom: calc(7vh + 14px);
  color: #1d1d1f;
  text-shadow: none;
}
.feed-item:has(.reader-overlay) .fi-meta .m-reason { display: none; }
.feed-item .fi-meta .m-title { font-weight: 700; font-size: var(--text-lg); }
.feed-item .fi-meta .m-sub { font-size: var(--text-sm); opacity: 0.85; margin-top: 2px; }
.feed-item .fi-meta .m-reason { font-size: 11px; opacity: 0.55; margin-top: 6px; }

.feed-rail {
  position: absolute; right: var(--s-3); bottom: var(--s-8); z-index: 3;
  display: flex; flex-direction: column; gap: var(--s-5); align-items: center;
}
.feed-rail button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #fff; font-size: var(--text-xs); text-shadow: 0 1px 6px rgba(0,0,0,0.6); }
.feed-rail svg { width: 32px; height: 32px; fill: #fff; filter: drop-shadow(0 1px 6px rgba(0,0,0,0.45)); }
.feed-rail button.on svg { fill: #ff375f; }

.feed-start {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-3);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  color: #fff;
}
.feed-start .play-big { width: 76px; height: 76px; border-radius: 50%; background: rgba(255,255,255,0.16); display: flex; align-items: center; justify-content: center; border: 1.5px solid rgba(255,255,255,0.6); }
.feed-start .play-big svg { width: 34px; height: 34px; fill: #fff; margin-left: 4px; }

/* ---------- feed scope pill: present if you look for it ---------- */
.scope-pill {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px;
  z-index: 30;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: rgba(255,255,255,0.55); backdrop-filter: blur(10px);
  font-size: 12px; font-weight: 700; color: #1d1d1f; letter-spacing: 0.02em;
  box-shadow: var(--shadow-card); opacity: 0.85;
  transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
.scope-pill:active { transform: scale(0.92); }
.comments-open ~ .scope-pill { display: none; }

/* ---------- Library: featured hero + on-page catalog browser ---------- */
.hero-card {
  position: relative; height: 168px; border-radius: var(--r-xl);
  overflow: hidden; margin: 14px 0 4px; cursor: pointer;
  background: linear-gradient(120deg, #2c2c54, #474787);
  box-shadow: var(--shadow-card);
}
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.hero-scrim { position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.62), rgba(0,0,0,0.05) 65%); }
.hero-tag {
  position: absolute; top: 12px; left: 14px; color: #fff;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em;
  background: rgba(255,255,255,0.18); backdrop-filter: blur(8px);
  padding: 4px 10px; border-radius: var(--r-pill);
}
.hero-text { position: absolute; left: 16px; bottom: 14px; right: 70px; color: #fff; }
.hero-title { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); }
.hero-sub { font-size: var(--text-sm); opacity: 0.85; }
.hero-play {
  position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(255,255,255,0.92); color: #1d1d1f;
  display: flex; align-items: center; justify-content: center;
}
/* Bible browser: book/chapter selects + full-width chapter pager */
.bp-controls { display: flex; gap: 10px; margin-bottom: 10px; }
.bp-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bp-field span { font-size: var(--text-sm); font-weight: 700; color: var(--ink); }
.bp-field select {
  width: 100%; padding: 10px 12px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-md);
  background: var(--bg-elevated); font-size: var(--text-sm); outline: none;
}
.bp-section { margin-bottom: 26px; }   /* breathing room before what follows */
.bp-pager {
  display: flex; overflow-x: auto; gap: 12px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  margin-bottom: 6px;
}
.bp-pager::-webkit-scrollbar { display: none; }
/* Bible pager hosts the standard content cards, sized so the next chapter
   peeks at the edge. */
.bp-pager .content-card {
  flex: 0 0 86%; max-width: none; cursor: pointer;
  background: #f4f4f4;   /* reader paper while preview.png loads */
}
/* On a wider screen, don't enlarge a single card to fill the page — show
   more cards (≈3 full + a peek of the 4th). Mobile keeps the big peek card. */
@media (min-width: 700px) {
  .bp-pager .content-card { flex-basis: 320px; }
}
/* Drag-to-scroll affordance on desktop (pointer handler in library.js). */
.carousel, .bp-pager { cursor: grab; }
.carousel.dragging, .bp-pager.dragging { cursor: grabbing; scroll-snap-type: none; }
.carousel.dragging .content-card, .bp-pager.dragging .content-card { pointer-events: none; }

/* Library header, scoped search, collection pages, inline reader block */
.lib-head { display: flex; justify-content: space-between; align-items: center; }
.search-input {
  width: 100%; padding: 11px 14px; margin-top: 6px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-pill);
  background: var(--bg-elevated); outline: none;
}
.search-results { margin-top: 8px; }
.section-title.sec-link { width: 100%; text-align: start; cursor: pointer; }
.section-title.sec-link:hover .see-all { text-decoration: underline; }
.col-desc { color: var(--ink-secondary); font-size: var(--text-md); line-height: 1.5;
  margin: 2px 0 12px; max-width: 70ch; }
.card-grid { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 8px; }
.card-grid .content-card { flex: none; max-width: none; width: 100%; }
.lib-reader { margin: 18px 0 26px; }
.lib-reader-stage {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  height: min(64vh, 540px); box-shadow: var(--shadow-card); background: #f4f4f4;
}
/* Keep the inline preview clean — no edit/like/save chrome (beats reader.css). */
.lib-reader .reader-overlay .reader-top { display: none; }
/* Static preview mount (render harness): no entry animation, no input. */
.reader-overlay.preview { animation: none; pointer-events: none; }

.bible-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.bible-tile {
  flex: 0 0 auto; min-width: 120px; text-align: start;
  padding: 14px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, #5d4037, #795548);
  color: #fff; box-shadow: var(--shadow-card);
}
.bible-tile .bt-name { font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-md); text-transform: capitalize; }
.bible-tile .bt-sub { font-size: var(--text-xs); opacity: 0.8; margin-top: 3px; }
.chapter-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 2px; }
.x-sub { padding-inline-start: 12px; border-inline-start: 2px solid var(--hairline); }
.x-grid { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: 10px 8px; }

/* ---------- TikTok-style social chrome (feed cards + library reader) ---- */
.tk-rail {
  position: absolute; right: 10px; bottom: calc(7vh + 84px); z-index: 7;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.tk-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 19px;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.tk-avatar.sm { width: 32px; height: 32px; font-size: 14px; border: none; flex-shrink: 0; }
.tk-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.tk-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tk-btn {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
  color: #1d1d1f;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.tk-btn:active { transform: scale(0.88); }
.tk-btn svg { fill: currentColor; }
.tk-btn.on { color: #ff375f; }
.tk-count {
  font-size: 12px; font-weight: 700; color: #1d1d1f;
  text-shadow: 0 0 6px rgba(255,255,255,0.9);
}
.tk-title {
  position: absolute; left: var(--s-4); bottom: calc(7vh + 16px); bottom: calc(7dvh + 16px);
  z-index: 6;
  max-width: 68%; color: #1d1d1f;
}
.tk-title .tk-t1 { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); letter-spacing: -0.01em; }
.tk-title .tk-t2 { font-size: var(--text-sm); opacity: 0.8; }
.tk-title .tk-t3 { font-size: var(--text-xs); opacity: 0.6; font-style: italic; }
.tk-title .tk-owner { font-size: var(--text-sm); font-weight: 600; margin-top: 3px; color: var(--accent); }
.tk-title-link { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tk-title-link:active { opacity: 0.7; }

/* Comments panel: bottom ≤75%, content shrinks above and keeps playing. */
.tk-panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: 72%;
  z-index: 40;
  background: var(--bg-elevated);
  color: var(--ink);              /* hosts (feed card) may be white-on-media */
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column;
  animation: slide-up var(--dur-med) var(--ease-spring);
  transition: transform var(--dur-med) var(--ease-spring);
}
/* Tap anywhere off the panel (the shrunken content) to close. */
.tk-panel-backdrop { position: absolute; inset: 0; z-index: 39; }
.tk-panel-head {
  position: relative; padding: 8px 16px 10px; text-align: center;
  border-bottom: 0.5px solid var(--hairline);
}
.tk-panel-head .grab { width: 36px; height: 4px; border-radius: 2px;
  background: rgba(60,60,67,0.3); margin: 0 auto 8px; }
.tk-panel-title { font-weight: 700; font-size: var(--text-sm); }
.tk-panel-close { position: absolute; right: 12px; top: 12px; color: var(--ink-secondary); }
.tk-info { text-align: start; padding: 2px 2px 10px; }
.tk-info-row { display: flex; align-items: center; gap: 10px; }
.tk-info-row .tk-avatar { width: 38px; height: 38px; font-size: 16px; border: none; }
.tk-info .tk-t1 { font-family: var(--font-display); font-weight: 800; font-size: var(--text-base); }
.tk-info .tk-t2 { font-size: var(--text-sm); color: var(--ink-secondary); }
.tk-info .tk-owner { font-size: var(--text-xs); font-weight: 600; color: var(--accent); }
.tk-info-stats { margin-top: 8px; letter-spacing: 0.02em; }
/* Calm hold screen — replaces spinners on primary views (+ boot splash) */
.calm, #boot-splash {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #eef2f7 0%, #e7ecf5 40%, #dfe7f2 100%);
  background-size: 200% 200%; animation: calm-pan 9s ease-in-out infinite;
}
@keyframes calm-pan { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@media (prefers-color-scheme: dark) {
  .calm, #boot-splash { background: linear-gradient(150deg, #15171c, #1b1f27 50%, #14161b); }
}
.calm-inner, #boot-splash .bs-inner {
  text-align: center; padding: 0 36px; max-width: 460px;
  animation: calm-rise var(--dur-med, .4s) ease both;
}
@keyframes calm-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.calm-mark, #boot-splash .bs-mark { font-size: 40px; margin-bottom: 12px; opacity: 0.85; }
.calm-line, #boot-splash .bs-line {
  font-family: var(--font-display, sans-serif); font-weight: 700;
  font-size: var(--text-lg, 19px); line-height: 1.45; color: var(--ink, #1d1d1f);
}
#boot-splash { position: fixed; z-index: 9000; transition: opacity .4s ease; }
#boot-splash.hide { opacity: 0; pointer-events: none; }

/* Create tab — channel tabs (brands) */
.chan-tabs {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--hairline); margin-bottom: 12px;
}
.chan-tabs::-webkit-scrollbar { display: none; }
.chan-tab {
  padding: 10px 16px; white-space: nowrap; font-size: var(--text-sm);
  font-weight: 600; color: var(--ink-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -1px; border-radius: var(--r-md) var(--r-md) 0 0;
}
.chan-tab.active { color: var(--ink); border-bottom-color: var(--accent);
  background: var(--bg-elevated); }
.chan-tab.add { color: var(--accent); font-weight: 700; }
.chan-tab.drop { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* Right-click / long-press context menu */
.ctx-menu {
  position: fixed; z-index: 9500; min-width: 160px; padding: 5px;
  background: var(--bg-elevated); border: 0.5px solid var(--hairline);
  border-radius: var(--r-md); box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column;
}
.ctx-item { text-align: start; padding: 9px 12px; border-radius: var(--r-sm);
  font-size: var(--text-sm); color: var(--ink); }
.ctx-item:hover { background: var(--bg-sunken, rgba(0,0,0,0.05)); }
.ctx-item.danger { color: var(--danger); }

/* Create — account/sign-in row + folder display-name header */
.create-acct { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.fb-header { margin: 6px 2px 8px; }
.fb-displayname { font-family: var(--font-display); font-weight: 800;
  font-size: var(--text-xl, 24px); line-height: 1.15; letter-spacing: -0.01em; }
.fb-slug { font-size: var(--text-xs); color: var(--ink-tertiary); margin-top: 2px; }
.fb-break { border: none; border-top: 1px solid var(--hairline); margin: 12px 0; }
.content-card .bg.ph { display: flex; align-items: center; justify-content: center;
  background: #20242c; font-size: 30px; }

/* Breadcrumb path line */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  font-size: var(--text-sm); margin-bottom: 10px; }
.crumb { padding: 4px 8px; border-radius: var(--r-sm); font-weight: 600;
  color: var(--accent); }
.crumb.drop { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.crumb-sep { color: var(--ink-tertiary); }

/* Folder + item list (Explorer-style) */
.fb-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.fb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fb-folder {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; cursor: pointer;
  border-bottom: 0.5px solid var(--hairline);
}
.fb-folder:hover { background: var(--bg-sunken, rgba(0,0,0,0.03)); }
.fb-folder.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.fb-folder .fb-ic { font-size: 22px; width: 34px; text-align: center; }
.fb-folder .fb-thumb { width: 44px; height: 28px; border-radius: 5px; flex: 0 0 auto;
  background-size: cover; background-position: center; box-shadow: inset 0 0 0 1px var(--hairline); }
.fb-folder .fb-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-folder .fb-count { color: var(--ink-tertiary); font-size: var(--text-xs); }
.fb-folder .fb-badge { color: var(--ink-secondary); font-size: var(--text-xs); }
.fb-folder .fb-menu { color: var(--ink-tertiary); font-size: 18px; padding: 0 6px; line-height: 1; }
.fb-folder .fb-menu:active { color: var(--ink); }
/* Content-piece folders are blue (a piece, not a container). */
.fb-folder.content { background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.bgw-card[draggable] { cursor: grab; }

/* Explorer toolbar (mockup): New ▾ · cut copy paste · Aa delete · Sort */
.fb-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 0; margin-bottom: 6px; }
.fb-tb { display: inline-flex; align-items: center; gap: 4px; padding: 7px 10px;
  border-radius: var(--r-md); font-size: var(--text-sm); color: var(--ink);
  border: 0.5px solid var(--hairline); background: var(--bg-elevated); white-space: nowrap; }
.fb-tb.ico { min-width: 38px; justify-content: center; font-size: 15px; }
.fb-tb.new { font-weight: 700; }
.fb-tb.disabled { opacity: 0.35; pointer-events: none; }
.fb-tb:not(.disabled):hover { background: var(--bg-sunken, rgba(0,0,0,0.05)); }
.fb-tb-sep { width: 1px; height: 22px; background: var(--hairline); margin: 0 4px; }
.fb-tb-spacer { flex: 1; }
.fb-tb.sort { border: none; background: none; color: var(--ink-secondary); }
/* Segmented list ⟷ table view toggle */
.fb-viewtoggle { display: inline-flex; gap: 2px; margin-right: 6px; padding: 2px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-md); background: var(--bg-elevated); }
.fb-viewtoggle .fb-tb.vt { border: none; background: none; min-width: 34px; padding: 5px 8px; }
.fb-viewtoggle .fb-tb.vt.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elevated)); color: var(--accent); }

/* Folder list + audit pane side by side (stacks on narrow screens) */
.fb-cols { display: flex; gap: 16px; align-items: flex-start; }
.fb-cols .fb-listwrap { flex: 1; min-width: 0; }
.fb-listhead { font-size: var(--text-xs); font-weight: 700; color: var(--ink-tertiary);
  text-transform: none; padding: 6px 8px; border-bottom: 1px solid var(--hairline);
  background: var(--bg-sunken, rgba(0,0,0,0.02)); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.fb-folder.sel { outline: 2px solid var(--accent); outline-offset: -2px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated)); }
.fb-audit { flex: 0 0 300px; border: 0.5px solid var(--hairline); border-radius: var(--r-lg);
  background: var(--bg-elevated); padding: 8px; align-self: stretch; }
.fb-audit.collapsed { flex: 0 0 auto; border: none; background: none; padding: 0; }
.fb-audit.collapsed .audit-head, .fb-audit.collapsed .audit-body { display: none; }
.audit-toggle { font-weight: 700; font-size: var(--text-sm); color: var(--accent);
  padding: 6px 4px; white-space: nowrap; }
.audit-head { display: flex; align-items: center; gap: 8px; margin: 6px 2px; font-size: var(--text-xs); }
.audit-head select { flex: 1; }
.audit-body { max-height: 60vh; overflow-y: auto; }
.audit-group { margin-bottom: 10px; }
.audit-gh { font-weight: 700; font-size: var(--text-sm); position: sticky; top: 0;
  background: var(--bg-elevated); padding: 4px 2px; }
.audit-gn { color: var(--ink-tertiary); font-weight: 400; }
.audit-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; cursor: pointer; }
.audit-row:hover { background: var(--bg-sunken, rgba(0,0,0,0.04)); border-radius: var(--r-sm); }
.audit-thumb { width: 40px; height: 24px; border-radius: 4px; flex: 0 0 auto;
  background-size: cover; background-position: center; background-color: #20242c; }
.audit-name { font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .fb-cols { flex-direction: column; }
  .fb-audit, .fb-audit.collapsed { flex: none; width: 100%; }
}

/* Flat completeness table (▦ view): pieces grouped by folder + file columns */
.fb-content { min-height: 30vh; }
.fb-table-sum { color: var(--ink-secondary); font-size: var(--text-xs); margin: 2px 2px 8px; }
.fb-table-note { color: #b8860b; font-size: var(--text-xs); margin: 0 2px 8px; }
.fb-table-scroll { overflow-x: auto; }
.grid-head, .gridrow { display: grid; align-items: center; column-gap: 4px; }
.grid-head { position: sticky; top: 0; z-index: 1; padding: 7px 8px;
  background: var(--bg-sunken, rgba(0,0,0,0.02)); border-bottom: 1px solid var(--hairline);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  color: var(--ink-tertiary); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.gridrow { padding: 6px 8px;
  border-bottom: 0.5px solid color-mix(in srgb, var(--hairline) 55%, transparent); }
.gridrow.folder { font-weight: 700; }
.gridrow.folder .fb-ic { font-size: 17px; margin-right: 7px; }
.gridrow.piece { cursor: pointer; }
.gridrow.piece:hover { background: var(--bg-sunken, rgba(0,0,0,0.03)); }
.grid-name { display: flex; align-items: center; min-width: 0; }
.grid-name .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gridrow.piece .grid-name .nm { color: var(--accent); }
.grid-tick { width: 1px; align-self: stretch; min-height: 15px; margin-right: 12px;
  background: var(--hairline); flex: 0 0 auto; }
.grid-cell { text-align: center; }
.grid-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.grid-dot.on { background: var(--accent); }
.grid-dot.off { width: 6px; height: 6px; background: var(--hairline); opacity: 0.55; }

/* Series/playlist folder shown inline as a carousel ("a book") */
.fb-series { margin: 4px 0; }
.fb-series-head { display: flex; align-items: center; justify-content: space-between;
  margin: 2px 2px 8px; }
.fb-series-head .fb-name { font-weight: 700; }

/* Folder settings panel (below the listing) */
.fld-settings { margin-top: 18px; border-top: 1px solid var(--hairline); padding-top: 10px; }
.fld-settings summary { font-weight: 700; cursor: pointer; font-size: var(--text-sm);
  color: var(--ink-secondary); }
.fld-body { display: flex; flex-direction: column; gap: 12px; padding: 12px 2px; }
.fld-row { display: flex; flex-direction: column; gap: 5px; }
.fld-row > span:first-child { font-size: var(--text-xs); font-weight: 600; color: var(--ink-secondary); }
.fld-row input, .fld-row textarea { padding: 9px 11px; border: 0.5px solid var(--hairline);
  border-radius: var(--r-md); background: var(--bg-elevated); outline: none; }
.fld-bg { width: 140px; height: 79px; border-radius: var(--r-md); background-size: cover;
  background-position: center; background-color: var(--bg-sunken, #eee);
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px var(--hairline); }
.fld-bg.sm { width: 110px; height: 62px; }
.fld-bg-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.fld-check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fld-check input { width: 18px; height: 18px; }

/* Image pool picker (slide-up) — set a background on a piece or whole folder */
.imgpool { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; max-height: 62vh; overflow-y: auto; padding: 2px; }
.imgpool-tile { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md);
  background-size: cover; background-position: center; background-color: #20242c;
  border: 0.5px solid var(--hairline); cursor: pointer; overflow: hidden; padding: 0; }
.imgpool-tile:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.imgpool-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.72)); padding: 10px 5px 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }

/* ---------- image studio: library manager + cropper ---------- */
.img-manager { padding: 4px 0; }
.img-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; }
.img-tile { position: relative; border: 0.5px solid var(--hairline); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg-elevated); }
.img-tile.pick { aspect-ratio: 16 / 9; cursor: pointer; background-size: cover;
  background-position: center; background-color: #20242c; padding: 0; }
.img-tile.pick:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.img-tile .img-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px;
  color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.72));
  padding: 10px 5px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left; }
.img-thumb { aspect-ratio: 1 / 1; background-size: cover; background-position: center;
  background-color: #20242c; }
.img-acts { display: flex; gap: 10px; padding: 6px 8px; font-size: var(--text-xs); flex-wrap: wrap; }
.link-btn { color: var(--accent); font-size: var(--text-xs); }
.link-btn.danger { color: var(--danger, #d33); }

/* Cropper: fixed-aspect frame, image dragged + zoomed underneath */
.cropper { display: flex; flex-direction: column; align-items: center; }
.crop-stage { display: flex; justify-content: center; align-items: center;
  background: #15171c; border-radius: var(--r-md); padding: 16px; width: 100%;
  min-height: 220px; margin: 8px 0; }
.crop-frame { position: relative; overflow: hidden; touch-action: none; cursor: grab;
  background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,0.25); border-radius: 4px; }
.crop-frame:active { cursor: grabbing; }
.crop-img { position: absolute; max-width: none; user-select: none; pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 10px; width: 100%;
  max-width: 320px; margin: 6px 0 12px; font-size: var(--text-sm); }
.crop-zoom input { flex: 1; }

/* ---------- video studio (vidGen) ---------- */
.vid-note { background: color-mix(in srgb, #b8860b 14%, var(--bg-elevated));
  border: 0.5px solid #b8860b; color: #8a6d0b; border-radius: var(--r-md);
  padding: 8px 10px; font-size: var(--text-sm); margin-bottom: 10px; }
.vid-variants { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.vid-variant { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-md); background: var(--bg-elevated); }
.vid-v-main { flex: 1; min-width: 0; }
.vid-v-name { font-weight: 600; font-size: var(--text-sm); }
.vid-v-dim { font-size: var(--text-xs); color: var(--ink-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.vid-v-clip { display: flex; gap: 8px; }
.vid-v-clip label { display: flex; flex-direction: column; font-size: 10px;
  color: var(--ink-tertiary); gap: 2px; }
.vid-num { width: 64px; padding: 5px 7px; border: 0.5px solid var(--hairline);
  border-radius: var(--r-sm); background: var(--bg); }
.vid-status { min-height: 18px; margin: 8px 2px; text-align: center; }
.vid-outputs { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.vid-out { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.vid-prev { max-width: 100%; max-height: 44vh; border-radius: var(--r-md);
  background: #000; box-shadow: var(--shadow-card); }

/* ---------- post-package (titles / descriptions / tags) ---------- */
.pkg-in { width: 100%; padding: 8px 10px; border: 0.5px solid var(--hairline);
  border-radius: var(--r-sm); background: var(--bg); }
.pkg-actions { display: flex; justify-content: flex-end; margin: 8px 0; }
.pkg-out { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.pkg-section { border: 0.5px solid var(--hairline); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg-elevated); }
.pkg-head { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; background: var(--bg-sunken, rgba(0,0,0,0.03));
  font-weight: 700; font-size: var(--text-sm); }
.pkg-body { margin: 0; padding: 10px 12px; max-height: 40vh; overflow: auto;
  white-space: pre-wrap; word-break: break-word; font-size: var(--text-xs);
  line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- posting copy (per-platform, in the video studio) ---------- */
.soc-studio { margin-top: 14px; }
.soc-divider { border: 0; border-top: 0.5px solid var(--hairline); margin: 8px 0 12px; }
.soc-platforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 14px; margin: 8px 0 10px; }
.soc-plat { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm);
  padding: 4px 0; cursor: pointer; }
.soc-field { padding: 8px 10px; border-top: 0.5px solid var(--hairline); }
.soc-field:first-child { border-top: 0; }
.soc-flabel { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-weight: 600; font-size: var(--text-xs); color: var(--ink-secondary);
  margin-bottom: 6px; }
.soc-title { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 5px 0; font-size: var(--text-sm); }
.soc-title span { min-width: 0; word-break: break-word; }

/* ---------- new-content pool browser / import ---------- */
.pool-flow { min-height: 32vh; }
.pool-list { display: flex; flex-direction: column; margin-top: 6px; max-height: 56vh; overflow-y: auto; }
.pool-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 8px; background: none; border: none;
  border-bottom: 0.5px solid color-mix(in srgb, var(--hairline) 60%, transparent); }
.pool-row:hover { background: var(--bg-sunken, rgba(0,0,0,0.03)); }
.pool-ic { font-size: 20px; width: 30px; text-align: center; flex: 0 0 auto; }
.pool-thumb { width: 48px; height: 30px; border-radius: 5px; flex: 0 0 auto;
  background-size: cover; background-position: center; background-color: #20242c; }
.pool-thumb.ph { background: var(--bg-sunken, #e7ecf5); }
.pool-name { flex: 1; min-width: 0; font-weight: 600; font-size: var(--text-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pool-count { color: var(--ink-tertiary); font-size: var(--text-xs); }
.pool-use { color: var(--accent); font-weight: 700; font-size: var(--text-xs); flex: 0 0 auto; }

/* Content-piece assets view */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin: 6px 0 16px; }
.asset-tile { display: block; padding: 14px; border-radius: var(--r-md);
  background: var(--bg-elevated); box-shadow: var(--shadow-card); }
.asset-tile.lyrics { cursor: pointer; }
.asset-name { font-weight: 600; font-size: var(--text-sm); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-btn { margin-top: 6px; color: var(--accent); font-size: var(--text-xs); font-weight: 600; }
.lyric-box { max-height: 60vh; overflow-y: auto; }
.lyric-line { padding: 7px 0; border-bottom: 0.5px solid var(--hairline); }

/* Creator content browser — background-artwork wall */
.bgwall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-top: 8px; }
.bgw-card { border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
  background: var(--bg-elevated); box-shadow: var(--shadow-card); }
.bgw-img { position: relative; aspect-ratio: 16 / 9;
  background: repeating-conic-gradient(#e9e9ee 0% 25%, #f6f6f9 0% 50%) 50% / 16px 16px;
  display: flex; align-items: center; justify-content: center; }
.bgw-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bgw-img.missing::after { content: '🚫'; font-size: 22px; opacity: 0.4; }
.bgw-info { padding: 8px 10px; }
.bgw-title { font-size: var(--text-sm); font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.bgw-sub { font-size: var(--text-xs); color: var(--ink-secondary); margin-top: 2px;
  display: flex; gap: 4px; align-items: center; }

/* Create tab — under-construction banner (non-builder users) */
/* Create, pre-launch: the visitor wish list. Big plain-sentence options a
   first-timer can read at a glance; selection state carries the meaning (no
   emoji, no icon fonts — one inline SVG tick). All text flows through t(),
   layout uses logical properties so RTL locales mirror correctly. */
.uc-lede { font-size: var(--text-lg); line-height: 1.5; margin: 2px 0 18px; max-width: 34em; }
.uc-opts { display: flex; flex-direction: column; gap: 10px; }
.uc-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 14px 16px; background: var(--bg-elevated); color: var(--ink);
  border: 0.5px solid var(--hairline); border-radius: var(--r-lg);
  font-size: var(--text-md); cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.uc-opt:hover { border-color: var(--ink-tertiary); }
.uc-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.uc-check {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--hairline); color: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.uc-opt.on .uc-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.uc-box {
  width: 100%; box-sizing: border-box; padding: 12px 14px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-lg);
  background: var(--bg-elevated); color: var(--ink); outline: none;
  resize: vertical; font-family: inherit; font-size: var(--text-md);
}
.uc-box:focus { border-color: var(--accent); }
.uc-done {
  padding: 30px 20px; margin-top: 8px; text-align: center;
  background: var(--bg-elevated); border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.uc-done-t { font-weight: 700; font-size: var(--text-lg); margin-bottom: 6px; }

.tk-desc { text-align: start; padding: 2px 2px 10px; }
.tk-desc-t { font-family: var(--font-display); font-weight: 800; font-size: var(--text-base); margin-bottom: 2px; }
.tk-desc-line { font-size: var(--text-sm); color: var(--ink-secondary); margin-top: 3px; }
.tk-comments { flex: 1; overflow-y: auto; padding: 6px 16px; }
.tk-comment { display: flex; gap: 10px; padding: 10px 0; }
.tk-comment.reply { margin-inline-start: 42px; }
.tk-c-name { font-size: var(--text-xs); font-weight: 700; color: var(--ink-secondary); }
.tk-c-body { font-size: var(--text-sm); margin-top: 2px; }
.tk-c-tools { display: flex; gap: 14px; margin-top: 4px; }
.tk-composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  border-top: 0.5px solid var(--hairline);
}
/* Signed-out: the composer row is the sign-in entry point. */
button.tk-composer.tk-signin {
  width: 100%; justify-content: center;
  color: var(--accent); font-weight: 600; font-size: var(--text-sm);
}
button.tk-composer.tk-signin:active { opacity: 0.7; }

/* Shrink the playing content while comments are open (CSS scale/translate
   compose with the engine's inline translateX transforms). */
.reader-overlay .slides-container { transition: scale .3s var(--ease-spring), translate .3s var(--ease-spring); }
.reader-overlay.tk-shrunk .slides-container { scale: 0.5; translate: 0 -31%; }
.reader-overlay.tk-shrunk .controls,
.reader-overlay.tk-shrunk .reader-top { opacity: 0; pointer-events: none; }
.comments-open .tk-rail, .comments-open .tk-title { display: none; }

/* Feed-embedded reader: TikTok rail replaces the reader's own top actions. */
.reader-overlay.embedded.feed-embed .reader-top { display: none; }


/* ---------- Overlays / sheets / toasts ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  animation: slide-up var(--dur-med) var(--ease-spring);
  display: flex; flex-direction: column;
}
@keyframes slide-up { from { transform: translateY(8%); opacity: 0.4; } to { transform: none; opacity: 1; } }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.4);
  animation: fade-in var(--dur-fast) ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1101;
  background: var(--bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-3) var(--s-4) calc(var(--s-6) + var(--safe-bottom));
  box-shadow: var(--shadow-sheet);
  animation: slide-up var(--dur-med) var(--ease-spring);
  max-height: 86dvh;
  overflow-y: auto;
}
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: rgba(60,60,67,0.3); margin: 0 auto var(--s-4); }
@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: 480px; border-radius: var(--r-xl); }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 16px);
  z-index: 1300;
  background: var(--glass-dark);
  backdrop-filter: var(--glass-blur);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  animation: fade-in var(--dur-fast) ease-out;
  max-width: 86vw; text-align: center;
}

/* ---------- Create wizard ---------- */
.wizard-steps { display: flex; gap: 6px; margin: var(--s-3) 0 var(--s-5); }
.wizard-steps .ws { flex: 1; height: 4px; border-radius: 2px; background: var(--hairline); }
.wizard-steps .ws.done { background: var(--accent); }

.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.kind-card {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-4);
  box-shadow: var(--shadow-card);
  text-align: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
  border: 1.5px solid transparent;
}
.kind-card:active { transform: scale(0.97); }
.kind-card.selected { border-color: var(--accent); }
.kind-card .emoji { font-size: 34px; margin-bottom: 8px; }
.kind-card .k-title { font-weight: 600; }
.kind-card .k-sub { font-size: var(--text-xs); color: var(--ink-secondary); margin-top: 4px; }

.guard-editor { position: relative; }
.guard-editor textarea {
  width: 100%; min-height: 280px;
  font-family: 'reader-regular', var(--font-ui);
  font-size: 16px; line-height: 1.6;
  padding: 12px 14px;
  border: 0.5px solid var(--hairline); border-radius: var(--r-md);
  background: var(--bg-elevated);
  white-space: pre; overflow-x: auto;
}
.guard-flag { color: var(--danger); font-size: var(--text-sm); margin-top: 6px; }
.words-status { margin: 6px 2px; min-height: 16px; }
.words-status.over { color: var(--danger); font-weight: 600; }
.words-ta.has-over { outline: 1.5px solid color-mix(in srgb, var(--danger) 55%, transparent);
  outline-offset: -1px; }

.review-line { background: var(--bg-elevated); border-radius: var(--r-md); padding: var(--s-3); margin-bottom: var(--s-3); box-shadow: var(--shadow-card); }
.review-line.overflow { outline: 1.5px solid var(--danger); }
.review-line .rl-words { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.review-line .rl-word {
  padding: 5px 10px; border-radius: var(--r-sm);
  background: var(--bg); border: 0.5px solid var(--hairline);
  font-size: var(--text-sm); cursor: pointer;
}
.review-line .rl-word.sel { background: var(--accent-soft); border-color: var(--accent); }
.review-line .rl-trans { width: 100%; border: none; background: transparent; font-size: var(--text-sm); color: var(--ink-secondary); outline: none; }
.review-line .rl-tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.tapsync-line {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 12px var(--s-4); border-radius: var(--r-md);
  background: var(--bg-elevated); margin-bottom: 8px;
  border: 1.5px solid transparent;
}
.tapsync-line.current { border-color: var(--accent); background: var(--accent-soft); }
.tapsync-line.done { opacity: 0.55; }
.tapsync-line .t { font-size: var(--text-xs); color: var(--ink-secondary); min-width: 44px; text-align: end; }

.style-preview {
  border-radius: var(--r-lg);
  aspect-ratio: 9 / 14;
  max-height: 380px; margin: 0 auto var(--s-4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #111; color: #fff; text-align: center; padding: var(--s-4);
  overflow: hidden; position: relative;
}
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin: var(--s-2) 0 var(--s-4); }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--accent); }

.record-stage { position: relative; background: #000; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 9 / 16; max-height: 70dvh; margin: 0 auto; }
/* The live canvas composites camera + lyrics (already mirrored in-canvas); the
   review video plays the recorded file as-is (WYSIWYG with the download). */
.record-stage canvas, .record-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.record-stage .rec-dot { position: absolute; top: 14px; left: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; z-index: 3; }
.record-stage .rec-countdown {
  position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 120px; color: #fff;
  text-shadow: 0 4px 30px rgba(0,0,0,0.6); background: rgba(0,0,0,0.18);
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Flashcards ---------- */
.flashcard {
  background: var(--bg-elevated); border-radius: var(--r-xl);
  box-shadow: var(--shadow-float);
  min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); padding: var(--s-6); text-align: center;
  cursor: pointer; user-select: none;
}
.flashcard .fc-word { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.02em; }
.flashcard .fc-answer { color: var(--ink-secondary); font-size: var(--text-lg); }
.fc-grades { display: flex; gap: var(--s-3); margin-top: var(--s-4); }
.fc-grades .btn { flex: 1; }

/* ---------- Admin ---------- */
.admin-stat { display: inline-flex; flex-direction: column; background: var(--bg-elevated); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-card); margin: 0 var(--s-2) var(--s-2) 0; }
.admin-stat .v { font-size: var(--text-xl); font-weight: 700; }
.admin-stat .k { font-size: var(--text-xs); color: var(--ink-secondary); }

/* ---------- Utility ---------- */
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--s-3); }
.spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--hairline); border-top-color: var(--accent);
  animation: rot 0.8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.empty-state { padding: var(--s-12) var(--s-4); color: var(--ink-secondary); text-align: center; }
.empty-state .big { font-size: 44px; margin-bottom: var(--s-3); }
