/* Recap Studio — Burmese-first UI.
   System Myanmar fonts first: Windows ships "Myanmar Text", macOS/iOS ship
   "Myanmar Sangam MN", Android/Linux have Noto Sans Myanmar. */
:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1d2430;
  --line: #2a3341;
  --text: #e8edf5;
  --muted: #93a1b5;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --ok: #2fbf71;
  --warn: #ffb020;
  --err: #ff5c6c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Myanmar Text", "Noto Sans Myanmar", "Myanmar Sangam MN",
               "Padauk", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: 64px; }

h1, h2, h3 { margin: 0 0 .3em; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.2rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .35em 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: 12px 18px 0;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(14, 17, 23, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { font-size: 1.8rem; }
.tagline { margin: 0; font-size: .82rem; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* -------------------------------------------------------------------- tabs */
/* The tab strip lives inside the sticky header, so the whole header is one
   sticky block and the strip never has to guess the header's height. */
.tabs {
  display: flex; gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
}
.tab:hover:not(.active) { background: rgba(255, 255, 255, .05); color: var(--text); }
.tab.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 -3px 0 0 var(--accent) inset;
}

/* ------------------------------------------------------------------ layout */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel { display: flex; flex-direction: column; gap: 20px; }

/* ---------------------------------------------------------------------- ad */
/* One ad, on the app page, as the first child of <main>. It is an <iframe>
   pointing at the apex — NOT the network's inline snippet — and that is
   deliberate: this origin holds the Gemini API key and keeps `script-src 'self'`,
   so the network's JavaScript runs on minkautomation.space instead, in a
   document that can see nothing of this page. Read the CSP note in _worker.js
   before changing this markup or the frame's src. */
.ad-app { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ad-tag { font-size: .72rem; letter-spacing: .08em; color: var(--muted); }
/* 300x250 is the unit's own size. max-width guards the 350px phone layout in
   case a creative ever comes back wider than the frame was asked for. */
.ad-frame { width: 300px; height: 250px; max-width: 100%; border: 0; display: block; }

/* The four stages a run walks through, shared by the Recap and Story tabs. It is
   a sibling of the panels rather than a panel itself, so it lays out exactly like
   one — and it starts hidden in the markup, which is the correct state for a page
   whose scripts failed to load. */
#stage-flow { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.step-num {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 700; color: #fff;
}
.step-head p { margin: 0; font-size: .9rem; }

/* ------------------------------------------------------------------ fields */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .93rem; }
.val { color: var(--accent); font-variant-numeric: tabular-nums; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: .93rem;
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .84rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 46px; height: 36px; padding: 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 22px; }

.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }

/* ----------------------------------------------------------------- buttons */
button, .primary, .ghost {
  font: inherit;
  font-size: .93rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: filter .15s, transform .05s, background .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover:not(:disabled), .primary:hover, .ghost:hover { filter: brightness(1.18); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.primary.big { width: 100%; padding: 16px; font-size: 1.08rem; margin-top: 8px; }
.ghost { background: transparent; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.actions .primary, .actions .ghost { flex: 1 1 auto; }

/* ---------------------------------------------------------------- dropzone */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(79, 140, 255, .07); }
.dz-icon { font-size: 2rem; margin-bottom: 6px; }
#dz-loaded video { width: 100%; max-height: 320px; border-radius: 10px; background: #000; }
.file-meta { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; text-align: left; }

/* --------------------------------------------------------------- progress */
.progress { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .3s ease;
}
.status { font-size: .92rem; margin: 0 0 10px; }
.log {
  background: #0a0d12; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 220px; overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.55; color: #9fb3cd;
  white-space: pre-wrap; word-break: break-word; margin: 0 0 14px;
}

/* ------------------------------------------------------------------ banner */
.banner { padding: 12px 18px; font-size: .9rem; }
.banner.warn { background: rgba(255, 176, 32, .13); border-bottom: 1px solid rgba(255, 176, 32, .35); color: #ffd591; }
.banner.err { background: rgba(255, 92, 108, .13); border-bottom: 1px solid rgba(255, 92, 108, .35); color: #ffb3bb; }

/* -------------------------------------------------------------- blur stage */
.blur-stage { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 20px; }
@media (max-width: 820px) { .blur-stage { grid-template-columns: 1fr; } }

.preview-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; line-height: 0; }
.preview-wrap video { width: 100%; display: block; }
.blur-box {
  position: absolute; left: 0; right: 0;
  border: 2px solid #ffd24a;
  background: rgba(255, 210, 74, .16);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .38);
  cursor: grab;
  touch-action: none;
  min-height: 8px;
}
.blur-box:active { cursor: grabbing; }
.blur-label {
  position: absolute; top: -22px; left: 4px;
  background: #ffd24a; color: #1a1a1a;
  font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 5px; line-height: 1.6;
  white-space: nowrap;
}
.blur-handle {
  position: absolute; left: 50%; width: 46px; height: 12px;
  transform: translateX(-50%);
  background: #ffd24a; border: 2px solid #1a1a1a; border-radius: 4px;
}
.blur-handle[data-h="t"] { top: -7px; cursor: ns-resize; }
.blur-handle[data-h="b"] { bottom: -7px; cursor: ns-resize; }
.blur-side { display: flex; flex-direction: column; gap: 4px; }

.output-preview { margin-top: 20px; }
.output-head { font-weight: 600; margin-bottom: 8px; font-size: .93rem; }
.output-preview canvas {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 60vh; margin: 0 auto;
  background: #000; border: 1px solid var(--line); border-radius: 10px;
}

/* ------------------------------------------------------------- script list */
.script-lines { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow: auto; padding-right: 4px; }
.script-line {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: start;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.script-line .ts { color: var(--accent); font-variant-numeric: tabular-nums; font-size: .84rem; padding-top: 7px; }
.script-line textarea { min-height: 42px; background: transparent; border: none; padding: 4px 0; font-family: inherit; font-size: .92rem; }
.script-line textarea:focus { outline: none; background: rgba(79, 140, 255, .08); border-radius: 6px; }
.script-line .tools { display: flex; flex-direction: column; gap: 4px; }
.script-line .tools button { padding: 4px 8px; font-size: .78rem; border-radius: 7px; }
.script-line.dropped { opacity: .4; }

/* --------------------------------------------------------------- render UI */
.render-preview { background: #000; border-radius: var(--radius); overflow: hidden; line-height: 0; margin-bottom: 14px; }
.render-preview canvas { width: 100%; max-height: 420px; object-fit: contain; display: block; }

.sync-meter { display: flex; align-items: center; gap: 12px; font-size: .84rem; margin-bottom: 12px; color: var(--muted); }
.sync-track { flex: 1; height: 8px; background: var(--panel-2); border-radius: 99px; position: relative; }
#sync-needle { position: absolute; top: -3px; width: 3px; height: 14px; background: var(--ok); border-radius: 2px; left: 50%; transition: left .2s; }
#sync-needle.bad { background: var(--err); }

.result-box { text-align: center; padding: 14px 0; }
.result-icon { font-size: 2.4rem; }
#result-video { width: 100%; max-height: 460px; border-radius: var(--radius); background: #000; margin: 14px 0; }
#btn-download { text-decoration: none; }
#narration-audio { width: 100%; margin-bottom: 8px; }

/* -------------------------------------------------------------------- tips */
.tips {
  background: rgba(79, 140, 255, .07);
  border: 1px solid rgba(79, 140, 255, .25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: .88rem;
}
/* The HEADING is a block; a <strong> inside a list item is emphasis and must
   stay inline. Scoped with `>` for that reason: the voice tab's tips lead a
   line with a bold control name ("⚠️ <strong>မြန်မာအသံ မပါ</strong>။"), and an
   unscoped rule breaks the sentence in two for no reason the reader can see. */
.tips > strong { display: block; margin-bottom: 4px; }
.tips ul, .tips ol { margin: 4px 0; padding-left: 20px; }
.tips li { margin: 3px 0; }

/* The cache tips share the box but not the colour. Two identical blue panels
   stacked read as one long block, and this one is a DECISION the user makes rather
   than a reassurance — amber says "read this before you press the button". The
   heading is the only <strong> that gets the colour, because every <strong> in the
   list is emphasis inside a sentence, not a title. */
.tips.cache {
  background: rgba(255, 176, 32, .07);
  border-color: rgba(255, 176, 32, .28);
}
.tips.cache > strong:first-child { color: var(--warn); }

/* ------------------------------------------------------------------ drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw);
  background: var(--panel); border-left: 1px solid var(--line);
  z-index: 50; display: flex; flex-direction: column;
  box-shadow: -20px 0 40px rgba(0, 0, 0, .5);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 1.05rem; }
.drawer-body { padding: 18px; overflow: auto; }
.drawer-body h3 { margin-top: 20px; color: var(--accent); }
.drawer-body h3:first-child { margin-top: 0; }
.drawer-body ul, .drawer-body ol { padding-left: 20px; margin: 6px 0; }
.drawer-body li { margin: 4px 0; font-size: .9rem; }

/* ---------------------------------------------------------------- advanced */
.advanced { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 14px; }
.advanced > summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style: none; }
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "▸ "; color: var(--accent); }
.advanced[open] > summary::before { content: "▾ "; }
.advanced .grid2 { margin-top: 12px; }

/* --------------------------------------------------- segmented control */
/* Used for "3 / 5 / 10 minutes" and for the TTS engine picker. Big targets,
   because on a phone this is the control people actually tap. */
.seg {
  display: flex; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
}
.seg-btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
}
.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}

/* ------------------------------------------------------- picker grids */
/* A 3x3 logo anchor and a 2x2 style picker. Deliberately NOT .seg: .seg turns
   into a column on a phone, and a position picker that reflows to a vertical
   list stops reading as a position picker. These stay grids at every width. */
.pickgrid {
  display: grid; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
}
.pickgrid.cols2 { grid-template-columns: repeat(2, 1fr); }
.pickgrid.cols3 { grid-template-columns: repeat(3, 1fr); }
.pickgrid button {
  min-height: 44px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
}
.pickgrid.cols3 button { font-size: 1.1rem; font-weight: 700; }
.pickgrid button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}

/* One letterbox band's own controls, boxed so "above" and "below" read as two
   things rather than as one list of seven sliders. */
.bandrow {
  display: grid; gap: 8px;
  margin-bottom: 8px; padding: 9px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.bandrow .pickgrid { grid-template-columns: repeat(2, 1fr); }
.bandrow input[type=range] { flex: 1 1 120px; min-width: 0; }
.bandrow .val { min-width: 2.2em; text-align: right; }

/* A colour swatch: the colour IS the button, so the value is never a label the
   user has to translate. Used both for a band's current colour and for the saved
   palette, which is why the size is the difference between them. */
.sw {
  width: 44px; height: 44px; min-height: 44px;
  padding: 0; border-radius: 9px;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .06);
}
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.palette .sw { width: 36px; height: 36px; min-height: 36px; }
.palette .sw.active { outline: 2px solid var(--accent); outline-offset: 2px; }
#logo-file {
  flex: 1 1 190px; min-width: 0;
  color: var(--muted);
  font-size: .86rem;
}
#logo-file::file-selector-button {
  font: inherit; font-weight: 600; font-size: .86rem;
  margin-right: 10px; padding: 9px 14px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
#logo-status { margin: 8px 0 10px; word-break: break-word; }

/* The voice studio's two clip pickers, styled like the logo picker — a native
   "Choose File" button next to this app's own controls reads as a different
   product, and these two are the most consequential inputs on the panel. */
#voice-clone-source, #voice-clone-consent {
  width: 100%;
  color: var(--muted);
  font-size: .86rem;
}
#voice-clone-source::file-selector-button,
#voice-clone-consent::file-selector-button {
  font: inherit; font-weight: 600; font-size: .86rem;
  margin-right: 10px; padding: 9px 14px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}

/* ------------------------------------------------------------- part list */
.part-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.part-row {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px;
}
.part-idx {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(79, 140, 255, .18); color: var(--accent);
  font-weight: 700; font-size: .85rem;
}
.part-meta { font-size: .9rem; min-width: 0; }
.part-row a.ghost { min-height: 40px; padding: 8px 14px; }

/* --------------------------------------------------------------- misc new */
.row.spread { justify-content: space-between; }
.dropzone.over, .dropzone.dragover { border-color: var(--accent); background: rgba(79, 140, 255, .07); }
#voice-text { font-family: inherit; font-size: .95rem; }
#voice-audio { width: 100%; margin: 6px 0 4px; }
/* The voice-design prompt is natural language, not code — the shared `textarea`
   rule makes every textarea monospace, which is right for a script and wrong for
   a sentence describing a voice. */
textarea.plain { font-family: inherit; font-size: .92rem; }
#voice-preview-audio { width: 100%; margin: 6px 0 4px; }
#voice-studio { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 14px; }
#voice-custom-id, #voice-design-name, #voice-design-lang, #voice-style { font-family: inherit; }
label.check.wrap { align-items: flex-start; margin: 4px 0 14px; }
label.check.wrap input { margin-top: 3px; }
.check code, .tips code { font-size: .82rem; }
.warn-box {
  background: rgba(255, 176, 32, .12);
  border: 1px solid rgba(255, 176, 32, .4);
  color: #ffd591;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .88rem;
  margin-bottom: 14px;
}
.warn-box strong { color: #ffe6b3; }
#split-dz-loaded .file-meta { margin-top: 0; }
#voice-gemini-opts .grid2 { gap: 0 22px; }

/* -------------------------------------------------------------- mobile */
/* A phone is the primary target: 16px inputs so iOS does not zoom on focus,
   44px minimum tap targets, and a little more breathing room at the bottom for
   the home indicator. */
@media (max-width: 640px) {
  html, body { font-size: 16px; }
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
  }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .tagline { display: none; }
  .topbar-actions .ghost { padding: 10px 12px; font-size: .88rem; }
  main { padding: 14px 12px 32px; gap: 14px; }
  .card { padding: 15px; border-radius: 12px; }
  .step-head { gap: 10px; margin-bottom: 14px; }
  .step-head p { font-size: .87rem; }
  input[type="text"], input[type="password"], input[type="email"],
  textarea, select { font-size: 16px; padding: 12px; }
  textarea { font-size: 15px; }
  .primary.big { padding: 17px; font-size: 1.05rem; }
  .tab { font-size: .88rem; padding: 10px 12px; }
  .seg { flex-direction: column; }
  .seg-btn { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .row > select, .row > input { flex: 1 1 100%; }
  .log { max-height: 170px; font-size: .74rem; }
  .tips { padding: 11px 13px; font-size: .86rem; }
  .part-row { grid-template-columns: 30px 1fr auto; padding: 9px; }
  .actions .primary, .actions .ghost { flex: 1 1 100%; }
  .drawer { width: 100vw; }
  .blur-label { font-size: .68rem; }
}

