/* ============ Tokens ============ */
:root {
  --bg: #0c0d0f;
  --surface: #141619;
  --surface-2: #1b1e22;
  --surface-3: #23272c;
  --line: #262a30;
  --line-2: #353a42;
  --text: #f1f1ec;
  --muted: #a0a5ad;
  --dim: #80858e;
  --accent: #c8f031;
  --accent-hover: #d6f75e;
  --on-accent: #0c0d0f;
  --danger: #ff7a6b;
  --ok: #c8f031;

  --r-lg: 18px;
  --r: 12px;
  --r-sm: 10px;
  --pill: 999px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 140ms;
  --t: 220ms;

  --top-h: 64px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--on-accent); }
[hidden] { display: none !important; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), color var(--t-fast), transform 80ms, opacity var(--t-fast);
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border: 1px solid var(--line-2); color: var(--text); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: #4a505a; }
.btn-icon { width: 44px; padding: 0; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.btn-sm.btn-icon { width: 36px; }
.spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.is-busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  background: rgba(12, 13, 15, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1240px; height: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.brand-mark .ic { width: 17px; height: 17px; stroke-width: 2.6; }
.nav-btn { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); color: var(--muted); font-size: 14px; font-weight: 500; }
.nav-btn:hover { color: var(--text); background: var(--surface-2); }

/* ============ Layout ============ */
.shell {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start;
}
.side {
  position: sticky; top: calc(var(--top-h) + 24px); margin-top: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; max-height: calc(100dvh - var(--top-h) - 48px); display: flex; flex-direction: column;
}

/* ============ Hero + composer ============ */
.hero { padding: 48px 0 24px; }
h1 { font-size: clamp(34px, 5.4vw, 58px); line-height: 1.04; letter-spacing: -.035em; font-weight: 800; text-wrap: balance; }
.hl { color: var(--accent); }
.sub { margin-top: 14px; color: var(--muted); font-size: 16.5px; max-width: 520px; }

.composer {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(200, 240, 49, .12); }
.composer textarea {
  display: block; width: 100%; min-height: 96px; max-height: 300px; resize: vertical;
  padding: 18px 18px 10px; background: transparent; border: 0; outline: 0; font-size: 16px;
}
.composer textarea::placeholder { color: var(--dim); }
.chips { list-style: none; margin: 0; padding: 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 4px 3px 4px; border-radius: var(--pill); background: var(--surface-3); font-size: 12.5px; color: var(--muted);
  animation: pop var(--t) var(--ease);
}
.chip .pf { width: 22px; height: 22px; font-size: 9.5px; }
.chip .u { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--dim); }
.chip button:hover { background: var(--line-2); color: var(--text); }
.chip button .ic { width: 13px; height: 13px; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 10px; }
.kbd-hint { margin-left: auto; font-size: 12px; color: var(--dim); }
.composer-bar .btn-primary { min-width: 132px; }
@keyframes pop { from { opacity: 0; transform: scale(.9); } }

.platforms { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.platforms li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.platforms .more { color: var(--dim); }

/* Huy hiệu nền tảng (monogram) */
.pf {
  width: 26px; height: 26px; flex: none; border-radius: 8px; display: inline-grid; place-items: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-2);
}
.pf[data-pf="tiktok"], .pf[data-pf="douyin"] { background: #f1f1ec; color: #0c0d0f; border-color: transparent; }

/* ============ Results ============ */
.results { margin-top: 40px; scroll-margin-top: calc(var(--top-h) + 16px); }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }

.card {
  display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 18px;
  padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
  animation: rise 320ms var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms);
  transition: border-color var(--t);
}
.card:hover { border-color: var(--line-2); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.thumb {
  position: relative; width: 132px; aspect-ratio: 3 / 4; border-radius: var(--r); overflow: hidden;
  background: var(--surface-3); display: block; align-self: start;
}
.thumb.wide { aspect-ratio: 16 / 10; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 400ms var(--ease), opacity var(--t); opacity: 0; }
.thumb img.ready { opacity: 1; }
.thumb:hover img { transform: scale(1.04); }
.play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(12, 13, 15, .72); backdrop-filter: blur(4px); color: #fff; display: grid; place-items: center;
  opacity: 0; transform: scale(.85); transition: opacity var(--t), transform var(--t) var(--ease);
}
.play .ic { width: 16px; height: 16px; margin-left: 2px; }
.card.is-ready .thumb:hover .play, .card.is-ready .thumb:focus-visible .play { opacity: 1; transform: none; }
.dur, .kind {
  position: absolute; bottom: 6px; padding: 2px 6px; border-radius: 6px; font-size: 11px;
  background: rgba(12, 13, 15, .8); color: #fff;
}
.dur { right: 6px; }
.kind { left: 6px; font-weight: 600; }
.dur:empty, .kind:empty { display: none; }

.body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.meta { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.title { font-size: 15.5px; font-weight: 600; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.err { display: flex; gap: 8px; align-items: flex-start; color: var(--danger); font-size: 13.5px; font-weight: 500; }
.err .ic { width: 16px; height: 16px; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.btn-dl { min-width: 0; }
.btn-dl .lbl { overflow: hidden; text-overflow: ellipsis; }
.btn-more .ic { transition: transform var(--t) var(--ease); }
.btn-more[aria-expanded="true"] .ic { transform: rotate(180deg); }
.card.is-done .btn-dl { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* Skeleton */
.card.is-loading .thumb { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.card.is-loading .title { color: var(--dim); font-weight: 500; font-size: 13.5px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.card.is-error .thumb { background: var(--surface-2); }

/* Danh sách định dạng */
.fmt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fmt-list.more { padding-top: 4px; animation: rise 220ms var(--ease); }
.fmt {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; text-align: left;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.fmt:hover { border-color: var(--accent); background: var(--surface-3); }
.fmt .ic { color: var(--muted); }
.fmt b { display: block; font-size: 13.5px; font-weight: 600; }
.fmt small { display: block; font-size: 11.5px; color: var(--dim); }
.fmt.is-done .ic { color: var(--accent); }

/* Thanh tiến trình */
.progress { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 200ms linear; }
.progress.indeterminate i { width: 35%; animation: indet 1.1s var(--ease) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ============ Steps + footer ============ */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line); }
.step p { margin-top: 12px; color: var(--muted); font-size: 14.5px; }
.step b { color: var(--text); font-weight: 600; }
.num { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--line-2); font-weight: 700; font-size: 13px; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 48px; padding: 24px 0 40px; border-top: 1px solid var(--line); }
.foot-left { display: grid; gap: 4px; }
.copy { font-size: 14px; font-weight: 600; }
.zalo {
  display: inline-flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 16px 6px 8px;
  border-radius: var(--pill); border: 1px solid var(--line-2); text-decoration: none; transition: border-color var(--t-fast), background var(--t-fast);
}
.zalo > .ic { width: 34px; height: 34px; padding: 8px; border-radius: 50%; background: #0068ff; color: #fff; }
.zalo span { display: grid; line-height: 1.25; font-weight: 700; font-size: 15px; }
.zalo small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.zalo:hover { border-color: #0068ff; background: rgba(0, 104, 255, .08); }
.zalo-sm { width: 100%; justify-content: center; padding: 6px 16px; }
.zalo-sm > .ic { width: 28px; height: 28px; padding: 6px; }
.zalo-sm span { font-size: 14px; font-weight: 600; }

/* ============ Sidebar history ============ */
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.side-head h2 { font-size: 16px; }
.history { list-style: none; padding: 0; margin: 0 -6px; overflow-y: auto; display: grid; gap: 2px; overscroll-behavior: contain; }
.h-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 6px; border-radius: var(--r-sm); }
.h-item:hover { background: var(--surface-2); }
.h-thumb { width: 44px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; }
.h-main { min-width: 0; }
.h-title { font-size: 13.5px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.h-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.h-acts { display: flex; gap: 2px; opacity: .6; transition: opacity var(--t-fast); }
.h-item:hover .h-acts, .h-item:focus-within .h-acts { opacity: 1; }
.h-acts button { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.h-acts button:hover { background: var(--surface-3); color: var(--text); }
.h-acts .ic { width: 16px; height: 16px; }
.empty { text-align: center; color: var(--dim); padding: 36px 12px; font-size: 13.5px; }
.empty .ic { width: 28px; height: 28px; margin-bottom: 10px; }

/* ============ Dock (hàng chờ) ============ */
.dock {
  position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 340px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5); overflow: hidden; animation: rise 260ms var(--ease);
}
.dock-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 16px; font-weight: 600; font-size: 14px; }
.dock-head .chev { margin-left: auto; transition: transform var(--t) var(--ease); }
.dock-head[aria-expanded="false"] .chev { transform: rotate(180deg); }
.dock-list { list-style: none; margin: 0; padding: 0 12px 12px; display: grid; gap: 10px; max-height: 280px; overflow-y: auto; }
.dock-head[aria-expanded="false"] + .dock-list { display: none; }
.q-item { display: grid; gap: 6px; padding: 10px; border-radius: var(--r-sm); background: var(--surface); }
.q-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.q-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.q-row .s { color: var(--muted); font-size: 12px; }
.q-item.is-done .s { color: var(--accent); }
.q-item.is-error .s { color: var(--danger); }

/* ============ Modals ============ */
.modal {
  padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  max-width: min(980px, calc(100vw - 40px)); width: 100%; max-height: calc(100dvh - 40px);
}
.modal::backdrop { background: rgba(5, 6, 7, .72); backdrop-filter: blur(6px); }
.modal[open] { animation: modal-in 240ms var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.pv { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); max-height: calc(100dvh - 42px); }
.pv-stage { background: #000; display: grid; place-items: center; min-height: 420px; max-height: calc(100dvh - 42px); position: relative; overflow: hidden; }
.pv-stage video, .pv-stage img { width: 100%; height: 100%; max-height: calc(100dvh - 42px); object-fit: contain; display: block; }
.pv-stage iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
.pv-stage audio { width: 85%; }
.pv-cover { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.pv-cover img { filter: brightness(.45); }
.pv-cover p { position: absolute; padding: 0 24px; text-align: center; color: var(--text); font-size: 14px; }
.gallery { display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; }
.gallery img { flex: 0 0 100%; scroll-snap-align: center; }
.gallery-count { position: absolute; top: 12px; right: 12px; background: rgba(12, 13, 15, .75); padding: 3px 9px; border-radius: var(--pill); font-size: 12px; }
.pv-side { padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.pv-top { display: flex; align-items: center; gap: 10px; }
.pv-top .close { margin-left: auto; }
.pv-title { font-size: 17px; line-height: 1.4; font-weight: 700; overflow-wrap: anywhere; }
.pv-caption-wrap { max-height: 140px; overflow-y: auto; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.pv-caption { font-size: 13.5px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.pv-caption:empty::before { content: "Không có caption"; color: var(--dim); }
.pv-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.label { font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.pv .fmt-list { grid-template-columns: 1fr 1fr; }

/* Settings sheet */
.modal-sheet { max-width: 480px; }
.sheet { padding: 20px; display: grid; gap: 22px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { font-size: 19px; }
.field { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.field legend { font-weight: 700; font-size: 14.5px; padding: 0; margin-bottom: 2px; }
.hint { font-size: 13px; color: var(--dim); margin-top: -6px; }
.seg { display: grid; gap: 8px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: grid; gap: 2px; padding: 12px 14px 12px 44px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface-2); transition: border-color var(--t-fast), background var(--t-fast); position: relative; }
.seg span::before { content: ""; position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; border: 2px solid var(--line-2); transition: border var(--t-fast); }
.seg b { display: flex; align-items: center; gap: 6px; font-size: 14.5px; }
.seg b .ic { width: 16px; height: 16px; }
.seg small { font-size: 12.5px; color: var(--dim); }
.seg input:checked + span { border-color: var(--accent); background: rgba(200, 240, 49, .06); }
.seg input:checked + span::before { border: 6px solid var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg .is-disabled { cursor: not-allowed; opacity: .55; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row span { display: grid; gap: 2px; }
.switch-row b { font-size: 14.5px; }
.switch-row small { font-size: 12.5px; color: var(--dim); }
.switch { appearance: none; width: 46px; height: 28px; flex: none; border-radius: var(--pill); background: var(--line-2); position: relative; cursor: pointer; transition: background var(--t-fast); margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text); transition: transform var(--t) var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--on-accent); }
.sheet-foot { border-top: 1px solid var(--line); padding-top: 18px; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--pill); background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); animation: toast-in 260ms var(--ease); }
.toast .ic { width: 16px; height: 16px; }
.toast.is-error { background: var(--danger); color: #1a0a08; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 200ms var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* Tab bar (mobile) */
.tabbar { display: none; }

/* ============ Responsive ============ */
@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(20, 22, 25, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tab { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; color: var(--dim); font-size: 11.5px; font-weight: 600; }
  .tab .ic { width: 22px; height: 22px; }
  .tab.is-active { color: var(--accent); }
  .badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--pill); background: var(--accent); color: var(--on-accent); font-size: 10.5px; display: grid; place-items: center; }
  .topnav { display: none; }
  body { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  .view { display: none; }
  .view.is-active { display: block; }
  .side.is-active { display: flex; position: static; margin: 20px 0; max-height: none; border: 0; background: transparent; padding: 0; }
  .side.is-active .history { margin: 0; }
  .dock { left: 12px; right: 12px; width: auto; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }
  .toasts { bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
}

@media (max-width: 640px) {
  .topbar-in, .shell { padding: 0 16px; }
  .hero { padding: 28px 0 18px; }
  .sub { font-size: 15px; }
  .kbd-hint { display: none; }
  .composer-bar .btn-primary { margin-left: auto; }
  .platforms { gap: 8px 14px; }
  .platforms li:nth-child(n+5):not(.more) { display: none; }
  .card { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .thumb { width: 92px; }
  .play { opacity: 1; transform: none; width: 36px; height: 36px; }
  .actions .btn-pv span { display: none; }
  .actions .btn-pv { width: 44px; padding: 0; }
  .actions .btn-dl { flex: 1; }
  .fmt-list { grid-template-columns: 1fr 1fr; }
  .results-head { align-items: center; }
  .steps { grid-template-columns: 1fr; gap: 16px; margin-top: 40px; }
  .step { display: flex; gap: 12px; align-items: center; }
  .step p { margin: 0; }
  .num { flex: none; }
  .foot { flex-direction: column; align-items: stretch; }
  .zalo { justify-content: center; }

  /* Modal thành bottom sheet toàn màn hình */
  .modal { max-width: 100vw; width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .modal[open] { animation: sheet-in 300ms var(--ease); }
  .modal-sheet { height: auto; max-height: 92dvh; margin-top: auto; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .sheet { padding-bottom: calc(20px + var(--safe-b)); }
  .pv { grid-template-columns: 1fr; grid-template-rows: minmax(0, 58dvh) minmax(0, 1fr); height: 100dvh; max-height: 100dvh; }
  .pv-stage { min-height: 0; max-height: 58dvh; }
  .pv-stage video, .pv-stage img { max-height: 58dvh; }
  .pv-side { padding-bottom: calc(18px + var(--safe-b)); }
  .pv-top .close { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2; background: rgba(12, 13, 15, .7); border-color: transparent; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

@media (hover: none) {
  .h-acts { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Logo nền tảng */
.pf svg { width: 58%; height: 58%; display: block; }
.pf .ic { width: 55%; height: 55%; }
.chip .pf { border-radius: 50%; }

/* ============ Chọn + tải hàng loạt ============ */
.card, .tile { position: relative; }
.pick { position: absolute; z-index: 3; top: 8px; left: 8px; width: 44px; height: 44px; display: grid; place-items: start; cursor: pointer; }
.card .pick { top: 14px; left: 14px; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick span {
  width: 24px; height: 24px; margin: 6px; border-radius: 7px; border: 2px solid rgba(255,255,255,.85);
  background: rgba(12,13,15,.55); backdrop-filter: blur(4px); display: grid; place-items: center;
  transition: background var(--t-fast), border-color var(--t-fast), transform 80ms;
}
.pick span::after { content: ""; width: 10px; height: 6px; border: 2.5px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.pick input:checked + span { background: var(--accent); border-color: var(--accent); }
.pick input:checked + span::after { opacity: 1; }
.pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick input:disabled + span { opacity: 0; }
.pick:active span { transform: scale(.9); }
.card.is-selected, .tile.is-selected { border-color: var(--accent); }

.batchbar {
  position: sticky; top: calc(var(--top-h) + 8px); z-index: 10;
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; padding: 10px 10px 10px 14px;
  background: rgba(20, 22, 25, .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
}
.batchbar .btn-primary { margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14px; font-weight: 600; }
.check input { appearance: none; width: 22px; height: 22px; margin: 0; border-radius: 7px; border: 2px solid var(--line-2); display: grid; place-items: center; cursor: pointer; transition: all var(--t-fast); }
.check input::after { content: ""; width: 9px; height: 5px; border: 2.5px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked, .check input:indeterminate { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { opacity: 1; }
.check input:indeterminate::after { opacity: 1; width: 10px; height: 0; border-left: 0; transform: none; }
.link-btn { min-height: 44px; padding: 0 4px; font-size: 13.5px; font-weight: 600; color: var(--accent); }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.bmode { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--surface-3); }
.bmode label { cursor: pointer; }
.bmode input { position: absolute; opacity: 0; }
.bmode span { display: grid; place-items: center; min-width: 56px; min-height: 38px; padding: 0 12px; border-radius: 8px; font-size: 13.5px; font-weight: 700; color: var(--muted); transition: background var(--t-fast), color var(--t-fast); }
.bmode input:checked + span { background: var(--text); color: var(--bg); }
.bmode input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ============ Kênh ============ */
.channel { margin-top: 40px; }
.ch-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ch-text { min-width: 0; }
.pf-lg { width: 44px; height: 44px; border-radius: 12px; }
.ch-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sel { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
select {
  appearance: none; min-height: 40px; padding: 0 34px 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a5ad' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.ch-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); animation: rise 260ms var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); transition: border-color var(--t-fast); }
.tile:hover { border-color: var(--line-2); }
.tile .thumb { width: 100%; aspect-ratio: 3 / 4; }
.ch-grid.wide .thumb { aspect-ratio: 16 / 9; }
.tile .thumb img { opacity: 1; }
.tile .play { opacity: 0; }
.tile .thumb:hover .play { opacity: 1; transform: none; }
.tile .kind { left: auto; right: 6px; top: 6px; bottom: auto; font-weight: 500; }
.t-title { font-size: 13.5px; font-weight: 600; line-height: 1.4; min-height: 2.8em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.t-acts { display: flex; gap: 6px; margin-top: auto; }
.t-acts .t-dl { flex: 1; }
.tile.is-done .t-dl { color: var(--accent); border-color: var(--accent); }
.tile.is-busy .thumb::after { content: ""; position: absolute; inset: 0; background: rgba(12,13,15,.45); }

.pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 22px; }
.pager button { min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; color: var(--muted); }
.pager button:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.pager button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.pager .gap { color: var(--dim); padding: 0 4px; }
.pager .jump { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; font-size: 13px; color: var(--muted); }
.pager .jump input { width: 64px; min-height: 44px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); text-align: center; font-weight: 600; }

@media (max-width: 640px) {
  .batchbar { top: calc(var(--top-h) + 4px); padding: 8px; gap: 6px 10px; }
  .batchbar .btn-primary { width: 100%; }
  .bmode span { min-width: 48px; padding: 0 8px; }
  .ch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .pick { top: 8px; left: 8px; }
  .pager .jump { width: 100%; justify-content: center; margin: 8px 0 0; }
}
.thumb.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; display: block; flex: none; }
.topnav { display: flex; gap: 4px; }
.nav-btn { text-decoration: none; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 4px 0; }
.foot-links a { color: var(--muted); font-size: 13.5px; text-decoration: none; }
.foot-links a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.step a { color: var(--accent); }

/* ============ Google Drive ============ */
.drive-panel { display: grid; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line-2); animation: rise 220ms var(--ease); }
.drive-panel .hint { margin-top: 8px; }
.btn-google { width: 100%; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; }
.btn-google:hover:not(:disabled) { background: #f3f4f6; }
.drive-acc, .drive-folder { display: flex; align-items: center; gap: 12px; }
.drive-acc img { width: 36px; height: 36px; border-radius: 50%; flex: none; background: var(--surface-3); }
.drive-folder > .ic { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--surface-3); color: var(--accent); }
.drive-acc-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.drive-acc-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-acc-text small { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#drive-signed-in { display: grid; gap: 14px; }
#drive-signed-in[hidden] { display: none; }
.dest-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: 220px; padding: 0 12px; border-radius: var(--pill); border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dest-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-pill .ic { width: 15px; height: 15px; }
.dest-pill:hover { color: var(--text); border-color: #4a505a; }
.dest-pill.is-drive { color: var(--accent); border-color: rgba(200, 240, 49, .4); background: rgba(200, 240, 49, .06); }
@media (max-width: 640px) { .dest-pill { max-width: 130px; } }
@media (max-width: 1080px) { .topnav { display: none; } }

/* ============ Nút mở Google Drive ============ */
.btn-drive { color: var(--text); }
.btn-drive .gd { width: 16px; height: 16px; color: #1fa463; }
.btn-drive:hover .gd { color: #34c779; }
.q-open { display: inline-flex; align-items: center; gap: 5px; flex: none; min-height: 30px; padding: 0 10px; border-radius: var(--pill); background: rgba(31, 164, 99, .14); color: #5ad893; font-size: 12px; font-weight: 700; text-decoration: none; }
.q-open:hover { background: rgba(31, 164, 99, .26); }
.q-open .gd { width: 13px; height: 13px; color: inherit; }
.h-drive { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: #1fa463; }
.h-drive:hover { background: var(--surface-3); }
.h-drive .ic { width: 16px; height: 16px; }
.toast.has-action { pointer-events: auto; padding-right: 8px; }
.toast-act { margin-left: 6px; padding: 6px 12px; border-radius: var(--pill); background: var(--bg); color: var(--text); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.toast-act:hover { background: #26292e; }
.t-acts .btn-drive { padding: 0 10px; }
.t-acts .btn-drive span { display: none; }
.skel-tile { animation: none; }
#ch-more.is-busy .spinner { display: inline-block; }

/* Dán link thư mục Drive */
.drive-link { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.drive-link-lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.drive-link-row { display: flex; gap: 8px; }
.drive-link-row input { flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; }
.drive-link-row input:focus { outline: none; border-color: var(--accent); }
.drive-link-row input::placeholder { color: var(--dim); }
#drive-link-msg { margin-top: 0; }