@font-face {
  font-family: "Noto Sans Lao";
  src: url("fonts/NotoSansLao-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Lao";
  src: url("fonts/NotoSansLao-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}
@font-face {
  font-family: "Noto Looped Lao";
  src: url("fonts/NotoLoopedLao-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif Lao";
  src: url("fonts/NotoSerifLao-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}

/* ພາສາໄທ (ໂຫຼດສະເພາະເມື່ອມີຕົວອັກສອນໄທ). */
@font-face {
  font-family: "Noto Sans Thai";
  src: url("fonts/NotoSansThai-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0E00-0E7F;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("fonts/NotoSansThai-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  unicode-range: U+0E00-0E7F;
}
@font-face {
  font-family: "Noto Looped Thai";
  src: url("fonts/NotoLoopedThai-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  unicode-range: U+0E00-0E7F;
}

:root {
  --ink: #2b1b3d;
  --ink-2: #5b476f;
  --ink-3: #8b7a9b;
  --paper: #fffaf0;
  --paper-2: #fff5e3;
  --cream: #fff3dd;
  --bg: #f2e6d2;
  --line: #2b1b3d;
  --accent: #f97316;
  --accent-2: #0d9488;
  --accent-soft: #ffe3cc;
  --accent-ink: #7c2d12;
  --danger: #e11d48;
  --ok: #15803d;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 5px 0 rgba(43, 27, 61, 0.12);
  --shadow-soft: 0 18px 40px rgba(43, 27, 61, 0.08);
  --font: "Noto Sans Lao", "Noto Sans Thai", "Phetsarath OT", "Saysettha OT", system-ui, sans-serif;
  --font-display: "Noto Looped Lao", "Noto Looped Thai", "Noto Sans Lao", "Noto Sans Thai", "Phetsarath OT", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(43, 27, 61, 0.09) 1px, transparent 1px),
    radial-gradient(circle at 8% 12%, var(--user-glow, rgba(249, 115, 22, 0.12)), transparent 32%),
    radial-gradient(circle at 94% 80%, var(--user-glow-2, rgba(13, 148, 136, 0.1)), transparent 30%);
  background-size: 22px 22px, auto, auto;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

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

/* ---------- ຫົວເວັບ ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  background:
    radial-gradient(circle at 16% 20%, rgba(249, 115, 22, 0.22), transparent 28%),
    radial-gradient(circle at 88% 110%, rgba(13, 148, 136, 0.24), transparent 38%),
    var(--ink);
  color: var(--cream);
  border-bottom: 4px solid var(--accent);
  box-shadow: 0 8px 24px rgba(43, 27, 61, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-mark {
  width: 82px;
  height: 52px;
  flex: none;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.22));
}
.brand-text { display: grid; line-height: 1.12; min-width: 0; }
.brand-kicker {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(255, 243, 221, 0.66);
  font-weight: 700;
}
.brand strong {
  font-family: var(--font-display);
  font-size: clamp(20px, 2vw, 28px);
  color: #fffaf0;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.lang-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border: 1.5px solid rgba(255, 243, 221, 0.35);
  border-radius: 999px;
  color: #fde68a;
  white-space: nowrap;
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- ປຸ່ມ ---------- */

.btn {
  --btn-bg: var(--paper);
  --btn-ink: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.1;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(43, 27, 61, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(43, 27, 61, 0.18); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 27, 61, 0.18); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-ink: #fffaf0;
  border-color: var(--ink);
}
.btn-dice {
  --btn-bg: var(--paper);
  min-width: 46px;
  padding: 10px;
  font-size: 18px;
}
.btn-small { min-height: 34px; padding: 7px 12px; font-size: 12.5px; }
.btn-danger-soft { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.btn-danger-soft:hover { background: #fee2e2; }
.btn-record {
  --btn-bg: var(--danger);
  --btn-ink: #fff;
  min-height: 48px;
  padding-inline: 22px;
  font-size: 14.5px;
}
.btn-download {
  --btn-bg: var(--ink);
  --btn-ink: #fff3dd;
}
.btn-top {
  --btn-bg: #fff3dd;
  --btn-ink: var(--ink);
  min-height: 36px;
  padding: 7px 14px;
  font-size: 12.5px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.btn-top-ghost {
  --btn-bg: transparent;
  --btn-ink: #fff3dd;
  border-color: rgba(255, 243, 221, 0.35);
  box-shadow: none;
}
.btn-top-ghost:hover { background: rgba(255, 243, 221, 0.1); }
.top-ico { font-size: 1.05em; line-height: 1; }
.top-label-sm { display: none; }

.mini-btn {
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 14px;
  padding: 0;
  box-shadow: 0 2px 0 rgba(43, 27, 61, 0.15);
  transition: transform 0.12s ease;
}
.mini-btn:hover { transform: rotate(-8deg) scale(1.05); }

.icon-btn {
  border: 1.5px solid rgba(255, 243, 221, 0.28);
  background: rgba(255, 243, 221, 0.08);
  color: #fff3dd;
  border-radius: 10px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 15px;
  padding: 0;
  flex: none;
  transition: background 0.15s, transform 0.12s;
}
.icon-btn:hover { background: rgba(255, 243, 221, 0.18); transform: translateY(-1px); }
.icon-btn.is-off { opacity: 0.45; }

/* ---------- ໂຄງສ້າງ ---------- */

.studio {
  max-width: 1840px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 430px;
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--shadow-soft);
}

.eyebrow {
  display: block;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.small { font-size: 12.5px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: rgba(43, 27, 61, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.92em;
}

/* ---------- ຄັງເລື່ອງ ---------- */

.rail {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 27, 61, 0.25) transparent;
}
.rail::-webkit-scrollbar { width: 6px; }
.rail::-webkit-scrollbar-thumb { background: rgba(43, 27, 61, 0.22); border-radius: 99px; }

.rail-block {
  padding: 14px 14px 16px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(43, 27, 61, 0.1);
  margin-bottom: 12px;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}
.count-badge {
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1.5px solid rgba(43, 27, 61, 0.18);
  font-size: 11px;
  font-weight: 800;
}

/* ---------- ປະເພດເລື່ອງ (genre) ---------- */
.genre-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.genre-tab {
  --genre: var(--accent);
  display: grid;
  justify-items: start;
  gap: 1px;
  padding: 8px 10px;
  text-align: left;
  border: 2px solid rgba(43, 27, 61, 0.14);
  border-radius: 13px;
  background: var(--paper);
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.genre-tab:hover { border-color: var(--genre); transform: translateY(-1px); }
.genre-tab.is-active {
  border-color: var(--line);
  background: color-mix(in srgb, var(--genre) 16%, var(--paper));
  box-shadow: inset 0 -3px 0 var(--genre), 0 2px 0 rgba(43, 27, 61, 0.12);
}
.genre-emoji { font-size: 20px; line-height: 1.1; }
.genre-tab strong { font-family: var(--font-display); font-size: 14px; }
.genre-count { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }

.series-tabs { display: grid; gap: 7px; }
.series-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 13px;
  background: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.series-tab:hover { background: rgba(249, 115, 22, 0.08); transform: translateX(2px); }
.series-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--line);
  box-shadow: 0 2px 0 rgba(43, 27, 61, 0.12);
}
.series-emoji {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 1.5px solid var(--line);
  font-size: 17px;
}
.series-copy { min-width: 0; display: grid; line-height: 1.25; }
.series-copy strong {
  font-family: var(--font-display);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.series-copy span {
  font-size: 10.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-list { display: grid; gap: 7px; }
.episode-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px;
  border: 1.5px solid rgba(43, 27, 61, 0.13);
  border-radius: 12px;
  background: var(--paper-2);
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}
.episode-card:hover {
  border-color: var(--line);
  background: #fff;
  transform: translateY(-1px);
}
.episode-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.episode-emoji {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--paper);
  border: 1.5px solid rgba(43, 27, 61, 0.18);
  display: grid;
  place-items: center;
  font-size: 17px;
}
.episode-copy { min-width: 0; display: grid; gap: 1px; }
.episode-copy strong {
  font-size: 12.5px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.episode-copy span { font-size: 10.5px; color: var(--ink-2); line-height: 1.35; }

.saved-list { display: grid; gap: 6px; }
.saved-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid rgba(43, 27, 61, 0.12);
  border-radius: 11px;
  background: var(--paper-2);
  padding: 2px 3px 2px 9px;
}
.saved-open {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 7px 2px;
  display: grid;
  gap: 1px;
}
.saved-open strong {
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.saved-open span { font-size: 10px; color: var(--ink-3); }
.saved-del {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
}
.saved-del:hover { background: rgba(225, 29, 72, 0.1); color: var(--danger); }
.saved-share {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-size: 13px;
}
.saved-share:hover { background: rgba(13, 148, 136, 0.12); }
.rail-note {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-3);
  padding: 0 6px;
  margin: 4px 0 8px;
}

/* ---------- ໄອເດຍ ---------- */

.main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.main > * { min-width: 0; }

.idea-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 16px;
  background:
    radial-gradient(circle at 94% 8%, rgba(249, 115, 22, 0.22) 0 64px, transparent 65px),
    radial-gradient(circle at 87% 22%, rgba(13, 148, 136, 0.16) 0 42px, transparent 43px),
    linear-gradient(120deg, var(--accent-soft), var(--paper-2) 58%, #fff);
}
.idea-card::after {
  content: "✿";
  position: absolute;
  right: 26px;
  bottom: -18px;
  font-size: 90px;
  color: rgba(43, 27, 61, 0.06);
  transform: rotate(-12deg);
  pointer-events: none;
}
.idea-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.idea-head h1 {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.1vw, 31px);
  line-height: 1.18;
  margin: 2px 0 0;
}
.idea-tip { font-size: 11px; color: var(--ink-2); text-align: right; max-width: 210px; }
.idea-form { display: flex; gap: 8px; align-items: stretch; position: relative; z-index: 1; }
.idea-input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 11px 18px;
  font-size: 14px;
  box-shadow: inset 0 2px 0 rgba(43, 27, 61, 0.06);
}
.idea-input::placeholder { color: var(--ink-3); }
.idea-input:focus { outline: 3px solid var(--accent-2); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; position: relative; z-index: 1; }
.chip {
  border: 1.5px solid rgba(43, 27, 61, 0.18);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  color: var(--ink-2);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.chip:hover { border-color: var(--accent); background: #fff; transform: translateY(-1px); }

/* ---------- ເວທີ ---------- */

.stage-card { padding: 16px; }
.stage-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.stage-title { min-width: 0; flex: 1; }
.title-input {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 2px dashed transparent;
  background: transparent;
  padding: 1px 0 3px;
  font-family: var(--font-display);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
  line-height: 1.22;
  border-radius: 4px;
}
.title-input:hover { border-bottom-color: rgba(43, 27, 61, 0.18); }
.title-input:focus { outline: none; border-bottom-color: var(--accent); }
.stage-meta { margin: 3px 0 0; font-size: 11px; color: var(--ink-2); }

.aspect-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
  flex: none;
}
.aspect-btn {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 5px 9px;
  display: grid;
  place-items: center;
  gap: 1px;
  line-height: 1;
  color: var(--ink-2);
  min-width: 48px;
}
.aspect-btn strong { font-size: 11px; letter-spacing: 0.03em; }
.aspect-btn span { font-size: 8.5px; opacity: 0.8; }
.aspect-btn.is-active {
  background: var(--ink);
  color: var(--cream);
  box-shadow: 0 2px 0 rgba(43, 27, 61, 0.2);
}

.stage-frame {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 243, 221, 0.1), transparent 60%),
    #1b1026;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  place-items: center;
  min-height: 260px;
  box-shadow: inset 0 0 0 5px rgba(255, 243, 221, 0.04), 0 3px 0 rgba(43, 27, 61, 0.15);
}
.stage-frame.is-portrait {
  max-width: min(100%, calc(62vh * 0.5625 + 20px));
  margin-inline: auto;
}
.stage-frame.is-square {
  max-width: min(100%, calc(62vh + 20px));
  margin-inline: auto;
}
.stage-frame canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 62vh;
  border-radius: 10px;
  background: #1b1026;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  background: var(--ink);
  border-radius: 14px;
  padding: 8px 11px;
  color: var(--cream);
}
.play-btn {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--cream);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.12s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn:active { transform: scale(0.96); }
.time-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 243, 221, 0.8);
  white-space: nowrap;
  min-width: 76px;
}
.timeline {
  position: relative;
  flex: 1;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 243, 221, 0.16);
}
.timeline-fill {
  position: absolute;
  left: 0;
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
  width: 0;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.55);
}
.timeline-marks { position: absolute; inset: 0; pointer-events: none; }
.timeline-mark {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 12px;
  margin-top: -6px;
  border-radius: 2px;
  background: rgba(255, 243, 221, 0.38);
}

.scene-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 2px 2px;
  scrollbar-width: thin;
}
.scene-chip {
  flex: none;
  border: 1.5px solid rgba(43, 27, 61, 0.18);
  background: var(--paper-2);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  transition: border-color 0.15s, background 0.15s;
}
.scene-chip span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.scene-chip strong {
  font-size: 9.5px;
  color: var(--accent-ink);
  flex: none;
}
.scene-chip:hover { border-color: var(--line); }
.scene-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 2px 0 rgba(43, 27, 61, 0.1);
}

.record-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.render-msg {
  font-size: 11.5px;
  color: var(--ink-2);
  min-height: 18px;
  flex: 1 1 180px;
}
.render-msg.bad { color: var(--danger); font-weight: 700; }
.render-msg.ok { color: var(--ok); font-weight: 700; }
.record-note { margin: 7px 2px 0; font-size: 10px; color: var(--ink-3); }

.progress {
  height: 9px;
  border-radius: 99px;
  background: rgba(43, 27, 61, 0.1);
  margin-top: 10px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.18s linear;
}

.result { margin-top: 12px; }
.result video {
  width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #000;
}
.result-note { margin: 7px 2px 0; font-size: 11px; color: var(--ink-2); }

.footer-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-3);
  margin: 4px 0 18px;
}

/* ---------- ບັນນາທິການ ---------- */

.editor {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-head {
  padding: 15px 16px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 2px dashed rgba(43, 27, 61, 0.14);
}
.editor-head h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.25;
}
.dirty-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(21, 128, 61, 0.1);
  color: var(--ok);
  border: 1px solid rgba(21, 128, 61, 0.2);
  white-space: nowrap;
}
.dirty-badge.is-dirty {
  background: rgba(249, 115, 22, 0.14);
  color: var(--accent-ink);
  border-color: rgba(249, 115, 22, 0.35);
}

.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px 0;
}
.editor-tabs button {
  flex: 1;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 10px 10px 0 0;
  padding: 7px 9px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.editor-tabs button.is-active {
  background: var(--accent-soft);
  border-color: var(--line);
  border-bottom-color: var(--accent-soft);
  color: var(--ink);
}

.editor-body {
  padding: 12px 14px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 27, 61, 0.22) transparent;
}
.editor-body::-webkit-scrollbar { width: 6px; }
.editor-body::-webkit-scrollbar-thumb { background: rgba(43, 27, 61, 0.2); border-radius: 99px; }

.cast-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}
.cast-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 4px;
  border: 1.5px solid rgba(43, 27, 61, 0.15);
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 10px;
}
.cast-avatar {
  width: 24px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background: var(--paper);
  border: 1px solid rgba(43, 27, 61, 0.15);
  display: block;
}
.cast-chip em { font-style: normal; color: var(--ink-3); font-size: 9px; }

.scene-editor { display: grid; gap: 10px; }
.scene-card {
  border: 1.5px solid rgba(43, 27, 61, 0.2);
  border-radius: 14px;
  background: #fff;
  padding: 9px;
  box-shadow: 0 2px 0 rgba(43, 27, 61, 0.06);
}
.scene-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.scene-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}
.scene-num {
  font-size: 9.5px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--cream);
  flex: none;
}
.scene-title-input {
  flex: 1 1 120px;
  min-width: 90px;
  border: 0;
  border-bottom: 1.5px dashed rgba(43, 27, 61, 0.22);
  background: transparent;
  padding: 3px 2px;
  font-size: 12px;
  font-weight: 700;
}
.scene-title-input:focus { outline: none; border-bottom-color: var(--accent); }
.scene-mini-actions { display: flex; gap: 2px; flex: none; }
.scene-mini-actions button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  width: 24px; height: 24px;
  border-radius: 7px;
  padding: 0;
  font-size: 12px;
}
.scene-mini-actions button:hover { background: rgba(43, 27, 61, 0.07); color: var(--ink); }
.scene-mini-actions button.danger:hover { background: rgba(225, 29, 72, 0.1); color: var(--danger); }

.field-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--ink-3);
}
.field-inline select {
  border: 1px solid rgba(43, 27, 61, 0.18);
  border-radius: 7px;
  background: var(--paper-2);
  font-size: 10px;
  padding: 3px 4px;
  max-width: 92px;
}
.field-inline select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.line-row {
  display: grid;
  grid-template-columns: 88px 82px minmax(0, 1fr) 24px;
  gap: 4px;
  align-items: start;
  margin-top: 5px;
}
.line-row select {
  border: 1px solid rgba(43, 27, 61, 0.16);
  border-radius: 7px;
  background: var(--paper-2);
  padding: 5px 3px;
  font-size: 10px;
  min-width: 0;
}
.line-row textarea {
  width: 100%;
  min-height: 38px;
  resize: vertical;
  border: 1px solid rgba(43, 27, 61, 0.18);
  border-radius: 8px;
  background: #fff;
  padding: 6px 7px;
  font-size: 11.5px;
  line-height: 1.5;
}
.line-row textarea:focus, .line-row select:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 0;
}
.line-del {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 6px;
  height: 30px;
  font-size: 11px;
  padding: 0;
}
.line-del:hover { background: rgba(225, 29, 72, 0.1); color: var(--danger); }
.add-line {
  margin-top: 6px;
  border: 1.5px dashed rgba(43, 27, 61, 0.28);
  background: transparent;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 10px;
  color: var(--ink-2);
  width: 100%;
}
.add-line:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.add-line:disabled { opacity: 0.45; cursor: not-allowed; }

.editor-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1.5px dashed rgba(43, 27, 61, 0.14);
}
.editor-actions .btn-primary { margin-left: auto; }

.textarea {
  width: 100%;
  border: 1.5px solid rgba(43, 27, 61, 0.22);
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}
.script-area { min-height: 380px; font-family: var(--font); margin-top: 8px; }
.textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

/* ---------- toast ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--ink);
  color: var(--cream);
  border: 2px solid rgba(255, 243, 221, 0.22);
  border-left: 5px solid var(--accent);
  border-radius: 13px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(43, 27, 61, 0.3);
  animation: toast-in 0.22s ease both;
}
.toast.ok { border-left-color: #22c55e; }
.toast.bad { border-left-color: #fb7185; }
.toast.out { animation: toast-out 0.25s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

.noscript {
  margin: 30px auto;
  max-width: 600px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

/* ---------- ຈໍນ້ອຍ ---------- */

/* ---- ແກ້ໄຂຕົວລະຄອນ --------------------------------------------------- */
button.cast-chip { font: inherit; font-size: 10px; color: inherit; cursor: pointer; transition: transform 0.12s, border-color 0.15s; }
button.cast-chip:hover { transform: translateY(-1px); border-color: var(--accent); }
.cast-chip-edit { border-style: dashed; }
.cast-edit-icon { width: 24px; text-align: center; font-size: 14px; }

.cast-dialog {
  width: min(1120px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  font-family: var(--font);
  overflow: hidden;
}
.cast-dialog[open] { display: grid; grid-template-rows: auto 1fr auto; }
.cast-dialog::backdrop { background: rgba(43, 27, 61, 0.55); }
.cast-dialog-head, .cast-dialog-foot {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
}
.cast-dialog-head { border-bottom: 1.5px solid rgba(43, 27, 61, 0.12); justify-content: space-between; }
.cast-dialog-head h2 { margin: 2px 0 0; font-family: var(--font-display); font-size: 20px; }
.cast-close { background: var(--cream); color: var(--ink); border-color: rgba(43, 27, 61, 0.2); }
.cast-dialog-foot { border-top: 1.5px solid rgba(43, 27, 61, 0.12); flex-wrap: wrap; }
.cast-foot-left, .cast-foot-right { display: flex; gap: 8px; flex-wrap: wrap; }
.cast-foot-note { flex: 1; min-width: 180px; margin: 0; }
.cast-dialog-body {
  display: grid; grid-template-columns: 190px 300px 1fr; gap: 16px;
  padding: 16px 18px; overflow: auto; min-height: 0;
}
.cast-list {
  display: flex; flex-direction: column; gap: 7px; min-height: 0;
  max-height: min(610px, calc(100dvh - 225px));
  position: sticky; top: 0; align-self: start;
}
.cast-list-tools { display: grid; gap: 6px; padding-bottom: 4px; background: var(--paper); z-index: 4; }
.cast-search-row { display: flex; align-items: center; gap: 5px; }
.cast-search {
  flex: 1; min-width: 0; min-height: 34px; padding: 6px 9px;
  border: 1.5px solid rgba(43, 27, 61, 0.2); border-radius: 9px;
  background: #fff; color: var(--ink); font: inherit; font-size: 12px;
}
.cast-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cast-search::-webkit-search-cancel-button { display: none; }
.cast-search-clear { flex: none; width: 30px; height: 30px; }
.cast-filter-line { display: flex; align-items: end; justify-content: space-between; gap: 6px; }
.cast-filter-line .cast-filter-row { flex: 1; min-width: 0; margin: 0; }
.cast-result-count { flex: none; padding-bottom: 7px; font-size: 10.5px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.cast-list-items {
  display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow: auto;
  padding-right: 3px; scroll-behavior: smooth; position: relative;
}
.cast-list-items::-webkit-scrollbar { width: 6px; }
.cast-list-items::-webkit-scrollbar-thumb { background: rgba(43, 27, 61, 0.18); border-radius: 999px; }
.cast-group-block { display: flex; flex-direction: column; gap: 4px; }
.cast-group-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; text-align: left; border: 1.5px solid rgba(43, 27, 61, 0.12);
  border-radius: 9px; background: var(--cream); color: var(--ink); font: inherit;
  font-size: 11px; font-weight: 800; cursor: pointer;
}
.cast-group-head:hover { border-color: var(--accent); }
.cast-group-head.has-active { border-color: var(--accent); background: var(--accent-soft); }
.cast-group-active { flex: none; font-size: 10px; font-weight: 900; color: var(--accent-ink, var(--accent)); }
.cast-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-group-count {
  flex: none; min-width: 20px; padding: 1px 6px; text-align: center; border-radius: 999px;
  background: rgba(43, 27, 61, 0.08); font-size: 10px;
}
.cast-group-chevron { flex: none; font-size: 12px; color: var(--ink-3); }
.cast-list-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; text-align: left;
  border: 1.5px solid rgba(43, 27, 61, 0.14); border-radius: 12px; background: var(--paper-2, #fff);
  font: inherit; color: inherit; cursor: pointer; flex: none;
}
.cast-list-item:hover { border-color: var(--accent); }
.cast-list-item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.cast-list-head { width: 40px; height: 40px; flex: none; }
.cast-list-copy { display: grid; min-width: 0; line-height: 1.2; }
.cast-list-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-list-copy em { font-style: normal; font-size: 10.5px; color: var(--ink-3, #7a6a85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-empty {
  display: grid; gap: 3px; padding: 10px; border: 1.5px dashed rgba(43, 27, 61, 0.18);
  border-radius: 10px; font-size: 11.5px; color: var(--ink-3);
}
.cast-empty strong { color: var(--ink); font-size: 12.5px; }
.cast-empty .btn { justify-self: start; margin-top: 3px; }
.cast-create {
  border-style: dashed; border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-ink, var(--ink));
}
.cast-create:hover { background: var(--paper); }
.cast-create-icon {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 12px; background: var(--accent); color: #fffaf0; font-size: 22px; font-weight: 800;
}
.cast-name-row { display: flex; gap: 6px; align-items: center; }
.cast-name-row .cast-input { flex: 1; min-width: 0; }
.cast-hint { margin: 0; }
.cast-filter-row {
  display: grid; gap: 4px; font-size: 11px; font-weight: 700; color: var(--ink-3, #7a6a85);
}
.cast-filter {
  min-height: 34px; padding: 5px 8px; border: 1.5px solid rgba(43, 27, 61, 0.2); border-radius: 9px;
  background: #fff; color: var(--ink); font: inherit; font-size: 12px; font-weight: 600;
}
.cast-equipment { display: grid; gap: 9px; }
.cast-equipment-group { display: grid; gap: 4px; }
.cast-equipment-label { margin: 0; font-size: 11px; font-weight: 700; color: var(--ink-3, #7a6a85); }
.cast-sub-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cast-sub-row .cast-sub { margin: 8px 0 0; }
.cast-pick-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: center; }
.cast-pick-row .cast-input { min-width: 0; }
.cast-equipment-actions { display: flex; gap: 5px; margin-left: auto; }

/* ---------- Part Studio: AI / upload avatar parts ---------- */
.part-studio { width: min(1000px, calc(100vw - 28px)); }
.part-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px 0; }
.part-tab {
  padding: 7px 12px; border-radius: 999px; border: 1.5px solid rgba(43, 27, 61, 0.18);
  background: var(--paper-2); color: var(--ink-2); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.part-tab.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.part-studio-body { grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.part-form { display: grid; gap: 12px; min-width: 0; }
.part-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.part-field { display: grid; gap: 4px; min-width: 0; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.part-field .cast-input { width: 100%; }
.part-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.part-chip { font-size: 11.5px; padding: 5px 10px; }
.part-form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.part-preview-pane {
  display: grid; gap: 8px; align-content: start; position: sticky; top: 0;
  padding: 10px; border: 2px solid var(--line); border-radius: 16px; background: var(--paper-2);
}
.part-preview-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 320 / 360;
  border: 1.5px solid rgba(43, 27, 61, 0.18); border-radius: 12px; background: #fff7e8;
}
.part-preview-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.part-preview-meta span {
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 12%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--accent) 38%, transparent);
}
.part-upload-row { display: flex; align-items: center; gap: 10px; }
.part-upload-thumb {
  width: 74px; height: 74px; flex: none; display: grid; place-items: center; overflow: hidden;
  border: 2px dashed rgba(43, 27, 61, 0.28); border-radius: 12px; background: var(--paper); font-size: 26px;
}
.part-upload-thumb img { width: 100%; height: 100%; object-fit: contain; }
.part-upload-copy { display: grid; gap: 5px; }
.part-sliders { grid-template-columns: 1fr; }
.part-range-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; min-height: 34px; }
.part-range { width: 100%; accent-color: var(--accent); }
.part-list { display: grid; gap: 6px; max-height: 360px; overflow: auto; }
.part-list-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1.5px solid rgba(43, 27, 61, 0.15); border-radius: 12px; background: var(--paper);
}
.part-list-icon { font-size: 20px; }
.part-list-copy { display: grid; min-width: 0; flex: 1; }
.part-list-copy strong { font-size: 13px; }
.part-list-copy span { font-size: 11px; color: var(--ink-3); }
.part-list-copy strong, .part-list-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-preset-panel {
  display: grid; gap: 6px; padding: 9px; border: 1.5px dashed rgba(43, 27, 61, 0.18);
  border-radius: 12px; background: rgba(255, 250, 240, 0.7);
}
.cast-preset-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.cast-preset-tab {
  padding: 4px 9px; border: 1.5px solid rgba(43, 27, 61, 0.16); border-radius: 999px;
  background: #fff; color: var(--ink); font: inherit; font-size: 11px; cursor: pointer;
}
.cast-preset-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fffaf0; }
.cast-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; }
.cast-preset {
  display: flex; align-items: center; gap: 5px; padding: 5px 7px; text-align: left;
  border: 1.5px solid rgba(43, 27, 61, 0.15); border-radius: 9px; background: #fff;
  color: var(--ink); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
.cast-preset:hover { border-color: var(--accent); background: var(--accent-soft); }
.cast-preset-icon { font-size: 15px; line-height: 1; }
.cast-stage { display: grid; gap: 10px; align-content: start; }
.cast-preview {
  width: 100%; height: auto; aspect-ratio: 320 / 360;
  border: 1.5px solid rgba(43, 27, 61, 0.15); border-radius: 16px;
  background: radial-gradient(circle at 50% 35%, #fff 0%, var(--cream) 70%);
}
.cast-stage-controls { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.cast-form { display: grid; gap: 8px; align-content: start; min-width: 0; }
.cast-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cast-field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; }
.cast-field.wide { grid-column: 1 / -1; }
.cast-input {
  min-height: 36px; padding: 6px 10px; border: 1.5px solid rgba(43, 27, 61, 0.2); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-weight: 500;
}
.cast-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cast-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.cast-sub { margin: 8px 0 0; font-size: 13px; font-family: var(--font-display); }
.cast-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.cast-toggle {
  padding: 6px 11px; border: 1.5px solid rgba(43, 27, 61, 0.2); border-radius: 999px;
  background: #fff; color: var(--ink); font: inherit; font-size: 12px; cursor: pointer;
}
.cast-toggle.is-on { background: var(--accent); border-color: var(--accent); color: #fffaf0; }
.cast-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cast-color { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.cast-color input[type="color"] {
  width: 34px; height: 30px; padding: 0; border: 1.5px solid rgba(43, 27, 61, 0.25); border-radius: 8px;
  background: none; cursor: pointer; flex: none;
}
@media (max-width: 940px) {
  .cast-dialog-body { grid-template-columns: 1fr; }
  .cast-stage { max-width: 320px; justify-self: center; width: 100%; }
}
@media (max-width: 520px) {
  .cast-grid { grid-template-columns: 1fr; }
}

/* ---- ສຽງພາກ ---------------------------------------------------------- */
.line-row .line-voice { grid-column: 1 / -1; }
.line-voice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; }
.voice-badge {
  font-size: 10.5px; padding: 3px 8px; border-radius: 999px; margin-right: 2px;
  background: rgba(43, 27, 61, 0.06); color: var(--ink-2, #5b4b6b);
}
.voice-badge.is-on { background: #dcfce7; color: #166534; }
.voice-badge.is-nc { background: #fef3c7; color: #92400e; }
.vbtn {
  min-height: 26px; padding: 2px 8px; border: 1.5px solid rgba(43, 27, 61, 0.18); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 11px; cursor: pointer;
}
.vbtn:hover { border-color: var(--accent); }
.vbtn:disabled { opacity: 0.5; cursor: wait; }
.vbtn.is-picked { background: var(--accent-soft); border-color: var(--accent); }
.vbtn.is-recording, .btn.is-recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: 0.65; } }
.voice-panel { display: grid; gap: 10px; }
.voice-status { margin: 0; font-size: 12.5px; font-weight: 600; }
.voice-card {
  display: grid; gap: 6px; padding: 10px 12px; border: 1.5px solid rgba(43, 27, 61, 0.14);
  border-radius: 12px; background: var(--paper-2, #fff);
}
.voice-card .editor-actions { margin-top: 2px; }
.voice-switch { grid-template-columns: auto 1fr; align-items: start; cursor: pointer; }
.voice-switch input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.voice-switch span { display: grid; gap: 3px; }
.voice-switch small { font-size: 11px; color: var(--ink-2, #5b4b6b); line-height: 1.45; }
.voice-warn { margin: 0; font-size: 11.5px; color: #92400e; background: #fef3c7; padding: 6px 8px; border-radius: 8px; }
.pron-list { display: grid; gap: 6px; }
.pron-row { display: flex; gap: 6px; align-items: center; }
.pron-row .cast-input { flex: 1; min-width: 0; }
.bank-list { display: grid; gap: 5px; }
.bank-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; text-align: left;
  padding: 7px 10px; border: 1.5px solid rgba(43, 27, 61, 0.12); border-radius: 10px; background: #fff;
  font: inherit; font-size: 12px; color: inherit; cursor: pointer;
}
.bank-row:hover { border-color: var(--accent); }
.bank-row em { font-style: normal; color: var(--ink-3, #7a6a85); font-size: 11px; }
.cast-voice { display: grid; gap: 8px; }
.cast-voice p { margin: 0; }
.bank-prompt {
  font-size: 15px !important; font-weight: 600; padding: 10px 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1.5px dashed var(--accent);
}
.bank-clips { display: grid; gap: 4px; max-height: 190px; overflow: auto; font-size: 12px; }
.bank-clip { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.bank-clip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-clip em { font-style: normal; color: var(--ink-3, #7a6a85); }

/* ---- Voice changer ----------------------------------------------------- */
.voice-changer { gap: 8px; }
.voice-changer > strong { font-family: var(--font-display); }
.fx-bulk {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 6px 8px; border-radius: 10px; background: var(--accent-soft);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.fx-bulk .cast-input { flex: 1; min-width: 150px; }
.fx-row {
  display: grid; gap: 6px; padding: 8px 9px; border-radius: 12px;
  background: #fff; border: 1.5px solid rgba(43, 27, 61, 0.12);
}
.fx-row-head { display: grid; grid-template-columns: minmax(70px, 1fr) minmax(130px, 1.4fr) auto auto; gap: 6px; align-items: center; }
.fx-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-preset { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.fx-range { display: grid; grid-template-columns: auto minmax(0, 1fr) 46px; gap: 7px; align-items: center; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.fx-range input[type="range"] { width: 100%; accent-color: var(--accent); }
.fx-range output { text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--ink-3); }
.fx-advanced { border-top: 1px dashed rgba(43, 27, 61, 0.15); padding-top: 4px; }
.fx-advanced summary { cursor: pointer; font-size: 11px; font-weight: 700; color: var(--ink-2); padding: 2px 0; }
.fx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; margin-top: 5px; }
.fx-grid .fx-range { grid-template-columns: 1fr; gap: 2px; }
.fx-grid .fx-range output { text-align: left; }
[data-fx-state] { margin: 0; }
[data-fx-state].is-dirty { color: var(--accent-ink); font-weight: 700; }
@media (max-width: 560px) {
  .fx-row-head { grid-template-columns: 1fr auto auto; }
  .fx-row-head .fx-name { grid-column: 1; }
  .fx-row-head .fx-preset { grid-column: 1 / -1; grid-row: 2; }
  .fx-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1520px) {
  .studio { grid-template-columns: 266px minmax(0, 1fr) 390px; gap: 14px; padding: 16px; }
}
@media (max-width: 1280px) {
  .studio { grid-template-columns: 250px minmax(0, 1fr); }
  .editor {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
  .editor-body { max-height: 520px; }
}
@media (max-width: 960px) {
  .lang-badge { display: none; }
}

@media (max-width: 940px) {
  .studio {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding:
      12px
      max(12px, env(safe-area-inset-right))
      12px
      max(12px, env(safe-area-inset-left));
  }
  .main, .rail, .editor { width: 100%; }
  .main { order: 1; margin-bottom: 12px; }
  .rail {
    order: 2;
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
    min-width: 0;
    width: 100%;
    margin-bottom: 12px;
  }
  .editor {
    order: 3;
    margin-top: 0;
    margin-bottom: 12px;
  }
  .editor-body { max-height: none; overflow: visible; }
  .rail-block { min-width: 0; }
  .series-tabs, .episode-list, .saved-list { min-width: 0; max-width: 100%; }
  .rail-block { padding: 12px; }
  .series-tabs {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 3px;
  }
  .series-tab { min-width: 190px; }
  .episode-list {
    display: flex;
    overflow-x: auto;
    gap: 7px;
    padding-bottom: 4px;
  }
  .episode-card { min-width: 215px; }
  .saved-list { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 9px 12px; gap: 8px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .brand-mark { width: 64px; height: 42px; }
  .brand-kicker { font-size: 9px; }
  .lang-badge { display: none; }
  .top-actions { margin-left: auto; }
  .btn-top { padding: 6px 10px; font-size: 11px; min-height: 32px; }
  .idea-card { padding: 14px; }
  .idea-head { display: block; }
  .idea-tip { text-align: left; margin-top: 3px; max-width: none; }
  .idea-form { flex-wrap: wrap; }
  .idea-input { flex: 1 1 100%; }
  .idea-form .btn-primary { flex: 1; }
  .stage-card { padding: 11px; }
  .stage-top { display: block; }
  .aspect-switch { margin-top: 9px; width: max-content; }
  .title-input { font-size: 20px; }
  .transport { gap: 6px; padding: 7px; }
  .time-label { min-width: 62px; font-size: 10px; }
  .icon-btn { width: 31px; height: 31px; font-size: 13px; }
  .play-btn { width: 36px; height: 36px; }
  .record-row .btn { flex: 1 1 auto; }
  .line-row { grid-template-columns: 1fr 1fr 24px; }
  .line-row textarea { grid-column: 1 / 3; grid-row: 2; }
  .line-row .line-del { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  .editor-head h2 { font-size: 17px; }
  .script-area { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ລະຫວ່າງການບັນທຶກ */
.is-recording .editor,
.is-recording .rail,
.is-recording .idea-card {
  opacity: 0.6;
  pointer-events: none;
}
.is-recording .stage-card {
  box-shadow: 0 0 0 4px var(--accent), var(--shadow);
}
.is-recording .stage-frame {
  position: relative;
}
.is-recording .stage-frame::after {
  content: "● ກຳລັງບັນທຶກ";
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(225, 29, 72, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  animation: rec-pulse 1.2s infinite;
  z-index: 4;
  pointer-events: none;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ແຖບສຽງອັດຕໍ່ປະໂຫຍກ */
.line-voice {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 1px 0 3px;
  padding: 3px 7px;
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: 7px;
  background: rgba(13, 148, 136, 0.07);
  font-size: 9.5px;
  color: var(--ink-2);
}
.line-voice-tag { font-weight: 700; color: #0f766e; }
.line-voice-len { color: var(--ink-3); }
.line-voice-del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  width: 20px;
  height: 20px;
  border-radius: 5px;
  padding: 0;
  font-size: 10px;
}
.line-voice-del:hover { background: rgba(225, 29, 72, 0.1); color: var(--danger); }

/* ---------- ໜ້າເຂົ້າສູ່ລະບົບ ---------- */

/* ເຊື່ອງໄວ້ຈົນກວ່າ auth.js ຈະກວດ session ແລ້ວ. */
html.auth-checking body { visibility: hidden; }

body.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  overflow-x: hidden;
  background:
    radial-gradient(circle at 6% 8%, rgba(249, 115, 22, 0.32), transparent 34%),
    radial-gradient(circle at 94% 86%, rgba(13, 148, 136, 0.34), transparent 38%),
    radial-gradient(rgba(255, 243, 221, 0.055) 1px, transparent 1px),
    linear-gradient(150deg, #362151 0%, #1b1027 58%, #241333 100%);
  background-size: auto, auto, 22px 22px, auto;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.login-shell {
  width: min(1090px, 100%);
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  align-items: center;
  gap: clamp(36px, 7vw, 88px);
}

/* ---- ຝັ່ງຍີ່ຫໍ້ ---- */

.login-hero { position: relative; min-width: 0; padding: 10px 0; color: var(--cream); }
.login-hero-brand { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.login-hero-logo {
  width: clamp(180px, 21vw, 250px);
  height: auto;
  flex: none;
  filter: drop-shadow(0 9px 0 rgba(0, 0, 0, 0.2)) drop-shadow(0 24px 32px rgba(0, 0, 0, 0.26));
}
.login-hero-text { min-width: 0; max-width: 460px; }
.login-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1.5px solid rgba(255, 243, 221, 0.28);
  border-radius: 999px;
  background: rgba(255, 243, 221, 0.08);
  color: #fde68a;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.login-hero-name {
  margin: 9px 0 0;
  color: #fffaf0;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.6vw, 56px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.01em;
  text-wrap: balance;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}
.login-hero-copy {
  max-width: 34ch;
  margin: 12px 0 0;
  color: rgba(255, 243, 221, 0.72);
  font-size: clamp(13px, 1.35vw, 15px);
  line-height: 1.65;
}
.login-features {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
.login-features li {
  padding: 8px 12px;
  border: 1.5px solid rgba(255, 243, 221, 0.18);
  border-radius: 999px;
  background: rgba(255, 243, 221, 0.07);
  color: #fff3dd;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.login-hero-art { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.login-bubble {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}
.login-bubble-a {
  top: 4%;
  right: 0;
  padding: 8px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 12px;
  transform: rotate(4deg);
}
.login-bubble-b {
  right: 12%;
  bottom: 12%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 21px;
  transform: rotate(-8deg);
}
.login-star { position: absolute; color: #fbbf24; font-size: 18px; line-height: 1; }
.login-star-a { top: 0; right: 31%; }
.login-star-b { right: 2%; bottom: 45%; color: #5eead4; font-size: 12px; }

/* ---- ບັດເຂົ້າສູ່ລະບົບ ---- */

.login-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  justify-self: end;
  padding: 30px 28px 24px;
  border: 2px solid var(--line);
  border-radius: 26px;
  background: var(--paper);
  text-align: left;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.24), 0 36px 70px rgba(0, 0, 0, 0.36);
  animation: login-in 0.35s ease both;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  right: 28px;
  height: 5px;
  border-radius: 0 0 99px 99px;
  background: linear-gradient(90deg, var(--accent), #f4b544, var(--accent-2));
}
.login-card.is-shaking { animation: login-shake 0.36s ease both; }

.login-kicker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.login-card h1 {
  margin: 11px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(27px, 3.1vw, 33px);
  line-height: 1.18;
}
.login-sub {
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
}

.login-form { display: grid; gap: 14px; text-align: left; }
.login-field { display: grid; gap: 6px; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.login-input {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 2px solid rgba(43, 27, 61, 0.22);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.18);
}
.login-pass { position: relative; display: block; }
.login-pass .login-input { padding-right: 58px; }
.login-eye {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(43, 27, 61, 0.06);
  font-size: 18px;
  transition: background 0.15s ease;
}
.login-eye:hover { background: rgba(43, 27, 61, 0.12); }

.login-error {
  margin: 0;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(225, 29, 72, 0.1);
  color: #9f1239;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
}
.login-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 2px;
  border-radius: 14px;
  font-size: 15px;
}
.login-note {
  margin: 19px 0 0;
  padding-top: 14px;
  border-top: 1.5px solid rgba(43, 27, 61, 0.1);
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
}

@keyframes login-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes login-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@media (hover: none) {
  .login-submit:hover { transform: none; box-shadow: 0 4px 0 rgba(43, 27, 61, 0.18); }
  .login-eye:hover { background: rgba(43, 27, 61, 0.06); }
}

/* ---- ແທັບເລັດ / ມືຖື: ແບຣນແບບກະທັດຮັດ + ຟອມເຕັມຄວາມກວ້າງ ---- */
@media (max-width: 900px) {
  body.login-page {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }
  .login-shell {
    min-height: calc(100vh - 34px);
    min-height: calc(100dvh - 34px);
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-content: center;
    justify-items: center;
  }
  .login-hero { width: min(100%, 520px); justify-self: center; padding: 0; }
  .login-hero-brand {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-align: left;
  }
  .login-hero-logo { width: 76px; }
  .login-hero-text { min-width: 0; }
  .login-hero-badge { padding: 3px 8px; font-size: 9.5px; }
  .login-hero-name {
    margin-top: 4px;
    font-size: clamp(23px, 6.5vw, 31px);
    line-height: 1.1;
  }
  .login-hero-copy { display: none; }
  .login-features { display: none; }
  .login-hero-art { display: none; }
  .login-card {
    width: min(100%, 520px);
    max-width: 100%;
    justify-self: center;
    padding: 24px 20px 20px;
    border-radius: 24px;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2), 0 24px 50px rgba(0, 0, 0, 0.3);
  }
  .login-card h1 { font-size: 27px; }
  .login-sub { margin-bottom: 17px; font-size: 12.5px; }
}

@media (max-width: 380px) {
  body.login-page {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .login-hero-logo { width: 62px; }
  .login-hero-name { font-size: 21px; }
  .login-card { padding: 21px 15px 17px; border-radius: 20px; }
  .login-card h1 { font-size: 24px; }
  .login-note { font-size: 10.5px; }
}

@media (max-height: 620px) and (max-width: 900px) {
  .login-shell { align-content: start; }
}

/* ---------- ຄັງໜັງ (movie library) ---------- */
body.library-open { overflow: hidden; }
.library {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow-y: auto;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(249, 115, 22, 0.16), transparent),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 58, 237, 0.14), transparent),
    var(--paper-2);
}
.library[hidden] { display: none; }
.library-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding:
    max(22px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}
.library-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.library-head h1 { margin: 2px 0 2px; font-family: var(--font-display); font-size: clamp(22px, 3vw, 32px); }
.library-head p { margin: 0; }
.library-bar {
  position: sticky; top: env(safe-area-inset-top); z-index: 3;
  display: grid; gap: 8px;
  margin: 6px 0 18px; padding: 10px 0 12px;
  background: var(--paper-2);
}
.library-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.library-search {
  flex: 1 1 260px; min-width: 180px;
  padding: 9px 14px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 14px;
}
.library-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.library-views {
  display: inline-flex; gap: 3px; padding: 3px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, var(--paper));
}
.library-view-btn { border: 0; box-shadow: none; background: transparent; padding: 6px 11px; border-radius: 999px; font-size: 12.5px; }
.library-view-btn.is-active { background: var(--ink); color: var(--paper); }
.library-audience { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.library-audience-btn { font-size: 12px; padding: 6px 10px; }
.library-audience-btn.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.library-adult-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 6px 0 0; padding: 8px 12px; border-radius: 12px;
  border: 1.5px solid #fca5a5; background: #fef2f2; color: #7f1d1d; font-size: 12.5px;
}
.library-adult-note strong { font-size: 13px; }
.library-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; position: static; background: none; }
.library-filter { font-size: 13px; padding: 7px 14px; }
.library-filter.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.library-group { margin-bottom: 30px; }
.library-group-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.library-group-head h2 { margin: 0; font-family: var(--font-display); font-size: 22px; }
.library-group-head .library-create-genre { margin-left: auto; }
.library-empty {
  display: grid; gap: 4px; place-items: center; padding: 42px 16px;
  border: 2px dashed var(--line); border-radius: 16px; text-align: center; color: var(--ink-2);
}
.library-empty strong { font-size: 16px; color: var(--ink); }
.story-list { display: grid; gap: 10px; }
.story-row {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--movie) 45%, transparent);
}
.story-row-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--movie) 9%, var(--paper));
  border-bottom: 1.5px solid rgba(43, 27, 61, 0.15);
}
.story-row-emoji { font-size: 26px; line-height: 1; }
.story-row-title { flex: 1 1 200px; min-width: 0; }
.story-row-title h3 { margin: 0; font-family: var(--font-display); font-size: 17px; color: color-mix(in srgb, var(--movie) 70%, var(--ink)); }
.story-row-title p { margin: 2px 0 0; font-size: 12px; color: var(--ink-2); }
.story-row-count {
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  border: 1.5px solid color-mix(in srgb, var(--movie) 35%, transparent);
}
.story-row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.story-row-actions .btn { margin-left: 0; }
.story-row-head > .btn { margin-left: auto; }
.story-episodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 6px; padding: 8px; }
.story-ep {
  display: grid; grid-template-columns: 22px 24px 1fr 20px; align-items: center; gap: 8px;
  text-align: left; padding: 8px 10px; border-radius: 11px;
  border: 1.5px solid rgba(43, 27, 61, 0.13); background: var(--paper-2);
  transition: border-color 0.15s, background 0.15s;
}
.story-ep:hover { border-color: var(--movie); background: color-mix(in srgb, var(--movie) 10%, var(--paper)); }
.story-ep-no { font-weight: 800; color: var(--ink-3); font-size: 11.5px; text-align: center; }
.story-ep-emoji { font-size: 17px; }
.story-ep-copy { display: grid; line-height: 1.25; min-width: 0; }
.story-ep-copy strong { font-size: 13.5px; }
.story-ep-copy span { font-size: 11px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-ep-play { color: var(--movie); font-size: 12px; text-align: right; }
.story-empty { grid-column: 1 / -1; margin: 4px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- ອອກແບບໜັງ (movie designer) ---------- */
.movie-designer { width: min(1180px, calc(100vw - 28px)); }
.movie-free-note {
  display: inline-block; margin: 6px 0 0; padding: 3px 10px;
  border: 1.5px solid #86efac; border-radius: 999px;
  background: #ecfdf5; color: #15803d; font-size: 12px; font-weight: 700;
}
.library-tools .movie-free-note { margin: 0; }
.movie-designer-body { grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.movie-form { display: grid; gap: 14px; min-width: 0; }
.movie-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.movie-field { display: grid; gap: 4px; min-width: 0; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.movie-field > span { padding-left: 2px; }
.movie-field > em { font-size: 11px; font-weight: 600; color: var(--ink-3); font-style: normal; }
.movie-field .cast-input { width: 100%; }
.movie-colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; grid-column: 1 / -1; }
.movie-color {
  width: 100%; height: 38px; padding: 3px; border: 1.5px solid rgba(43, 27, 61, 0.2);
  border-radius: 9px; background: var(--paper); cursor: pointer;
}
.movie-range-wrap { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-height: 38px; }
.movie-range { width: 100%; accent-color: var(--accent); }
.movie-textarea { min-height: 58px; resize: vertical; }
.movie-subhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.movie-subhead strong { font-family: var(--font-display); font-size: 15px; }
.movie-cast-count { font-size: 11.5px; color: var(--ink-3); }
.movie-cast-picker {
  display: grid; gap: 9px; max-height: 230px; overflow: auto;
  padding: 10px; border: 1.5px solid rgba(43, 27, 61, 0.14); border-radius: 12px; background: var(--paper-2);
}
.movie-cast-group { display: grid; gap: 5px; }
.movie-cast-group-label { font-size: 11.5px; color: var(--ink-3); }
.movie-cast-options { display: flex; flex-wrap: wrap; gap: 5px; }
.movie-cast-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  background: var(--paper); border: 1.5px solid rgba(43, 27, 61, 0.18); font-size: 12px; cursor: pointer;
}
.movie-cast-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.movie-cast-chip input { accent-color: var(--accent); }
.movie-episode-box {
  display: grid; gap: 9px; padding: 12px; border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 14px; background: color-mix(in srgb, var(--accent) 6%, var(--paper));
}
.movie-episode-box > strong { font-family: var(--font-display); font-size: 15px; }
.movie-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.movie-check input { accent-color: var(--accent); }
.movie-preview-pane {
  display: grid; gap: 8px; align-content: start; position: sticky; top: 0;
  padding: 10px; border: 2px solid var(--line); border-radius: 16px; background: var(--paper-2);
}
.movie-preview-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9;
  border-radius: 10px; border: 1.5px solid rgba(43, 27, 61, 0.18); background: var(--cream);
}
.movie-preview-pane p { margin: 0; line-height: 1.4; }
.movie-preview-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.movie-preview-tags span {
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 12%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--accent) 38%, transparent);
}
.movie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.movie-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--movie) 45%, transparent);
  transition: transform 0.15s;
}
.movie-card:hover { transform: translateY(-2px); }
.movie-card.is-open { grid-row: span 2; }
.movie-poster-wrap { position: relative; border-bottom: 2px solid var(--line); background: var(--movie); }
.movie-poster { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.movie-genre {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(43, 27, 61, 0.82); color: #fde68a; font-size: 12px; font-weight: 700;
}
.movie-rating {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: #991b1b; color: #fef2f2; font-size: 11.5px; font-weight: 800;
  border: 1.5px solid #fecaca;
}
.movie-card.is-adult { box-shadow: 0 5px 0 rgba(153, 27, 27, 0.45); }
.story-row.is-adult { box-shadow: 0 4px 0 rgba(153, 27, 27, 0.4); }
.library-group.is-adult .library-group-head h2 { color: #991b1b; }
.movie-body { padding: 12px 14px 14px; display: grid; gap: 8px; }
.movie-body h3 { margin: 0; font-family: var(--font-display); font-size: 18px; color: color-mix(in srgb, var(--movie) 70%, var(--ink)); }
.movie-tagline { margin: -4px 0 0; color: var(--ink-2); font-size: 13px; }
.movie-cast { display: flex; flex-wrap: wrap; gap: 5px; }
.movie-chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--movie) 14%, var(--paper));
  border: 1.5px solid color-mix(in srgb, var(--movie) 45%, transparent);
}
.movie-chip.is-host { background: transparent; border-style: dashed; color: var(--ink-3); }
.movie-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.movie-episodes { display: grid; gap: 6px; }
.movie-episodes[hidden] { display: none; }
.movie-episode {
  display: grid; grid-template-columns: 24px 26px 1fr 22px; align-items: center; gap: 8px;
  text-align: left; padding: 8px 10px; border-radius: 12px;
  border: 1.5px solid rgba(43, 27, 61, 0.15); background: var(--paper-2);
  transition: border-color 0.15s, background 0.15s;
}
.movie-episode:hover { border-color: var(--movie); background: color-mix(in srgb, var(--movie) 10%, var(--paper)); }
.movie-ep-no { font-weight: 800; color: var(--ink-3); font-size: 12px; text-align: center; }
.movie-ep-emoji { font-size: 18px; }
.movie-ep-copy { display: grid; line-height: 1.3; min-width: 0; }
.movie-ep-copy strong { font-size: 14px; }
.movie-ep-copy span { font-size: 11.5px; color: var(--ink-2); }
.movie-ep-play { color: var(--movie); font-size: 13px; }
.cast-group {
  margin: 8px 2px 0; font-size: 11px; font-weight: 800; color: var(--ink-3);
  text-transform: none; grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .library-tools { gap: 6px; }
  .library-search { flex: 1 1 100%; }
  .library-tools > .btn { flex: 1 1 auto; }
  .library-views { width: 100%; justify-content: center; }
  .library-audience { width: 100%; justify-content: center; }
  .story-row-head { align-items: flex-start; }
  .story-row-actions { width: 100%; margin-left: 0; }
  .story-row-actions .btn { flex: 1 1 auto; }
  .story-episodes { grid-template-columns: 1fr; }
  .movie-designer-body { grid-template-columns: 1fr; }
  .movie-preview-pane { order: -1; position: static; }
  .movie-fields { grid-template-columns: 1fr; }
  .movie-colors { grid-template-columns: 1fr 1fr; }
  .movie-cast-picker { max-height: 190px; }
  .part-studio-body { grid-template-columns: 1fr; }
  .part-preview-pane { order: -1; position: static; }
  .part-fields { grid-template-columns: 1fr; }
  .part-tabs { padding: 8px 12px 0; }
}
@media (max-width: 520px) {
  .library-inner { padding: 14px 16px 40px; }
  .movie-card.is-open { grid-row: auto; }
}

/* ---------- ບົດຮຽນສຽງ (own Lao voice) ---------- */
.voice-card.learn { gap: 10px; }
.learn-voice select { width: 100%; }
.learn-ref { display: grid; grid-template-columns: 1fr 90px; gap: 8px; align-items: center; }
.learn-meter { display: grid; gap: 4px; }
.learn-bar { height: 10px; border-radius: 999px; background: rgba(43, 27, 61, 0.1); overflow: hidden; }
.learn-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width 0.3s; }
.learn-lessons { display: grid; gap: 5px; }
.learn-lesson {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 7px 10px; border-radius: 10px; text-align: left;
  border: 1.5px solid rgba(43, 27, 61, 0.15); background: var(--paper);
  font-size: 12.5px;
}
.learn-lesson span { color: var(--ink-3); font-weight: 700; font-size: 11.5px; }
.learn-lesson.is-active { border-color: var(--accent); background: var(--accent-soft); }
.learn-lesson.is-done strong::after { content: " ✓"; color: #16a34a; }
.learn-card {
  display: grid; gap: 6px; justify-items: center; text-align: center;
  padding: 14px 12px; border-radius: 14px; border: 2px dashed var(--accent); background: var(--paper);
}
.learn-card.is-done { border-style: solid; border-color: #16a34a; }
.learn-word { font-family: var(--font-display); font-size: clamp(34px, 6vw, 52px); line-height: 1.3; color: var(--ink); }
.learn-rec { min-width: 110px; }
.learn-rec.is-recording { background: #dc2626; border-color: #7f1d1d; animation: learn-pulse 1s infinite; }
@keyframes learn-pulse { 50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.2); } }

/* ---------- AI ຂຽນເລື່ອງ / ຊ່ອງບໍ່ຢຸດ ---------- */
.rail-head-actions { display: inline-flex; gap: 6px; }
.story-agent { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; position: relative; z-index: 1; }
.story-agent-label { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.story-agent-select {
  padding: 5px 10px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.story-agent-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.story-agent-select option:disabled { color: #9ca3af; }
.story-engine { margin: 0; font-size: 11.5px; color: var(--ink-3); }
.story-engine.is-ai { color: #15803d; font-weight: 700; }
.story-progress {
  margin: 8px 0 0; padding: 8px 12px; border-radius: 12px; position: relative; z-index: 1;
  background: var(--accent-soft); border: 1.5px dashed var(--accent); font-size: 13px; font-weight: 700;
  animation: story-pulse 1.6s ease-in-out infinite;
}
.story-progress[hidden] { display: none; }
@keyframes story-pulse { 50% { opacity: 0.6; } }
body.story-busy [data-new-episode] { cursor: progress; }
.channel-btn.is-on { background: var(--accent); color: #fff; border-color: var(--line); }
.episode-card { position: relative; }
.episode-del {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; color: var(--ink-3); background: transparent; cursor: pointer;
}
.episode-del:hover { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
@media (prefers-reduced-motion: reduce) { .story-progress { animation: none; } }

/* ---------- ສິ່ງຂອງ ແລະ ການສຳຜັດ ---------- */
.props-editor {
  display: grid; gap: 6px; margin: 8px 0 10px; padding: 8px 10px;
  border: 1.5px dashed rgba(43, 27, 61, 0.2); border-radius: 12px; background: var(--paper-2);
}
.props-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.prop-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(60px, 1fr) auto auto; gap: 6px; align-items: center; }
.prop-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.props-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.props-actions .add-line { flex: 1; }
.mini-select {
  min-width: 0; max-width: 100%; font-size: 11.5px; padding: 4px 6px; border-radius: 8px;
  border: 1.5px solid rgba(43, 27, 61, 0.2); background: var(--paper); color: var(--ink);
}
.mini-select[hidden] { display: none; }
.touch-controls { display: flex; gap: 4px; flex-wrap: wrap; grid-column: 1 / -1; }
@media (max-width: 520px) {
  .prop-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- ຄັງສາກ ---------- */
.scene-lib-body { display: grid; gap: 10px; padding: 14px 18px 18px; overflow: auto; }
.scene-lib-list { display: grid; gap: 6px; }
.scene-lib-item {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
  padding: 8px 10px; border: 1.5px solid rgba(43, 27, 61, 0.15); border-radius: 12px; background: var(--paper);
}
.scene-lib-emoji { font-size: 20px; text-align: center; }
.scene-lib-copy { display: grid; line-height: 1.3; min-width: 0; }
.scene-lib-copy span { font-size: 11.5px; color: var(--ink-2); }
.prop-move { grid-column: 1 / -1; justify-self: start; }
.prop-row .mini-select[hidden] { display: none; }
@media (max-width: 520px) { .scene-lib-item { grid-template-columns: 28px 1fr; } }

/* ==========================================================================
   ມືຖື / ຈໍນ້ອຍ — ປັບໃຫ້ກົດງ່າຍ, ອ່ານຊັດ ແລະ ບໍ່ລົ້ນຈໍ
   ========================================================================== */

/* ການແຕະ ແລະ ການຊູມຂອງ iOS */
button, input, select, textarea { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* ເມນູລອຍຕ້ອງບໍ່ຖືກຂອບລຸ່ມຂອງຈໍ */
.toasts {
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: min(92vw, 460px);
}

/* ບໍ່ໃຫ້ເນື້ອຫາຖືກເມນູຕິດໜຶບຕອນເລື່ອນຫາ */
.stage-card, .editor, .rail, .result, .scene-card { scroll-margin-top: 104px; }

/* ແຖບເລື່ອນນອນ: ເລື່ອນລຽບ + ບໍ່ມີແຖບ scrollbar ເທິງມືຖື */
.series-tabs, .episode-list, .scene-strip {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* ແທັບເລັດ: ຫົວເວັບຍັງແຖວດຽວ ແຕ່ຫຍໍ້ປ້າຍບຸ່ມໃຫ້ບໍ່ທັບກັນ */
@media (min-width: 681px) and (max-width: 900px) {
  .topbar { gap: 10px; }
  .brand-mark { width: 64px; height: 42px; }
  .brand-kicker { font-size: 9px; }
  .brand strong { font-size: 20px; }
  .top-actions { gap: 6px; }
  .top-actions .btn-top {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 11.5px;
    gap: 5px;
  }
  .top-label { display: none; }
  .top-label-sm { display: inline; }
}

/* ຕົວລະຄອນ (ແທັບເລັດ/ມືຖື): ລາຍຊື່ແນວຕັ້ງ ມີກອງ ແລະ ຄົ້ນຫາ */
@media (max-width: 940px) {
  .cast-list { position: static; grid-row: 1; height: 340px; max-height: 340px; }
  .cast-stage { grid-row: 2; }
  .cast-form { grid-row: 3; }
  .cast-list-item { min-width: 0; }
  .cast-list-tools { position: sticky; top: 0; }
}

@media (max-width: 680px) {
  /* ---- ຫົວເວັບ: ສອງແຖວຕື້ນໆ, ປຸ່ມບໍ່ຕົກໄປແຖວໃໝ່ ---- */
  .topbar {
    gap: 6px 8px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      8px
      max(12px, env(safe-area-inset-left));
  }
  .brand { gap: 8px; }
  .brand-mark { width: 56px; height: 36px; }
  .brand-kicker { font-size: 8.5px; letter-spacing: 0.14em; }
  .brand strong { font-size: 19px; }
  .top-actions {
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    padding-bottom: 1px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions .btn-top {
    flex: none;
    min-height: 38px;
    padding: 6px 10px;
    font-size: 11.5px;
    gap: 5px;
  }
  .top-label { display: none; }
  .top-label-sm { display: inline; }
  .top-actions .btn-top-ghost[data-logout] {
    min-width: 38px;
    padding-inline: 9px;
  }

  /* ---- ໂຄງລວມ ---- */
  .studio {
    gap: 10px;
    padding:
      10px
      max(10px, env(safe-area-inset-right))
      calc(16px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }
  .main, .rail, .editor { margin-bottom: 0; }
  .main { gap: 12px; }
  .rail-block { padding: 12px 12px 14px; }
  .rail-head { font-size: 14px; }
  .rail-note { font-size: 11px; }
  .count-badge { min-width: 25px; height: 25px; font-size: 11.5px; }
  .mini-btn { width: 38px; height: 38px; font-size: 16px; }

  /* ---- ປ້ອງກອກໄອເດຍ ---- */
  .idea-card { padding: 14px; }
  .idea-input { min-height: 48px; font-size: 16px; padding: 10px 16px; }
  .chip { padding: 8px 12px; font-size: 12.5px; }
  .chips { gap: 7px; }
  .story-agent { gap: 7px; }
  .story-agent-label { font-size: 13px; }
  .story-agent-select { min-height: 38px; font-size: 16px; }
  .story-progress { font-size: 13px; }

  /* ---- ເວທີ: ຄວບຄຸມໃຫຍ່ຂຶ້ນ ແລະ timeline ເຕັມແຖວ ---- */
  .stage-card { padding: 10px; }
  .stage-frame { min-height: 0; padding: 6px; }
  .stage-frame canvas { max-height: 58vh; max-height: 58dvh; }
  .aspect-switch { padding: 3px; gap: 2px; }
  .aspect-btn { min-width: 52px; min-height: 42px; padding: 6px 8px; }
  .aspect-btn strong { font-size: 12px; }
  .aspect-btn span { font-size: 9.5px; }
  .transport { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
  .transport .play-btn { order: 1; }
  .transport .time-label { order: 2; }
  .transport .icon-btn { order: 3; }
  .transport .timeline { order: 4; }
  .play-btn { width: 38px; height: 38px; font-size: 15px; }
  .time-label { flex: 1 1 58px; min-width: 0; font-size: 11px; }
  .transport .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .timeline { flex: 1 0 100%; height: 34px; margin-top: 1px; }
  .timeline::before, .timeline-fill { height: 8px; }
  .timeline-mark { height: 16px; margin-top: -8px; }
  .record-row { gap: 8px; }
  .record-row .btn { min-height: 46px; font-size: 13px; }
  .render-msg { flex-basis: 100%; font-size: 12px; }
  .record-note { font-size: 11px; line-height: 1.5; }
  .scene-chip { min-height: 38px; font-size: 12px; padding: 8px 11px; }
  .result video { max-height: 52vh; max-height: 52dvh; }

  /* ---- ລາຍການທາງຊ້າຍ: ປະເພດເປັນແຖວນອນ, ການ໌ດໃຫຍ່ຂຶ້ນ ---- */
  .genre-tabs {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .genre-tabs::-webkit-scrollbar { display: none; }
  .genre-tab {
    flex: 0 0 auto;
    min-width: 126px;
    min-height: 58px;
    scroll-snap-align: start;
  }
  .genre-emoji { font-size: 19px; }
  .genre-tab strong { font-size: 14px; }
  .genre-count { font-size: 11px; }
  .series-tabs, .episode-list {
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .series-tabs::-webkit-scrollbar, .episode-list::-webkit-scrollbar { display: none; }
  .series-tab { min-width: 206px; min-height: 54px; scroll-snap-align: start; }
  .series-copy strong { font-size: 14px; }
  .series-copy span { font-size: 11.5px; }
  .episode-card { min-width: 228px; min-height: 60px; scroll-snap-align: start; }
  .episode-copy strong { font-size: 13px; }
  .episode-copy span { font-size: 11.5px; }
  .saved-open { padding: 9px 2px; }
  .saved-open strong { font-size: 13px; }
  .saved-open span { font-size: 11px; }
  .saved-del, .saved-share { width: 34px; height: 34px; font-size: 15px; }
  .episode-del { top: 7px; right: 7px; width: 30px; height: 30px; font-size: 13px; }

  /* ---- ບັນນາທິການ: ຊ່ອງປ້ອນ 16px ກັນ iOS ຊູມ, ປຸ່ມໃຫຍ່ຂຶ້ນ ---- */
  .editor-tabs { gap: 3px; padding: 10px 10px 0; }
  .editor-tabs button { min-height: 44px; padding: 8px 6px; font-size: 12.5px; }
  .editor-body { padding: 10px 10px 14px; }
  .editor-head { padding: 13px 14px 11px; }
  .editor-head h2 { font-size: 18px; }
  .cast-strip { gap: 6px; }
  button.cast-chip { min-height: 38px; padding: 4px 9px 4px 4px; font-size: 11.5px; }
  .cast-avatar { width: 28px; height: 32px; }
  .scene-card { padding: 10px; border-radius: 12px; }
  .scene-card-head {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
    align-items: center;
    margin-bottom: 8px;
  }
  .scene-num { grid-row: 1; grid-column: 1; justify-self: start; }
  .scene-title-input {
    grid-row: 1;
    grid-column: 2;
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 4px 2px;
    font-size: 16px;
  }
  .scene-mini-actions { grid-row: 1; grid-column: 3; justify-self: end; gap: 0; }
  .scene-mini-actions button { width: 32px; height: 32px; font-size: 14px; }
  .scene-card-head > .field-inline {
    grid-row: 2;
    width: 100%;
    min-width: 0;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    font-size: 10.5px;
  }
  .scene-card-head > .field-inline.scene-skin-field {
    grid-row: 3;
    grid-column: 1 / -1;
  }
  .field-inline select {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 38px;
    padding: 4px 6px;
    font-size: 16px;
  }
  .props-editor { padding: 9px; }
  .props-head { font-size: 13px; }
  .mini-select { min-height: 38px; padding: 5px 7px; font-size: 16px; }
  .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px; gap: 6px; }
  .line-row select { min-height: 38px; padding: 4px 6px; font-size: 16px; }
  .line-row textarea {
    grid-column: 1 / 3;
    grid-row: 2;
    min-height: 62px;
    padding: 8px 9px;
    font-size: 16px;
  }
  .line-row .line-del {
    grid-column: 3;
    grid-row: 1 / 3;
    width: 38px;
    height: auto;
    min-height: 38px;
    font-size: 14px;
  }
  .line-voice { gap: 6px; padding: 5px 8px; font-size: 11px; }
  .vbtn { min-height: 36px; padding: 4px 9px; font-size: 12px; }
  .line-voice-del { width: 30px; height: 30px; font-size: 12px; }
  .touch-controls { gap: 6px; }
  .add-line { min-height: 40px; padding: 8px; font-size: 12px; }
  .editor-actions { gap: 8px; }
  .editor-actions .btn { min-height: 42px; }
  .editor-actions .btn-primary { margin-left: 0; }
  .textarea { font-size: 16px; }
  .script-area { min-height: 320px; }
  .cast-input { min-height: 42px; font-size: 16px; }

  /* ---- ຄັງໜັງ ---- */
  .library-inner {
    padding:
      calc(14px + env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      calc(40px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .library-head { margin-bottom: 12px; }
  .library-head h1 { font-size: 22px; }
  .library-head .btn { min-height: 44px; }
  .library-filters {
    top: env(safe-area-inset-top);
    gap: 6px;
    margin-bottom: 14px;
  }
  .library-filter { min-height: 42px; padding: 8px 13px; font-size: 12.5px; }
  .movie-grid { grid-template-columns: 1fr; gap: 12px; }
  .movie-body { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .movie-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    min-height: 42px;
    white-space: normal;
    text-align: center;
  }
  .movie-actions .btn-primary { flex-basis: 100%; }
  .movie-episode {
    min-height: 58px;
    padding: 8px;
    grid-template-columns: 22px 24px minmax(0, 1fr) 20px;
  }
  .movie-ep-copy strong { font-size: 13.5px; }
  .movie-ep-copy span { font-size: 11.5px; }

  /* ---- ປັອບອັບ (ຕົວລະຄອນ / ຄັງສາກ) ---- */
  .cast-dialog {
    width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 16px;
  }
  .cast-dialog-head { padding: 12px 14px; gap: 8px; }
  .cast-dialog-head h2 { font-size: 18px; }
  .cast-dialog-body { padding: 12px; gap: 12px; }
  .cast-dialog-foot { padding: 10px 12px; gap: 8px; }
  .cast-list-item { min-height: 50px; }
  .cast-toggle { min-height: 38px; padding: 7px 12px; font-size: 12.5px; }
  .cast-color input[type="color"] { width: 40px; height: 34px; }
  .scene-lib-body { padding: 12px 12px 16px; }
  .scene-lib-item { padding: 9px 10px; }
  .scene-lib-item .btn { grid-column: 1 / -1; min-height: 40px; }
}

@media (max-width: 520px) {
  /* ຕົວລະຄອນ: ລາຍຊື່ສັ້ນລົງ ແລະ ຟອມຢູ່ໃກ້ຂຶ້ນ */
  .cast-list { height: 300px; max-height: 300px; }
  .cast-search { min-height: 38px; font-size: 13px; }
  .cast-stage { max-width: 190px; justify-self: center; width: 100%; }
  .cast-foot-note { display: none; }
  .cast-foot-left, .cast-foot-right { flex: 1 1 auto; }
  .cast-foot-left .btn { flex: 1 1 auto; }
  .cast-grid { grid-template-columns: 1fr; }
  .library-head .btn { width: 100%; }
  .genre-tab { min-width: 118px; }
  .idea-head h1 { font-size: 24px; }
}

@media (max-width: 380px) {
  .brand strong { font-size: 17px; }
  .brand-mark { width: 48px; height: 32px; }
  .top-actions { gap: 3px; }
  .top-actions .btn-top { padding: 6px 7px; font-size: 11px; }
  .transport { gap: 5px 6px; }
  .play-btn { width: 36px; height: 36px; }
  .transport .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .time-label { font-size: 10.5px; }
  .button-row, .editor-actions { gap: 6px; }
  .scene-mini-actions button { width: 28px; height: 28px; }
  .scene-title-input { font-size: 15px; }
  .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .line-row .line-del { width: 34px; }
  .genre-tab { min-width: 112px; }
}

/* ຈໍເຕ້ຍ / ມືຖືຕັ້ງຂວາງ: ຫົວເວັບແຖວດຽວ ແລະ ປັອບອັບແບບສອງຖັນ */
@media (max-height: 500px) and (max-width: 940px) {
  .topbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding:
      max(6px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      6px
      max(12px, env(safe-area-inset-left));
  }
  .brand-mark { width: 44px; height: 30px; }
  .brand-kicker { display: none; }
  .brand strong { font-size: 16px; }
  .top-actions {
    flex: 0 1 auto;
    width: auto;
    margin-left: auto;
    gap: 4px;
    overflow: visible;
  }
  .top-label, .top-label-sm { display: none; }
  .top-actions .btn-top { min-height: 34px; min-width: 36px; padding: 5px 8px; }
  .top-actions .btn-top-ghost[data-logout] { min-width: 36px; padding-inline: 8px; }
}

@media (max-height: 520px) and (min-width: 560px) {
  .cast-dialog { max-height: calc(100dvh - 12px); }
  .cast-dialog-head { padding: 8px 12px; }
  .cast-dialog-head h2 { font-size: 16px; }
  .cast-dialog-head .eyebrow { display: none; }
  .cast-dialog-foot { padding: 8px 12px; }
  .cast-foot-note { display: none; }
  .cast-dialog-body {
    grid-template-columns: 170px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
  }
  .cast-list { grid-column: 1 / -1; grid-row: 1; }
  .cast-stage { grid-column: 1; grid-row: 2; max-width: 170px; }
  .cast-form { grid-column: 2; grid-row: 2; }
}

/* ---------- ຊື່ເລື່ອງ + ຄັງຊັບພະຍາກອນ ---------- */
.title-row { display: flex; align-items: center; gap: 8px; }
.title-row .title-input { flex: 1; min-width: 0; }
.title-dice { flex: none; width: 32px; height: 32px; font-size: 15px; }

.resource-dialog[open] { display: grid; grid-template-rows: auto auto 1fr auto; }
.resource-dialog .cast-dialog-head { align-items: flex-start; }
.resource-dialog .cast-dialog-head h2 { margin-top: 2px; }
.resource-dialog .cast-dialog-head p { margin: 3px 0 0; }
.resource-tabs {
  display: flex; gap: 5px; padding: 10px 18px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1.5px solid rgba(43, 27, 61, 0.12);
}
.resource-tabs::-webkit-scrollbar { display: none; }
.resource-tab {
  flex: none; border: 1.5px solid rgba(43, 27, 61, 0.16); border-radius: 999px;
  background: var(--paper-2, #fff); color: var(--ink-2); font: inherit; font-size: 12px;
  font-weight: 700; padding: 7px 12px; cursor: pointer;
}
.resource-tab:hover { border-color: var(--accent); }
.resource-tab.is-active { background: var(--accent); border-color: var(--line); color: #fffaf0; }
.resource-body {
  display: grid; gap: 12px; align-content: start;
  padding: 14px 18px 20px; overflow: auto; min-height: 0;
}
.resource-section {
  display: grid; gap: 9px; padding: 12px;
  border: 1.5px solid rgba(43, 27, 61, 0.14); border-radius: 14px;
  background: var(--paper-2, #fff);
}
.resource-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.resource-head h3 { margin: 0; font-family: var(--font-display); font-size: 16px; line-height: 1.25; }
.resource-head p { margin: 2px 0 0; }
.resource-actions { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.part-dialog { width: min(760px, calc(100vw - 32px)); }
.part-editor {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px; padding: 16px 18px; overflow: auto; align-content: start;
}
.part-editor .field-inline { align-self: end; padding-bottom: 6px; }
.part-preview {
  display: grid; gap: 3px; padding: 10px 12px; border: 1.5px dashed rgba(43, 27, 61, 0.2);
  border-radius: 12px; background: var(--cream);
}
.part-preview strong { font-family: var(--font-display); font-size: 14px; }
.part-preview p { margin: 0; font-weight: 600; font-size: 12.5px; }
.part-preview p.small { font-weight: 500; }
.resource-upload { display: inline-flex; }
.resource-list { display: grid; gap: 6px; }
.resource-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px; align-items: center; padding: 8px 10px;
  border: 1.5px solid rgba(43, 27, 61, 0.13); border-radius: 12px;
  background: #fff; cursor: pointer;
}
.resource-row:hover { border-color: var(--accent); }
.resource-row.is-active { border-color: var(--accent); background: var(--accent-soft); }
.resource-row-emoji { font-size: 20px; line-height: 1; }
.resource-row-copy { display: grid; min-width: 0; line-height: 1.3; }
.resource-row-copy strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-row-copy span { font-size: 10.8px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.res-cast-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 7px; }
.res-cast-card {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 7px; align-items: center;
  padding: 8px; border: 1.5px solid rgba(43, 27, 61, 0.13); border-radius: 12px; background: #fff;
}
.res-cast-head { width: 52px; height: 52px; }
.res-cast-copy { display: grid; min-width: 0; line-height: 1.3; }
.res-cast-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-cast-copy span { font-size: 10.8px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-cast-card .res-actions { grid-column: 1 / -1; justify-content: flex-start; }
.res-add-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.res-add-row .cast-input { flex: 1; min-width: 135px; }
/* ✨ AI ສ້າງຈາກຄຳອະທິບາຍ */
.res-describe { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.res-describe .res-describe-input { flex: 1 1 220px; min-width: 0; }
.res-describe .res-describe-who { flex: 0 1 160px; min-width: 110px; }
.res-describe .btn-primary { white-space: nowrap; }
@media (max-width: 560px) {
  .res-describe .res-describe-who, .res-describe .res-describe-input { flex: 1 1 100%; }
  .res-describe .btn-primary { flex: 1 1 100%; }
}
.resource-scene-select { max-width: 100%; }
.resource-at { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.resource-at .cast-input { width: 78px; min-height: 30px; padding: 3px 7px; }
.res-cue {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 74px 80px auto;
  gap: 6px; align-items: center; padding: 7px 9px;
  border: 1.5px solid rgba(43, 27, 61, 0.13); border-radius: 11px; background: #fff;
}
.res-cue-icon { font-size: 15px; }
.res-cue-copy { display: grid; min-width: 0; line-height: 1.25; }
.res-cue-copy strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-cue-copy span { font-size: 10px; color: var(--ink-3); }
.res-cue-at { min-height: 30px; padding: 3px 6px; font-size: 11.5px; }
.res-cue-vol { width: 100%; accent-color: var(--accent); }
.res-sound-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 5px; max-height: 270px; overflow: auto; padding: 2px;
}
.res-sound-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 6px; align-items: center; padding: 5px 7px;
  border: 1.5px solid rgba(43, 27, 61, 0.12); border-radius: 10px; background: #fff;
}
.res-sound-name { font-size: 11.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sound-id { grid-column: 1; font-size: 9.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sound-item .res-actions { grid-column: 2; grid-row: 1 / 3; }
.resource-sub { margin: 7px 0 0; font-size: 12.5px; font-family: var(--font-display); }
.res-title-now {
  margin: 0; padding: 10px 12px; border: 2px dashed var(--accent); border-radius: 12px;
  background: var(--accent-soft); font-family: var(--font-display); font-size: 18px; font-weight: 700;
}
.resource-foot { padding: 8px 18px; border-top: 1.5px solid rgba(43, 27, 61, 0.12); }

@media (max-width: 700px) {
  .resource-tabs { padding: 8px 10px; }
  .resource-body { padding: 10px; gap: 10px; }
  .resource-foot { padding: 7px 12px; }
  .resource-row { grid-template-columns: auto minmax(0, 1fr); }
  .resource-row .res-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .res-cast-list { grid-template-columns: 1fr; }
  .res-cue { grid-template-columns: auto minmax(0, 1fr) auto; }
  .res-cue-at, .res-cue-vol { grid-column: 2; }
  .res-cue .res-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .res-sound-grid { grid-template-columns: 1fr; max-height: 320px; }
  .resource-section { padding: 10px; }
}

/* ເຄຣດິດເວັບ ແລະ ລິ້ງຕິດຕໍ່ — ມາດຕະຖານດຽວກັບ smart projects */
.bb-project-footer {
  margin-top: 24px; padding: 16px 20px; border-top: 1px solid rgba(148, 163, 184, .35);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 20px; font: 13px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; color: inherit;
}
.bb-project-footer > span { opacity: .8; }
.bb-project-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.bb-project-footer a { color: inherit; text-decoration: none; font-weight: 600; }
.bb-project-footer a:hover { text-decoration: underline; }
.bb-project-footer > span a { font-weight: 700; text-decoration: underline; }
.login-page .bb-project-footer { width: min(1180px, calc(100% - 32px)); margin: 0 auto 20px; }

/* ຄຳຄິດເຫັນ / ຂໍອັບເດດ */
.feedback-count {
  position: absolute; top: 5px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #ef4444; color: #fff; font: 700 10px/16px system-ui, sans-serif;
  text-align: center; box-shadow: 0 0 0 2px var(--paper, #fffaf0);
}
.btn-top { position: relative; }
.footer-link-btn {
  padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600;
  cursor: pointer;
}
.footer-link-btn:hover { text-decoration: underline; }
.feedback-dialog { width: min(1040px, calc(100vw - 32px)); }
.feedback-body-wrap {
  display: grid; grid-template-columns: minmax(280px, .9fr) minmax(320px, 1.1fr);
  min-height: 0; overflow: hidden;
}
.feedback-form { display: grid; gap: 10px; align-content: start; padding: 16px 18px; overflow: auto; }
.feedback-textarea { min-height: 140px; resize: vertical; line-height: 1.55; }
.feedback-history {
  display: grid; grid-template-rows: auto 1fr; gap: 8px; min-height: 0;
  padding: 16px 18px; border-left: 1.5px solid rgba(43, 27, 61, .12);
  background: rgba(255, 250, 240, .55); overflow: hidden;
}
.feedback-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.feedback-list { display: grid; gap: 8px; align-content: start; overflow: auto; min-height: 0; padding-right: 2px; }
.feedback-item {
  display: grid; gap: 6px; padding: 10px 12px; border: 1.5px solid rgba(43, 27, 61, .13);
  border-radius: 12px; background: #fff;
}
.feedback-item.is-new { border-left: 4px solid #ef4444; }
.feedback-item.is-reviewing { border-left: 4px solid #f59e0b; }
.feedback-item.is-planned { border-left: 4px solid #3b82f6; }
.feedback-item.is-done { border-left: 4px solid #16a34a; }
.feedback-item.is-closed { opacity: .72; }
.feedback-item-head { display: flex; align-items: flex-start; gap: 8px; }
.feedback-kind { font-size: 20px; line-height: 1.2; }
.feedback-item-title { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.feedback-item-title strong { font-size: 13.5px; overflow-wrap: anywhere; }
.feedback-item-title span { font-size: 11px; color: var(--ink-3, #6b6474); }
.feedback-badge {
  flex: none; padding: 3px 8px; border-radius: 999px; font: 700 10.5px/1.4 system-ui, sans-serif;
  background: #eef2f7; color: #475569;
}
.feedback-badge.is-new { background: #fee2e2; color: #b91c1c; }
.feedback-badge.is-reviewing { background: #fef3c7; color: #b45309; }
.feedback-badge.is-planned { background: #dbeafe; color: #1d4ed8; }
.feedback-badge.is-done { background: #dcfce7; color: #15803d; }
.feedback-body { margin: 0; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-note { margin: 0; padding: 6px 8px; border-radius: 8px; background: var(--cream, #fff3dd); font-size: 11.5px; }
.feedback-status { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-3, #6b6474); }
.feedback-status.ok { color: #15803d; }
.feedback-status.bad { color: #b91c1c; }
.feedback-admin { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.feedback-admin .cast-input { min-height: 32px; font-size: 12px; }
@media (max-width: 760px) {
  .feedback-body-wrap { grid-template-columns: 1fr; overflow: auto; }
  .feedback-history { border-left: 0; border-top: 1.5px solid rgba(43, 27, 61, .12); max-height: 46vh; }
  .feedback-admin { grid-template-columns: 1fr; }
}

/* ---- ປຸ່ມເລືອກພາສາ (assets/i18n.js) ---- */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.lang-switch select {
  font: inherit;
  font-family: var(--font);
  padding: 4px 6px;
  border: 2px solid rgba(43, 27, 61, 0.18);
  border-radius: 10px;
  background: #fff;
  color: #2b1b3d;
  cursor: pointer;
}
.lang-switch-floating {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 20px rgba(43, 27, 61, 0.18);
}
.movie-lang select { min-width: 0; }
@media (max-width: 640px) {
  .lang-switch { font-size: 12px; }
  .lang-switch select { padding: 3px 4px; }
}

/* ---- ຫົວເວັບແທັບເລັດ: ປຸ່ມເລື່ອນຂ້າງໄດ້ ບໍ່ລົ້ນຈໍ (ມີປຸ່ມພາສາ ແລະ ຕິດຕັ້ງແອັບ) ---- */
@media (min-width: 681px) and (max-width: 1100px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .top-actions {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions .btn-top { flex: none; }
}
.topbar .lang-switch { color: #fde68a; flex: none; }
.topbar .lang-switch select { border-color: rgba(255, 243, 221, 0.35); }

/* ---- ປຸ່ມຮູບແບບວິດີໂອ + ພາສາໜັງ: ລົງແຖວໃໝ່ໄດ້ໃນຈໍແຄບ ---- */
.aspect-switch { flex-wrap: wrap; max-width: 100%; align-items: center; }
.aspect-switch .movie-lang { padding: 0 4px; font-size: 12px; }
@media (max-width: 680px) {
  .aspect-switch { flex: 1 1 100%; justify-content: space-between; }
  .aspect-switch .movie-lang span { display: none; }
  .install-app .top-label { display: none; }
}

/* ---- ປຸ່ມຕິດຕັ້ງແອັບ (assets/pwa.js) ---- */
.install-app { flex: none; }
.install-app-floating {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1000;
}
.is-app .install-app { display: none; }

/* ---- ຈໍກາງ (ແລັບທັອບນ້ອຍ): ຫົວເວັບໃຊ້ປ້າຍສັ້ນ ເພື່ອບໍ່ລົ້ນເມື່ອຂໍ້ຄວາມພາສາອັງກິດຍາວ ---- */
@media (min-width: 1101px) and (max-width: 1500px) {
  .top-actions .top-label { display: none; }
  .top-actions .top-label-sm { display: inline; }
  .top-actions .install-app .top-label { display: inline; }
}
@media (min-width: 1101px) {
  .top-actions { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions .btn-top { flex: none; }
}

/* ---- ເມນູ "ເພີ່ມເຕີມ" ໃນຫົວເວັບ (ປຸ່ມທີ່ບໍ່ໄດ້ໃຊ້ເລື້ອຍ) ---- */
.top-more { position: relative; flex: none; }
.top-more > summary { list-style: none; cursor: pointer; }
.top-more > summary::-webkit-details-marker { display: none; }
.top-more[open] > summary { background: var(--accent, #f97316); color: #fff; }
.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  display: grid;
  min-width: 270px;
  padding: 8px;
  border: 2px solid var(--ink, #2b1b3d);
  border-radius: 16px;
  background: #fffaf0;
  color: var(--ink, #2b1b3d);
  box-shadow: 0 18px 40px rgba(43, 27, 61, 0.28);
}
.more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.more-item:hover, .more-item:focus-visible { background: rgba(249, 115, 22, 0.12); outline: none; }
.more-item[hidden] { display: none; }
.more-ico { width: 24px; text-align: center; font-size: 18px; }
.more-menu .feedback-count { margin-left: auto; }
@media (max-width: 680px) {
  .top-more { position: static; }
  .more-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    min-width: 0;
    max-height: 70vh;
    overflow-y: auto;
  }
  .more-item { padding: 14px 12px; font-size: 16px; }
}
/* ປ້າຍຫົວເວັບເຕັມຄຳ ເມື່ອມີບ່ອນ (ປຸ່ມໜ້ອຍລົງແລ້ວ) */
@media (min-width: 1101px) {
  .top-actions .top-label { display: inline; }
  .top-actions .top-label-sm { display: none; }
}
.topbar .lang-switch { margin-left: 8px; }

/* ---- ຊ່ວຍຜູ້ເລີ່ມຕົ້ນ (assets/easy.js) ---- */
.easy-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 2px dashed rgba(249, 115, 22, 0.55);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.9);
}
.easy-steps[hidden] { display: none; }
.easy-steps-title { font-size: 14px; margin-right: 4px; }
.easy-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 7px;
  border: 2px solid var(--ink, #2b1b3d);
  border-radius: 999px;
  background: #fff;
  color: var(--ink, #2b1b3d);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.easy-step:hover { background: #fff3e0; }
.easy-step-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  font-weight: 900;
}
.easy-steps-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.6;
}
@keyframes easy-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
  30% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0.55); }
  60% { box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.35); }
}
.easy-spotlight { animation: easy-pulse 0.9s ease-in-out 3; border-radius: 16px; }

.easy-welcome {
  width: min(520px, calc(100% - 32px));
  padding: 26px 24px 22px;
  border: 3px solid var(--ink, #2b1b3d);
  border-radius: 22px;
  background: #fffaf0;
  color: var(--ink, #2b1b3d);
  text-align: center;
}
.easy-welcome::backdrop { background: rgba(43, 27, 61, 0.55); }
.easy-welcome h2 { margin: 6px 0 4px; font-family: var(--font-display); font-size: 24px; }
.easy-welcome-hero { font-size: 48px; line-height: 1; }
.easy-welcome-lead { margin: 0 0 14px; color: #5b476f; }
.easy-welcome-steps { display: grid; gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; text-align: left; }
.easy-welcome-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: #fff; border: 2px solid rgba(43, 27, 61, 0.12); }
.easy-welcome-steps strong { font-size: 16px; }
.easy-welcome-steps p { margin: 2px 0 0; font-size: 14px; color: #5b476f; }
.easy-welcome-tip { font-size: 13px; color: #5b476f; margin: 0 0 14px; }
.easy-welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.easy-welcome-x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 18px; cursor: pointer; }

.editor-mode {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  margin-left: auto;
  border: 2px solid var(--line, rgba(43, 27, 61, 0.15));
  border-radius: 999px;
  background: var(--paper-2, #fff4e2);
}
.editor-mode button {
  border: 0;
  border-radius: 999px;
  padding: 5px 11px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: inherit;
}
.editor-mode button.is-active { background: var(--ink, #2b1b3d); color: #fff; }

/* ໂໝດງ່າຍ: ເຊື່ອງເຄື່ອງມືຂັ້ນສູງ */
.simple-mode .line-voice,
.simple-mode .touch-controls,
.simple-mode .props-editor,
.simple-mode .editor-tabs [data-tab="script"],
.simple-mode .editor-tabs [data-tab="voice"] { display: none !important; }

/* ປຸ່ມ ງ່າຍ/ເຕັມ ບໍ່ຕັດແຖວ; ຫົວເວັບມືຖື: ປຸ່ມໜ້ອຍລົງແລ້ວ ໃຫ້ລົງແຖວໄດ້ (ບໍ່ຕ້ອງເລື່ອນຂ້າງ) */
.editor-mode { flex: none; }
.editor-mode button { white-space: nowrap; }
/* ທຸກຂະໜາດຈໍ: ຫົວເວັບບໍ່ເປັນກ່ອງເລື່ອນ — ຖ້າເປັນ overflow:auto ເມນູ ☰ ເພີ່ມເຕີມ ຈະຖືກຕັດ (ກົດບໍ່ໄດ້ໃນ PC). */
.top-actions { flex-wrap: wrap; overflow: visible; row-gap: 6px; justify-content: flex-end; }

/* ລະຫັດປະເທດ + ເບີໂທ (assets/phone.js) */
.phone-field { display: flex; gap: 6px; align-items: stretch; min-width: 0; }
.phone-field .phone-cc { flex: 0 1 46%; min-width: 132px; max-width: 220px; padding-left: 10px; padding-right: 4px; text-overflow: ellipsis; }
.phone-field .phone-local { flex: 1 1 auto; min-width: 0; }
@media (max-width: 360px) { .phone-field { flex-wrap: wrap; } .phone-field .phone-cc { flex-basis: 100%; max-width: none; } }

/* ປຸ່ມພາສາໃນສ່ວນຫົວຂອງໜ້າເຂົ້າສູ່ລະບົບ/ສະໝັກ; ໜ້າອື່ນທີ່ລອຍ → ເວັ້ນບ່ອນລຸ່ມ ບໍ່ໃຫ້ທັບປຸ່ມ */
.lang-switch-hero { margin-top: 10px; color: #fde68a; }
.lang-switch-hero select { border-color: rgba(255, 243, 221, 0.4); }
body:has(.lang-switch-floating) { padding-bottom: 72px; }
.login-page .bb-project-footer { color: rgba(255, 243, 221, 0.86); }
.login-page .bb-project-footer a { color: #fde68a; }

/* ---------- ຕົວຢ່າງຄ້າງໄວ້ໃນຈໍ ຂະນະເລື່ອນຟອມແກ້ໄຂ (ຕົວລະຄອນ / Parts / ໜັງ) ---------- */
.cast-stage { position: sticky; top: 0; align-self: start; z-index: 3; }
@media (max-width: 940px) {
  /* ຈໍແຄບ: ຕົວຢ່າງນ້ອຍລົງ ແລະ ຕິດຢູ່ເທິງສຸດ ເພື່ອເຫັນການປ່ຽນແປງທັນທີ */
  .cast-stage,
  .part-preview-pane,
  .movie-preview-pane {
    position: sticky; top: -12px; z-index: 5;
    margin-inline: -4px;
    box-shadow: 0 8px 14px -10px rgba(43, 27, 61, 0.45);
  }
  .cast-stage {
    max-width: none; width: auto; justify-self: stretch;
    grid-template-columns: auto minmax(0, 1fr); align-items: center;
    padding: 8px; border-radius: 14px; background: var(--paper);
    border: 1.5px solid rgba(43, 27, 61, 0.12);
  }
  .cast-preview { width: auto; height: min(30dvh, 220px); justify-self: center; }
  .cast-stage-controls { flex-direction: column; align-items: stretch; }
  .part-preview-pane { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .part-preview-pane > :not(canvas) { grid-column: 2; }
  .part-preview-canvas { grid-row: 1 / span 3; width: auto; height: min(26dvh, 200px); }
  .movie-preview-canvas { width: auto; max-width: 100%; height: min(24dvh, 200px); justify-self: center; }
  .movie-preview-pane p { display: none; }
}
@media (max-width: 680px) {
  .cast-preview { height: min(26dvh, 180px); }
}
@media (max-height: 520px) and (min-width: 560px) {
  /* ຈໍເຕ້ຍ ສອງຖັນ: ຕົວຢ່າງຢູ່ຖັນຊ້າຍ ຄ້າງໄວ້ */
  .cast-stage { grid-template-columns: 1fr; margin: 0; box-shadow: none; top: 0; }
  .cast-preview { width: 100%; height: auto; max-height: calc(100dvh - 190px); }
}

/* ==========================================================================
   ເອກະລັກ Smart Cartoon Studio — ລາຍສິ້ນລາວ ແລະ ດອກຈຳປາ
   - ແຖບລາຍສິ້ນ (ລາຍຂິດ) ໃຕ້ຫົວເວັບ ແທນເສັ້ນສີສົ້ມທຳມະດາ.
   - ດອກຈຳປາຈາງໆ ເປັນພື້ນຫຼັງ ແລະ ລາຍນ້ຳໃນກ່ອງໄອເດຍ.
   - ຫົວຂໍ້ນ້ອຍມີດອກຈຳປາ, ປຸ່ມຫຼັກມີແສງເງົາຄືສະຕິກເກີ.
   ========================================================================== */
:root {
  --sinh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='12' viewBox='0 0 28 12'%3E%3Crect width='28' height='12' fill='%232b1b3d'/%3E%3Cpath d='M14 0 22 6 14 12 6 6Z' fill='%23f97316'/%3E%3Cpath d='M14 3 18 6 14 9 10 6Z' fill='%23fde68a'/%3E%3Cpath d='M0 0 4 6 0 12ZM28 0 24 6 28 12Z' fill='%230d9488'/%3E%3Ccircle cx='14' cy='6' r='1.1' fill='%23e11d48'/%3E%3C/svg%3E");
  --champa: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-20 -20 40 40'%3E%3Cg fill='%23fffaf0' stroke='%23f2c46d' stroke-width='.8'%3E%3Cellipse rx='5.4' ry='10' cy='-9' transform='rotate(0)'/%3E%3Cellipse rx='5.4' ry='10' cy='-9' transform='rotate(72)'/%3E%3Cellipse rx='5.4' ry='10' cy='-9' transform='rotate(144)'/%3E%3Cellipse rx='5.4' ry='10' cy='-9' transform='rotate(216)'/%3E%3Cellipse rx='5.4' ry='10' cy='-9' transform='rotate(288)'/%3E%3C/g%3E%3Ccircle r='4.2' fill='%23f6b73c'/%3E%3C/svg%3E");
  --champa-field: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cdefs%3E%3Cg id='f'%3E%3Cg fill='%23fffaf0' fill-opacity='.75'%3E%3Cellipse rx='5' ry='9' cy='-8'/%3E%3Cellipse rx='5' ry='9' cy='-8' transform='rotate(72)'/%3E%3Cellipse rx='5' ry='9' cy='-8' transform='rotate(144)'/%3E%3Cellipse rx='5' ry='9' cy='-8' transform='rotate(216)'/%3E%3Cellipse rx='5' ry='9' cy='-8' transform='rotate(288)'/%3E%3C/g%3E%3Ccircle r='3.6' fill='%23f6b73c' fill-opacity='.55'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23f' transform='translate(46 52) rotate(12)'/%3E%3Cuse href='%23f' transform='translate(166 160) rotate(-20) scale(.7)'/%3E%3C/svg%3E");
}

body {
  background-image:
    var(--champa-field),
    radial-gradient(rgba(43, 27, 61, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 8% 12%, var(--user-glow, rgba(249, 115, 22, 0.12)), transparent 32%),
    radial-gradient(circle at 94% 80%, var(--user-glow-2, rgba(13, 148, 136, 0.1)), transparent 30%);
  background-size: 220px 220px, 22px 22px, auto, auto;
}

/* ແຖບລາຍສິ້ນໃຕ້ຫົວເວັບ (ທຸກໜ້າ). */
.topbar,
.account-topbar,
.admin-topbar { border-bottom: 0; }
.topbar::after,
.account-topbar::after,
.admin-topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 10px;
  background: var(--sinh) repeat-x left center / 28px 10px;
  box-shadow: 0 6px 14px rgba(43, 27, 61, 0.18);
  pointer-events: none;
}
.topbar { margin-bottom: 10px; }

/* ດອກຈຳປາເປັນລາຍນ້ຳໃນກ່ອງໄອເດຍ (ແທນ ✿). */
.idea-card::after {
  content: "";
  right: 18px;
  bottom: -34px;
  width: 132px;
  height: 132px;
  background: var(--champa) center / contain no-repeat;
  opacity: 0.55;
  transform: rotate(-14deg);
}

/* ຫົວຂໍ້ນ້ອຍ (eyebrow) ມີດອກຈຳປານ້ອຍ. */
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  margin-right: 5px;
  vertical-align: -0.17em;
  background: var(--champa) center / contain no-repeat;
}

/* ແບບເລືອກປະເພດ: ບໍ່ໃຫ້ລົ້ນຂອບ (ຄໍລຳສອງບໍ່ຖືກຕັດ). */
.genre-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.genre-tab { min-width: 0; }
.genre-tab strong { overflow-wrap: anywhere; }
.genre-count { white-space: normal; overflow-wrap: anywhere; }

/* ຫົວແຜງແກ້ໄຂ: ຊື່ເລື່ອງໃຊ້ຄວາມກວ້າງເຕັມ, ປຸ່ມ ງ່າຍ/ເຕັມ ລົງແຖວໃໝ່ເມື່ອບໍ່ພໍ. */
.editor-head { flex-wrap: wrap; align-items: center; }
.editor-head > div:first-child { flex: 1 1 190px; min-width: 0; }
.editor-head h2 { overflow-wrap: anywhere; }

/* ---------- ສະໄຕລ໌ສະເພາະຜູ້ໃຊ້ (userstyle.js) ---------- */
.user-badge { display: inline-flex; align-items: center; gap: 6px; min-width: 0; vertical-align: middle; }
.user-badge-avatar {
  display: grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ub-1, var(--accent)), var(--ub-2, var(--accent-2)));
  font-size: 12px; line-height: 1;
}
.user-badge-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ub-1, inherit); font-weight: 700; }
[data-account-chip] .account-avatar[role="button"] { cursor: pointer; }
.user-style-picker {
  position: absolute; z-index: 1000;
  padding: 14px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-soft), var(--shadow);
}
.user-style-picker > strong { display: block; margin-bottom: 10px; font-size: 14px; }
.user-style-picker > p { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); }
.user-style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.user-style-swatch {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 8px; border: 1.5px solid rgba(43, 27, 61, 0.18); border-radius: 10px;
  background: var(--paper-2); font-size: 12px; text-align: left;
}
.user-style-swatch:first-child { grid-column: 1 / -1; }
.user-style-swatch[aria-pressed="true"] { border-color: var(--sw-1); box-shadow: 0 0 0 2px var(--sw-1) inset; }
.user-style-dot {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sw-1) 50%, var(--sw-2) 50%);
}

/* ລາກວາງລະຄອນ/ສິ່ງຂອງໃນຈໍ */
.stage-frame canvas.can-drag { cursor: grab; }
.stage-frame canvas.is-dragging { cursor: grabbing; touch-action: none; }
.stage-frame canvas { touch-action: pan-y pinch-zoom; }
.blocking-reset { margin: 0 0 8px; }
.line-walk, .line-pose { max-width: 150px; }
.stage-drag-hint { margin: 6px 2px 0; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ສີຜິວຕົວລະຄອນມະນຸດ */
.skin-tones { display: flex; flex-wrap: wrap; gap: 6px; }
.skin-tone {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(43, 27, 61, 0.35); padding: 0;
}
.skin-tone:hover { transform: scale(1.08); }
.skin-tone.active { border-color: #2b1b3d; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.7); }

/* ---- 📖 ສ້າງມັງງະ / ກາຕູນຊ່ອງ ---------------------------------------------------- */
.manga-dialog { width: min(1240px, calc(100vw - 24px)); }
.manga-body {
  display: grid; grid-template-columns: 320px 1fr; gap: 16px;
  padding: 14px 18px; overflow: auto; min-height: 0;
}
.manga-controls { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.manga-idea-row { display: flex; gap: 6px; }
.manga-idea {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 8px 10px;
  border: 1.5px solid rgba(43, 27, 61, 0.2); border-radius: var(--radius-sm); background: #fff;
}
.manga-field { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.manga-select, .manga-mini {
  font: inherit; font-size: 13px; padding: 7px 8px; border-radius: 10px;
  border: 1.5px solid rgba(43, 27, 61, 0.2); background: #fff; color: var(--ink);
}
.manga-mini { font-size: 11px; padding: 3px 4px; border-radius: 7px; }
.manga-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.manga-check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.manga-sub { margin: 6px 0 0; font-size: 13px; }
.manga-panels {
  display: flex; flex-direction: column; gap: 4px; overflow: auto;
  max-height: min(380px, calc(100dvh - 470px)); min-height: 120px;
  border: 1.5px solid rgba(43, 27, 61, 0.1); border-radius: var(--radius-sm); padding: 6px;
}
.manga-scene-head { font-size: 11px; font-weight: 800; color: var(--accent-ink); margin-top: 4px; }
.manga-panel-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; font-size: 12px; }
.manga-panel-row.is-hidden .manga-panel-text { opacity: 0.4; text-decoration: line-through; }
.manga-panel-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manga-panel-opts { display: flex; gap: 3px; }
.manga-stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; align-items: center; }
.manga-nav { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.manga-preview {
  width: 100%; display: flex; justify-content: center; align-items: flex-start;
  background: repeating-linear-gradient(45deg, #ece6da 0 10px, #e4ddcf 10px 20px);
  border-radius: var(--radius-sm); padding: 12px; min-height: 300px;
  max-height: calc(100dvh - 260px); overflow: auto;
}
.manga-canvas { max-width: 100%; height: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); background: #fff; }
.manga-preview .manga-canvas { max-height: calc(100dvh - 290px); }
.manga-status { margin: 0; font-size: 12px; text-align: center; }
@media (max-width: 820px) {
  .manga-body { grid-template-columns: 1fr; }
  .manga-preview .manga-canvas { max-height: none; }
  .manga-panels { max-height: 240px; }
}
.manga-preview .manga-canvas.is-strip { max-height: none; width: min(100%, 560px); }

/* 📖 ສ້າງມັງງະຈາກຕອນ */
.episode-manga {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  font-size: 14px; cursor: pointer; background: transparent; transition: background 0.15s, transform 0.15s;
}
.episode-manga:hover, .episode-manga:focus-visible { background: rgba(43, 27, 61, 0.1); transform: scale(1.1); }
.episode-card .episode-manga { position: absolute; right: 6px; bottom: 6px; }
.episode-card { padding-right: 34px; }
.story-ep { grid-template-columns: 22px 24px 1fr 26px 20px; }
.btn-manga { background: #111; color: #fff; border-color: #111; }
.btn-manga:hover:not(:disabled) { background: #333; }

/* 📚 ແປງທຸກເລື່ອງເປັນມັງງະ */
.manga-batch .manga-body { grid-template-columns: 300px 1fr; }
.manga-batch-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.manga-batch-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.manga-batch-list {
  display: flex; flex-direction: column; gap: 3px; overflow: auto;
  max-height: calc(100dvh - 330px); min-height: 160px;
  border: 1.5px solid rgba(43, 27, 61, 0.1); border-radius: var(--radius-sm); padding: 8px;
}
.manga-batch-group {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  margin-top: 6px; padding: 4px 2px; font-size: 13px; border-bottom: 1px solid rgba(43, 27, 61, 0.1); cursor: pointer;
}
.manga-batch-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  padding: 3px 4px 3px 18px; font-size: 12.5px; border-radius: 7px; cursor: pointer;
}
.manga-batch-item:hover { background: rgba(43, 27, 61, 0.05); }
.manga-batch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manga-batch-item.is-busy { background: var(--accent-soft); }
.manga-batch-item.is-done .muted { color: var(--ok); }
.manga-batch-item.is-fail .muted { color: var(--danger); }
.manga-note { font-size: 11.5px; margin: 4px 0 0; }
.manga-batch-progress { margin: 0; }
@media (max-width: 820px) { .manga-batch .manga-body { grid-template-columns: 1fr; } }

/* 📽 ອ່ານມັງງະແບບນຳທາງ */
.manga-reader {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: #0b0b0f; color: #fff; overflow: hidden;
}
.manga-reader::backdrop { background: #0b0b0f; }
.manga-reader[open] { display: flex; flex-direction: column; }
.manga-reader-canvas { flex: 1; width: 100%; min-height: 0; display: block; cursor: pointer; }
.manga-reader-progress { height: 4px; background: rgba(255, 255, 255, 0.12); }
.manga-reader-bar { height: 100%; width: 0; background: linear-gradient(90deg, #f97316, #ec4899); transition: width 0.4s ease; }
.manga-reader-ui {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  padding: 10px; background: #15151c;
}
.manga-reader-ui .btn { background: #26262f; color: #fff; border-color: #3a3a46; }
.manga-reader-ui .btn:hover:not(:disabled) { background: #33333f; }
.manga-reader-count { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 72px; text-align: center; }

/* 🎬 ສະໄຕລ໌ໜັງຈີນ AI (cinema.js) */
.cinema-panel { position: relative; align-self: center; }
.cinema-panel > summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 9px;
  font-weight: 700; font-size: 13px; white-space: nowrap; background: #1f1630; color: #fde68a;
}
.cinema-panel > summary::-webkit-details-marker { display: none; }
.cinema-panel[open] > summary { box-shadow: 0 0 0 2px #fde68a inset; }
.cinema-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: min(440px, 90vw);
  background: var(--paper, #fff); border: 2px solid var(--line, #ddd); border-radius: 13px; padding: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.25);
}
.cinema-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.cinema-preset {
  border: 2px solid var(--line, #ddd); background: var(--paper-2, #f7f3ea); border-radius: 10px;
  padding: 6px 9px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.cinema-preset.is-active { border-color: #e11d48; background: #ffe4e6; }
.cinema-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; font-weight: 700; }
.cinema-row > input, .cinema-row > select { flex: 1; min-width: 0; padding: 5px 7px; border-radius: 8px; border: 2px solid var(--line, #ddd); font: inherit; }
.cinema-flags { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 8px; font-size: 12.5px; }
.cinema-flag { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.cinema-tip { margin: 8px 0 0; font-size: 12px; opacity: .75; }
@media (max-width: 560px) { .cinema-flags { grid-template-columns: 1fr; } .cinema-pop { right: auto; left: 0; } }

/* ---- 🎯 ສ້າງສຳລັບ (TikTok / ເລົ່າເລື່ອງ / ໜັງ / ມັງງະ / ໜ້າປົກ) --------------------- */
.format-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.format-label { font-size: 12px; font-weight: 800; color: var(--ink-2); margin-right: 2px; }
.format-btn {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 6px 11px; border-radius: 999px;
  border: 1.5px solid rgba(43, 27, 61, 0.18); background: var(--card, #fff); color: var(--ink, #2b1b3d);
}
.format-btn:hover:not(:disabled) { border-color: var(--accent, #ff7a3d); }
.format-btn.is-active { background: var(--accent, #ff7a3d); border-color: var(--accent, #ff7a3d); color: #fff; }
.format-btn.format-tool { border-style: dashed; }
.format-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 640px) { .format-btn { flex: 1 1 auto; min-height: 40px; } }

/* ---- 🖼 ໜ້າປົກຄລິບ ------------------------------------------------------------------ */
.btn-cover { background: linear-gradient(135deg, #ff2d6f, #ff9a3d); color: #fff; border-color: transparent; }
.btn-cover:hover:not(:disabled) { filter: brightness(1.06); }
.btn-facebook { background: linear-gradient(135deg, #1877f2, #0a58ca); color: #fff; border-color: transparent; }
.btn-facebook:hover:not(:disabled) { filter: brightness(1.06); }
.cover-dialog .manga-body { grid-template-columns: 340px 1fr; }
.cover-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.cover-chip {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 5px 9px; border-radius: 9px;
  border: 1.5px solid rgba(43, 27, 61, 0.18); background: var(--card, #fff); color: var(--ink, #2b1b3d);
}
.cover-chip.is-active { background: #2b1b3d; border-color: #2b1b3d; color: #fff; }
.cover-two { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
.cover-preview {
  display: block; max-width: 100%; max-height: min(72vh, 760px); width: auto; height: auto;
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28); background: #111;
}
.cover-caption {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 12px; line-height: 1.5;
  padding: 8px; border-radius: 9px; border: 1.5px solid rgba(43, 27, 61, 0.18); resize: vertical;
}
.cover-dialog .manga-idea-row select { flex: 1; min-width: 0; }
@media (max-width: 820px) { .cover-dialog .manga-body { grid-template-columns: 1fr; } }

/* ---- 📘 ໂພສ Facebook: ຮູບກາຕູນ + ຄຳບັນຍາຍ + ຕົວຢ່າງ Feed ------------------------ */
.fb-dialog { width: min(1180px, calc(100vw - 24px)); }
.fb-dialog .manga-body { grid-template-columns: 390px 1fr; }
.fb-controls { padding-right: 2px; }
@media (min-width: 901px) {
  .fb-body { overflow: hidden; }
  .fb-controls { overflow-y: auto; padding-right: 8px; scrollbar-gutter: stable; }
}
.fb-chips .cover-chip.is-active { background: #1877f2; border-color: #1877f2; }
.fb-text-hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-2); opacity: 0.72; }
.fb-text-fields { display: grid; gap: 10px; }
.fb-text-fields[hidden] { display: none; }
.manga-field.is-disabled { opacity: 0.45; }
.manga-field.is-disabled input { cursor: not-allowed; }
.fb-caption-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.fb-caption-label { font-size: 12px; font-weight: 800; color: var(--ink-2); }
.fb-count { font-size: 11px; font-weight: 600; color: var(--ink-2); opacity: 0.65; }
.fb-caption { min-height: 150px; font-size: 13px; line-height: 1.55; }
.fb-caption-actions { display: flex; gap: 6px; }
.fb-caption-actions .btn { flex: 1; }
.fb-stage { align-items: stretch; }
.fb-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.fb-tab {
  font: inherit; font-size: 12.5px; font-weight: 800; cursor: pointer;
  padding: 7px 13px; border-radius: 999px;
  border: 1.5px solid rgba(43, 27, 61, 0.18); background: var(--card, #fff); color: var(--ink, #2b1b3d);
}
.fb-tab.is-active { background: #1877f2; border-color: #1877f2; color: #fff; }
.fb-view {
  width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  max-height: min(72vh, 820px); overflow: auto; padding: 2px;
}
.fb-view > * { flex: 0 0 auto; }
.fb-view[hidden] { display: none; }
.fb-photo {
  display: block; width: auto; height: auto; max-width: 100%; max-height: min(68vh, 760px);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); background: #111;
}
.fb-feed {
  width: min(100%, 520px); overflow: hidden;
  background: #fff; color: #050505; border: 1px solid #d0d2d6; border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans Lao", sans-serif;
}
.fb-feed-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.fb-feed-avatar {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 22px; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32);
}
.fb-feed-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.fb-feed-name { font-size: 14px; font-weight: 800; color: #050505; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-feed-time { font-size: 12px; color: #65676b; }
.fb-feed-more { color: #65676b; font-size: 20px; line-height: 1; letter-spacing: 1px; padding: 4px 2px; }
.fb-feed-text {
  padding: 0 14px 10px; font-size: 14px; line-height: 1.48;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 190px; overflow: auto;
}
.fb-feed-text.is-empty { color: #8a8d91; font-style: italic; }
.fb-tag { color: #1877f2; }
.fb-feed-media { display: flex; background: #f0f2f5; }
.fb-feed-canvas { display: block; width: 100%; height: auto; }
.fb-feed-reactions {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-bottom: 1px solid #ced0d4; font-size: 12.5px; color: #65676b;
}
.fb-feed-reacts { font-size: 14px; letter-spacing: 1px; padding-right: 2px; }
.fb-feed-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px 8px; }
.fb-feed-action {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 4px; border-radius: 7px; font-size: 12.5px; font-weight: 700; color: #65676b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-demo-note { max-width: 520px; margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-2); opacity: 0.7; text-align: center; }

/* 📘 ໂພສ Facebook ຫຼາຍເລື່ອງ (Batch) */
.fb-batch .manga-body { grid-template-columns: 320px 1fr; }
.fb-batch .manga-batch-list { max-height: calc(100dvh - 360px); }
.fb-batch-file {
  display: grid; gap: 3px; padding: 9px 11px;
  border: 1.5px dashed rgba(24, 119, 242, 0.45); border-radius: 10px;
  background: rgba(24, 119, 242, 0.06); font-size: 12px; line-height: 1.45; color: var(--ink-2);
}
.fb-batch-file strong { color: var(--ink); font-size: 12.5px; }
.fb-batch-hint { color: #1877f2; font-weight: 700; }
@media (max-width: 820px) {
  .fb-batch .manga-body { grid-template-columns: 1fr; grid-auto-rows: max-content; align-content: start; }
  .fb-batch .manga-batch-list { max-height: 42dvh; }
}
@media (max-width: 900px) {
  .fb-dialog .manga-body { grid-template-columns: 1fr; grid-auto-rows: max-content; align-content: start; }
  .fb-view { max-height: none; }
  .fb-photo { max-height: none; }
}
@media (max-width: 560px) {
  .fb-tab { flex: 1 1 auto; min-height: 40px; }
  .fb-feed-action { gap: 3px; }
  .fb-feed-action span:last-child { font-size: 11px; }
}

/* ---- ອອກແບບໜັງ: ຕົວເລືອກຕົກແຕ່ງພັບໄວ້ (ຜູ້ເລີ່ມຕົ້ນເຫັນສະເພາະສິ່ງຈຳເປັນ) ---- */
.movie-more {
  border: 1.5px solid rgba(43, 27, 61, 0.14);
  border-radius: 12px;
  background: var(--paper-2);
}
.movie-more > summary {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 12px;
  font-size: 13px; font-weight: 700; color: var(--ink-2);
  cursor: pointer; list-style: none;
}
.movie-more > summary::-webkit-details-marker { display: none; }
.movie-more > summary::after { content: "▾"; margin-left: auto; transition: transform 0.15s; }
.movie-more[open] > summary::after { transform: rotate(180deg); }
.movie-more[open] > summary { border-bottom: 1.5px dashed rgba(43, 27, 61, 0.14); }
.movie-more > .movie-fields { padding: 10px 12px 12px; }
.movie-episode-box .movie-more { background: var(--paper); }
.movie-episode-box .movie-more[open] { display: grid; gap: 9px; padding-bottom: 10px; }
.movie-episode-box .movie-more > :not(summary) { margin: 0 12px; }

/* ---- ມືຖື: ແຖບນຳທາງລຸ່ມຈໍ (assets/easy.js) ---- */
.mobile-nav { display: none; }
@media (max-width: 680px) {
  /* ຫົວເວັບສູງ ~160px ເທິງມືຖື — ໃຫ້ເລື່ອນຫາຍໄປ, ໃຊ້ແຖບລຸ່ມແທນ */
  .app-page .topbar { position: relative; }
  .stage-card, .editor, .rail, .result, .scene-card { scroll-margin-top: 12px; }

  .mobile-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: var(--ink, #2b1b3d);
    border-top: 3px solid var(--accent, #f97316);
    box-shadow: 0 -8px 24px rgba(43, 27, 61, 0.25);
  }
  .mobile-nav-btn {
    display: grid; justify-items: center; align-content: center; gap: 1px;
    min-height: 54px; padding: 4px 2px;
    border: 0; border-radius: 12px;
    background: transparent; color: rgba(255, 243, 221, 0.78);
    font: inherit; font-size: 11.5px; font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-ico { font-size: 20px; line-height: 1.2; }
  .mobile-nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav-btn.is-active { background: rgba(249, 115, 22, 0.22); color: #fff; }
  .mobile-nav-btn:active { transform: scale(0.95); }
  body.has-mobile-nav { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  body.has-mobile-nav.is-typing { padding-bottom: 0; }
  body.is-typing .mobile-nav { display: none; }
  body.has-mobile-nav .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.has-mobile-nav .more-menu { bottom: calc(72px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 120px); }

  /* ແຖບ 3 ຂັ້ນຕອນຊ້ຳກັບແຖບລຸ່ມ — ເຊື່ອງເທິງມືຖື (ຍັງມີໃນໜ້າຕ້ອນຮັບ) */
  .app-page .easy-steps { display: none; }

  /* ປຸ່ມໃຫຍ່ພໍສຳລັບນິ້ວ (ຢ່າງໜ້ອຍ ~40px) */
  .transport { flex-wrap: wrap; row-gap: 8px; }
  .transport .timeline { order: 5; flex: 1 1 100%; height: 30px; }
  .play-btn { width: 44px; height: 44px; font-size: 18px; }
  .transport .icon-btn { width: 40px; height: 40px; font-size: 15px; }
  .time-label { flex: 1; min-width: 78px; font-size: 12px; }
  .mini-btn { min-width: 36px; min-height: 36px; }
  .editor-tabs button { min-height: 42px; }
  .record-row .btn { min-height: 46px; }

  /* ຕົວອັກສອນ 16px ໃນຊ່ອງພິມ: iPhone ຈະບໍ່ຊູມເຂົ້າເວລາກົດພິມ */
  .app-page input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=color]),
  .app-page select,
  .app-page textarea { font-size: 16px; }

  /* ອອກແບບໜັງ: ປຸ່ມ "ສ້າງໜັງ" ໃຫຍ່ ຢູ່ເທິງສຸດຂອງແຖບລຸ່ມ */
  .movie-designer .cast-foot-right { order: -1; flex: 1 1 100%; }
  .movie-designer .cast-foot-right .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
  .movie-designer .cast-foot-left { flex: 1 1 100%; }
  .movie-designer .cast-foot-left > * { flex: 1 1 auto; }
  .movie-designer .movie-preview-canvas { max-height: 30vh; object-fit: contain; }
  .movie-cast-chip { min-height: 38px; padding: 6px 11px; font-size: 13px; }
}

/* ---- ຄັງໜັງ: ແຖບເຄື່ອງມືບໍ່ຕິດເທິງ (ເຄີຍສູງ ~480px ເທິງມືຖື ແລະ ບັງໜັງ);
 *      ຕິດເທິງສະເພາະແຖວປະເພດ ທີ່ເປັນແຖວດຽວເລື່ອນຂ້າງໄດ້ ---- */
.library-bar { position: static; margin-bottom: 4px; padding-bottom: 4px; }
.library-filters {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 3;
  margin: 0 0 16px;
  padding: 8px 0 10px;
  background: var(--paper-2);
  box-shadow: 0 10px 12px -12px rgba(43, 27, 61, 0.35);
}
.library-filter { flex: none; }
.library-filter.is-fav:not(.is-active) { border-color: #f59e0b; background: #fffbeb; }
@media (max-width: 680px) {
  .library-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    margin-inline: -4px;
    padding-inline: 4px;
  }
  .library-filters::-webkit-scrollbar { display: none; }
  .library-filter { white-space: nowrap; }
}

/* ---- ປຸ່ມ ⭐ ໜັງທີ່ມັກ ---- */
.movie-fav {
  flex: none;
  min-width: 40px; min-height: 36px;
  padding: 4px 8px;
  font-size: 18px; line-height: 1;
  color: #b45309;
}
.movie-fav.is-on { background: #fef3c7; border-color: #f59e0b; }
.movie-title-row { display: flex; align-items: flex-start; gap: 8px; }
.movie-title-row h3 { flex: 1; min-width: 0; }
.story-row-head > .movie-fav { margin-left: 0; }

/* ---- ♻ ອັບເດດເລື່ອງເກົ່າ (assets/remake.js) ---- */
.remake-dialog { width: min(560px, calc(100vw - 24px)); }
.remake-body { display: grid; gap: 12px; padding: 14px 18px; overflow: auto; min-height: 0; }
.remake-body > p { margin: 0; }
.remake-scope { display: grid; gap: 6px; margin: 0; padding: 10px 12px; border: 1.5px solid rgba(43, 27, 61, 0.14); border-radius: 12px; }
.remake-scope legend { padding: 0 4px; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.remake-scope label { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; font-weight: 700; cursor: pointer; }
.remake-scope input { width: 18px; height: 18px; accent-color: var(--accent); }
.remake-options { display: grid; gap: 8px; }
.remake-option {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border: 1.5px solid rgba(43, 27, 61, 0.14); border-radius: 12px; background: var(--paper-2, #fff);
  cursor: pointer;
}
.remake-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.remake-option input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.remake-option span { display: grid; gap: 2px; }
.remake-option strong { font-size: 14px; }
.remake-option small { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
.remake-option.is-disabled { opacity: 0.5; cursor: not-allowed; }
.remake-status { margin: 0; min-height: 1.4em; font-weight: 700; color: var(--accent-ink, #9a3412); }
@media (max-width: 680px) {
  .remake-dialog .cast-foot-right { order: -1; flex: 1 1 100%; }
  .remake-dialog .cast-foot-right .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
  .remake-dialog .cast-foot-left { flex: 1 1 100%; }
  .remake-dialog .cast-foot-left > * { flex: 1 1 auto; }
}
