:root {
  --bg: #120f17; --panel: #1c1824; --panel2: #241f2e; --text: #f1edf6; --muted: #a39cb0;
  --border: #322b3e; --accent: #fbbf24; --accent-text: #1a1305; --accent2: #f97316;
  --danger: #f87171; --ok: #4ade80; --info: #60a5fa; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; margin: 0; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 13px; }
.user { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 53px); }
aside { border-right: 1px solid var(--border); padding: 16px; background: var(--panel); }
aside h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin: 18px 0 8px; }
.proj-list { display: flex; flex-direction: column; gap: 4px; }
.proj-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.proj-item:hover { background: var(--panel2); }
.proj-item.active { border-color: var(--accent); background: var(--panel2); }
.proj-item .n { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-item .m { font-size: 12px; color: var(--muted); }
main { padding: 20px; max-width: 1500px; width: 100%; min-width: 0; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--border); }
  .proj-list { flex-direction: row; overflow-x: auto; }
  .proj-item { min-width: 170px; }
  .brand small, #who { display: none; }
  main { padding: 12px; }
}
.section { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; }
.section > h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 4px;
  color: var(--accent); }
.section > .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
input:not([type]), input[type=text], input[type=url], input[type=number], input[type=password], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; }
textarea { resize: vertical; min-height: 70px; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); padding: 7px 14px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
button.big { width: 100%; padding: 13px; font-size: 16px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.msg { margin-top: 10px; font-size: 14px; }
.msg.err { color: var(--danger); }
.banner { background: #3b2a06; color: #fcd34d; border: 1px solid #6b4d0c; padding: 10px 14px;
  border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }
/* upload */
.drop { border: 2px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 120px; }
.drop.over { border-color: var(--accent); }
.drop video { max-height: 320px; max-width: 100%; border-radius: 8px; }
/* product rows */
.prod-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: var(--panel2); }
.prod-row .thumb { width: 96px; height: 96px; border-radius: 8px; border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px;
  color: var(--muted); cursor: pointer; overflow: hidden; background: var(--bg); }
.prod-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-row .fields { display: grid; gap: 6px; }
.prod-row .fields input, .prod-row .fields textarea { padding: 7px 10px; font-size: 14px; }
.prod-row .fields textarea { min-height: 44px; }
@media (max-width: 600px) { .prod-row { grid-template-columns: 72px 1fr; } .prod-row .thumb { width: 72px; height: 72px; }
  .prod-row .del { grid-column: 1 / -1; } }
/* project view */
.ref-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.ref-wrap video { width: 100%; border-radius: 10px; background: #000; max-height: 390px; }
@media (max-width: 700px) { .ref-wrap { grid-template-columns: 1fr; } .ref-wrap video { max-width: 240px; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-top: 10px; }
.timeline { font-size: 13px; margin-top: 8px; display: grid; gap: 6px; }
.timeline div { padding: 6px 10px; border-left: 3px solid var(--accent2); background: var(--panel2); border-radius: 0 6px 6px 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #1f5133; }
.badge.err { color: var(--danger); border-color: #5c2626; }
.badge.run { color: var(--info); border-color: #1e3a5f; }
.badge.ready { color: var(--accent); border-color: #6b4d0c; }
.product { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); margin-bottom: 16px; overflow: hidden; }
.product .head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.product .head img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.product .head .t { flex: 1; min-width: 0; }
.product .head .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product .body { padding: 14px 16px; }
.final { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-bottom: 14px; }
.final video { width: 100%; border-radius: 10px; background: #000; }
@media (max-width: 700px) { .final { grid-template-columns: 1fr; } }
.scenes { display: grid; gap: 10px; }
.scene { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px; background: var(--panel2);
  border-radius: 10px; border: 1px solid var(--border); }
.scene .media { width: 90px; aspect-ratio: 9/16; border-radius: 6px; background: var(--bg); overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); text-align: center; }
.scene .media img, .scene .media video { width: 100%; height: 100%; object-fit: cover; }
.scene .top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.scene .top b { color: var(--text); }
.scene textarea { min-height: 52px; font-size: 14px; }
.scene .en { font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.chip.done { color: var(--ok); border-color: #1f5133; }
.chip.busy { color: var(--info); border-color: #1e3a5f; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .9s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-wrap .section { width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-logo img { width: 56px; height: 56px; border-radius: 14px; }
.login-logo small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.ios-hint { background: var(--accent); color: var(--accent-text); padding: 10px 16px; font-size: 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.ios-hint[hidden] { display: none; }
.ios-hint button { background: transparent; border: 0; color: inherit; }
.who { color: var(--muted); text-decoration: none; }
.who:hover { color: var(--text); }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a { color: var(--text); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.side-links a:hover, .side-links a.active { background: var(--panel2); }
@media (max-width: 860px) { .side-links { flex-direction: row; flex-wrap: wrap; } }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.users td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users td .row { justify-content: flex-end; }
.users button { padding: 4px 10px; font-size: 13px; }
@media (max-width: 700px) {
  .users thead { display: none; }
  .users tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .users td { display: block; border: 0; padding: 3px 0; }
  .users td .row { justify-content: flex-start; }
}
.form-narrow { max-width: 420px; }
.usage-box { margin-top: 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; color: var(--muted); }
.usage-box b { color: var(--text); font-size: 18px; }
/* ảnh sản phẩm khi tạo dự án */
.prod-row { grid-template-columns: 220px 1fr auto; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 2px; right: 2px; padding: 0 6px; font-size: 11px; background: rgba(0,0,0,.65); border: 0; color: #fff; }
.photos .ph.add { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted);
  border-style: dashed; cursor: pointer; font-size: 20px; line-height: 1.1; }
.photos .ph.add small { font-size: 11px; }
@media (max-width: 600px) { .prod-row { grid-template-columns: 1fr; } .photos { grid-template-columns: repeat(4, 1fr); } }
/* bộ ảnh của sản phẩm */
.gal-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
@media (max-width: 600px) { .gallery { grid-template-columns: repeat(3, 1fr); gap: 6px; } .gi .cap { display: none; } }
.gi { position: relative; aspect-ratio: 9/16; border-radius: 10px; overflow: hidden; background: var(--bg);
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 12px; color: var(--muted); }
.gi img { width: 100%; height: 100%; object-fit: cover; }
.gi.pickable { cursor: pointer; }
.gi.pickable:hover { border-color: var(--muted); }
.gi.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.gi .num { position: absolute; top: 6px; left: 6px; background: var(--accent); color: var(--accent-text); width: 26px; height: 26px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.gi .tag { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.gi .zoom { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; text-decoration: none;
  width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.gi .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 34px 6px 6px; font-size: 11px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 6px; }
.strip img { height: 110px; aspect-ratio: 9/16; object-fit: cover; border-radius: 6px; }
.noimg { width: 52px; height: 52px; border-radius: 8px; background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: var(--muted); text-align: center; }
[hidden] { display: none !important; }

/* ===================== bàn làm việc 4 bước ===================== */
.quick-btn { display: block; text-align: center; margin-top: 8px; padding: 10px; border: 1px dashed var(--accent);
  border-radius: 8px; color: var(--accent); text-decoration: none; font-weight: 600; }
.proj-item .bar, .statusbar .bar, .brow .bar { height: 4px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s; }
.ws { display: grid; grid-template-columns: 400px 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .ws { grid-template-columns: 1fr; } }
.ws-left { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }
@media (max-width: 1100px) { .ws-left { position: static; max-height: none; } }
.ws-right { min-width: 0; }
.title-in { font-size: 17px; font-weight: 700; }
.block { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.ws-right > .block:first-child, .section > .block:first-child, #settingsBox > .block:first-child { }
.block h4 { margin: 0 0 4px; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.ws-right .block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 label { margin-top: 8px; }
label.chk { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 8px 0 0; }
label.chk input { width: auto; }
.seg.locked { opacity: .55; pointer-events: none; }
.seg { margin-bottom: 2px; }
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.asset { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; color: var(--muted); padding: 0; }
.asset img { width: 100%; height: 100%; object-fit: cover; }
.asset.add { border-style: dashed; cursor: pointer; line-height: 1.1; }
.asset.add small { font-size: 10px; }
.asset .no { position: absolute; top: 3px; left: 3px; background: var(--accent); color: var(--accent-text); font-size: 10px;
  width: 17px; height: 17px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.asset .nm { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; color: #fff; background: rgba(0,0,0,.6); text-align: center; }
.asset > button { position: absolute; top: 2px; right: 2px; padding: 0 5px; font-size: 10px; background: rgba(0,0,0,.65); border: 0; color: #fff; }
.refv { max-height: 160px; max-width: 100%; border-radius: 8px; background: #000; }
.steps { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px;
  position: sticky; bottom: -14px; background: var(--panel); padding-bottom: 10px; }
.step { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 12px; }
.step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.step small { margin-left: auto; color: var(--muted); }
.step.ok { border-color: #1f5133; }
.step.ok i { background: var(--ok); color: #062; }
.statusbar { position: sticky; top: 60px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.statusbar .bar { flex-basis: 100%; }
.statusbar.failed { border-color: #5c2626; color: var(--danger); }
.statusbar.running, .statusbar.queued { border-color: #1e3a5f; }
.pct { font-weight: 700; color: var(--accent); }
.scenes2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin-bottom: 14px; }
.scard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-width: 0; }
.shead { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shead b { background: var(--accent); color: var(--accent-text); border-radius: 50%; width: 22px; height: 22px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 12px; flex: none; }
.smedia { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cell { position: relative; aspect-ratio: 9/16; background: var(--bg); border-radius: 8px; overflow: hidden; display: flex;
  align-items: center; justify-content: center; border: 1px solid var(--border); }
.cell img, .cell video { width: 100%; height: 100%; object-fit: cover; }
.cell .lab { position: absolute; top: 4px; left: 4px; z-index: 1; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.cell .ph { color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }
.row.sm { margin-top: 8px; gap: 6px; }
.row.sm button, .row.sm select { padding: 4px 8px; font-size: 12px; width: auto; }
.scard label { margin: 8px 0 4px; font-size: 12px; }
.scard textarea { min-height: 0; font-size: 14px; }
.final2 { display: grid; grid-template-columns: 240px 1fr; gap: 14px; margin-top: 14px; }
.final2 video { width: 100%; border-radius: 10px; background: #000; }
.final2 .col { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
@media (max-width: 600px) { .final2 { grid-template-columns: 1fr; } .scenes2 { grid-template-columns: 1fr; } }
.brow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.brow:last-child { border-bottom: 0; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.char { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.char img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.char.pick { cursor: pointer; font-weight: 400; margin: 0; }
.char.pick input { width: auto; }
.char.pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#cPhoto { width: 96px; flex: none; }
