:root {
  --bg: #0f0f12; --card: #17171c; --card2: #1f1f26; --line: #2a2a33;
  --fg: #f2f2f5; --muted: #9a9aa6; --accent: #ff3b5c; --accent2: #ffd400;
  --ok: #3ddc84; --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
body { padding-bottom: calc(76px + var(--safe-b)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: rgba(15,15,18,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; margin-right: 6px; }

main { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.lbl { font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; margin-top: 10px; flex-wrap: wrap; }
input[type=url], input[type=text] { flex: 1; min-width: 0; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 12px 14px; outline: none; }
input:focus { border-color: var(--accent); }

.ghost { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--fg); background: var(--card2); }
.ghost.small { padding: 10px 12px; font-size: 14px; white-space: nowrap; }
.primary { background: var(--accent); color: #fff; border-radius: 14px; padding: 14px 18px; font-weight: 800; }
.primary.big { width: 100%; font-size: 18px; padding: 16px; box-shadow: 0 8px 30px rgba(255,59,92,.35); }
.primary:disabled { opacity: .5; box-shadow: none; }
.danger { color: #ff7a8a; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 0; }

.preview { margin-top: 12px; display: flex; gap: 12px; align-items: center; background: var(--card2); border-radius: 12px; padding: 10px; }
.preview img { width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #000; }
.preview .pt { font-weight: 700; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.preview .pm { color: var(--muted); font-size: 12px; margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #2a2a33; color: var(--muted); margin-right: 6px; }
.badge.ok { background: rgba(61,220,132,.15); color: var(--ok); }
.badge.warn { background: rgba(255,212,0,.15); color: var(--accent2); }

/* template cards (mini mock-ups of each layout) */
.tpls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl { border: 2px solid var(--line); border-radius: 14px; padding: 8px; text-align: left; background: var(--card2); transition: border-color .15s, transform .15s; }
.tpl.on { border-color: var(--accent); transform: translateY(-2px); }
.tpl .ph { position: relative; aspect-ratio: 9/16; border-radius: 10px; overflow: hidden; }
.tpl .ph .vid { position: absolute; left: 0; right: 0; background: linear-gradient(135deg, #5a6d8a, #2a3345); background-size: cover; }
.tpl .ph .bar { position: absolute; left: 0; right: 0; top: 0; }
.tpl .ph .ttl { position: absolute; left: 4px; right: 4px; text-align: center; font-size: 9px; font-weight: 900; line-height: 1.25; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.tpl .ph .ttl.noshadow { text-shadow: none; }
.tpl .ph .cap { position: absolute; left: 4px; right: 4px; text-align: center; font-size: 8px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; }
.tpl .ph .cap.outl { text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 3px #000; }
.tpl .ph .cap span.bx { padding: 1px 4px; border-radius: 2px; display: inline-block; }
.tpl .ph .cap .hl { color: var(--hl, #ffd400); }
.tpl .nm { font-size: 12px; font-weight: 700; margin-top: 8px; line-height: 1.25; }
.tpl .ref { font-size: 10px; color: var(--accent); font-weight: 700; }
.tpl .ds { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* font picker */
.fontpick { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; text-align: left; }
.fontpick img { height: 30px; width: 166px; object-fit: cover; object-position: left; border-radius: 6px; background: #1f1f26; }
.fontpick .fn { font-size: 13px; color: var(--muted); flex: 1; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 82vh; background: var(--card); border-radius: 20px 20px 0 0; z-index: 21; display: flex; flex-direction: column; padding: 14px 14px calc(14px + var(--safe-b)); gap: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; margin-right: 8px; }
.fs-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.fs-item { display: flex; flex-direction: column; gap: 4px; background: var(--card2); border: 2px solid transparent; border-radius: 12px; padding: 8px 10px; text-align: left; }
.fs-item.on { border-color: var(--accent); }
.fs-item img { width: 100%; height: 44px; object-fit: cover; object-position: left; border-radius: 6px; background: #1f1f26; }
.fs-item .fl { font-size: 12px; color: var(--muted); }

/* options */
.opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.opt:first-of-type { border-top: 0; }
.opt small { display: block; color: var(--muted); font-size: 12px; }
.opt.col { flex-direction: column; align-items: stretch; }
.opt.col input { width: 100%; margin-top: 8px; }
.seg { display: flex; background: var(--card2); border-radius: 10px; padding: 3px; gap: 2px; flex-shrink: 0; }
.seg button { padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #2f2f3a; color: var(--fg); font-weight: 700; }
.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #33333f; border-radius: 999px; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

/* job */
.job-head { display: flex; gap: 12px; align-items: center; }
.job-head .thumb { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: #000; }
.job-head .title { font-weight: 700; font-size: 15px; }
.job-head .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.progress { height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ff8a5c); transition: width .5s; }
.bar.done { background: var(--ok); }
.bar.err { background: #c33; }
.msg { color: var(--muted); font-size: 14px; }
.pct { font-weight: 800; font-variant-numeric: tabular-nums; }

.clips { display: flex; flex-direction: column; gap: 14px; }
.clip { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.clip video { width: 100%; aspect-ratio: 9/16; max-height: 70vh; background: #000; display: block; }
.clip .cb { padding: 12px 14px; }
.clip .ct { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.clip .cm { color: var(--muted); font-size: 12px; margin-top: 4px; }
.clip .cc { color: var(--muted); font-size: 12px; margin-top: 8px; max-height: 60px; overflow: hidden; line-height: 1.4; }
.clip .ca { display: flex; gap: 8px; margin-top: 12px; }
.clip .ca a, .clip .ca button { flex: 1; text-align: center; text-decoration: none; }

/* clip editor */
.editor { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 6px; }
.editor select { background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
.cap-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.cap-row .ct-time { color: var(--muted); font-size: 11px; width: 74px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.cap-row input { flex: 1; min-width: 0; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.caps { max-height: 320px; overflow: auto; }
#addClip input { flex: 1; min-width: 0; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 12px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: left; width: 100%; }
.item img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #000; flex-shrink: 0; }
.item .it { font-weight: 700; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .im { color: var(--muted); font-size: 12px; margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(15,15,18,.95); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + var(--safe-b)); backdrop-filter: blur(10px); }
.tab { flex: 1; padding: 12px; border-radius: 12px; color: var(--muted); font-weight: 700; }
.tab.active { color: var(--fg); background: var(--card2); }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: #fff; color: #000; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; z-index: 10; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* login */
.login { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.login input { width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 12px 14px; font: inherit; }
#who { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* narration mode */
.seg.wide { width: 100%; }
.seg.wide button { flex: 1; padding: 10px; font-size: 14px; }
.or { color: var(--muted); font-size: 12px; text-align: center; margin: 12px 0 8px; }
.jtabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.jtabs button { flex: 1; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.jtabs button.on { background: var(--card2); color: var(--fg); }
.nar-video { position: relative; background: #000; border-radius: 12px; overflow: hidden; }
.nar-video video { display: block; width: 100%; max-height: 52vh; object-fit: contain; }
.nar-video .mark { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 3px solid var(--accent2); border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.6); pointer-events: none; }
.nar-video .mark::after { content: ""; position: absolute; inset: 7px; background: var(--accent2); border-radius: 50%; }
.nar-video .arm { position: absolute; left: 10px; right: 10px; top: 10px; text-align: center; background: rgba(255,212,0,.9); color: #000; font-size: 12px; font-weight: 700; padding: 6px; border-radius: 8px; pointer-events: none; }
.nar-video.armed video { cursor: crosshair; }
.scene { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 10px; }
.scene.close { border-color: rgba(255,212,0,.35); }
.scene.hold { border-color: rgba(112,176,255,.45); }
.scene .sc-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.scene .sc-head .row button { padding: 4px 8px; font-size: 12px; }
.scene .tl { display: grid; grid-template-columns: auto 1fr auto auto 1fr auto; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.scene .tl input { width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 7px 8px; font-size: 14px; }
.scene .tl button { padding: 6px 8px; font-size: 12px; }
.scene textarea { width: 100%; margin-top: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 14px; min-height: 58px; resize: vertical; }
.scene .zm { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.scene .zm input { width: 64px; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.scene .zm button { padding: 6px 9px; font-size: 12px; }
.scene .zm button.on { border-color: var(--accent2); color: var(--accent2); }
.scene .cap-prev { font-size: 11px; color: var(--muted); margin-top: 6px; }
.num { width: 86px; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 8px 10px; font: inherit; text-align: right; }
#no-voice { flex: 1; min-width: 0; max-width: 55%; background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
.notes { font-size: 12px; color: var(--accent2); margin-top: 6px; }

.sel { background: var(--card2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
.reacts { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.react { display: grid; grid-template-columns: 56px 56px 1fr 72px 30px; gap: 6px; align-items: center; margin-top: 6px; }
.react input, .react select { width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 8px; padding: 7px 8px; font: inherit; font-size: 13px; }
.react .x { padding: 6px; color: #ff7a8a; }
.react-h { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.react-h .row button { padding: 5px 9px; font-size: 12px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

.quick textarea { width: 100%; margin-top: 8px; background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 14px; min-height: 96px; resize: vertical; }
.quick input[type=text] { background: var(--card2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 10px 12px; }
.quick .sel { width: 100%; }
