/* AI Edit Video — theme: dark green + yellow on cream */
:root {
  --teal-700: #0f4a2e;
  --teal-600: #166b3f;
  --teal-500: #1e8449;
  --teal-400: #2f9e5b;
  --green-500: #1e8449;
  --green-400: #2f9e5b;
  --yellow-500: #f6c216;
  --yellow-400: #ffd84d;
  --yellow-100: #fff4c7;
  --grad: linear-gradient(110deg, #fff4cc 0%, #ffe68a 38%, #f9d95c 62%, #e7f3dc 100%);
  --grad-btn: linear-gradient(100deg, #0f4a2e 0%, #17603b 100%);
  --grad-yellow: linear-gradient(100deg, #ffd84d 0%, #f6c216 100%);
  --bg: #fbf8ee;
  --card: #ffffff;
  --line: #e9e6d6;
  --fg: #12261b;
  --muted: #6c786f;
  --err: #d64545;
  --ok: #2f9e6b;
  --warn: #c98a12;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(40, 52, 20, 0.08);
  --shadow-hover: 0 10px 30px rgba(40, 52, 20, 0.14);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: linear-gradient(90deg, #fff6dc 0%, #fbf8ee 35%, #f6f8ee 65%, #ecf6ea 100%) fixed; color: var(--fg); font-size: 14px; line-height: 1.5;
  font-family: "Plus Jakarta Sans", "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
}

/* ---------------- top bar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1280px; margin: auto; padding: 10px 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--teal-700);
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(15, 74, 46, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.brand-text small { font-size: 11px; font-weight: 700; color: var(--teal-600); letter-spacing: .4px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button {
  background: none; border: none; padding: 9px 16px; cursor: pointer; font: inherit; font-weight: 600;
  font-size: 14px; color: var(--fg); border-radius: 999px; transition: background .15s, color .15s;
}
nav button:hover { background: #f2f7ea; color: var(--teal-700); }
nav button.active { background: var(--grad-btn); color: #fff; box-shadow: 0 4px 12px rgba(15, 74, 46, .3); }

/* ---------------- hero */
.hero { position: relative; background: var(--grad); color: var(--teal-700); overflow: hidden; border-bottom: 1px solid rgba(15,74,46,.12); margin-bottom: 18px; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 300px at 15% 0%, rgba(255,255,255,.55), transparent 70%),
              repeating-linear-gradient(120deg, rgba(255,255,255,.18) 0 2px, transparent 2px 26px);
}
.hero-inner {
  position: relative; max-width: 1280px; margin: auto; padding: 26px 24px 28px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 560px); align-items: center; gap: 32px;
}
.hero-text { min-width: 0; }
.hero-art svg { display: block; width: 100%; height: auto; }
.hero-art { animation: hero-float 6s ease-in-out infinite; }
@keyframes hero-float { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .hero-art { animation: none; } }
.hero-feats { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0 16px; }
.hero-feats li {
  background: rgba(255,255,255,.6); border: 1px solid rgba(15,74,46,.15); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 700;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 999px;
  border: 1px solid rgba(15,74,46,.25); background: rgba(255,255,255,.55); font-size: 13px; font-weight: 700;
}
.pill b { background: var(--teal-700); color: var(--yellow-400); padding: 3px 10px; border-radius: 999px; font-weight: 800; }
.hero h2 { font-size: 36px; line-height: 1.3; font-weight: 800; margin: 14px 0 8px; letter-spacing: -.8px; }
.hero p { margin: 0; font-size: 15px; color: #2c4a35; max-width: 680px; }
.hero-status {
  background: rgba(255,255,255,.6); border: 1px solid rgba(15,74,46,.15); border-radius: var(--radius);
  padding: 10px 16px; backdrop-filter: blur(6px); max-width: 520px; display: inline-block;
}
.hero-status-title { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; opacity: .85; font-weight: 700; margin-bottom: 4px; }
#health { font-size: 13px; font-weight: 600; }

/* ---------------- layout */
main { padding: 8px 24px 40px; max-width: 1280px; margin: auto; }
.tab { display: none; } .tab.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } .hero h2 { font-size: 28px; }
  .hero-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 20px; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--shadow);
}
h2 { font-size: 18px; font-weight: 800; margin: 0 0 14px; letter-spacing: -.3px; }
h3 { font-size: 14px; font-weight: 700; margin: 18px 0 8px; color: var(--teal-700); }

/* ---------------- forms */
label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fffdf6; color: var(--fg); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-400); box-shadow: 0 0 0 3px rgba(30, 132, 73, .18); background: #fff;
}
input[type=checkbox] { accent-color: var(--teal-500); width: 16px; height: 16px; }
input[type=color] { padding: 2px; height: 38px; }
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type=color] { width: 46px; flex: none; cursor: pointer; }
.color-field .hex { flex: 1; min-width: 0; font-family: "Cascadia Code", Consolas, monospace; text-transform: uppercase; }
.color-field .hex.invalid { border-color: var(--err); box-shadow: 0 0 0 3px rgba(214, 69, 69, .15); }
input[type=file] { padding: 8px; background: #f8f8ee; border-style: dashed; border-color: #cfe0c2; color: var(--muted); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 700; font-size: 13px; margin-right: 12px; padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--teal-400); background: #fff; color: var(--teal-700); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: #f2f7ea; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 12px 14px; }
legend { font-weight: 700; color: var(--teal-700); padding: 0 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; } .row > label { flex: 1; min-width: 150px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.stack > p { margin: 0 0 12px; }
.stack > p:last-child { margin: 8px 0 0; }

/* ---------------- buttons */
button {
  font: inherit; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--teal-400); background: #fff; color: var(--teal-700);
  transition: transform .1s, box-shadow .15s, background .15s;
}
button:hover { background: #f2f7ea; }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--grad-btn); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgba(15, 74, 46, .3);
}
button.primary:hover { box-shadow: 0 8px 22px rgba(15, 74, 46, .4); filter: brightness(1.03); }
button:disabled { opacity: .5; cursor: default; }
.list button { padding: 4px 10px; font-size: 12px; }

/* ---------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 10px 12px; border-radius: 12px; cursor: pointer; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.list li + li { margin-top: 4px; }
.list li:hover { background: #f4f8ee; border-color: var(--line); }
.list li.sel { background: #eef6e8; border-color: #cfe5c4; }
.list li small { color: var(--muted); }
.list.small li { cursor: default; font-size: 12px; padding: 6px 10px; }
.list.small li:hover { background: none; border-color: transparent; }

.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #f1efe4; color: var(--muted); white-space: nowrap; }
.badge.done { background: #e2f5ea; color: var(--ok); }
.badge.failed { background: #fde8e8; color: var(--err); }
.badge.awaiting_review { background: #fff3d6; color: var(--warn); }

/* ---------------- job detail */
.progress { height: 8px; background: #efeee2; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress div { height: 100%; background: var(--grad-btn); width: 0; transition: width .4s; border-radius: 99px; }
video { width: 100%; max-height: 70vh; background: #0c1a12; border-radius: 14px; }
pre {
  background: #fbfaf2; border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 320px;
  overflow: auto; white-space: pre-wrap; font-family: "Cascadia Code", Consolas, monospace;
}
#jd-outputs a {
  display: inline-block; margin: 10px 8px 0 0; padding: 6px 14px; border-radius: 999px; font-weight: 700;
  font-size: 13px; text-decoration: none; color: var(--teal-700); background: #eef6e8;
}
#jd-outputs a:hover { background: #dcecd2; }

/* ---------------- misc */
.small { font-size: 12px; } .hidden { display: none !important; }
.msg { color: var(--muted); } .error { color: var(--err); }
.warn { background: #fff6e0; border: 1px solid #f6e0a8; padding: 10px 12px; border-radius: 12px; font-size: 12px; color: #7a5a06; }
.sev-error { color: var(--err); } .sev-warning { color: var(--warn); }
a { color: var(--teal-600); }
::selection { background: rgba(30, 132, 73, .25); }

/* ---------------- mode switch (AI Agent | Thủ công) */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 4px 0 22px; }
.mode-btn {
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 18px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: #fff; color: var(--fg); box-shadow: var(--shadow); font-weight: 500;
}
.mode-btn:hover { border-color: var(--teal-400); background: #fff; }
.mode-btn b { display: block; font-size: 15px; font-weight: 800; }
.mode-btn small { color: var(--muted); font-size: 12px; font-weight: 500; }
.mode-ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: #eef5e6; color: var(--teal-600); font-size: 18px;
}
.mode-btn.active { border-color: transparent; background: var(--grad-btn); color: #fff; box-shadow: 0 8px 22px rgba(15, 74, 46, .3); }
.mode-btn.active small { color: rgba(255,255,255,.9); }
.mode-btn.active .mode-ico { background: rgba(255,255,255,.22); color: #fff; }
@media (max-width: 600px) { .mode-switch { grid-template-columns: 1fr; } }

/* ---------------- agent form */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.chip { padding: 5px 12px; font-size: 12px; font-weight: 600; border-width: 1px; border-color: #d6e8cc; color: var(--teal-700); background: #f6f9ef; }

/* ---------------- chat */
.agent-cols { align-items: start; }
.chat-card { display: flex; flex-direction: column; min-height: 640px; position: sticky; top: 76px; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.chat-head h2 { margin: 0; }
.chat-log { flex: 1; overflow-y: auto; max-height: 62vh; padding: 14px 2px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { color: var(--muted); text-align: center; margin: auto; max-width: 280px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; line-height: 1.5; }
.bubble.user { align-self: flex-end; background: var(--grad-btn); color: #fff; border-bottom-right-radius: 4px; }
.bubble.agent { align-self: flex-start; background: #f5f8ef; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.question { align-self: flex-start; background: #fff7e0; border: 1px solid #f3dc9b; border-bottom-left-radius: 4px; }
.bubble.question::before { content: "Agent hỏi bạn"; display: block; font-size: 11px; font-weight: 800; color: var(--warn); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.bubble.error { align-self: stretch; background: #fdecec; border: 1px solid #f5c2c2; color: #8f2424; }
.ev-line { align-self: flex-start; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.ev-line::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal-400); flex: none; }
.ev-line.done::before { background: var(--ok); }
.variant-card { align-self: stretch; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; box-shadow: var(--shadow); }
.variant-card video { max-height: 340px; }
.variant-card .vc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.variant-card .vc-links a { display: inline-block; margin: 8px 6px 0 0; padding: 4px 12px; border-radius: 999px; background: #eef6e8; color: var(--teal-700); font-weight: 700; font-size: 12px; text-decoration: none; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 10px 14px; background: #f5f8ef; border-radius: 16px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--teal-500); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 12px; }
.chat-input textarea { flex: 1; resize: none; }
.badge.running, .badge.analyzing { background: #eaf4e2; color: var(--teal-700); }
.badge.waiting_user { background: #fff3d6; color: var(--warn); }
.badge.stopped { background: #f1efe4; color: var(--muted); }

/* ---------------- multi-file list */
.file-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.file-list li {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; border-radius: 10px;
  background: #f4f8ee; border: 1px solid var(--line); font-size: 13px;
}
.file-list .fl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .fl-size { color: var(--muted); font-size: 12px; flex: none; }
.file-list .fl-del {
  flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: none; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1;
}
.file-list .fl-del:hover { background: #fde8e8; color: var(--err); }
input[type=file].has-files { color: transparent; }
input[type=file].drag { border-color: var(--teal-500); background: #eef6e8; }

/* ---------------- aspect picker (agent form) */
.field { margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field-label small { color: var(--muted); font-weight: 500; }
.aspect-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-opt { margin: 0; flex-direction: row; cursor: pointer; }
.pill-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pill-opt span {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: 13px; color: var(--fg);
  transition: border-color .15s, background .15s, color .15s;
}
.pill-opt:hover span { border-color: var(--teal-400); }
.pill-opt input:checked + span { background: var(--grad-btn); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(15, 74, 46, .28); }
.pill-opt input:focus-visible + span { outline: 2px solid var(--teal-400); outline-offset: 2px; }
.ar {
  display: inline-block; height: 16px; aspect-ratio: var(--w) / var(--h); max-width: 26px;
  border: 2px solid currentColor; border-radius: 3px; opacity: .85;
}

/* ---------------- agent composer */
.composer {
  border: 1.5px solid var(--line); border-radius: 18px; background: #fffdf6; margin-bottom: 16px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.composer:focus-within { border-color: var(--teal-400); box-shadow: 0 0 0 3px rgba(30, 132, 73, .15); background: #fff; }
.composer.drag { border-color: var(--teal-500); background: #eef6e8; }
.composer textarea { width: 100%; border: none; background: transparent; resize: vertical; min-height: 96px; padding: 14px 16px 6px; box-shadow: none; }
.composer textarea:focus { box-shadow: none; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.attach-chips:empty { display: none; }
.chip-file {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 10px; border-radius: 999px;
  background: #eef5e6; border: 1px solid #d6e8cc; font-size: 12px;
}
.chip-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.chip-file small { color: var(--muted); }
.chip-file button { width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; }
.chip-file button:hover { background: #fde8e8; color: var(--err); }
.composer-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
.composer-hint { flex: 1; color: var(--muted); font-size: 12px; }
.composer-bar .send-btn { margin-left: auto; }
.attach-wrap { position: relative; }
.attach-btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; }
.attach-menu {
  position: absolute; bottom: 46px; left: 0; z-index: 5; min-width: 220px; padding: 6px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-hover); display: flex; flex-direction: column; gap: 2px;
}
.attach-menu button { border: none; text-align: left; border-radius: 10px; padding: 9px 12px; font-weight: 600; color: var(--fg); }
.attach-menu button:hover { background: #f2f7ea; color: var(--teal-700); }
.pill-opt span small { font-weight: 500; opacity: .8; }
.vc-edit { margin: 8px 0 0; padding: 4px 12px; font-size: 12px; }
#jd-editor-wrap { margin: 8px 0 16px; padding: 12px 14px; border: 1px dashed #cfe5c4; border-radius: 14px; background: #fbfaf1; }
.chip-thumb { width: 28px; height: 18px; object-fit: cover; border-radius: 4px; flex: none; }
.lib-pick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; }
.lib-pick-row .attach-chips { padding: 0; }
.interchange { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.interchange .row { align-items: center; margin-bottom: 8px; }
.ix-link { display: inline-block; padding: 4px 12px; border-radius: 999px; background: #eef6e8; color: var(--teal-700); font-weight: 700; font-size: 12px; text-decoration: none; }
.ix-link:hover { background: #dcecd2; }
.ix-import { font-size: 12px; }

/* ---------------- toasts + armed (two-step) delete buttons */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { padding: 10px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-hover); font-size: 13px; transition: opacity .4s, transform .4s; }
.toast.error { border-color: #f5c2c2; background: #fdecec; color: #8f2424; }
.toast.ok { border-color: #bfe5d0; background: #e2f5ea; color: var(--ok); }
.toast.hide { opacity: 0; transform: translateY(6px); }
button.armed { background: var(--err) !important; border-color: var(--err) !important; color: #fff !important; width: auto !important; padding: 4px 12px !important; border-radius: 999px !important; font-size: 12px !important; }
.admin-back { text-decoration: none; font-weight: 600; color: var(--teal-700); padding: 9px 16px; border-radius: 999px; } .admin-back:hover { background: #f2f7ea; }
.skill-select { width: 100%; } .skill-desc { margin: 6px 0 0; min-height: 1em; }


/* ---------------- green + yellow accents */
.brand-mark svg path { fill: var(--yellow-400); }
.brand-mark { box-shadow: 0 4px 12px rgba(15, 74, 46, .25) !important; }
.progress div { background: linear-gradient(90deg, #f6c216, #2f9e5b) !important; }
.attach-btn { background: var(--grad-yellow) !important; border-color: transparent !important; color: var(--teal-700) !important; font-weight: 800; box-shadow: 0 4px 12px rgba(246, 194, 22, .45); }
.send-btn, #agent-form .send-btn { background: var(--grad-yellow) !important; color: var(--teal-700) !important; box-shadow: 0 6px 16px rgba(246, 194, 22, .45) !important; }
.pill-opt input:checked + span { background: var(--teal-700) !important; color: #fff !important; }
.mode-btn.active .mode-ico { background: var(--yellow-400) !important; color: var(--teal-700) !important; }
.mode-ico { background: var(--yellow-100) !important; color: var(--teal-700) !important; }
.badge.awaiting_review, .badge.waiting_user { background: var(--yellow-100); color: #7a5a06; }
.bubble.user { background: var(--teal-700) !important; }
h3 { color: var(--teal-700); }

/* =================================================================== mobile */
/* grid/flex children may shrink below their content width (prevents horizontal overflow) */
.cols > *, .card, .row > label, .grid2 > *, .color-field, .composer, fieldset { min-width: 0; }
.msg, pre, .file-list .fl-name, .chip-file span { overflow-wrap: anywhere; }
nav::-webkit-scrollbar { display: none; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  /* header: brand row + one horizontally scrollable nav row */
  .topbar-inner { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px 6px; }
  .brand-text small { display: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; gap: 2px; scrollbar-width: none;
        scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  nav button, nav a { flex: none; padding: 8px 14px; scroll-snap-align: start; }
  /* hero */
  .hero-inner { padding: 16px 16px 18px; }
  .hero h2 { font-size: 26px; margin: 10px 0 6px; }
  .hero p { font-size: 14px; }
  .hero-status { display: none; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .hero-feats { margin: 10px 0 0; gap: 6px; }
  .hero-feats li { font-size: 12px; padding: 3px 10px; }
  /* layout */
  main { padding: 4px 12px 32px; }
  .cols { gap: 14px; }
  .card { padding: 16px 14px; margin-bottom: 14px; border-radius: 14px; }
  .row { gap: 8px; }
  .row > label { flex: 1 1 140px; }
  .mode-switch { gap: 10px; margin-bottom: 14px; }
  .mode-btn { padding: 12px 14px; }
  /* agent composer + chat */
  .composer-hint { display: none; }
  .composer-bar { justify-content: space-between; }
  .chat-card { position: static; min-height: 420px; }
  .chat-log { max-height: 60vh; }
  .bubble { max-width: 94%; }
  .aspect-picker { gap: 6px; }
  .pill-opt span { padding: 7px 12px; }
  /* touch targets */
  input[type=checkbox] { width: 20px; height: 20px; }
  label.inline { min-height: 32px; }
  #admin-link a { display: inline-block; padding: 8px 0; }
  .list li { padding: 10px; }
  #toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* =================================================================== mascot */
.mascot { object-fit: contain; user-select: none; -webkit-user-drag: none; flex: none; }
.mascot.float { animation: mascot-float 3.2s ease-in-out infinite; }
@keyframes mascot-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .mascot.float { animation: none; } }
.mascot.inline { vertical-align: middle; margin-right: 2px; }
.mascot-block { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); padding: 12px 6px; }
.empty-li { justify-content: center !important; cursor: default !important; }
.empty-li:hover { background: none !important; border-color: transparent !important; }
.mode-ico { width: 52px !important; height: 52px !important; background: var(--yellow-100) !important; overflow: visible; }
.mode-ico .mascot { width: 52px; height: 52px; margin-top: -8px; }
.pill-mascot { margin: -6px 0 -6px -4px; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.with-mascot { display: flex; align-items: flex-end; gap: 6px; align-self: stretch; }
.with-mascot > .bubble, .with-mascot > .typing, .with-mascot > .ev-line { margin-bottom: 4px; }
.with-mascot .bubble.error { flex: 1; }
.done-line { align-items: center; }
.jd-head { display: flex; align-items: center; gap: 12px; }
.jd-head h2 { margin: 0; }
.h2-mascot { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.h2-mascot h2 { margin: 0; }
.toast { display: flex; align-items: center; gap: 8px; }
.toast-mascot { width: 40px; height: 40px; margin: -4px 0; }
.as-intro { display: flex; align-items: center; gap: 12px; }
.as-intro-mascot { width: 72px; height: 72px; }
.ml-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
@media (max-width: 960px) {
}
@media (max-width: 640px) {
  .with-mascot .mascot { width: 40px; height: 40px; }
  .as-intro { flex-direction: column; text-align: center; }
}

/* =================================================================== account menu */
.account { margin-left: auto; position: relative; flex: none; }
.acc-btn {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 12px 4px 4px; font: inherit; font-weight: 700; color: var(--teal-700); cursor: pointer;
}
.acc-btn:hover, .acc-btn[aria-expanded=true] { border-color: rgba(15,74,46,.35); box-shadow: 0 4px 12px rgba(15,74,46,.12); }
.acc-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--grad-yellow); color: var(--teal-700); font-size: 12px; font-weight: 800;
}
.acc-avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.acc-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-caret { font-size: 11px; opacity: .7; }
.acc-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 290px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-hover); padding: 8px; z-index: 30;
}
.acc-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 10px; }
.acc-head b { display: block; } .acc-head small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.acc-role { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 800; background: var(--teal-700); color: var(--yellow-400); border-radius: 999px; padding: 1px 8px; }
.acc-usage { background: var(--yellow-100); border-radius: 12px; padding: 8px 10px; margin: 0 0 6px; font-size: 13px; }
.acc-usage-top { display: flex; justify-content: space-between; gap: 8px; }
.acc-bar { height: 6px; border-radius: 3px; background: rgba(15,74,46,.12); margin-top: 6px; overflow: hidden; }
.acc-bar i { display: block; height: 100%; background: var(--teal-500); border-radius: 3px; }
.acc-bar i.warn { background: var(--warn); }
.acc-menu > button, .acc-menu > a {
  display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--fg);
  padding: 9px 10px; border-radius: 10px; cursor: pointer; text-decoration: none;
}
.acc-menu > button:hover, .acc-menu > a:hover { background: #f2f7ea; }
.acc-logout { color: var(--err) !important; }
.acc-dialog { border: 0; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-hover); width: min(400px, calc(100vw - 28px)); }
.acc-dialog::backdrop { background: rgba(15, 38, 27, .35); }
.acc-pw { padding: 20px 22px; }
.acc-pw h3 { margin: 0 0 12px; }
.acc-pw label { display: block; margin-bottom: 10px; font-weight: 600; }
.acc-pw label small { color: var(--muted); font-weight: 500; }
.acc-pw input { width: 100%; margin-top: 4px; }
.acc-actions { display: flex; justify-content: flex-end; gap: 8px; }
.auth-error { color: var(--err); font-size: 13px; font-weight: 600; min-height: 18px; margin: 4px 0 8px; }
@media (max-width: 640px) {
  .brand { order: 1; } .account { order: 2; } nav { order: 3; }
  .acc-name, .acc-caret { display: none; }
  .acc-btn { padding: 2px; }
  .acc-menu { width: min(290px, calc(100vw - 24px)); }
}

/* =================================================================== admin: users */
.ua-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ua-head h2 { margin: 0; }
.ua-new { display: flex; gap: 8px; flex-wrap: wrap; }
.ua-new input { min-width: 0; width: 210px; }
.ua-search { width: 100%; margin: 14px 0 10px; }
.ua-table-wrap { overflow-x: auto; }
.ua-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ua-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ua-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ua-table td small { display: block; color: var(--muted); }
.ua-table td b { display: block; }
.ua-table input[type=number] { width: 100px; }
.ua-usage { font-weight: 700; white-space: nowrap; }
.ua-act { white-space: nowrap; text-align: right; }
.ua-act button { margin-left: 4px; }
.ua-disabled td:not(.ua-act) { opacity: .5; }
.ua-secret { display: flex; gap: 8px; align-items: center; background: var(--yellow-100); border-radius: 10px; padding: 10px 12px; margin: 6px 0 14px; }
.ua-secret code { flex: 1; font-size: 16px; font-weight: 700; letter-spacing: .5px; overflow-wrap: anywhere; }

.queue-line { background: var(--yellow-100); border-radius: 12px; padding: 8px 12px; font-weight: 600; color: #7a5a06; }

.acc-usage-wrap .acc-usage + .acc-usage { margin-top: 6px; }
.acc-warn { display: block; color: var(--warn); font-weight: 600; margin-top: 4px; }
.jd-manage { gap: 8px; margin: 8px 0 0; }
button.danger-ghost { border-color: rgba(214, 69, 69, .35); color: var(--err); background: #fff; }
button.danger-ghost:hover { background: #fdf0f0; }
button.danger-ghost.armed { background: var(--err); color: #fff; }
