/* Nền cam đất nhiều lớp + thẻ kính mờ nổi. Nạp sau app.css nên ghi đè các biến màu. */
:root {
  --bg: #c9764c; --surface: rgba(255, 236, 220, .58); --surface-solid: #fff1e4; --surface-2: rgba(255, 222, 198, .55);
  --text: #2a140b; --muted: #73483a; --border: rgba(255, 255, 255, .55);
  --accent: #b9410f; --accent-2: #e2681f; --accent-soft: rgba(185, 65, 15, .14); --accent-text: #ffffff;
  --green: #17734a; --green-soft: rgba(23, 115, 74, .16); --amber: #8a4b00; --amber-soft: rgba(255, 196, 110, .42);
  --red: #b3261e; --red-soft: rgba(179, 38, 30, .14); --gray-soft: rgba(90, 40, 20, .12);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .65), inset 0 -1px 0 rgba(120, 50, 20, .10), 0 2px 4px rgba(70, 24, 6, .16), 0 22px 44px -14px rgba(70, 24, 6, .50);
  --glass: linear-gradient(155deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0) 42%);
  --glow-1: rgba(255, 206, 150, .60); --glow-2: rgba(255, 128, 86, .42); --glow-3: rgba(112, 40, 18, .46);
  --base-1: #dd9166; --base-2: #9a4c2b; --grid: rgba(70, 24, 6, .12);
}
:root[data-theme="dark"] {
  --bg: #1a0c07; --surface: rgba(62, 32, 21, .56); --surface-solid: #2b160e; --surface-2: rgba(96, 52, 35, .50);
  --text: #fcefe5; --muted: #cfab97; --border: rgba(255, 205, 170, .20);
  --accent: #ff9a5c; --accent-2: #ffc46b; --accent-soft: rgba(255, 154, 92, .16); --accent-text: #2a1206;
  --green: #6fe0a6; --green-soft: rgba(111, 224, 166, .14); --amber: #ffc978; --amber-soft: rgba(255, 201, 120, .15);
  --red: #ff8f85; --red-soft: rgba(255, 130, 120, .15); --gray-soft: rgba(255, 205, 170, .10);
  --shadow: inset 0 1px 0 rgba(255, 225, 200, .16), inset 0 -1px 0 rgba(0, 0, 0, .30), 0 2px 4px rgba(0, 0, 0, .35), 0 24px 48px -14px rgba(0, 0, 0, .65);
  --glass: linear-gradient(155deg, rgba(255, 220, 190, .12), rgba(255, 220, 190, 0) 42%);
  --glow-1: rgba(232, 118, 64, .42); --glow-2: rgba(255, 176, 96, .22); --glow-3: rgba(150, 58, 28, .34);
  --base-1: #4a2313; --base-2: #150a06; --grid: rgba(255, 205, 170, .07);
}
body { background: var(--base-2); }
/* ba lớp: quầng sáng ngả màu, lưới mờ có chiều sâu, tối dần về mép */
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; }
body::before {
  background:
    radial-gradient(1100px 640px at 10% -8%, var(--glow-1), transparent 62%),
    radial-gradient(920px 660px at 94% 4%, var(--glow-2), transparent 60%),
    radial-gradient(1100px 760px at 58% 114%, var(--glow-3), transparent 64%),
    linear-gradient(160deg, var(--base-1), var(--base-2) 72%);
}
body::after {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px, 44px 44px, 176px 176px, 176px 176px;
  filter: blur(.5px);
  -webkit-mask-image: radial-gradient(ellipse 88% 78% at 50% 34%, #000 22%, transparent 80%);
  mask-image: radial-gradient(ellipse 88% 78% at 50% 34%, #000 22%, transparent 80%);
}
#app, #toasts, .overlay { position: relative; z-index: 1; }
.overlay { position: fixed; }
#toasts { position: fixed; }
.login { background: transparent; }
.side, .card, .table-wrap, .job, .step, .proj, .login-card, .thread-head, .composer-box, .chain .node {
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
}
.card, .table-wrap, .job, .step, .proj, .login-card { box-shadow: var(--shadow); }
.modal { background: var(--surface-solid); }
.convs { background: transparent; }
th { background: transparent; }
.btn { background: var(--surface); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #fff; }
.logo, .msg .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.msg.user .bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.chart .col i { background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.bar > i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.nav a.on { box-shadow: inset 3px 0 0 var(--accent); }
.input, select.input, textarea.input { background: var(--surface); }
.toast { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); }

/* ---------- Xưởng video ---------- */
.page.wide { max-width: 1280px; }
.section-title { font-size: 18px; margin: 30px 0 14px; }
.flow { display: grid; grid-template-columns: minmax(0, 1.25fr) 36px minmax(0, 1fr) 36px minmax(0, 1fr); align-items: stretch; }
.flow-arrow { display: grid; place-items: center; color: var(--accent); position: relative; }
.flow-arrow::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .45; }
.flow-arrow .ico { position: relative; width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: var(--surface-solid); border: 1px solid var(--border); }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.step header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step h3 { font-size: 16px; }
.step .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; }
.step .lbl { font-size: 13px; font-weight: 600; margin-top: 4px; }
.step textarea.input { flex: 1; min-height: 150px; }
.flow-link { margin-top: auto; padding-top: 8px; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; text-decoration: none; color: var(--accent); font-weight: 550; }
.flow-link:hover { text-decoration: underline; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--gray-soft); }
.seg button { flex: 1; height: 34px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 550; font-size: 13.5px; color: var(--muted); white-space: nowrap; padding: 0 8px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; }
.hint .ico { margin-top: 1px; color: var(--accent); }
.img-pick { min-height: 74px; display: flex; align-items: center; }
.thumb.lg { width: 96px; height: 72px; }
.btn.big { height: 48px; font-size: 15.5px; border-radius: 13px; margin-top: auto; }
.projects { display: flex; flex-direction: column; gap: 14px; }
.proj { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
.proj.tall { grid-template-columns: 220px minmax(0, 1fr); }
.proj-media { border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; display: grid; }
.proj.tall .proj-media { aspect-ratio: 9 / 16; }
.proj-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; color: #dbe4f5; background: radial-gradient(circle at 50% 30%, #1b2742, #0a0f1c); }
.stage-box.bad { color: #ffb4b4; }
.stage-box .bar { background: rgba(255, 255, 255, .14); }
.proj-prompt { margin: 10px 0 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.track { display: flex; align-items: center; flex-wrap: wrap; row-gap: 10px; }
.node { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.node img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }
.node .dot { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--gray-soft); position: relative; }
.node .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.node b { display: block; font-size: 13px; line-height: 1.2; }
.node span { font-size: 11.5px; color: var(--muted); }
.node.done { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.node.done .dot::after { background: var(--green); }
.node.run { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.node.run .dot::after { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.node.fail { border-color: var(--red); }
.node.fail .dot::after { background: var(--red); }
.node.wait { opacity: .6; }
@keyframes pulse { 50% { transform: scale(1.7); opacity: .45; } }
.link { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 22px; padding: 0 3px; }
.link i { display: block; width: 100%; min-width: 16px; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .55; }
.link span { font-size: 9.5px; color: var(--muted); white-space: nowrap; order: -1; }
.scenes { margin-top: 10px; font-size: 13px; }
.scenes summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.scenes ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.scenes li { margin-bottom: 6px; }
.bubble-wrap { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.to-video { opacity: 0; transition: opacity .12s; }
.msg.assistant:hover .to-video, .to-video:focus-visible { opacity: 1; }
@media (hover: none) { .to-video { opacity: 1; } }

@media (max-width: 1000px) {
  .flow { grid-template-columns: 1fr; }
  .flow-arrow { height: 34px; }
  .flow-arrow::before { left: 50%; right: auto; top: 0; bottom: 0; width: 2px; height: auto; }
  .flow-arrow .ico { transform: rotate(90deg); }
  .proj, .proj.tall { grid-template-columns: 1fr; }
  .proj.tall .proj-media { max-width: 240px; }
}

.ref { position: relative; }
.ref .btn { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-solid); }
.ref .btn .ico { width: 13px; height: 13px; }

.idea-panel { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 190px; }
.idea-panel textarea.input { flex: 1; }
.step select.input { height: 38px; font-size: 13.5px; }

/* ---------- thẻ kính mờ nổi ---------- */
.side, .card, .table-wrap, .job, .step, .proj, .login-card, .wnode, .hub { background: var(--glass), var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.side { box-shadow: none; border-width: 0 1px 0 0; }
.card, .wnode, .hub, .proj, .job { transition: transform .18s ease, box-shadow .18s ease; }
.wnode:hover, .hub:hover { transform: translateY(-2px); }
.btn { background: var(--glass), var(--surface); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px var(--accent); }
:root[data-theme="dark"] .btn.primary { color: var(--accent-text); }
.seg { background: var(--gray-soft); box-shadow: inset 0 1px 2px rgba(60, 20, 5, .18); }

/* ---------- workflow: nút quanh trung tâm, sợi neon nối vào ---------- */
.board { position: relative; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 400px) minmax(280px, 1fr); column-gap: 84px; align-items: start; }
.bcol { display: flex; flex-direction: column; gap: 18px; position: relative; z-index: 1; min-width: 0; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; overflow: visible; }
.wire, .wire-glow, .wire-flow { fill: none; stroke-linecap: round; }
.wire { stroke-width: 1.5; opacity: .62; }
.wire-glow { stroke-width: 7; opacity: .16; filter: blur(4px); }
.wire-flow { stroke-width: 2.4; stroke-dasharray: 3 19; opacity: 0; animation: wire-run 1s linear infinite; }
.wire-dot { opacity: 0; filter: drop-shadow(0 0 5px currentColor) drop-shadow(0 0 10px currentColor); }
.wire-end { opacity: .9; filter: drop-shadow(0 0 4px currentColor); }
.board.flowing .wire { opacity: .9; }
.board.flowing .wire-glow { opacity: .34; }
.board.flowing .wire-flow, .board.flowing .wire-dot { opacity: 1; }
@keyframes wire-run { to { stroke-dashoffset: -22; } }
.wnode { border-radius: 18px; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; }
.wnode::before { content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 2px; border-radius: 2px; background: var(--wire); box-shadow: 0 0 12px var(--wire); opacity: .9; }
.wnode header { display: flex; align-items: center; gap: 10px; }
.wnode h3 { font-size: 15px; flex: 1; }
.wicon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: #2a1206; background: var(--wire); box-shadow: 0 0 14px -2px var(--wire), inset 0 1px 0 rgba(255, 255, 255, .5); flex: none; }
.wicon .ico { width: 16px; height: 16px; }
.wport { width: 9px; height: 9px; border-radius: 50%; background: var(--wire); box-shadow: 0 0 10px var(--wire); flex: none; }
.wnode textarea.input { min-height: 150px; }
.wnode select.input { height: 38px; font-size: 13.5px; }
.refs-box { display: flex; flex-direction: column; gap: 10px; }
.hub { position: sticky; top: 16px; z-index: 1; align-self: start; margin-top: 46px; border-radius: 26px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hub::before { content: ""; position: absolute; inset: -1px; border-radius: 27px; padding: 1px; background: linear-gradient(140deg, #ff9f5a, #ffd166, #5ee7ff, #b79cff, #ff6b8b); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .55; pointer-events: none; }
.board.flowing .hub::before { opacity: 1; animation: hub-pulse 1.6s ease-in-out infinite; }
@keyframes hub-pulse { 50% { opacity: .45; } }
.hub-core { display: flex; align-items: center; gap: 12px; }
.hub-core .logo { width: 44px; height: 44px; border-radius: 14px; box-shadow: 0 0 22px -4px var(--accent); }
.hub-state { display: flex; flex-direction: column; gap: 12px; align-items: stretch; min-height: 150px; justify-content: center; }
.hub-idle, .hub-live { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 18px 10px; border-radius: 16px; background: var(--gray-soft); }
.hub-live .bar { width: 82%; }
.hub-live.bad { color: var(--red); background: var(--red-soft); }
.hub-media { border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.hub-media.tall { aspect-ratio: 9 / 16; max-height: 430px; align-self: center; }
.hub-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.hub .btn.big { margin-top: 0; }
@media (max-width: 1100px) { .board { column-gap: 54px; grid-template-columns: minmax(250px, 1fr) minmax(280px, 340px) minmax(250px, 1fr); } }
@media (max-width: 960px) {
  .board { grid-template-columns: 1fr; row-gap: 18px; }
  .hub { position: static; margin-top: 0; order: 3; }
  .wires { display: none; }
}

/* ---------- hai cột workflow cao bằng nhau ---------- */
.board { align-items: stretch; }
.bcol > .wnode { flex: 1 1 auto; }
.hub { position: relative; top: auto; align-self: center; margin-top: 0; }

/* ---------- đang tạo: viền trung tâm chạy neon đủ màu như đang nhận dữ liệu ---------- */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.hub::after { content: ""; position: absolute; inset: -4px; border-radius: 30px; padding: 7px; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: conic-gradient(from var(--ang), #ff9f5a, #ffd166, #7cf29a, #5ee7ff, #b79cff, #ff6b8b, #ff9f5a);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; filter: blur(9px); }
.board.flowing .hub::before { background: conic-gradient(from var(--ang), #ff9f5a, #ffd166, #7cf29a, #5ee7ff, #b79cff, #ff6b8b, #ff9f5a); padding: 2px; opacity: 1; animation: hub-spin 2.8s linear infinite; }
.board.flowing .hub::after { opacity: .85; animation: hub-spin 2.8s linear infinite; }
@keyframes hub-spin { to { --ang: 360deg; } }

/* ---------- ô chờ gợn sóng: mực nước dâng theo phần trăm ---------- */
.hub-wave { --p: 0; position: relative; overflow: hidden; isolation: isolate; min-height: 230px; border-radius: 18px; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 190, 140, .16), transparent 60%), linear-gradient(180deg, #2b140c, #1a0b06); box-shadow: inset 0 1px 0 rgba(255, 220, 190, .18), inset 0 0 40px rgba(0, 0, 0, .45); }
.hub-wave .fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(14% + var(--p) * .78%); transition: height 1.4s cubic-bezier(.4, 0, .2, 1);
  background: linear-gradient(180deg, rgba(255, 150, 84, .92), rgba(255, 104, 128, .82) 55%, rgba(150, 110, 255, .72)); }
.hub-wave .fill i { position: absolute; left: 0; bottom: calc(100% - 1px); width: 200%; background-repeat: repeat-x; background-size: 50% 100%; }
.hub-wave .w1 { height: 22px; animation: wave-x 5.5s linear infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 22' preserveAspectRatio='none'%3E%3Cpath d='M0 11 Q25 0 50 11 T100 11 T150 11 T200 11 V22 H0Z' fill='%23ff9654' fill-opacity='.92'/%3E%3C/svg%3E"); }
.hub-wave .w2 { height: 30px; opacity: .45; animation: wave-x 9s linear infinite reverse;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 30' preserveAspectRatio='none'%3E%3Cpath d='M0 15 Q25 30 50 15 T100 15 T150 15 T200 15 V30 H0Z' fill='%23ffd166'/%3E%3C/svg%3E"); }
@keyframes wave-x { to { transform: translateX(-50%); } }
.hub-wave .bubbles i { position: absolute; bottom: -12px; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .5); animation: bubble 5s ease-in infinite; }
.hub-wave .bubbles i:nth-child(1) { left: 14%; animation-duration: 4.6s; }
.hub-wave .bubbles i:nth-child(2) { left: 34%; width: 5px; height: 5px; animation-duration: 6.2s; animation-delay: 1.1s; }
.hub-wave .bubbles i:nth-child(3) { left: 56%; width: 10px; height: 10px; animation-duration: 5.4s; animation-delay: .5s; }
.hub-wave .bubbles i:nth-child(4) { left: 72%; width: 6px; height: 6px; animation-duration: 7s; animation-delay: 2s; }
.hub-wave .bubbles i:nth-child(5) { left: 88%; animation-duration: 5.8s; animation-delay: 1.6s; }
@keyframes bubble { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: .8; } 100% { transform: translateY(-190px) scale(1.1); opacity: 0; } }
.hub-wave-txt { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; text-align: center; text-shadow: 0 2px 10px rgba(40, 10, 0, .65); padding: 14px; }
.hub-wave-txt .pct { font-size: 52px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.hub-wave-txt b { font-size: 15.5px; }
.hub-wave-txt b::after { content: "…"; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.4s steps(4) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }
.hub-wave-txt .small { color: rgba(255, 240, 228, .9); }
@media (prefers-reduced-motion: reduce) { .hub-wave .fill i, .hub-wave .bubbles i, .board.flowing .hub::before, .board.flowing .hub::after { animation: none !important; } }

/* ================= phần chỉ dùng cho mobile: mặc định ẩn trên màn hình rộng ================= */
.wbody { display: contents; }
.wsum, .dock, .menu-btn, .sheet-head, .sheet-back, .board-label { display: none; }

/* ================= MOBILE: menu điều hướng ở góc trái + thẻ rõ nét hơn ================= */
@media (max-width: 900px) {
  .shell { grid-template-rows: auto 1fr; }
  .side { overflow: visible; padding: 10px 14px; gap: 10px; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; position: relative; z-index: 50; }
  .menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; }
  .menu-btn .ico { width: 22px; height: 22px; }
  .brand { padding: 0; gap: 9px; font-size: 16px; position: absolute; left: 50%; transform: translateX(-50%); }
  .brand span { display: inline-flex; }
  .brand .logo { display: none; }
  /* danh sách mục: thả xuống từ nút menu */
  .nav { display: none; position: absolute; left: 14px; top: 60px; z-index: 60; flex-direction: column; gap: 2px; width: min(260px, calc(100vw - 28px)); max-height: 70vh; overflow: auto; padding: 8px;
    border-radius: 18px; background: var(--surface-solid); border: 1px solid var(--border); box-shadow: 0 24px 50px -12px rgba(0, 0, 0, .7); }
  .side.menu-open .nav { display: flex; }
  .nav a { flex: none; flex-direction: row; gap: 12px; padding: 12px 12px; min-height: 48px; border-radius: 12px; font-size: 15px; }
  .nav a span:last-child { display: block; }
  .nav a .ico { width: 22px; height: 22px; }
  .nav a.on { box-shadow: none; }
  .nav-title { display: block; padding: 8px 12px 2px; }
  .main { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .page { padding: 6px 14px 28px; }
  .page-head { margin-bottom: 12px; }
  .page-head h1 { font-size: 20px; }
  .page-head p { display: none; }
  /* thẻ tách hẳn khỏi nền */
  .card, .wnode, .hub, .proj, .job, .table-wrap, .step { background: linear-gradient(155deg, rgba(255, 255, 255, .50), rgba(255, 255, 255, .10) 46%), rgba(255, 241, 228, .90); border-color: rgba(255, 255, 255, .80); }
  :root[data-theme="dark"] .card, :root[data-theme="dark"] .wnode, :root[data-theme="dark"] .hub, :root[data-theme="dark"] .proj, :root[data-theme="dark"] .job, :root[data-theme="dark"] .table-wrap, :root[data-theme="dark"] .step {
    background: linear-gradient(155deg, rgba(255, 220, 190, .17), rgba(255, 220, 190, .04) 48%), rgba(74, 40, 27, .95); border-color: rgba(255, 205, 170, .34); }
  .wnode:hover, .hub:hover { transform: none; }
}

/* ================= MOBILE: Xưởng video – Ý tưởng ở trên, 6 ô thiết lập thành 2 hàng, Tạo video ở dưới ================= */
@media (max-width: 760px) {
  .board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 12px; row-gap: 26px; align-items: stretch; }
  .bcol { display: contents; }
  .wires { display: block; }
  .wire-end { opacity: .95; }
  .board-label { display: block; grid-column: 1 / -1; order: 1; margin: -8px 0 -14px; font-size: 16px; font-weight: 700; position: relative; z-index: 1; }
  .section-title { margin-top: 26px; }
  .wnode { position: relative; z-index: 1; flex: none; margin: 0; }
  .wnode::before { display: none; }
  /* Ý tưởng: luôn mở, gọn bằng nửa chiều cao cũ */
  .wnode.idea { grid-column: 1 / -1; order: 0; padding: 12px 14px 12px; gap: 8px; border-radius: 18px; }
  .wnode.idea header { cursor: default; }
  .wnode.idea .wbody { display: flex; flex-direction: column; gap: 8px; }
  .wnode.idea .wsum { display: block; margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: var(--gray-soft); }
  .wnode.idea .wport, .wnode.idea .flow-link { display: none; }
  .wnode.idea textarea.input { min-height: 74px; height: 74px; }
  .idea-panel { min-height: 0; }
  .wnode.idea .seg button { height: 34px; }
  /* 6 ô thiết lập: biểu tượng, giá trị đang chọn, tên mục */
  .wnode.tile { order: var(--ord); padding: 0; border-radius: 16px; }
  .wnode.tile header { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 10px 12px 12px; min-height: 104px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .wnode.tile .wicon { width: 32px; height: 32px; border-radius: 10px; }
  .wnode.tile .wsum { display: block; order: 2; font-size: 15px; font-weight: 700; line-height: 1.2; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wnode.tile:not(.filled) .wsum { color: var(--muted); font-weight: 600; }
  .wnode.tile h3 { order: 3; flex: none; font-size: 12px; font-weight: 550; line-height: 1.25; color: var(--muted); }
  .wnode.tile .wport { position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; opacity: 0; }
  .wnode.tile.filled .wport { opacity: 1; }
  .wnode.tile:active { transform: scale(.97); }
  /* popup thao tác: trượt lên từ đáy */
  .wnode.tile .wbody { display: none; }
  .wnode.tile.open .wbody { display: flex; flex-direction: column; gap: 12px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; max-height: 78vh; overflow: auto;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0; background: var(--surface-solid); border-top: 2px solid var(--wire);
    box-shadow: 0 -24px 60px -10px rgba(0, 0, 0, .75); animation: sheet-up .22s ease-out; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
  .sheet-head b { flex: 1; font-size: 17px; }
  .sheet-head .btn { height: 36px; padding: 0 16px; }
  .board.sheet-on .sheet-back { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(10, 4, 2, .62); }
  .board.sheet-on .wnode { z-index: auto; }
  .wnode .input, .wnode select.input { font-size: 16px; } /* 16px để iPhone không tự phóng to khi gõ */
  .wnode.tile select.input { height: 46px; }
  .wnode.tile .seg button { height: 44px; font-size: 14px; padding: 0 6px; }
  /* Trung tâm: nơi mọi sợi đổ về, có nút Tạo video */
  .hub { order: 99; grid-column: 1 / -1; margin: 0; padding: 14px; border-radius: 22px; align-self: stretch; position: relative; z-index: 1; }
  .hub-core .logo { width: 36px; height: 36px; border-radius: 12px; }
  .hub-state { min-height: 0; }
  .hub-idle { padding: 12px 10px; }
  .hub-media.tall { max-height: 300px; }
  .hub-wave { min-height: 190px; }
  .hub > .hint { font-size: 12.5px; }
  .hub .btn.big { height: 52px; font-size: 16px; border-radius: 14px; }
  .proj, .proj.tall { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .wnode.idea .sheet-head { display: none; }
  .wnode.idea .idea-panel { flex: none; min-height: 0; }
  .wnode.idea textarea.input { flex: none; height: 86px; min-height: 86px; }
  .wnode.tile .wsum { white-space: normal; font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (max-width: 760px) {
  /* nút Tạo video nằm ngay dưới hai hàng ô; tiến độ và video kết quả hiện phía dưới nút */
  .hub-core { order: -3; }
  .hub .btn.big { order: -2; }
  .hub > .hint { order: -1; }
}
@media (max-width: 760px) {
  /* ô đang mở nổi lên trên lớp phủ mờ, popup của nó nằm trên cùng */
  .board.sheet-on .wnode.tile.open { z-index: 90; }
}
@media (max-width: 760px) {
  /* hiệu ứng nhấn chỉ đặt lên phần đầu ô: đặt lên cả ô làm popup bên trong bị xê dịch lúc chạm, khiến nút Xong không nhận */
  .wnode.tile:active { transform: none; }
  .wnode.tile header:active { opacity: .8; }
  /* "Thiết lập video": một thẻ ngang gọn nằm sát dưới Ý tưởng, ba sợi nối từ đáy thẻ xuống ba ô */
  .board-label { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; order: 1; margin: -16px 0 0; padding: 9px 14px; min-height: 48px; border-radius: 14px; font-size: 15px;
    background: linear-gradient(155deg, rgba(255, 255, 255, .50), rgba(255, 255, 255, .10) 46%), rgba(255, 241, 228, .90); border: 1px solid rgba(255, 255, 255, .80); box-shadow: var(--shadow); position: relative; z-index: 1; }
  :root[data-theme="dark"] .board-label { background: linear-gradient(155deg, rgba(255, 220, 190, .17), rgba(255, 220, 190, .04) 48%), rgba(74, 40, 27, .95); border-color: rgba(255, 205, 170, .34); }
  .board-label .wicon { --wire: var(--accent); width: 30px; height: 30px; border-radius: 10px; }
  .board-label b { flex: 1; font-weight: 700; }
}
@media (max-width: 760px) {
  /* "Thiết lập video": dải mỏng dính liền dưới ô Ý tưởng, chữ ở giữa, không biểu tượng */
  .wnode.idea { border-radius: 18px 18px 0 0; }
  .board-label { margin: -27px 0 0; padding: 6px 14px; min-height: 34px; justify-content: center; border-radius: 0 0 16px 16px; border-top-color: transparent; font-size: 14px; }
  :root[data-theme="dark"] .board-label { border-top-color: transparent; }
  .board-label .wicon, .board-label .small { display: none; }
  .board-label b { flex: none; letter-spacing: .01em; }
}
@media (max-width: 760px) {
  /* 6 ô gọn: bỏ biểu tượng và chấm góc; màu của mục chỉ còn là một vạch mảnh trên đầu ô, trùng màu sợi nối */
  .wnode.tile .wicon, .wnode.tile .wport { display: none; }
  .wnode.tile header { min-height: 0; padding: 14px 10px 12px 12px; gap: 3px; }
  .wnode.tile::before { display: block; left: 12px; right: 12px; top: 0; width: auto; height: 3px; border: 0; border-radius: 0 0 3px 3px; background: var(--wire); box-shadow: none; opacity: .95; }
  .wnode.tile .wsum { font-size: 15px; }
  .board { row-gap: 20px; }
  .board-label { margin-top: -21px; }
  /* sợi nối mảnh và dịu hơn */
  .wire { stroke-width: 1.2; opacity: .5; }
  .wire-glow { opacity: .08; }
  .wire-end { r: 2.4; opacity: .8; }
}

/* ================= MOBILE bản gộp: Ý tưởng + Thiết lập video + Tạo video nằm chung MỘT khung ================= */
@media (max-width: 760px) {
  .board { column-gap: 8px; row-gap: 10px; padding: 14px; border-radius: 22px; box-shadow: var(--shadow);
    background: linear-gradient(155deg, rgba(255, 255, 255, .50), rgba(255, 255, 255, .10) 46%), rgba(255, 241, 228, .90); border: 1px solid rgba(255, 255, 255, .80); }
  :root[data-theme="dark"] .board { background: linear-gradient(155deg, rgba(255, 220, 190, .17), rgba(255, 220, 190, .04) 48%), rgba(74, 40, 27, .95); border-color: rgba(255, 205, 170, .34); }
  .wires { display: none; }
  /* các phần bên trong không còn khung riêng */
  .board .wnode.idea, .board .board-label, .board .hub,
  :root[data-theme="dark"] .board .wnode.idea, :root[data-theme="dark"] .board .board-label, :root[data-theme="dark"] .board .hub { background: none; border: 0; box-shadow: none; border-radius: 0; }
  .board .wnode.idea { padding: 0; }
  .board .hub::before, .board .hub::after { display: none; }
  /* tiêu đề nhóm: một dòng chữ có vạch ngăn mảnh phía trên */
  .board .board-label { margin: 4px 0 0; padding: 12px 0 0; min-height: 0; justify-content: flex-start; border-top: 1px solid var(--border); font-size: 14px; }
  :root[data-theme="dark"] .board .board-label { border-top: 1px solid var(--border); }
  /* 6 mục thành 6 nút lựa chọn */
  .board .wnode.tile, :root[data-theme="dark"] .board .wnode.tile { background: var(--gray-soft); border: 1px solid var(--border); box-shadow: none; border-radius: 12px; }
  .board .wnode.tile::before { display: none; }
  .board .wnode.tile header { padding: 9px 10px 9px; gap: 1px; min-height: 54px; justify-content: center; }
  .board .wnode.tile h3 { order: 1; font-size: 11.5px; }
  .board .wnode.tile .wsum { order: 2; font-size: 14.5px; -webkit-line-clamp: 1; }
  .board .wnode.tile.filled { border-color: color-mix(in srgb, var(--wire) 55%, var(--border)); }
  /* Tạo video: phần cuối của cùng khung */
  .board .hub { margin: 4px 0 0; padding: 14px 0 0; border-top: 1px solid var(--border); gap: 12px; }
  :root[data-theme="dark"] .board .hub { border-top: 1px solid var(--border); }
  .board .hub-core { display: none; }
  /* khi đang tạo: viền neon chạy quanh cả khung chung */
  .board.flowing { border-color: transparent; background-clip: padding-box; outline: 2px solid var(--accent); outline-offset: -1px; animation: board-glow 1.6s ease-in-out infinite; }
  @keyframes board-glow { 50% { outline-color: var(--accent-2); box-shadow: 0 0 26px -4px var(--accent); } }
}
@media (max-width: 760px) {
  /* tên ngắn cho nút trên mobile (Nhân vật, Kịch bản) để không xuống dòng */
  .board .wnode.tile h3 span { display: none; }
  .board .wnode.tile h3::after { content: attr(data-m); }
  .board .wnode.tile h3 { white-space: nowrap; }
  .board .wnode.tile .wsum { font-size: 13.5px; }
  .board .wnode.tile header { padding: 9px 8px 9px 10px; }
}
@media (max-width: 760px) {
  /* gọn chiều cao + chữ căn giữa */
  .page-head { margin-bottom: 8px; }
  .page-head h1 { font-size: 18px; }
  .board { padding: 12px; row-gap: 8px; border-radius: 20px; }
  .wnode.idea { gap: 6px; }
  .wnode.idea header { gap: 8px; }
  .wnode.idea .wicon { width: 26px; height: 26px; border-radius: 8px; }
  .wnode.idea .wicon .ico { width: 14px; height: 14px; }
  .wnode.idea h3 { font-size: 14.5px; }
  .wnode.idea .wbody { gap: 6px; }
  .wnode.idea .seg { padding: 3px; }
  .wnode.idea .seg button { height: 30px; font-size: 13px; }
  .wnode.idea textarea.input { height: 64px; min-height: 64px; padding: 8px 10px; }
  .board .board-label { margin: 2px 0 0; padding: 9px 0 0; justify-content: center; font-size: 13px; }
  .board .wnode.tile header { align-items: center; text-align: center; min-height: 44px; padding: 6px 6px; gap: 0; }
  .board .wnode.tile h3 { font-size: 11px; }
  .board .wnode.tile .wsum { font-size: 13.5px; text-align: center; }
  .board .hub { margin: 2px 0 0; padding: 10px 0 0; gap: 8px; }
  .hub .btn.big { height: 46px; font-size: 15.5px; }
  .hub > .hint { justify-content: center; text-align: center; font-size: 12px; }
  .hub > .hint .ico { display: none; }
}
@media (max-width: 760px) {
  /* 6 ô trông như nút bấm: nổi khối, có mũi tên xổ xuống, giá trị mang màu nhấn, nhấn thì lún */
  .board .wnode.tile, :root[data-theme="dark"] .board .wnode.tile { border-radius: 12px; border: 1px solid rgba(255, 255, 255, .85);
    background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 232, 214, .92)); box-shadow: 0 2px 0 rgba(120, 50, 20, .28), 0 6px 12px -6px rgba(70, 24, 6, .45); }
  :root[data-theme="dark"] .board .wnode.tile { border-color: rgba(255, 205, 170, .38);
    background: linear-gradient(180deg, rgba(126, 74, 52, .98), rgba(92, 50, 34, .98)); box-shadow: inset 0 1px 0 rgba(255, 225, 200, .22), 0 2px 0 rgba(0, 0, 0, .45), 0 8px 14px -8px rgba(0, 0, 0, .7); }
  .board .wnode.tile header { position: relative; padding: 6px 20px 6px 8px; }
  .board .wnode.tile header::after { content: ""; position: absolute; right: 9px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); opacity: .9; }
  .board .wnode.tile .wsum { color: var(--accent); font-weight: 750; }
  .board .wnode.tile h3 { color: var(--text); opacity: .72; }
  .board .wnode.tile:not(.filled) { border-style: dashed; border-color: var(--accent); }
  .board .wnode.tile:not(.filled) .wsum { color: var(--accent); }
  .board .wnode.tile header:active { opacity: 1; }
  .board .wnode.tile:has(header:active) { box-shadow: inset 0 2px 5px rgba(0, 0, 0, .35); filter: brightness(.94); }
  .board.sheet-on .wnode.tile.open { outline: 2px solid var(--accent); outline-offset: 1px; }
}
@media (max-width: 760px) {
  .board .wnode.tile header { padding: 6px 17px 6px 6px; }
  .board .wnode.tile header::after { right: 8px; width: 5px; height: 5px; }
  .board .wnode.tile .wsum { font-size: 13px; }
}
@media (max-width: 760px) {
  .board .wnode.tile header::after { border-color: var(--muted); opacity: .7; }
}
@media (max-width: 760px) {
  .wnode.idea textarea.input { height: 110px; min-height: 110px; }
}

/* ================= nút gửi sang tạo video + hộp chọn nơi nhận ảnh ================= */
.to-video, .msg.assistant .to-video { opacity: 1; margin-top: 8px; }
.to-video .ico, .send-video .ico { width: 15px; height: 15px; }
.pick-list { display: flex; flex-direction: column; gap: 10px; }
.pick-thumb { align-self: center; max-height: 150px; max-width: 100%; border-radius: 12px; object-fit: contain; }
.pick-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--glass), var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pick-opt:hover { border-color: var(--accent); }
.pick-opt .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick-opt .wicon { --wire: var(--accent); }
.pick-opt > .ico { color: var(--muted); }
.toptabs { display: none; }

/* ================= MOBILE: thanh 3 tab Chat – Tạo ảnh – Tạo video ================= */
@media (max-width: 900px) {
  .side { flex-wrap: wrap; row-gap: 10px; }
  .toptabs { display: flex; order: 9; flex: 1 0 100%; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow); }
  .toptabs a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border-radius: 10px; font-size: 13.5px; font-weight: 650; color: var(--muted); text-decoration: none; white-space: nowrap; }
  .toptabs a .ico { width: 17px; height: 17px; }
  .toptabs a.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); box-shadow: 0 6px 14px -8px var(--accent); }
  /* ba mục này đã ở trên thanh tab nên không lặp lại trong menu */
  .nav a[data-id="chat"], .nav a[data-id="images"], .nav a[data-id="studio"] { display: none; }
  .side.no-menu .menu-btn { visibility: hidden; }
  body[data-view="studio"] .page-head, body[data-view="images"] .page-head { display: none; }
  .page { padding-top: 4px; }
}
@media (max-width: 900px) {
  .brand { top: 32px; transform: translate(-50%, -50%); }
}
.to-video[hidden] { display: none !important; }
@media (max-width: 900px) {
  /* tên app về bên trái */
  .brand { position: static; transform: none; left: auto; top: auto; }
  .side.no-menu .menu-btn { display: none; }
  /* iPhone tự phóng to trang khi chạm vào ô nhập có chữ nhỏ hơn 16px: mọi ô nhập trên mobile dùng đúng 16px */
  input, textarea, select, .input, .composer textarea { font-size: 16px !important; }
  html, body { overflow-x: hidden; max-width: 100%; }
  .composer { padding: 10px 14px 14px; }
  .composer textarea { padding: 9px 0; }
  .composer textarea::placeholder, .input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Logo SimVids (chốt 2026-12-03): ô icon ba dải phim + chữ Sim-V-ids; bản sáng cho giao diện sáng, bản tối cho giao diện tối.
   Tệp do logo/tao_logo_chot.py sinh ra. */
.logo { background: url('/simvids-icon-toi.svg') center / 100% 100% no-repeat; border-radius: 23%; box-shadow: 0 6px 16px -10px rgba(70, 24, 6, .55); }
.logo .ico { visibility: hidden; }
.brand .logo { background-image: url('/simvids-icon-nho-toi.svg'); }
:root[data-theme="dark"] .logo { box-shadow: 0 6px 18px -8px rgba(255, 140, 60, .45); }
.login-card > .logo { width: 84px; height: 84px; }
.brand .wm { white-space: nowrap; letter-spacing: -.01em; }
.login-card h1.wm { margin: 20px 0 6px; }

/* Hạn mức lưu video: thanh đếm + chọn nhiều để xóa */
.store-bar { display: grid; gap: 10px; margin-bottom: 14px; }
.store-bar:empty { display: none; }
.store-tools { align-items: center; gap: 10px; }
.pick-all, .pick-one { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.pick-all input, .pick-one input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
