/* =========================================================
   Video AI Studio — hệ thiết kế (sáng / tối theo hệ điều hành)
   ========================================================= */
:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --surface-2: #f2f0f5;
  --line: #e7e4ec;
  --ink: #17141c;
  --ink-2: #4a4552;
  --muted: #8a8492;
  --brand-1: #ff4d8d;
  --brand-2: #7c4dff;
  --brand: #e8337a;
  --brand-soft: #ffe8f1;
  --brand-ink: #b0185a;
  --ok: #129a5c;
  --ok-soft: #e3f6ec;
  --warn: #a06a00;
  --warn-soft: #fff4d6;
  --err: #d92d4b;
  --err-soft: #fde8ec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 10, 40, .04), 0 4px 16px rgba(20, 10, 40, .04);
  --shadow-lg: 0 10px 40px rgba(20, 10, 40, .12);
  --grad: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --cta-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d12;
    --surface: #17151d;
    --surface-2: #1f1c27;
    --line: #2a2633;
    --ink: #f3f1f6;
    --ink-2: #c9c4d2;
    --muted: #8d8799;
    --brand: #ff5c97;
    --brand-soft: #3a1a2a;
    --brand-ink: #ff9cc0;
    --ok: #3ed492;
    --ok-soft: #12301f;
    --warn: #ffc84a;
    --warn-soft: #33290d;
    --err: #ff6b84;
    --err-soft: #3a1720;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 4px 18px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
.hidden { display: none !important; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }
h1, h2 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); margin: 0; }
.muted.sm { font-size: 13px; }
.err { color: var(--err); font-size: 14px; margin: 8px 0 0; }
.err:empty { display: none; }
.center { text-align: center; }

/* ---------- Ô nhập ---------- */
input[type=text], input[type=password], select {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 650; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .1s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary {
  border: 0; color: #fff; background: var(--grad);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand-1) 35%, transparent);
}
.btn.primary:disabled { opacity: .55; box-shadow: none; }
.btn.lg { height: 52px; padding: 0 22px; font-size: 16px; }
.btn.block { width: 100%; height: 50px; }
.btn.danger { color: var(--err); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.sm svg { width: 15px; height: 15px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Nhãn ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.accent { background: var(--brand-soft); color: var(--brand-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.neutral { background: var(--surface-2); color: var(--ink-2); }
.pill.dark { background: rgba(0, 0, 0, .6); color: #fff; }

/* ---------- Logo ---------- */
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-1) 40%, transparent); }
.brand-mark svg { width: 16px; height: 16px; margin-left: 2px; }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 18px; }
.brand-mark.lg svg { width: 28px; height: 28px; }
.brand-name { font-weight: 750; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--brand-1) 14%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 36px 24px 28px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; }
.login-card .muted { margin: 6px 0 24px; font-size: 14px; }
.login-card form { display: grid; gap: 12px; }

/* ---------- Khung app ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
main { max-width: 680px; margin: 0 auto; padding: 8px 14px calc(var(--tabbar-h) + var(--cta-h) + 28px + var(--safe-b)); }
body.on-jobs main { padding-bottom: calc(var(--tabbar-h) + 24px + var(--safe-b)); }
.page-head { padding: 14px 4px 18px; }
.page-head .muted { margin-top: 4px; font-size: 14px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.step { width: 30px; height: 30px; border-radius: 10px; flex: 0 0 auto; display: grid; place-items: center; font-weight: 750; font-size: 14px; color: var(--brand-ink); background: var(--brand-soft); }

.field { display: block; margin-top: 16px; }
.card-head + .field { margin-top: 0; }
.field-label { display: block; font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 8px; }
.field-label em { font-style: normal; font-weight: 500; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; gap: 0; } }

/* ---------- Khu tải ảnh ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px 16px; cursor: pointer; text-align: center;
  border: 1.5px dashed color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand-soft) 45%, var(--surface)); transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input { display: none; }
.dz-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; margin-bottom: 8px; }
.dz-title { font-weight: 700; color: var(--ink); }
.dz-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Danh sách ảnh ---------- */
.shot-list { display: grid; gap: 10px; margin-bottom: 12px; }
.shot-list:empty { display: none; }
.shot { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; background: var(--surface-2); }
.shot-thumb { position: relative; width: 64px; aspect-ratio: 9/16; border-radius: 10px; overflow: hidden; background: var(--line); }
.shot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-thumb .num { position: absolute; left: 5px; top: 5px; min-width: 20px; height: 20px; border-radius: 7px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }
.shot-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.shot-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.shot-body select { height: 40px; font-size: 14px; }
.shot-ctrl { display: flex; flex-direction: column; gap: 6px; }
.shot-ctrl .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.shot-ctrl .icon-btn svg { width: 16px; height: 16px; }
.shot-ctrl .del { color: var(--err); }

/* ---------- Gợi ý ---------- */
.tip { margin-top: 12px; border-radius: var(--radius-sm); background: var(--surface-2); padding: 0 14px; font-size: 13.5px; color: var(--ink-2); }
.tip summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 0; font-weight: 650; color: var(--ink); list-style: none; }
.tip summary::-webkit-details-marker { display: none; }
.tip summary svg { width: 18px; height: 18px; color: var(--brand); }
.tip ol { margin: 0 0 6px; padding-left: 20px; }
.tip li { margin: 3px 0; }
.tip p { margin: 6px 0 12px; color: var(--muted); }

/* ---------- Nhóm lựa chọn ---------- */
.seg.chips { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg.chips button { flex: 1; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-weight: 650; font-size: 14px; cursor: pointer; transition: background .15s, color .15s; }
.seg.chips button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.seg.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg.cards button {
  text-align: left; padding: 14px; border-radius: 16px; cursor: pointer; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.seg.cards button.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 10%, transparent); }
.opt-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.opt-title .spark { width: 16px; height: 16px; color: var(--brand-2); }
.opt-desc { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
@media (max-width: 380px) { .seg.cards { grid-template-columns: 1fr; } }

/* ---------- Thanh tạo video ---------- */
.cta-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 25;
  bottom: calc(var(--tabbar-h) + 10px + var(--safe-b)); width: min(652px, calc(100% - 20px));
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
}
body.on-jobs .cta-bar { display: none; }
.cta-est { flex: 1; min-width: 0; }
.cta-price { font-size: 20px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.cta-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Thanh tab ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 8px;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 12px var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  position: relative; isolation: isolate; flex: 1; max-width: 220px; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--brand); }
.tabbar button.on::before { content: ""; position: absolute; top: 5px; left: 50%; width: 52px; height: 30px; margin-left: -26px; border-radius: 10px; background: var(--brand-soft); z-index: -1; }
.badge { position: absolute; top: 2px; left: calc(50% + 10px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--grad); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; }

/* ---------- Danh sách video ---------- */
.jobs { display: grid; gap: 12px; }
.job { display: grid; grid-template-columns: 104px 1fr; gap: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.job-pv { position: relative; width: 104px; aspect-ratio: 9/16; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); border: 0; padding: 0; font: inherit; }
.job-pv img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.job-pv.playable { cursor: pointer; }
.job-pv .play { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.92); color: #111; box-shadow: 0 4px 16px rgba(0,0,0,.3); transition: transform .15s; }
.job-pv.playable:hover .play { transform: scale(1.08); }
.job-pv .play svg { width: 18px; height: 18px; margin-left: 2px; }
.job-pv .dur { position: absolute; right: 6px; bottom: 6px; }
.job-pv.busy img { filter: blur(3px) brightness(.8); transform: scale(1.1); }
.job-pv .spin { position: relative; color: #fff; }
.job-info { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.job-top { display: flex; align-items: flex-start; gap: 8px; }
.job-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-date { font-size: 12px; color: var(--muted); margin-top: -6px; }
.job-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.job-tags .pill { height: 22px; font-size: 11.5px; }
.job-progress { display: grid; gap: 6px; }
.job-step { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.job-step .pct { margin-left: auto; color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .5s ease; }
.job-err, .job-warn { font-size: 12.5px; border-radius: 10px; padding: 8px 10px; word-break: break-word; }
.job-err { color: var(--err); background: var(--err-soft); }
.job-warn { color: var(--warn); background: var(--warn-soft); }
.job-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.empty { text-align: center; padding: 48px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty .dz-icon { margin: 0 auto 14px; }
.empty h2 { color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 18px; }

/* ---------- Xem video ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.viewer video { max-width: 100%; max-height: 100%; border-radius: 16px; }
.viewer .icon-btn { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; background: rgba(255,255,255,.14); color: #fff; border: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 70; bottom: calc(var(--tabbar-h) + var(--cta-h) + 24px + var(--safe-b));
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 90vw;
  animation: rise .2s ease;
}

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
.spin.lg { width: 26px; height: 26px; border-width: 3px; }
@keyframes sp { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (min-width: 900px) {
  main { padding-top: 16px; }
  h1 { font-size: 30px; }
}

/* Tinh chỉnh */
.btn.sm.only { width: 34px; padding: 0; }
.shot .pill.neutral { background: var(--surface); }
@media (prefers-color-scheme: dark) {
  .seg.chips button.on { background: #2c2836; box-shadow: none; }
}

/* ---------- Bảng Đăng TikTok ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(10, 6, 20, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); color: var(--ink);
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); box-shadow: var(--shadow-lg); animation: up .22s ease;
}
@media (min-width: 600px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.sheet-head h2 svg { width: 22px; height: 22px; }
.sheet-video { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; background: var(--surface-2); margin-bottom: 14px; }
.sheet-video img { width: 44px; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; }
.sheet-video .t { font-weight: 700; font-size: 14px; }
.sheet-video .m { font-size: 12.5px; color: var(--muted); }
.cap-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cap-head .field-label { margin: 0; }
textarea.cap {
  width: 100%; min-height: 150px; padding: 12px 14px; resize: vertical; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px; line-height: 1.55; outline: none;
}
textarea.cap:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.cap-count { text-align: right; font-size: 12px; color: var(--muted); margin: 4px 2px 12px; }
.sheet-actions { display: grid; gap: 8px; margin-bottom: 16px; }
.sheet-actions .btn { width: 100%; height: 48px; }
.btn.done { background: var(--ok) !important; box-shadow: none !important; }
.steps { list-style: none; margin: 0; padding: 14px; border-radius: 14px; background: var(--surface-2); display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: 13.5px; color: var(--ink-2); counter-increment: s; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 8px; background: var(--surface); color: var(--brand-ink); font-weight: 750; font-size: 12px; display: grid; place-items: center; }
.steps b { color: var(--ink); }
.steps-title { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: var(--ink-2); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.cat-pick { margin-bottom: 14px; }
.cat-pick button { padding: 14px 16px; }
.cat-pick .opt-title { font-size: 15.5px; }

/* Giọng đọc */
.opt { font-style: normal; font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 4px; }
textarea.cap.script { min-height: 110px; }
.voice-box { display: grid; gap: 0; }
.voice-box.off { opacity: .45; pointer-events: none; }
.voice-row { display: grid; grid-template-columns: 1fr 46px; gap: 8px; }
.voice-row .icon-btn { width: 46px; height: 46px; }
.seg.dim { opacity: .45; pointer-events: none; }

.cat-pick { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .cat-pick { grid-template-columns: 1fr; } }
