/* WebVideo: nền trắng, một màu nhấn tím, co giãn từ điện thoại 320px tới màn hình rộng. */
:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --text: #1d2030;
  --muted: #6b6f80;
  --line: #e6e7ef;
  --accent: #6b3cf0;
  --accent-strong: #5a2ee0;
  --accent-soft: #f1ecff;
  --ok: #18794e;
  --ok-soft: #e7f6ee;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.04), 0 4px 16px rgba(20, 20, 40, 0.05);
  --topbar: 64px;
  --sidebar: 236px;
  --bottombar: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Nút, ô nhập ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; white-space: nowrap; text-decoration: none !important; color: var(--text);
}
.btn:hover { border-color: #cfd1de; }
.btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-big { min-height: 56px; padding: 10px 24px; font-size: 16px; flex-direction: column; gap: 0; line-height: 1.2; }
.btn-big small { font-weight: 500; opacity: 0.9; }

.field { display: grid; gap: 6px; }
.label { font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.label small { font-weight: 400; color: var(--muted); }
.input, .textarea, select.input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 10px 12px; min-height: 42px;
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  min-width: 72px; min-height: 40px; padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500;
}
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 14px; cursor: pointer; font-size: 14px; white-space: nowrap; min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-run { background: var(--accent-soft); color: var(--accent-strong); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); }
.notice-bad { background: var(--bad-soft); color: var(--bad); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---- Khung trang ---- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text) !important; text-decoration: none !important; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand-mark svg { width: 16px; height: 16px; fill: #fff; stroke: none; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav .nav-item { padding: 8px 12px; border-radius: var(--radius-sm); white-space: nowrap; }
.topnav .nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.credit-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; background: var(--surface); white-space: nowrap; cursor: pointer; min-height: 38px; }
.credit-pill .icon { color: #d89b00; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 700; overflow: hidden; cursor: pointer; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); padding: 20px 12px; position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--text) !important; text-decoration: none !important; cursor: pointer; border: 0; background: none; font-weight: 500; text-align: left; width: 100%; }
.nav-item:hover { background: #f4f4f8; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong) !important; font-weight: 600; }
.nav-sub { padding-left: 46px; font-size: 14px; }
.main { padding: 24px; min-width: 0; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

.bottombar { display: none; }
.menu-popover { position: absolute; right: 16px; top: calc(var(--topbar) - 6px); z-index: 40; min-width: 220px; padding: 8px; }
.menu-popover .nav-item { padding: 10px 12px; }

/* ---- Tạo nội dung ---- */
.mode-switch { display: inline-flex; padding: 4px; gap: 4px; border-radius: 10px; background: #efeff5; }
.mode-switch button { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; min-height: 38px; }
.mode-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.create-grid { display: grid; gap: 20px; }
.prompt-box { position: relative; }
.prompt-box .textarea { padding-bottom: 36px; }
.counter { position: absolute; right: 12px; bottom: 8px; font-size: 12px; color: var(--muted); pointer-events: none; }
.ref-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.dropzone {
  flex: 1 1 280px; min-height: 120px; border: 1.5px dashed #cdd0de; border-radius: var(--radius);
  display: grid; place-items: center; text-align: center; padding: 16px; cursor: pointer; color: var(--muted); background: #fbfbfe;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.dropzone .icon { width: 28px; height: 28px; margin: 0 auto 6px; }
.thumb { position: relative; width: 120px; height: 120px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #f0f0f5; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(20, 20, 30, 0.7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb .remove .icon { width: 14px; height: 14px; }
.thumb-index { position: absolute; left: 6px; bottom: 6px; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: rgba(20, 20, 30, 0.7); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.ref-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.ref-strip img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.pick-grid button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pick-tile { width: 120px; height: 120px; border-radius: var(--radius); border: 1px solid var(--line); background: #f4f4f8; display: grid; place-items: center; text-align: center; cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px; flex: none; }
.pick-tile:hover { color: var(--accent-strong); border-color: var(--accent); }
.options { display: grid; grid-template-columns: auto auto 1fr; gap: 20px; align-items: end; }
.option-group { display: grid; gap: 8px; }
.option-group .label { justify-content: flex-start; }
.submit-wrap { justify-self: end; min-width: 240px; }

/* ---- Thư viện ---- */
.lib-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 28px 0 14px; }
.lib-head h2 { margin-right: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.search { position: relative; margin-left: auto; min-width: 220px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search .input { padding-left: 38px; border-radius: 999px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.job { overflow: hidden; display: flex; flex-direction: column; }
.job-media { position: relative; aspect-ratio: 16 / 10; background: #eceef4; display: grid; place-items: center; cursor: pointer; overflow: hidden; border: 0; padding: 0; width: 100%; }
.job-media img, .job-media video { width: 100%; height: 100%; object-fit: cover; }
.job-media .duration { position: absolute; right: 8px; bottom: 8px; background: rgba(15, 15, 25, 0.75); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.job-media .kind { position: absolute; left: 8px; top: 8px; background: rgba(255, 255, 255, 0.92); color: var(--text); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.job-placeholder { color: var(--muted); display: grid; gap: 8px; place-items: center; padding: 12px; text-align: center; font-size: 13px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #d9d4f7; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.job-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.job-title { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.job-title strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-prompt { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---- Gói, bảng ---- */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.pack { padding: 20px; display: grid; gap: 10px; }
.pack .price { font-size: 26px; font-weight: 700; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
.plus { color: var(--ok); font-weight: 600; }
.minus { color: var(--bad); font-weight: 600; }
.keyline { font-family: Consolas, "Courier New", monospace; font-size: 13px; background: #f4f4f8; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; word-break: break-all; }
pre.code { margin: 0; font-family: Consolas, "Courier New", monospace; font-size: 13px; background: #16161f; color: #e9e9f2; border-radius: var(--radius-sm); padding: 14px; overflow-x: auto; white-space: pre; }

/* ---- Hộp thoại, thông báo ---- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 15, 25, 0.55); display: grid; place-items: center; padding: 16px; }
.dialog { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; display: grid; gap: 14px; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-head h2 { flex: 1; }
.dialog .media-full img, .dialog .media-full video { width: 100%; max-height: 60vh; object-fit: contain; background: #0f0f15; border-radius: var(--radius-sm); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.pick-grid button { border: 2px solid transparent; border-radius: var(--radius-sm); padding: 0; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: #eee; }
.pick-grid button:hover, .pick-grid button:focus-visible { border-color: var(--accent); }
.pick-grid img { width: 100%; height: 100%; object-fit: cover; }
.toast-area { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: #1d2030; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; }
.toast.bad { background: var(--bad); }
#payos-frame { min-height: 520px; border-radius: var(--radius-sm); overflow: hidden; }

/* ---- Hỏi đáp ---- */
.help-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 20px rgba(107, 60, 240, 0.35);
}
.help-fab:hover { background: var(--accent-strong); }
.help-fab:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 3px; }
.help-fab .icon { width: 22px; height: 22px; }
.help-panel {
  position: fixed; right: 20px; bottom: 84px; z-index: 50; width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px)); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 40px rgba(20, 20, 40, 0.18);
}
.help-head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.help-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.help-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.help-msg.bot { align-self: flex-start; background: #f2f2f7; border-bottom-left-radius: 4px; }
.help-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.help-action { margin-top: 8px; display: flex; }
.help-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.help-form .input { min-height: 40px; }
.help-form .btn { padding: 8px 12px; }

/* ---- Đăng nhập: trái là hình minh họa vẽ bằng canvas, phải là khu đăng nhập ---- */
.login-wrap { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(440px, 100%); padding: 32px 28px; display: grid; gap: 18px; text-align: center; }
body.auth-mode { background: var(--surface); }
body.auth-mode .topbar { display: none; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(400px, 1fr); }
.auth-visual { position: relative; overflow: hidden; background: #0d0b17; color: #fff; min-height: 100vh; min-height: 100dvh; }
.auth-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.auth-brand { position: absolute; z-index: 1; top: 32px; left: 48px; display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.auth-tagline { position: absolute; z-index: 1; left: 48px; right: 48px; bottom: 48px; }
.auth-tagline h1 { font-size: clamp(32px, 3.3vw, 46px); line-height: 1.08; letter-spacing: -0.025em; font-weight: 700; }
.auth-tagline p { margin: 12px 0 0; font-size: 17px; color: rgba(255, 255, 255, 0.66); }
.auth-panel { display: grid; place-items: center; padding: 48px 40px; background: var(--surface); }
.auth-box { width: min(360px, 100%); display: grid; }
.auth-box h2 { font-size: 30px; letter-spacing: -0.02em; }
.auth-sub { margin: 8px 0 32px; color: var(--muted); font-size: 16px; }
.auth-box .notice { margin: -12px 0 20px; }
.google-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 54px; padding: 0 20px; border-radius: 12px; background: #131314; color: #fff !important;
  font-size: 16px; font-weight: 600; text-decoration: none !important; transition: background-color 0.15s, transform 0.15s;
}
.google-btn:hover { background: #2b2a33; }
.google-btn:active { transform: translateY(1px); }
.google-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.google-mark { width: 30px; height: 30px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.google-mark svg { width: 18px; height: 18px; }
.google-btn[aria-busy="true"] { pointer-events: none; background: #2b2a33; }
.google-btn[aria-busy="true"] .google-mark { background: transparent; border: 2.5px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.google-btn[aria-busy="true"] .google-mark svg { display: none; }
.auth-note { margin: 18px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-visual { min-height: 0; height: clamp(320px, 54vh, 460px); }
  .auth-brand { top: 18px; left: 20px; font-size: 16px; }
  .auth-tagline { left: 20px; right: 20px; bottom: 22px; }
  .auth-tagline h1 { font-size: 26px; }
  .auth-tagline p { margin-top: 6px; font-size: 15px; }
  .auth-panel { place-items: start center; padding: 28px 20px calc(32px + env(safe-area-inset-bottom)); }
  .auth-box h2 { font-size: 24px; }
  .auth-sub { margin-bottom: 24px; font-size: 15px; }
}

/* ---- Màn hình vừa (máy tính bảng) ---- */
@media (max-width: 1100px) {
  .topnav { display: none; }
  .options { grid-template-columns: 1fr 1fr; }
  .submit-wrap { grid-column: 1 / -1; justify-self: stretch; }
}

/* ---- Điện thoại ---- */
@media (max-width: 760px) {
  :root { --topbar: 56px; }
  body { font-size: 15px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand > span:not(.brand-mark) { display: none; }
  .layout { display: block; }
  .sidebar { display: none; }
  .main { padding: 16px 12px calc(var(--bottombar) + 24px); }
  h1 { font-size: 22px; }
  .panel { padding: 16px; }
  .btn-topup-label { display: none; }
  .bottombar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottombar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bottombar a { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--muted) !important; text-decoration: none !important; min-height: 48px; }
  .bottombar a[aria-current="page"] { color: var(--accent-strong) !important; font-weight: 600; }
  .options { grid-template-columns: 1fr; gap: 16px; }
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); width: 100%; }
  .mode-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .mode-switch button { justify-content: center; }
  .thumb, .pick-tile { width: 96px; height: 96px; }
  .dropzone { min-height: 96px; }
  .lib-head { margin-top: 24px; }
  .search { margin-left: 0; width: 100%; min-width: 0; order: 3; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .job-body { padding: 8px 10px 10px; }
  .job-actions .btn { flex: 1; }
  .packs { grid-template-columns: 1fr; }
  .toast-area { bottom: calc(var(--bottombar) + 16px); }
  .help-fab { right: 14px; bottom: calc(var(--bottombar) + 14px + env(safe-area-inset-bottom)); width: 48px; height: 48px; }
  .help-panel { left: 8px; right: 8px; width: auto; bottom: calc(var(--bottombar) + 72px + env(safe-area-inset-bottom)); height: min(480px, calc(100vh - var(--bottombar) - 150px)); }
  .dialog { padding: 16px; }
  .overlay { padding: 8px; align-items: end; }
  .menu-popover { right: 8px; left: 8px; }
  table.responsive thead { display: none; }
  table.responsive tr { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.responsive td { border: 0; padding: 2px 4px; text-align: left !important; }
  table.responsive td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  /* Biến động credit: hai hàng gọn — nội dung | khả dụng, thời gian | đang giữ */
  table.ledger thead { display: none; }
  table.ledger tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.ledger td { border: 0; padding: 0; }
  table.ledger td:nth-child(1) { grid-area: 2 / 1; color: var(--muted); font-size: 13px; }
  table.ledger td:nth-child(2) { grid-area: 1 / 1; }
  table.ledger td:nth-child(3) { grid-area: 1 / 2; }
  table.ledger td:nth-child(4) { grid-area: 2 / 2; font-size: 13px; }
  table.ledger td:nth-child(4)::before { content: "giữ "; color: var(--muted); font-weight: 400; }
}
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
  .credit-pill { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}
