/* FlowSmart Desktop — themeable UI (two-axis token system: mode × accent)
   ---------------------------------------------------------------------------
   Redesign 2026-07-09 (Claude Design → "FlowSmart Redesign"). Tokens are driven
   on <html> by two attributes:  data-mode="dark|light"  ×  data-theme="purple|
   ocean|emerald|sunset|neutral".  See doc/UI-Redesign-DECISIONS.md.
   Old token NAMES (--bg-card, --accent-red, --radius, …) are preserved as an
   alias bridge at the bottom so all existing shell CSS keeps working. */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 100 700;
  src: url('material-symbols.woff2') format('woff2');
}
/* Be Vietnam Pro — friendly geometric sans w/ full Vietnamese diacritics */
@font-face { font-family:'Be Vietnam Pro'; font-style:normal; font-weight:400; font-display:swap; src:url('BeVietnamPro-Regular.ttf') format('truetype'); }
@font-face { font-family:'Be Vietnam Pro'; font-style:normal; font-weight:500; font-display:swap; src:url('BeVietnamPro-Medium.ttf') format('truetype'); }
@font-face { font-family:'Be Vietnam Pro'; font-style:normal; font-weight:600; font-display:swap; src:url('BeVietnamPro-SemiBold.ttf') format('truetype'); }
@font-face { font-family:'Be Vietnam Pro'; font-style:normal; font-weight:700; font-display:swap; src:url('BeVietnamPro-Bold.ttf') format('truetype'); }

/* ================================================================ 1 · MODE-INDEPENDENT TOKENS */
:root{
  --font-sans:"Be Vietnam Pro",-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;
  --font-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --fw-body:400; --fw-medium:500; --fw-semibold:600; --fw-bold:700;
  --fs-display:30px; --fs-title:22px; --fs-h2:18px; --fs-h3:16px;
  --fs-lg:14px; --fs-body:13px; --fs-label:12px; --fs-micro:11px; --fs-caption:10px;
  --lh-tight:1.2; --lh-body:1.55;
  --r-xs:6px; --r-sm:8px; --r-md:12px; --r-lg:16px; --r-xl:20px; --r-pill:999px;
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px; --s6:24px; --s7:32px; --s8:40px;
  --rail-w:240px; --rail-collapsed:68px; --topbar-h:52px; --toolbar-h:48px;
  --rpanel-w:300px; --bottomnav-h:60px;
  --ease:cubic-bezier(.2,.7,.2,1); --dur:.16s;
}

/* ================================================================ 2 · MODE AXIS · DARK (default) */
:root, [data-mode="dark"]{
  --bg-app:#0b0b10; --bg-sunken:#08080c; --bg-chrome:#0d0d12;
  --surface-1:#121218; --surface-2:#17171f; --surface-3:#1e1e28; --bg-media:#101014;
  --border-soft:#1c1c26; --border:#282833; --border-strong:#383844;
  --text-primary:#f3f3f7; --text-secondary:#a6a6b6; --text-tertiary:#84848f;
  --text-faint:#5c5c68; --text-on-accent:#ffffff;
  --success:#22b981; --success-text:#37d29a; --success-soft:rgba(34,185,129,.16);
  --warning:#f0a52e; --warning-text:#f5b544; --warning-soft:rgba(240,165,46,.16);
  --danger:#e5545f; --danger-text:#f2727c; --danger-soft:rgba(229,84,95,.16);
  --shadow-1:0 1px 2px rgba(0,0,0,.45); --shadow-2:0 6px 18px rgba(0,0,0,.45); --shadow-3:0 16px 40px rgba(0,0,0,.5);
  --overlay:rgba(4,4,8,.62); --scrollbar-thumb:rgba(255,255,255,.10); --scrollbar-hover:rgba(255,255,255,.20);
  color-scheme:dark;
}

/* ================================================================ 2 · MODE AXIS · LIGHT (new, warm off-white) */
[data-mode="light"]{
  --bg-app:#f6f5f2; --bg-sunken:#eceae4; --bg-chrome:#efece6;
  --surface-1:#ffffff; --surface-2:#ebe7dd; --surface-3:#ffffff; --bg-media:#e9e8e3;
  --border-soft:#eeece6; --border:#e1ded5; --border-strong:#cdcabf;
  --text-primary:#201f26; --text-secondary:#56545f; --text-tertiary:#74727d;
  --text-faint:#a4a2ab; --text-on-accent:#ffffff;
  --success:#0f9d6b; --success-text:#0b7d54; --success-soft:rgba(15,157,107,.12);
  --warning:#d68f1e; --warning-text:#8f5d0f; --warning-soft:rgba(214,143,30,.14);
  --danger:#d64550; --danger-text:#bf3742; --danger-soft:rgba(214,69,80,.10);
  --shadow-1:0 1px 2px rgba(28,26,45,.06); --shadow-2:0 6px 18px rgba(28,26,45,.08); --shadow-3:0 16px 40px rgba(28,26,45,.14);
  --overlay:rgba(28,26,40,.32); --scrollbar-thumb:rgba(20,18,40,.16); --scrollbar-hover:rgba(20,18,40,.30);
  color-scheme:light;
}

/* ================================================================ 3 · THEME AXIS · ACCENT RAMP (theme × mode) */
:root, [data-theme="purple"][data-mode="dark"], [data-mode="dark"]:not([data-theme]){
  --accent:#7B61FF; --accent-strong:#8f78ff; --accent-text:#a595ff; --accent-secondary:#d16be6; }
[data-theme="purple"][data-mode="light"], [data-mode="light"]:not([data-theme]){
  --accent:#6D55F0; --accent-strong:#5c43e0; --accent-text:#5a44cf; --accent-secondary:#c159d8; }
[data-theme="ocean"][data-mode="dark"]{
  --accent:#4F8CF5; --accent-strong:#6ba0f7; --accent-text:#7fb0f8; --accent-secondary:#38BDF8; }
[data-theme="ocean"][data-mode="light"]{
  --accent:#2F74E6; --accent-strong:#1f63d4; --accent-text:#1f63d4; --accent-secondary:#0e93cf; }
[data-theme="emerald"][data-mode="dark"]{
  --accent:#2FD39B; --accent-strong:#4fe0b0; --accent-text:#4fe0b0; --accent-secondary:#22D3EE; --text-on-accent:#04140d; }
[data-theme="emerald"][data-mode="light"]{
  --accent:#0F9D6B; --accent-strong:#0b855a; --accent-text:#0b7d54; --accent-secondary:#0a9bb0; }
[data-theme="sunset"][data-mode="dark"]{
  --accent:#F59E0B; --accent-strong:#ffb02e; --accent-text:#f7b23f; --accent-secondary:#FF5C5C; --text-on-accent:#1a1206; }
[data-theme="sunset"][data-mode="light"]{
  --accent:#D97706; --accent-strong:#b45f05; --accent-text:#9a5a08; --accent-secondary:#e5484d; --text-on-accent:#1a1206; }
[data-theme="neutral"][data-mode="dark"]{
  --accent:#B4B4C2; --accent-strong:#c9c9d4; --accent-text:#c7c7d2; --accent-secondary:#d4d4d8; --text-on-accent:#14141a; }
[data-theme="neutral"][data-mode="light"]{
  --accent:#44444F; --accent-strong:#33333c; --accent-text:#3a3a44; --accent-secondary:#6b6b76; }

/* Derived accent tokens — read live --accent, so they follow every theme */
:root, [data-mode]{
  --accent-softer:color-mix(in oklab,var(--accent) 8%,transparent);
  --accent-soft:color-mix(in oklab,var(--accent) 14%,transparent);
  --accent-border:color-mix(in oklab,var(--accent) 32%,transparent);
  --accent-glow:color-mix(in oklab,var(--accent) 34%,transparent);
  --gradient-accent:linear-gradient(135deg,var(--accent),var(--accent-secondary));
  --ring:0 0 0 3px color-mix(in oklab,var(--accent) 42%,transparent);
  /* Panel-boundary line (UI polish 2026-07-09): one token for every divider
     between major panels, deliberately more visible than --border-soft. */
  --panel-line:var(--border-strong);
}

/* ================================================================ 4 · LEGACY ALIAS BRIDGE
   Old token names kept so all pre-redesign shell CSS keeps resolving. Map onto
   the new two-axis tokens; they inherit the correct value per mode automatically. */
:root, [data-mode]{
  --bg-primary:var(--bg-app);
  --bg-card:var(--surface-1);
  --bg-hover:var(--surface-2);
  --bg-elevated:var(--surface-3);
  --bg-header:var(--bg-chrome);
  --bg-input:var(--surface-3);
  --accent-dim:var(--accent-strong);
  --accent-subtle:var(--accent-soft);
  --accent-green:var(--success);
  --accent-amber:var(--warning);
  --accent-red:var(--danger);
  --radius:var(--r-md);
  --radius-sm:var(--r-sm);
  --sidebar-w:220px;
  --rightpanel-w:234px;
  --tabbar-h:38px;
  --toolbar-h:46px;
  --statusbar-h:28px;
  --gradient-btn:var(--gradient-accent);
  --gradient-btn-hover:linear-gradient(135deg,var(--accent-strong),var(--accent-secondary));
}

/* ----------------------------------------------------------------- resets */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; background: transparent; border: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }
::-webkit-scrollbar-track { background: transparent; }


/* ----------------------------------------------------------------- layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
}

/* ---- Dev-mode performance bar (top strip, only when Settings → devMode is on) ---- */
.perf-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 26px; z-index: 9999;
  display: flex; align-items: center; gap: 10px; padding: 0 10px;
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #cbd5e1; background: rgba(10, 10, 15, 0.96);
  border-bottom: 1px solid var(--border-soft); backdrop-filter: blur(6px);
  white-space: nowrap; overflow-x: auto; overflow-y: hidden; user-select: text;
}
.perf-bar::-webkit-scrollbar { height: 0; }
.perf-bar .pf-tag { color: #7c6cf5; font-weight: 800; letter-spacing: .5px; }
.perf-bar .pf-item { display: inline-flex; align-items: center; gap: 4px; }
.perf-bar .pf-item b { color: #f1f5f9; font-weight: 700; }
.perf-bar .pf-sep { color: #475569; }
.perf-bar .pf-warn b { color: #fbbf24; }
.perf-bar .pf-hot b { color: #f87171; }
.perf-bar .pf-x { margin-left: auto; color: #94a3b8; font-weight: 800; padding: 0 4px; }
.perf-bar .pf-x:hover { color: #f87171; }
body.perf-on .app { height: calc(100vh - 26px); margin-top: 26px; }
/* macOS hiddenInset traffic-lights float at top-left over web content → pad the bar so its text
   clears them (the OS still draws the buttons on top of the bar's background, which is fine). */
body.os-darwin .perf-bar { padding-left: 82px; -webkit-app-region: drag; }
body.os-darwin .perf-bar .pf-item, body.os-darwin .perf-bar .pf-x, body.os-darwin .perf-bar .pf-tag { -webkit-app-region: no-drag; }

/* ----------------------------------------------------------------- sidebar */
.sidebar {
  background: var(--bg-header);
  border-right: 1px solid var(--panel-line);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
  overflow-y: auto;
  position: relative;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 50;
  transition: background 0.2s;
}
.sidebar-resizer:hover {
  background: var(--accent);
}
body.os-darwin .sidebar {
  padding-top: 36px;
}
.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 6px 8px 14px;
  -webkit-app-region: drag;
  display: flex;
  align-items: center;
  gap: 7px;
}
.logo-mark { flex: none; display: block; }
.logo .flow { color: var(--text-primary); }
.logo .smart { color: var(--accent); }
.logo .ver {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary, #888);
  margin-left: 6px;
  letter-spacing: 0;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  padding: 14px 10px 6px;
  font-weight: 700;
}
/* Collapsible WORKER ACCOUNTS header (toggles #viewer-list; "Add account" stays visible) */
.nav-label-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 8px;
  user-select: none;
}
.nav-label-toggle:hover { color: var(--text-secondary); background: rgba(255,255,255,0.03); }
.nav-label-toggle .nav-chevron { font-size: 11px; transition: transform 0.2s ease; opacity: 0.7; }
body.workers-collapsed #viewer-list { display: none; }
body.workers-collapsed .nav-label-toggle .nav-chevron { transform: rotate(-90deg); }
/* Worker list scrolls on its own (≈5 cards visible); the rest of the sidebar — Add account,
   Activity, Settings — stays put instead of the whole rail scrolling. */
#viewer-list { max-height: 320px; overflow-y: auto; overflow-x: hidden; flex: none; }
#viewer-list::-webkit-scrollbar { width: 6px; }
#viewer-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#viewer-list::-webkit-scrollbar-thumb:hover { background: var(--border-strong, #555); }

/* ---- Live generation-activity panel (sidebar) ---- */
.gen-activity {
  margin: 10px 6px 0; padding: 8px; border-radius: 12px;
  background: rgba(255,255,255,0.025); border: 1px solid var(--border-soft, rgba(255,255,255,0.06));
  display: flex; flex-direction: column; min-height: 0;
}
.ga-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 9.5px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--text-tertiary, #8a8a9a); padding: 2px 4px 8px;
}
.ga-clear { cursor: pointer; opacity: 0.55; font-size: 11px; padding: 0 4px; border-radius: 6px; }
.ga-clear:hover { opacity: 1; background: rgba(255,255,255,0.06); }
.ga-list { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; min-height: 0; max-height: 255px; }
.ga-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 7px; border-radius: 9px;
  background: rgba(255,255,255,0.03); border-left: 2px solid transparent;
}
.ga-item.running { border-left-color: var(--accent, #7c6cf5); }
.ga-item.done    { border-left-color: #34d399; }
.ga-item.failed  { border-left-color: #f87171; }
.ga-item.ga-clickable { cursor: pointer; }
.ga-item.ga-clickable:hover { background: color-mix(in srgb, var(--accent-red, #e05260) 16%, rgba(255,255,255,0.03)); }
/* spotlight a history card jumped-to from the Activity panel */
.qh-card.qh-flash, .queue-item.qh-flash { animation: qhFlash 2.2s ease-out; }
@keyframes qhFlash {
  0%, 18% { box-shadow: 0 0 0 2px var(--accent, #7c6cf5), 0 0 16px color-mix(in srgb, var(--accent, #7c6cf5) 60%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.ga-item.ga-more { justify-content: center; font-size: 10px; font-weight: 700; color: var(--text-tertiary, #8a8a9a); background: transparent; padding: 3px 7px; }
.ga-cd { flex: 0 0 auto; margin-left: auto; font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-tertiary, #8a8a9a); background: rgba(255,255,255,0.05); border-radius: 6px; padding: 1px 5px; opacity: 0.75; }
body.sidebar-collapsed .ga-cd { display: none; }
.ga-ic { width: 16px; flex: 0 0 16px; text-align: center; font-size: 12px; }
.ga-ok { color: #34d399; font-weight: 900; }
.ga-bad { color: #f87171; font-weight: 900; }
.ga-wait { color: var(--accent, #7c6cf5); font-weight: 900; }
.ga-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.ga-label { font-size: 11.5px; font-weight: 700; color: var(--text-primary, #eee); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ga-sub { font-size: 9.5px; color: var(--text-tertiary, #8a8a9a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ga-spin {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid rgba(124,108,245,0.25); border-top-color: var(--accent, #7c6cf5);
  animation: ga-spin 0.7s linear infinite;
}
@keyframes ga-spin { to { transform: rotate(360deg); } }
/* Collapsed sidebar → show only the status dots */
body.sidebar-collapsed .gen-activity { margin: 8px 4px 0; padding: 6px 4px; }
body.sidebar-collapsed .ga-head, body.sidebar-collapsed .ga-body { display: none; }
body.sidebar-collapsed .ga-item { justify-content: center; padding: 5px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-secondary));
}
.nav-item .ico { width: 17px; text-align: center; opacity: 0.9; font-size: 14px; }
.nav-item .badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.4px;
}
.badge-ultra { background: var(--accent-subtle); color: var(--accent); }
.badge-new { background: rgba(29,158,117,0.18); color: var(--accent-green); }

/* Content-agent notice dot on the Workspace nav item: pulsing while the AI turn runs in the
   background (tab switched away), solid green when it finishes. Cleared on opening Workspace. */
.nav-item .agent-badge-dot {
  margin-left: auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}
.nav-item .agent-badge-dot.running { background: var(--accent, #7c6cf5); animation: agentDotPulse 1.1s ease-in-out infinite; }
.nav-item .agent-badge-dot.done { background: var(--accent-green, #22c55e); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
@keyframes agentDotPulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
body.sidebar-collapsed .nav-item .agent-badge-dot { position: absolute; top: 6px; right: 6px; margin: 0; }

.nav-divider { height: 1px; background: var(--border-soft); margin: 10px 6px; }

/* viewer list inside sidebar */
.viewer-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}
.viewer-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.viewer-item.active { background: var(--bg-hover); color: var(--text-primary); }
.viewer-item .vname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-item .vmeta { margin-left: auto; font-size: 10px; color: var(--text-tertiary); }
/* Worker item: name row + a small info row (connection / plan / credits / id). */
.worker-item { align-items: flex-start; }
.worker-item .dot { margin-top: 5px; }
.worker-item .vmeta { margin-top: 2px; }
.wk-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.wk-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wk-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.wk-sub > span {
  font-size: 9px; font-weight: 700; line-height: 1; letter-spacing: .02em;
  padding: 2px 6px; border-radius: 999px; border: 1px solid var(--border, rgba(255,255,255,.08));
  color: var(--text-tertiary); white-space: nowrap;
}
/* Connection mark BEFORE the worker name: green ✓ = connected, muted ✗ = logged out.
   flex:none keeps it fixed so the long name truncates instead of hiding the mark. */
.wk-verified { font-size: 11px; line-height: 1; flex: none; cursor: help; }
.wk-verified.on { color: var(--accent-green); }
.wk-verified.off { color: var(--text-tertiary); }
.wk-name-row .vname { flex: 1 1 auto; min-width: 0; }
.wk-plan { color: var(--accent-amber); border-color: color-mix(in srgb, var(--accent-amber) 40%, transparent); text-transform: uppercase; }
.wk-cr { color: var(--accent-green); border-color: color-mix(in srgb, var(--accent-green) 30%, transparent); }
.wk-id { color: var(--text-tertiary); font-family: ui-monospace, monospace; }
.wk-email { font-size: 10px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ico-lab { font-size: 13px; flex: none; filter: hue-rotate(0deg); }
.viewer-item.flowsmart-launch {
  background: linear-gradient(90deg, rgba(124,108,245,0.14), rgba(217,108,232,0.05));
  border: 1px solid var(--accent-border);
  margin-bottom: 6px; font-weight: 600; color: var(--text-primary);
}
.viewer-item.flowsmart-launch:hover { background: linear-gradient(90deg, rgba(124,108,245,0.24), rgba(217,108,232,0.1)); }
.viewer-item.flowsmart-launch .ico-lab { color: var(--accent); }

.add-viewer {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin-top: 2px;
  border-radius: var(--radius-sm);
  color: var(--accent); font-weight: 600; font-size: 12.5px;
  border: 1px dashed var(--border);
}
.add-viewer:hover { background: rgba(124,108,245,0.08); }

.sidebar-spacer { flex: 1; }

.worker-item.selected-gen {
  box-shadow: inset 0 0 0 1px var(--accent);
  background: rgba(124,108,245,0.08);
}
.worker-item.selected-gen.selected-gen-red {
  box-shadow: inset 0 0 0 1px var(--accent-red, #e05260);
  background: rgba(224,82,96,0.12);
}

/* status dots */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-ready { background: var(--accent-green); }
/* Faint halo on an idle, connected worker so the status dot reads as "live" on its own
   (the old ✓ pill is gone). Generating keeps its pulse; other states keep their flat color. */
.dot-ready.connected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-green) 16%, transparent); }
.dot-generating { background: var(--accent); box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 1.4s infinite; }
.dot-cooldown { background: var(--accent-amber); }
.dot-low_credits { background: var(--accent-amber); }
.dot-logged_out, .dot-offline { background: #44445a; }
.dot-unusual { background: var(--accent-red, #e5484d); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  70% { box-shadow: 0 0 0 6px rgba(124,108,245,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,108,245,0); }
}

/* ----------------------------------------------------------------- center */
.center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
  position: relative;
}

/* tab bar */
.tabbar {
  height: var(--tabbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid var(--panel-line);
  overflow-x: auto;
  background: var(--bg-header);
}
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px;
  border-radius: 7px 7px 0 0;
  color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  max-width: 180px; white-space: nowrap;
}
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab.active { background: var(--bg-card); color: var(--text-primary); }
.tab .tclose { opacity: 0.5; font-size: 13px; padding: 0 2px; }
.tab .tclose:hover { opacity: 1; color: var(--accent-red); }
.tab-hint { color: var(--text-tertiary); font-size: 11px; padding-left: 6px; }

/* toolbar */
.toolbar {
  height: var(--toolbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--panel-line);
  background: var(--bg-header);
}
.tb-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: transparent; border: none;
  color: var(--text-secondary); font-size: 14px;
}
.tb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tb-btn:disabled { opacity: 0.3; cursor: default; }
.btn-login-popup { color: var(--accent-amber); }
.urlbar {
  flex: 1;
  height: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 0 12px;
  font-size: 12px;
  outline: none;
}
.urlbar:focus { border-color: var(--accent); color: var(--text-primary); }
.acc-select {
  height: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary); padding: 0 8px; font-size: 12px; outline: none;
  max-width: 170px;
}

/* content area */
.content {
  flex: 1;
  position: relative;
  overflow: hidden;
}
/* where the BrowserView is positioned (kept empty, measured for bounds) */
#viewer-host {
  position: absolute;
  inset: 0;
  display: none;
}
#viewer-host.show { display: block; }
.viewer-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-secondary);
}
.viewer-empty .big { font-size: 40px; opacity: 0.4; }

/* scrollable pages (dashboard / accounts / queue / settings) */
.page {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 22px 26px;
  display: none;
}
.page.show { display: block; }
.page-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-secondary); font-size: 12.5px; margin-bottom: 20px; }

/* status bar */
.statusbar {
  height: var(--statusbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  border-top: 1px solid var(--panel-line);
  background: var(--bg-header);
  color: var(--text-secondary);
  font-size: 11px;
}
.statusbar .sb-sep { color: var(--text-tertiary); }
.statusbar .sb-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ----------------------------------------------------------------- cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}
.stat-card .label { color: var(--text-secondary); font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 8px; }
.stat-card .value.accent { background: linear-gradient(90deg, var(--accent), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card .sub { color: var(--text-tertiary); font-size: 11px; margin-top: 4px; }

.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-secondary);
  margin: 6px 0 12px; display: flex; align-items: center; gap: 10px;
}
.section-title .count { color: var(--text-tertiary); font-weight: 600; }

/* account row card */
.acc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  flex: none;
}
.acc-info { min-width: 0; flex: none; width: 190px; }
.acc-info .nm { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.acc-info .em { color: var(--text-secondary); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Settings page: setting descriptions must show in FULL (wrap), not truncate with "…" like the
   fixed-width account-card emails this class is shared with. Scoped to #page-settings only. */
#page-settings .acc-info { width: auto; flex: 1 1 auto; }
#page-settings .acc-info .em { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.45; }
#page-settings .acc-card > div:first-child { flex: 1; min-width: 0; padding-right: 16px; }
.credit-wrap { flex: 1; min-width: 90px; }
.credit-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); margin-bottom: 5px; }
.credit-bar { height: 7px; background: #1d1d2a; border-radius: 5px; overflow: hidden; }
.credit-fill { height: 100%; border-radius: 5px; transition: width 0.3s; }
.credit-fill.hi { background: var(--accent-green); }
.credit-fill.mid { background: var(--accent-amber); }
.credit-fill.lo { background: var(--accent-red); }
.status-badge {
  font-size: 10.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  display: flex; align-items: center; gap: 6px; flex: none; text-transform: capitalize;
}
.sb-ready { background: rgba(29,158,117,0.15); color: var(--accent-green); }
.sb-generating { background: var(--accent-subtle); color: var(--accent); }
.sb-cooldown, .sb-low_credits { background: rgba(239,159,39,0.15); color: var(--accent-amber); }
.sb-logged_out { background: rgba(120,120,140,0.15); color: var(--text-secondary); }
.sb-unusual { background: rgba(229,72,77,0.15); color: var(--accent-red, #e5484d); }
/* width:100% + order:1 forces these onto their own full-width row BELOW the card's
   main flex row (the card is flex-wrap:wrap; actions keep order:0 so they stay up top). */
.acc-err { width: 100%; order: 1; margin-top: 4px; font-size: 11px; line-height: 1.3;
  color: var(--accent-red, #e5484d); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Sticky "unusual activity" flag: persists until cleared, with timestamp + dismiss. */
.acc-flag { width: 100%; order: 1; margin-top: 4px; display: flex; align-items: center; gap: 8px;
  font-size: 11px; line-height: 1.3; padding: 5px 8px; border-radius: 6px;
  background: rgba(229,72,77,0.12); border: 1px solid rgba(229,72,77,0.35); }
.acc-flag-msg { flex: 1; min-width: 0; color: var(--accent-red, #e5484d);
  overflow: hidden; text-overflow: ellipsis; white-space: normal; }
.acc-flag-time { color: var(--text-secondary); }
.acc-flag-clear { flex: none; padding: 3px 10px; font-size: 11px;
  color: var(--accent-red, #e5484d); border-color: rgba(229,72,77,0.5); }
.acc-actions { display: flex; gap: 6px; flex: none; }

/* Incognito manual-login recovery block (auto_failed → manual_open → manual_active|manual_failed) */
.acc-incog { width: 100%; order: 1; margin-top: 4px; padding: 7px 9px; border-radius: 7px;
  font-size: 11px; line-height: 1.35; background: rgba(124,108,245,0.10); border: 1px solid rgba(124,108,245,0.35); }
.acc-incog-manual_active { background: rgba(80,200,140,0.10); border-color: rgba(80,200,140,0.40); }
.acc-incog-manual_failed { background: rgba(229,72,77,0.10); border-color: rgba(229,72,77,0.40); }
.acc-incog-note { color: var(--text-secondary); margin-bottom: 6px; }
.acc-incog-manual_active .acc-incog-note { color: var(--accent-green, #50c88c); }
.acc-incog-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-incog-btns .btn { padding: 3px 10px; font-size: 11px; }
.acc-incog-go { color: var(--accent, #7c6cf5); border-color: rgba(124,108,245,0.5); }

/* ----------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 600;
  transition: background 0.12s, border 0.12s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--bg-hover); border-color: #3a3a55; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--accent-red); }
.btn-danger:hover { background: rgba(224,82,96,0.1); border-color: var(--accent-red); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-icon { padding: 6px 8px; }

/* ----------------------------------------------------------------- right panel */
.rightpanel {
  background: var(--bg-header);
  border-left: 1px solid var(--panel-line);
  display: flex; flex-direction: column;
  overflow-y: auto;
  padding: 14px 13px;
}
.rp-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-tertiary); margin: 4px 2px 10px;
}
.rp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px;
}
.rp-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rp-row:last-child { margin-bottom: 0; }
.rp-row .k { color: var(--text-secondary); font-size: 12px; }

/* toggle switch */
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: #25253a; border-radius: 20px; transition: 0.18s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: 0.18s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(17px); }

.rp-select, .rp-input {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text-primary); padding: 7px 9px; font-size: 12px; outline: none;
}
.rp-select:focus, .rp-input:focus { border-color: var(--accent); }
.field-label { font-size: 11px; color: var(--text-secondary); margin: 8px 0 5px; font-weight: 600; }

/* theme picker */
.theme-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  background: var(--bg-elevated); border: 2px solid transparent;
  transition: all 0.2s ease;
}
.theme-chip:hover { background: var(--bg-hover); border-color: var(--border); }
.theme-chip.active { border-color: var(--accent); background: var(--accent-subtle); }
.theme-dot {
  width: 18px; height: 18px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.theme-chip.active .theme-dot {
  box-shadow: 0 2px 12px var(--accent-glow);
}
.theme-label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.theme-chip.active .theme-label { color: var(--text-primary); }

/* Light / dark mode segmented toggle (Appearance) */
.mode-seg { display: inline-flex; gap: 3px; padding: 3px; background: var(--bg-hover); border: 1px solid var(--border-soft); border-radius: var(--r-sm); }
.mode-opt { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: transparent; border: none; cursor: pointer; transition: all .16s ease; }
.mode-opt .ico { font-family: 'Material Symbols Outlined'; font-size: 17px; line-height: 1; }
.mode-opt:hover { color: var(--text-primary); }
.mode-opt.active { background: var(--accent); color: var(--text-on-accent); }

/* ============================================================================
   PHASE-2 (v2) — Settings screen refinement (data-layout="v2", scoped to
   #page-settings only, so other vanilla pages keep the classic look).
   CSS-only restyle of the existing markup to match redesign/screen-settings.html:
   deeper row cards, larger title, tuned section headers + theme chips.
   styles.css is static-linked → ⌘R only, no rebuild.
   ============================================================================ */
[data-layout="v2"] #page-settings { max-width: 860px; }
[data-layout="v2"] #page-settings .page-title { font-size: var(--fs-title); letter-spacing: -0.01em; }
[data-layout="v2"] #page-settings .page-sub { font-size: var(--fs-label); }
[data-layout="v2"] #page-settings .section-title {
  font-size: var(--fs-label); letter-spacing: 0.05em;
  color: var(--text-tertiary); margin: 24px 0 12px;
}
[data-layout="v2"] #page-settings .acc-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
}
[data-layout="v2"] #page-settings .acc-card:hover { border-color: var(--border); }
[data-layout="v2"] #page-settings .theme-chip { border-radius: var(--r-sm); }
[data-layout="v2"] #page-settings .theme-chip.active { background: var(--accent-soft); }
[data-layout="v2"] #page-settings .mode-seg { background: var(--surface-2); }

/* ============================================================================
   PHASE-2 (v2) — vanilla DATA screens refinement (Thư viện / Hàng đợi / Tài khoản).
   Same safe CSS-only pattern as Settings v2, extended to the other vanilla pages
   so v2 desktop coverage is consistent with redesign/screen-{gallery,queue,accounts}.
   Shared classes (page-title/page-sub/section-title + card classes) → mockup
   typography + gentle card depth. No max-width (these are full-width grids).
   styles.css static-linked → ⌘R only, no rebuild.
   ============================================================================ */
[data-layout="v2"] #page-gallery .page-title,
[data-layout="v2"] #page-queue .page-title,
[data-layout="v2"] #page-accounts .page-title { font-size: var(--fs-title); letter-spacing: -0.01em; }
[data-layout="v2"] #page-gallery .page-sub,
[data-layout="v2"] #page-queue .page-sub,
[data-layout="v2"] #page-accounts .page-sub { font-size: var(--fs-label); }
[data-layout="v2"] #page-gallery .section-title,
[data-layout="v2"] #page-queue .section-title,
[data-layout="v2"] #page-accounts .section-title {
  font-size: var(--fs-label); letter-spacing: 0.05em; color: var(--text-tertiary);
}
/* Gentle card depth + unified radius on the pages' cards, matching the mockups'
   "cards carry --shadow-1" language. Additive (keeps each card's own bg/border). */
[data-layout="v2"] #page-gallery .g-card,
[data-layout="v2"] #page-queue .qh-card,
[data-layout="v2"] #page-queue .acc-card,
[data-layout="v2"] #page-accounts .acc-card,
[data-layout="v2"] #page-accounts .stat-card,
[data-layout="v2"] #page-accounts .usage-card {
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

/* ============================================================================
   PHASE-2 (v2) — app-wide cosmetic refinement (data-layout="v2").
   Applies to BOTH shells (vanilla + the React studios' Tailwind output, which
   this file is loaded alongside). COSMETIC ONLY — no markup / handler / layout
   change, so zero generation risk. Encodes the two DECISIONS-doc levers:
   "subtle softness" (calm oversized corners) + "premium warm light" (card depth).
   The [data-layout="v2"] ancestor gives these higher specificity than the bare
   Tailwind utility, so they win regardless of stylesheet order.
   ============================================================================ */
/* 1 · Subtle radius unification — tame the oversized studio corners to --r-lg (16px) */
[data-layout="v2"] .rounded-3xl,
[data-layout="v2"] .rounded-\[2rem\],
[data-layout="v2"] .rounded-\[32px\] { border-radius: var(--r-lg); }

/* 2 · Premium light elevation — real cards get gentle depth on the warm-white page.
   bg-surface = the card/panel surface across dashboard + studios. Light-only so the
   dark look is untouched (dark drop-shadows read as noise on near-black anyway). */
[data-layout="v2"][data-mode="light"] .bg-surface { box-shadow: var(--shadow-1); }

/* ============================================================================
   PHASE-2 (v2) — SHELL RAIL refinement + responsive (data-layout="v2").
   Brings the vanilla shell's sidebar / nav / statusbar into the `.fs-rail`
   visual language (see src/fs-components.css) so the chrome matches the v2
   Dashboard/Settings screens. CSS-ONLY, scoped to the v2 flag → classic shell
   untouched, ⌘R only (no build). Closes the "rail/worker-bar/statusbar restyle
   to .fs-rail spec is NOT done yet" item in UI-Redesign-STATUS.
   ============================================================================ */
/* Nav items → .fs-navitem spec: calmer padding, solid accent-soft active state
   with a solid (not gradient) accent tick, brighter icons. */
[data-layout="v2"] .nav-item { padding: 9px 11px; gap: 11px; border-radius: var(--r-sm); }
[data-layout="v2"] .nav-item .ico { font-size: 16px; width: 20px; opacity: 1; }
[data-layout="v2"] .nav-item.active {
  background: var(--accent-soft); color: var(--accent-text); font-weight: 600;
}
[data-layout="v2"] .nav-item.active::before {
  top: 8px; bottom: 8px; background: var(--accent);
}
/* Section labels → fs-navlabel letter-spacing/weight. */
[data-layout="v2"] .nav-label { letter-spacing: 0.09em; font-weight: 700; padding: 14px 11px 6px; }
[data-layout="v2"] .nav-divider { background: var(--border-soft); margin: var(--s3, 10px) var(--s2, 6px); }
/* Statusbar → fs-statusbar: quieter tertiary text on chrome. */
[data-layout="v2"] .statusbar { color: var(--text-tertiary); background: var(--bg-chrome); }
[data-layout="v2"] .statusbar .sb-sep { color: var(--border-strong); }
/* Worker-selection bar → align to chrome + soft divider like fs-topbar. */
[data-layout="v2"] .ws-bar { background: var(--bg-chrome); border-bottom-color: var(--border-soft); }

/* --- Mobile bottom-nav + rail drawer (web / PWA build). Base = hidden at every
   width so desktop is untouched; the @media below reveals them under v2 only. */
.mobile-nav, .rail-drawer-backdrop { display: none; }
.mobile-nav .nav-item, .mobile-nav .mnav-item {
  flex-direction: column; gap: 3px; flex: 1; justify-content: center;
  padding: 6px 2px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--text-tertiary); font-size: 9.5px; font-weight: 600; min-width: 0;
}
.mobile-nav .nav-item .ico { width: auto; font-size: 22px; opacity: 1; }
.mobile-nav .nav-item:hover { background: transparent; color: var(--text-secondary); }
.mobile-nav .nav-item.active { background: transparent; color: var(--accent-text); }
.mobile-nav .nav-item.active::before { display: none; }
.mobile-nav .mnav-lbl { line-height: 1; }

/* --- Responsive: narrow viewports (web / PWA) reflow to a single column with a
   fixed bottom-nav; the full rail becomes an off-canvas drawer opened by "Thêm".
   Scoped to v2 so the desktop Electron window (always wide, defaults to classic)
   is never affected — matches redesign/screen-video-studio.html narrow mode. */
@media (max-width: 860px) {
  [data-layout="v2"] .app { grid-template-columns: 1fr; }
  /* Rail → off-canvas drawer. position:fixed lifts it out of the grid. */
  [data-layout="v2"] .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 200;
    transform: translateX(-100%); transition: transform 0.24s var(--ease, ease);
    box-shadow: var(--shadow-3);
  }
  [data-layout="v2"] .sidebar-resizer { display: none; }
  [data-layout="v2"] #rail-drawer-cb:checked ~ .app .sidebar { transform: none; }
  [data-layout="v2"] #rail-drawer-cb:checked ~ .rail-drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 150;
    background: var(--overlay, rgba(0,0,0,0.5));
  }
  /* Bottom-nav visible; statusbar is desktop chrome → hide it under the nav. */
  [data-layout="v2"] .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 58px; z-index: 140;
    align-items: stretch; gap: 2px; padding: 4px 6px;
    background: var(--bg-chrome); border-top: 1px solid var(--border-soft);
  }
  [data-layout="v2"] .statusbar { display: none; }
  /* Keep page content clear of the fixed bottom-nav. */
  [data-layout="v2"] .content { padding-bottom: 58px; }
}

/* ============================================================================
   PHASE-2 (v2) — STUDIO overlay (direction #1, data-layout="v2").
   Brings the Video/Image React studios toward the redesign/screen-video-studio
   mockup look WITHOUT touching JSX or gen wiring — pure cosmetic overrides of the
   Tailwind utility classes those views already emit (this file loads alongside
   flowsmart-tw.css; the [data-layout="v2"] ancestor out-specifies the bare
   single-class utilities, so no !important needed). Keeps the batch multi-prompt
   editor. CSS-only → ⌘R only; verify the studios on the real running app.
   ============================================================================ */
/* 1 · Calm the heavy drop-shadows to the token scale. The studios stack
   shadow-lg/xl/2xl (heavy, "app-y"); the mockup uses gentle --shadow-1/2. This is
   the biggest single delta toward the mockup and encodes the DECISIONS "subtle"
   lever. Cosmetic + reversible; applies app-wide in v2 for one calm shadow system. */
[data-layout="v2"] .shadow-lg { box-shadow: var(--shadow-1); }
[data-layout="v2"] .shadow-xl { box-shadow: var(--shadow-2); }
[data-layout="v2"] .shadow-2xl { box-shadow: var(--shadow-2); }
/* 2 · Composer / prompt / config surfaces → mockup composer feel: real card
   surface, soft border, gentle depth in BOTH modes (the earlier refinement only
   lifted light). Targets the studios' `bg-surface border` cards. */
[data-layout="v2"] .flowsmart-root .bg-surface.border,
[data-layout="v2"] .flowsmart-root .bg-surface.border-line-soft { box-shadow: var(--shadow-1); }
/* 3 · Gradient generate button → mockup hover glow (base stays calm from §1). */
[data-layout="v2"] .flowsmart-root .gradient-button:hover,
[data-layout="v2"] .flowsmart-root .bg-gradient-to-r.from-accent:hover { box-shadow: 0 8px 28px var(--accent-glow); }


/* queue items */
.queue-item {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 9px 10px; margin-bottom: 8px;
  /* With hundreds of queued cards, laying out + painting every one on each re-render is the
     jank. content-visibility:auto makes the browser skip all rendering work for cards outside
     the viewport (they still exist in the DOM for search/drag); contain-intrinsic-size 'auto'
     remembers each card's last real height so the scrollbar stays accurate. */
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
}
/* ===== Wave / delay indicator (queue stats) ===== */
.q-wavebar { margin: 12px 2px 2px; }
.q-wavebar-label { font-size: 11.5px; font-weight: 800; letter-spacing: .2px; margin-bottom: 6px; }
.q-wavebar-track { position: relative; height: 9px; border-radius: 6px; background: rgba(255,255,255,0.07); overflow: hidden; }
.q-wavebar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; width: 0; }
/* RUNNING: translucent segment = launched/generating, solid segment (on top) = finished */
.mode-run .q-wavebar-run { background: var(--accent-subtle, rgba(124,108,245,.32)); transition: width .45s ease; }
.mode-run .q-wavebar-done { background: linear-gradient(90deg, var(--accent, #7c6cf5), #a78bfa); transition: width .45s ease; box-shadow: 0 0 8px rgba(124,108,245,.5); }
.mode-run .q-wavebar-label { color: var(--accent, #7c6cf5); }
/* the running-ahead portion gently pulses so it reads as "in progress" */
.mode-run .q-wavebar-run::after { content: ''; position: absolute; inset: 0; border-radius: 6px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  animation: qWaveShimmer 1.4s ease-in-out infinite; }
@keyframes qWaveShimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
/* DELAY: single GREEN bar shrinking from full → empty (countdown); 1s linear = smooth tick */
.mode-delay .q-wavebar-run { background: linear-gradient(90deg, #10b981, #34d399); transition: width 1s linear; box-shadow: 0 0 8px rgba(52,211,153,.5); }
.mode-delay .q-wavebar-done { display: none; }
.mode-delay .q-wavebar-label { color: var(--accent-green, #34d399); }

.q-more-btn { display: block; width: 100%; margin: 4px 0 12px; padding: 9px; text-align: center;
  background: var(--bg-card); border: 1px dashed var(--border-soft); border-radius: 8px;
  color: var(--text-secondary); font-weight: 700; font-size: 12px; }
.q-more-btn:hover { color: var(--accent); border-color: var(--accent-border, rgba(124,108,245,.4)); }
.queue-item .qp { font-size: 12px; line-height: 1.35; max-height: 34px; overflow: hidden; }
.queue-item .qmeta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 10.5px; color: var(--text-tertiary); }
.qstatus { font-weight: 700; padding: 2px 7px; border-radius: 12px; text-transform: capitalize; }
.qs-waiting { background: rgba(120,120,140,0.15); color: var(--text-secondary); }
.qs-assigned, .qs-generating { background: var(--accent-subtle); color: var(--accent); }
.qs-done { background: rgba(29,158,117,0.15); color: var(--accent-green); }
.qs-failed { background: rgba(224,82,96,0.15); color: var(--accent-red); }

/* ===== Queue & History center ===== */
.q-stats { justify-content: space-between; align-items: center; }
.q-stats b { font-size: 18px; }
.q-stats b.okc { color: var(--accent-green, #34d399); }
.q-stats b.badc { color: var(--accent-red, #f87171); }
.q-flag-note { align-self: center; font-size: 11.5px; font-weight: 700; color: var(--accent-red, #f87171); background: color-mix(in srgb, var(--accent-red, #e05260) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent-red, #e05260) 30%, transparent); padding: 5px 10px; border-radius: 999px; }
.q-retry { display: flex; flex-direction: column; gap: 2px; }
.q-retry input { width: 56px; background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-primary); border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.queue-item.editing { border-color: var(--accent-border, rgba(124,108,245,.4)); }

/* queue control bar (conc / delay / auto-retry / countdown / start-pause) */
.q-ctrls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.q-ctrl { display: flex; flex-direction: column; gap: 2px; }
.q-ctrl input, .q-ctrl select { width: 72px; background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-primary); border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.q-ctrl select { width: 84px; }
.q-countdown { font-size: 12px; font-weight: 800; color: var(--accent, #7c6cf5); background: var(--accent-subtle, rgba(124,108,245,.12)); padding: 4px 10px; border-radius: 12px; align-self: center; }
.q-formbar { display: flex; justify-content: flex-end; margin: 4px 0 10px; }

/* pending cards: prompt + config chips + per-card inline editor */
.queue-item .qp { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px; max-height: none; }
.queue-item .qp-sub { font-size: 11px; color: var(--text-tertiary); line-height: 1.35; max-height: 30px; overflow: hidden; margin-top: 2px; }
.queue-item.q-running { border-color: var(--accent-border, rgba(124,108,245,.45)); }
.queue-item.q-studio { border-style: dashed; opacity: .92; }
.q-src { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--text-tertiary); border: 1px solid var(--border-soft); border-radius: 8px; padding: 1px 6px; }
.q-chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.q-chip { font-size: 10px; font-weight: 700; color: var(--text-secondary); background: var(--bg-elevated, rgba(255,255,255,.05)); border: 1px solid var(--border-soft); border-radius: 8px; padding: 1px 7px; white-space: nowrap; }
.q-chip-off { color: var(--text-tertiary); opacity: .65; }
.q-acc { font-size: 10.5px; color: var(--text-tertiary); }
.q-erow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.q-f { display: flex; flex-direction: column; gap: 2px; min-width: 120px; flex: 1; }
.q-f input, .q-f select { background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-primary); border-radius: 8px; padding: 6px 8px; font-size: 12px; width: 100%; }

.q-tabs { display: flex; align-items: center; gap: 6px; margin: 18px 0 12px; border-bottom: 1px solid var(--border-soft); }
.q-tab { background: none; border: none; color: var(--text-tertiary); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.q-tab.on { color: var(--text-primary); border-bottom-color: var(--accent, #7c6cf5); }
.q-tab .count { background: var(--bg-card); color: var(--text-tertiary); border-radius: 10px; padding: 1px 7px; font-size: 10px; margin-left: 4px; }
.q-draft { font-size: 11px; color: var(--accent, #7c6cf5); font-weight: 700; }
.q-draft a { cursor: pointer; margin-left: 6px; opacity: .7; }
.q-draft a:hover { opacity: 1; }

.qf-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.qf-search { flex: 1 1 220px; min-width: 160px; padding: 8px 12px; font-size: 12.5px; }
.qf-chips { display: inline-flex; gap: 4px; background: var(--bg-card); padding: 3px; border-radius: 10px; border: 1px solid var(--border-soft); }
.qf-chip { background: none; border: none; color: var(--text-secondary); font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.qf-chip.on { background: var(--accent, #7c6cf5); color: #fff; }
.qf-batch { max-width: 160px; }

.qh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.qh-card { display: flex; flex-wrap: wrap; gap: 10px; background: var(--bg-card); border: 1px solid var(--border-soft); border-left: 3px solid transparent; border-radius: 12px; padding: 10px; position: relative; content-visibility: auto; contain-intrinsic-size: auto 88px; }
.qh-card.sel { background: var(--bg-hover); border-color: var(--accent, #7c6cf5); }
.qh-check-wrap { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 2px; border-radius: 4px; display: flex; }
.qh-card.done { border-left-color: var(--accent-green, #34d399); }
.qh-card.failed { border-left-color: var(--accent-red, #f87171); }
.qh-card.running, .qh-card.generating { border-left-color: var(--accent, #7c6cf5); }
.qh-thumb-col { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 84px; flex: 0 0 84px; }
.qh-thumb { width: 100%; height: 84px; border-radius: 9px; overflow: hidden; background: #000; position: relative; display: flex; align-items: center; justify-content: center; }
.qh-thumb img, .qh-thumb video { width: 100%; height: 100%; object-fit: cover; }
.qh-thumb.empty { color: var(--text-tertiary); font-size: 22px; background: var(--bg-elevated, #1c1c28); }
.qh-thumb.empty.failed { color: var(--accent-red, #f87171); }
.qh-jobid { font-size: 10px; font-weight: 700; color: var(--text-tertiary); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-align: center; font-variant-numeric: tabular-nums; opacity: 0.7; }
.qh-jobid:hover { color: var(--text-primary); opacity: 1; }
a.qh-filter-link { color: inherit; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.2); cursor: pointer; }
a.qh-filter-link:hover { color: var(--text-primary); text-decoration-color: currentColor; }
.qh-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.7); pointer-events: none; }
.qh-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qh-row1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qh-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 800; text-transform: uppercase; padding: 2px 7px; border-radius: 10px; }
.qh-badge.done { background: rgba(52,211,153,.16); color: var(--accent-green, #34d399); }
.qh-badge.failed { background: rgba(248,113,113,.16); color: var(--accent-red, #f87171); }
.qh-badge.running, .qh-badge.generating, .qh-badge.waiting { background: var(--accent-subtle, rgba(124,108,245,.16)); color: var(--accent, #7c6cf5); }
.qh-type { font-size: 12px; }
.qh-batch { font-size: 9.5px; font-weight: 700; background: rgba(124,108,245,.14); color: var(--accent, #7c6cf5); padding: 1px 7px; border-radius: 8px; cursor: pointer; }
.qh-time { font-size: 9.5px; color: var(--text-tertiary); margin-left: auto; }
.qh-name { font-size: 12.5px; font-weight: 800; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qh-prompt { font-size: 11px; color: var(--text-secondary); line-height: 1.35; max-height: 30px; overflow: hidden; }
.qh-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 9.5px; color: var(--text-tertiary); margin-top: 2px; }
.qh-error { font-size: 10px; color: var(--accent-red, #f87171); margin-top: 3px; line-height: 1.35; word-wrap: break-word; }
.qh-actions { display: flex; flex-direction: column; gap: 4px; }
.qh-act { background: var(--bg-elevated, rgba(255,255,255,.05)); border: 1px solid var(--border-soft); border-radius: 8px; width: 34px; min-height: 30px; height: auto; padding: 4px 2px; cursor: pointer; font-size: 11px; color: var(--text-secondary, #a1a1aa); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; word-break: break-all; }
.qh-act:hover { border-color: var(--accent-border, rgba(124,108,245,.4)); background: var(--accent-subtle, rgba(124,108,245,.12)); }
.qh-act.danger:hover { border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.12); }
.qh-group { margin-bottom: 16px; }
.qh-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--border-soft); }
.qh-group-name { font-size: 12px; font-weight: 800; color: var(--accent, #7c6cf5); }
.qh-group-stat { font-size: 10.5px; color: var(--text-tertiary); }
.qh-group-stat .failtxt { color: var(--accent-red, #f87171); }
.qh-more { text-align: center; font-size: 11px; color: var(--text-tertiary); padding: 12px; }

/* add-form: context-aware video/image inputs (frames, refs, characters) */
.qf-vsec { display: flex; flex-direction: column; gap: 10px; }
.q-voice-hint { font-size: 11px; color: var(--text-tertiary); line-height: 1.4; }
.qf-frame { display: flex; flex-direction: column; gap: 4px; }
.qf-thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qf-thumb-row { display: flex; align-items: center; gap: 10px; }
.qf-thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: #000; flex: 0 0 64px; }
.qf-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qf-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: none; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.qf-x:hover { background: var(--accent-red, #f87171); }
.qf-char { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.qf-char .qf-thumb { width: 44px; height: 44px; flex: 0 0 44px; }

/* Image picker (add-form "Thêm ảnh") — choose from library or upload from computer. */
.qip { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; }
.qip-back { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.qip-body { position: relative; width: min(680px, 92vw); max-height: 82vh; overflow: auto; background: var(--bg-elevated, #16161f); border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 14px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.qip-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.qip-head b { font-size: 15px; }
.qip-close { border: none; background: transparent; color: var(--text-secondary); font-size: 16px; cursor: pointer; }
.qip-close:hover { color: var(--text-primary); }
.qip-upload { width: 100%; }
.qip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.qip-cell { aspect-ratio: 1/1; border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; border: 2px solid transparent; }
.qip-cell:hover { border-color: var(--accent, #7c6cf5); }
.qip-cell img { width: 100%; height: 100%; object-fit: cover; }
.qip-empty { grid-column: 1 / -1; text-align: center; color: var(--text-tertiary); padding: 24px 0; }

/* "Tạo trên" bar pinned at the top of the Hàng đợi page — render as a rounded card (not the
   studio's sticky full-width top strip) so it reads as a clean section above the stats. */
#page-queue .ws-bar { position: static; border: 1px solid var(--border-soft); border-radius: 10px; margin-bottom: 14px; }

/* Two-click delete confirm (FS.armConfirm): armed state turns the button danger-red. */
.btn.arming { background: var(--accent-red, #e05260) !important; border-color: var(--accent-red, #e05260) !important; color: #fff !important; }

/* Pending tab: bulk toolbar (search / batch filter / select-all / bulk-change actions). */
.q-bulk { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.q-bulk-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-bulk-act { padding: 10px 12px; border: 1px solid var(--accent-border, rgba(124,108,245,.35)); border-radius: 10px; background: var(--accent-subtle, rgba(124,108,245,.12)); }
.q-bulk-n { font-size: 11px; font-weight: 800; color: var(--accent, #7c6cf5); white-space: nowrap; }
.q-selall { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; cursor: pointer; }
.q-selall input, .q-check { width: 15px; height: 15px; accent-color: var(--accent, #7c6cf5); cursor: pointer; }

/* Pending tab: always-on inline editor card (no Save button — every field auto-saves). */
.queue-item.q-edit { display: block; }
.queue-item.q-edit.sel { border-color: var(--accent, #7c6cf5); box-shadow: 0 0 0 1px var(--accent, #7c6cf5) inset; }
.queue-item[draggable="true"] { cursor: grab; }
.queue-item.drag-over { border-top: 2px solid var(--accent, #7c6cf5); }
.q-edit-head { display: flex; align-items: center; gap: 8px; }
.q-idx-input { width: 44px; text-align: center; padding: 2px 4px; font-size: 11px; font-weight: 800; border-radius: 4px; border: 1px solid var(--border-soft); background: var(--bg-deep); color: var(--text-secondary); cursor: text; -moz-appearance: textfield; }
.q-idx-input::-webkit-outer-spin-button, .q-idx-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.q-edit-name { font-weight: 800; font-size: 13px; color: var(--text-primary); }

/* Collapsed (default) pending card — click the body to expand into the inline editor */
.queue-item.q-collapsed { cursor: pointer; }
.queue-item.q-collapsed .qp-sub { max-height: 18px; }
.q-expand-area { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.queue-item.q-collapsed .qp-sub.q-expand-area,
.queue-item.q-collapsed .qmeta.q-expand-area { display: flex; }
.q-chevron { color: var(--text-tertiary); font-size: 11px; flex: 0 0 auto; transition: color .15s; }
.q-chevron-btn { cursor: pointer; padding: 0 2px; }
.q-chevron-btn:hover, .q-expand-area:hover .q-chevron { color: var(--accent, #7c6cf5); }
.q-toggle-btn { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; white-space: nowrap; color: var(--accent, #7c6cf5); }
.q-toggle-btn:hover { background: color-mix(in srgb, var(--accent, #7c6cf5) 14%, transparent); }
/* auto-download: master toolbar checkbox + per-card controls */
.q-ctrl-check { flex-direction: row; align-items: center; gap: 6px; cursor: pointer; }
.q-ctrl-check input { width: 15px; height: 15px; accent-color: var(--accent, #7c6cf5); }
.q-ctrl-check .field-label { margin: 0; cursor: pointer; }
.q-dl-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.q-dl-row input { width: 15px; height: 15px; accent-color: var(--accent, #7c6cf5); }
.q-dl-toggle { opacity: .4; filter: grayscale(1); }
.q-dl-toggle.on { opacity: 1; filter: none; color: var(--accent, #7c6cf5); background: color-mix(in srgb, var(--accent, #7c6cf5) 14%, transparent); }
.queue-item.q-collapsed .q-edit-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Studio-pending pseudo-cards in the History tab (queued, not yet started) */
.qh-card.waiting { opacity: .85; border-style: dashed; }
.qh-thumb.empty.waiting { color: var(--accent, #7c6cf5); }
.qh-grid.qh-studio { margin-bottom: 10px; }

.warning-banner {
  background: rgba(239,159,39,0.1);
  border: 1px solid rgba(239,159,39,0.3);
  color: var(--accent-amber);
  border-radius: 8px; padding: 9px 11px; font-size: 11.5px; margin-bottom: 12px;
  display: flex; gap: 8px; align-items: flex-start;
}

/* log */
.logbox {
  background: #08080c; border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 8px; font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10.5px; color: var(--text-secondary); line-height: 1.5;
  height: 120px; overflow-y: auto; white-space: pre-wrap;
}

/* ----------------------------------------------------------------- modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; width: 380px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.modal h3 { font-size: 16px; margin-bottom: 4px; }
.modal p.hint { color: var(--text-secondary); font-size: 12px; margin-bottom: 16px; line-height: 1.45; }
.modal label { display: block; font-size: 11.5px; color: var(--text-secondary); margin: 12px 0 5px; font-weight: 600; }
.modal input {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); padding: 9px 11px; font-size: 13px; outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* --------------------------------------------------- FlowSmart embed cleanup */
/* hide FlowSmart's own left sidebar + its floating collapse buttons — our app's
   sidebar drives it now */
.fs-own-sidebar, .fs-collapse-btns { display: none !important; }
/* when viewing a FlowSmart view, give it full width (hide our Rotation panel) */
body.fs-mode { --rightpanel-w: 0px; }
body.fs-mode .rightpanel { display: none; }

/* Right panel collapse (Activity Log) — persists via localStorage. */
body.rp-collapsed { --rightpanel-w: 0px; }
body.rp-collapsed .rightpanel { display: none; }
.rp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rp-header .rp-title { margin: 0; }
.rp-icon-btn {
  background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-secondary);
  border-radius: 7px; width: 24px; height: 24px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none;
}
.rp-icon-btn:hover { color: var(--text-primary); border-color: var(--border); }
/* Floating reopen tab — only on our pages (not Studio) when collapsed. */
.rp-reopen {
  position: fixed; top: 16px; right: 0; z-index: 60; display: none;
  background: var(--bg-card); border: 1px solid var(--border-soft); border-right: none;
  color: var(--text-secondary); border-radius: 8px 0 0 8px; padding: 8px 9px; cursor: pointer; font-size: 14px;
}
.rp-reopen:hover { color: var(--text-primary); }
body.rp-collapsed:not(.fs-mode) .rp-reopen { display: block; }

/* — FlowSmart mobile top bar — force hidden in desktop embed.
   The mobile nav bar + mobile queue drawer are not needed — our app's
   sidebar handles navigation. Target by data-testid for reliability. */
[data-testid="fs-mobile-topbar"] { display: none !important; }

/* — Force FlowSmart's main content to NOT add mobile padding-top.
   Its <main> has pt-16 lg:pt-0; force pt-0 always in desktop embed. */
.flowsmart-root .fs-app main {
  padding-top: 0 !important;
}

/* — Mobile queue drawer also hidden (we have our own Queue page). */
.flowsmart-root [id="mobile-queue-portal-root"] {
  display: none !important;
}


/* — Right panel collapse ">" button — blend into theme, more subtle */
[data-testid="fs-panel-collapse"],
.flowsmart-root button[class*="rounded-full"][class*="absolute"][class*="-left-3"],
.flowsmart-root button[class*="rounded-l-xl"][class*="absolute"],
.flowsmart-root button[class*="rounded-r-xl"][class*="absolute"] {
  background: #0f0f18 !important;
  border-color: rgba(255,255,255,0.06) !important;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
}
[data-testid="fs-panel-collapse"]:hover,
.flowsmart-root button[class*="rounded-full"][class*="absolute"][class*="-left-3"]:hover,
.flowsmart-root button[class*="rounded-l-xl"][class*="absolute"]:hover,
.flowsmart-root button[class*="rounded-r-xl"][class*="absolute"]:hover {
  opacity: 1;
  border-color: var(--accent-border) !important;
}


/* ----------------------------------------------------------------
   FlowSmart Theme Bridge — map hardcoded Tailwind accent colors &
   backgrounds to CSS variables so they respond to theme changes.
   ---------------------------------------------------------------- */

/* Form controls inherit the app font — Tailwind preflight is disabled, and without
   this Chrome renders every textarea in its default monospace. */
.flowsmart-root input,
.flowsmart-root textarea,
.flowsmart-root select,
.flowsmart-root button {
  font-family: inherit;
}

/* Form elements — dark themed. Studio Kịch (.sk-root) opts out: its components carry
   full Tailwind styling (transparent inline-edit fields) and these !important
   overrides turn them into boxes. */
.flowsmart-root input:not(.sk-root *),
.flowsmart-root textarea:not(.sk-root *),
.flowsmart-root select:not(.sk-root *) {
  background-color: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}
.flowsmart-root input:focus:not(.sk-root *),
.flowsmart-root textarea:focus:not(.sk-root *),
.flowsmart-root select:focus:not(.sk-root *) {
  border-color: var(--accent-border) !important;
  outline: none !important;
}
.flowsmart-root input:not(.sk-root *)::placeholder,
.flowsmart-root textarea:not(.sk-root *)::placeholder {
  color: var(--text-tertiary) !important;
}

/* --- Accent color overrides (#7c6cf5 → var(--accent)) --- */
/* Background accents */
.flowsmart-root .bg-\[\#7c6cf5\] { background-color: var(--accent) !important; }
.flowsmart-root .bg-\[\#7c6cf5\]\/20 { background-color: var(--accent-subtle) !important; }
/* Text accents */
.flowsmart-root .text-\[\#7c6cf5\] { color: var(--accent) !important; }
/* Border accents */
.flowsmart-root .border-\[\#7c6cf5\] { border-color: var(--accent) !important; }
/* Shadow accents */
.flowsmart-root .shadow-\[\#7c6cf5\]\/20 { --tw-shadow-color: var(--accent-glow); }
.flowsmart-root .shadow-lg.shadow-\[\#7c6cf5\]\/20 { box-shadow: 0 10px 15px -3px var(--accent-glow); }

/* --- Secondary accent (#ff4b91 → var(--accent-secondary)) --- */
.flowsmart-root .bg-\[\#ff4b91\] { background-color: var(--accent-secondary) !important; }
.flowsmart-root .text-\[\#ff4b91\] { color: var(--accent-secondary) !important; }
.flowsmart-root .border-\[\#ff4b91\] { border-color: var(--accent-secondary) !important; }

/* --- Background overrides (#0a0a0f, #13131a, #0d0d12 → var(--bg-*)) --- */
.flowsmart-root .bg-\[\#0a0a0f\] { background-color: var(--bg-primary) !important; }
.flowsmart-root .bg-\[\#13131a\] { background-color: var(--bg-card) !important; }
.flowsmart-root .bg-\[\#0d0d12\] { background-color: var(--bg-header) !important; }
.flowsmart-root .bg-\[\#0d0d12\]\/80 { background-color: var(--bg-header) !important; }
.flowsmart-root .bg-\[\#0f0f18\] { background-color: var(--bg-elevated) !important; }
.flowsmart-root .bg-\[\#1a1a24\] { background-color: var(--bg-elevated) !important; }

/* Border overrides */
.flowsmart-root .border-white\/5 { border-color: var(--border-soft) !important; }
.flowsmart-root .border-white\/10 { border-color: var(--border) !important; }

/* --- Gradient from-* classes --- */
.flowsmart-root .from-\[\#7c6cf5\] { --tw-gradient-from: var(--accent); }
.flowsmart-root .to-\[\#d96ce8\] { --tw-gradient-to: var(--accent-secondary); }

/* --- Emerald accents used in success states --- */
.flowsmart-root .bg-emerald-500 { background-color: var(--accent-green) !important; }
.flowsmart-root .bg-emerald-500\/10 { background-color: rgba(29,158,117,0.1) !important; }

/* Scrollbar for the entire FlowSmart area */
.flowsmart-root *::-webkit-scrollbar { width: 6px; height: 6px; }
.flowsmart-root *::-webkit-scrollbar-track { background: transparent; }
.flowsmart-root *::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
.flowsmart-root *::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Recharts (dashboard charts) — theme aware */
.flowsmart-root .recharts-cartesian-grid-horizontal line,
.flowsmart-root .recharts-cartesian-grid-vertical line {
  stroke: var(--border-soft);
}
.flowsmart-root .recharts-text { fill: var(--text-tertiary); }

/* Toast notifications */
.flowsmart-root [class*="animate-slide-down"] { z-index: 9999 !important; }


/* logo row + language toggle + collapse */
.logo-row { display: flex; align-items: center; gap: 6px; padding: 0 4px 8px; }
.logo-row .logo { padding: 6px 4px; flex: 1; }
.lang-toggle, .collapse-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 7px; font-size: 11px; font-weight: 700; height: 26px; min-width: 26px; padding: 0 7px;
}
.lang-toggle:hover, .collapse-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.nav-item .ico.mi {
  font-family: 'Material Symbols Outlined'; font-size: 19px; line-height: 1;
}

/* collapsible sidebar */
body.sidebar-collapsed { --sidebar-w: 58px; }
body.sidebar-collapsed .lbl,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .lang-toggle,
body.sidebar-collapsed .logo .flow,
body.sidebar-collapsed .logo .ver,
body.sidebar-collapsed #viewer-list .vname,
body.sidebar-collapsed #viewer-list .wk-sub,
body.sidebar-collapsed #viewer-list .wk-email,
body.sidebar-collapsed #viewer-list .vmeta,
body.sidebar-collapsed .nav-item .badge { display: none; }
body.sidebar-collapsed .top-actions { padding: 0 0 14px 0; justify-content: center; }
body.sidebar-collapsed .logo { font-size: 15px; padding: 6px 0; text-align: center; }
body.sidebar-collapsed .logo-row { flex-direction: column; gap: 4px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
body.sidebar-collapsed .nav-item .ico { width: auto; }

#page-studio { padding: 0; }
#page-studio.show { display: flex; flex-direction: column; overflow: hidden; }
/* FlowSmart's root is w-screen/h-screen — make it fit our container instead */
.flowsmart-root { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.flowsmart-root .fs-app {
  width: 100% !important; max-width: 100% !important;
  height: 100% !important; max-height: 100% !important;
  position: relative !important; /* contain fixed children */
}
/* FlowSmart's internal fixed elements (toasts, modals) need to be
   positioned relative to the flowsmart-root container, not viewport */
.flowsmart-root .fs-app > .fixed {
  position: absolute !important;
}
.ws-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: 7px 44px 7px 14px; border-bottom: 1px solid var(--border-soft);
  background: var(--bg-header); position: sticky; top: 0; z-index: 20;
  min-height: 38px;
}
/* Account chips scroll horizontally in ONE row so a long worker list never wraps/clips the bar. */
.ws-chips {
  display: flex; align-items: center; gap: 8px; flex: 1;
  overflow-x: auto; overflow-y: hidden; min-width: 0; padding-bottom: 2px;
}
.ws-chips::-webkit-scrollbar { height: 5px; }
.ws-chips::-webkit-scrollbar-thumb { background: var(--border-strong, rgba(255,255,255,.15)); border-radius: 99px; }
.ws-chips .ws-chip { flex: none; }

/* Collapse ALL top bars to reclaim working space; a floating handle brings them back. */
body.topbars-collapsed #ws-bar,
body.topbars-collapsed #global-progress { display: none !important; }
#topbars-toggle {
  position: fixed; top: 5px; right: 10px; z-index: 400;
  width: 26px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; opacity: .55; transition: opacity .12s, background .12s;
}
#topbars-toggle:hover { opacity: 1; background: var(--bg-hover); color: var(--text-primary); }
#topbars-toggle .material-symbols-outlined { font-family: 'Material Symbols Outlined'; font-size: 16px; line-height: 1; }
/* When collapsed with work still running, the handle pulses an accent dot so it's obvious to reopen. */
#topbars-toggle .tb-dot { display: none; position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
body.topbars-collapsed.topbars-busy #topbars-toggle .tb-dot { display: block; animation: gprogPulse 1.1s infinite; }
.ws-bar-label {
  font-size: 9px; font-weight: 800; letter-spacing: 1.2px;
  color: var(--text-tertiary); text-transform: uppercase;
}

/* Global progress strip — one pill per active process (image/video/audio/agent). */
.gprog-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 44px 7px 14px; border-bottom: 1px solid var(--border-soft);
  background: var(--bg-input, var(--bg-header));
}
.gprog-lead {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  color: var(--accent); white-space: nowrap; flex: none;
}
.gprog-bar .material-symbols-outlined { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; line-height: 1; }
.gprog-lead .material-symbols-outlined { font-size: 14px; }
.gprog-pills { display: flex; align-items: center; gap: 9px; flex: 1; overflow-x: auto; }
.gprog-pills::-webkit-scrollbar { height: 0; }
.gprog-count { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; flex: none; }
.gprog-pill {
  display: flex; align-items: center; gap: 8px;
  min-width: 150px; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  cursor: pointer; text-align: left; transition: border-color .12s, background .12s;
}
.gprog-pill:hover { border-color: var(--border-strong, var(--accent)); background: var(--bg-hover); }
.gprog-pill .material-symbols-outlined { font-size: 15px; flex: none; }
.gprog-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.gprog-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.gprog-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gprog-num { font-family: monospace; color: var(--text-tertiary); flex: none; }
.gprog-track { height: 4px; border-radius: 99px; background: var(--bg-input, rgba(255,255,255,.08)); overflow: hidden; }
.gprog-fill { height: 100%; border-radius: 99px; transition: width .3s ease; }
.gprog-dots { display: inline-flex; gap: 3px; padding: 2px 0; }
.gprog-dots i { width: 4px; height: 4px; border-radius: 50%; background: #34d399; animation: gprogPulse 1s infinite; }
.gprog-dots i:nth-child(2) { animation-delay: .15s; }
.gprog-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes gprogPulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
.ws-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
  transition: all 0.15s;
}
.ws-chip:hover { border-color: var(--accent-border); color: var(--text-primary); }
.ws-chip.on { border-color: var(--accent); color: var(--text-primary); background: var(--accent-subtle); }
.ws-chip input { display: none; }
.flowsmart-root { background: var(--bg-primary); min-height: calc(100vh - var(--statusbar-h) - 44px); }
.flowsmart-root .material-symbols-outlined {
  font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal;
  line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block;
  white-space: nowrap; word-wrap: normal; direction: ltr;
}

/* ----------------------------------------------------------------- gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
/* HistoryCard-style card: 16:10 thumbnail + meta with a hover action overlay */
.g-card {
  display: flex; flex-direction: column; background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border-soft); overflow: hidden; transition: all .2s; position: relative;
}
.g-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.g-card:hover { border-color: rgba(255,255,255,.12); box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.g-card.sel:hover { border-color: var(--accent); }
.g-check-wrap { position: absolute; top: 8px; left: 8px; z-index: 10; padding: 2px; border-radius: 4px; display: flex; background: rgba(0,0,0,0.4); }
.g-check { width: 15px; height: 15px; accent-color: var(--accent, #7c6cf5); cursor: pointer; }
.g-thumb { aspect-ratio: 16/10; background: #0d0d14; display: grid; place-items: center; overflow: hidden; }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s; }
.g-card:hover .g-thumb img { transform: scale(1.04); }
.g-thumb img.img-fail { display: none; }
.g-placeholder { color: var(--text-tertiary); font-size: 12px; }

.g-meta { padding: 14px 16px 16px; position: relative; min-height: 132px; }
.g-meta-top { display: flex; align-items: center; gap: 8px; }
.g-type-badge {
  font-size: 8px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px;
}
.g-type-badge.vid { color: #ff4b91; background: rgba(255,75,145,.18); }
.g-type-badge.img { color: #7c6cf5; background: rgba(124,108,245,.18); }
.g-idx { font-size: 10px; font-weight: 900; letter-spacing: 1px; color: var(--text-tertiary); text-transform: uppercase; }
.g-time { margin-left: auto; font-size: 9px; font-weight: 800; letter-spacing: 1px; color: var(--text-tertiary); }
.g-acct { flex-basis: 100%; margin-top: 2px; font-size: 9px; font-weight: 800; letter-spacing: .3px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-title { margin-top: 6px; font-size: 10px; font-weight: 900; letter-spacing: .5px; text-transform: uppercase; color: #ff4b91; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-prompt { margin-top: 6px; font-size: 12px; line-height: 1.4; color: var(--text-secondary); max-height: 34px; overflow: hidden; }

/* Hover overlay over the meta area: action buttons */
.g-hover {
  position: absolute; inset: 0; padding: 12px 14px; border-radius: 0;
  background: rgba(10,10,15,.96); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.g-card:hover .g-hover { opacity: 1; pointer-events: auto; }
.g-act-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.g-act {
  height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: #fff;
  border-radius: 11px; cursor: pointer; font-size: 8px; font-weight: 900; letter-spacing: .3px;
  text-transform: uppercase; transition: all .15s;
}
.g-act .g-act-ic { font-size: 16px; line-height: 1; }
.g-act:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); }
.g-act-violet:hover { border-color: #7c6cf5; background: rgba(124,108,245,.12); }
.g-act-pink:hover { border-color: #ff4b91; background: rgba(255,75,145,.12); }
.g-act-play {
  width: 100%; height: 46px; flex-direction: row; gap: 8px; font-size: 11px;
  background: #fff; color: #000; border: none;
}
.g-act-play .g-act-ic { font-size: 18px; }
.g-act-play:hover { background: #e6e6e6; }
.g-act-row { display: flex; gap: 8px; }
.g-act-dl {
  flex: 1; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); color: var(--text-secondary);
  border-radius: 11px; cursor: pointer; font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  transition: all .15s;
}
.g-act-dl:hover { background: rgba(255,255,255,.08); color: #fff; }
.g-act-rm {
  width: 44px; height: 44px; display: grid; place-items: center; font-size: 17px;
  background: rgba(224,82,96,.1); border: 1px solid rgba(224,82,96,.25); color: #e05260;
  border-radius: 11px; cursor: pointer; transition: all .15s;
}
.g-act-rm:hover { background: #e05260; color: #fff; }

/* Gallery header: title + stats on the left, Upload button on the right */
.g-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.g-head-left { min-width: 0; }
.g-stat {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: 20px; padding: 2px 10px;
}
.g-head .btn { flex-shrink: 0; }

/* Gallery storage-folder row (where gen + uploaded media is kept on disk) */
.g-folder {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap;
  padding: 7px 12px; border: 1px solid var(--border-soft); border-radius: 10px;
  background: var(--bg-card); max-width: 100%;
}
.g-folder-path { flex: 1 1 220px; }
.g-folder-ico { font-size: 14px; flex-shrink: 0; }
.g-folder-label { font-size: 11px; font-weight: 700; color: var(--text-tertiary); flex-shrink: 0; text-transform: uppercase; letter-spacing: .5px; }
.g-folder-path {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.g-folder .btn { flex-shrink: 0; }

/* Gallery filter tabs */
.g-tabs { display: flex; align-items: center; gap: 8px; margin: 16px 0 4px; flex-wrap: wrap; }
/* divider between the type tabs (all/image/video) and the source ticks (upload/local) */
.g-tabs-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border-soft); }
/* source ticks read as checkboxes, not as the single-select pill tabs */
.g-src .g-src-box {
  width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1;
}
.g-src.active { background: color-mix(in srgb, var(--accent-green) 16%, transparent); border-color: var(--accent-green); color: var(--accent-green); }
.g-src.active .g-src-box { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.g-tab {
  background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-secondary);
  border-radius: 9px; padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: all .15s;
}
.g-tab:hover { color: var(--text-primary); border-color: var(--border); }
.g-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.g-tab-n { font-size: 10.5px; opacity: .7; background: rgba(255,255,255,.12); border-radius: 6px; padding: 1px 6px; }
.g-filterrow { display: flex; align-items: center; gap: 12px; margin: 12px 0 2px; flex-wrap: wrap; }
.g-search {
  flex: 1 1 240px; max-width: 360px; display: block;
  background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--text-primary);
  border-radius: 9px; padding: 9px 13px; font-size: 13px; outline: none;
}
.g-search:focus { border-color: var(--accent); }
.g-search::placeholder { color: var(--text-tertiary); }
/* Date filter (calendar) */
.g-datebar { display: inline-flex; align-items: center; gap: 6px; }
.g-date-ico { font-size: 14px; opacity: .8; }
.g-date-preset, .g-date-input, .g-batch-select {
  background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; outline: none; transition: border .2s;
}
.g-date-preset:focus, .g-date-input:focus, .g-batch-select:focus { border-color: var(--accent); }
.g-bulk { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 12px 16px; background: var(--accent-subtle); border: 1px solid var(--accent-border); border-radius: 10px; }
.g-bulk-left { display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 13px; }
.g-bulk-right { display: flex; align-items: center; gap: 8px; }
.g-date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }
/* Portrait (9:16) thumbnails: letterbox inside the uniform 16:10 box (don't stretch tall). */
.g-thumb.g-portrait img, .g-thumb.g-portrait video.g-vid { object-fit: contain; }

/* Gallery video thumbnails */
.g-thumb { position: relative; cursor: pointer; }
.g-thumb video.g-vid { width: 100%; height: 100%; object-fit: cover; display: block; background: #0d0d14; }
.g-thumb .g-play {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 26px; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.7);
}
.g-thumb .g-play::before {
  content: ''; position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.25); z-index: -1;
}
.g-badge { font-size: 10px; background: rgba(255,255,255,.08); border-radius: 5px; padding: 1px 6px; }
.g-badge.up { background: rgba(124,108,245,.18); color: #b9aefc; }

/* Gallery viewer (lightbox / video player) */
#fs-gallery-viewer { position: fixed; inset: 0; z-index: 9000; display: none; align-items: center; justify-content: center; }
#fs-gallery-viewer .gv-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.88); backdrop-filter: blur(8px); }
#fs-gallery-viewer .gv-body { position: relative; max-width: 92vw; max-height: 90vh; display: flex; }
#fs-gallery-viewer .gv-body img,
#fs-gallery-viewer .gv-body video { max-width: 92vw; max-height: 90vh; border-radius: 14px; box-shadow: 0 20px 80px rgba(0,0,0,.6); display: block; }
#fs-gallery-viewer .gv-close {
  position: absolute; top: -14px; right: -14px; width: 38px; height: 38px; border-radius: 50%;
  background: #1a1a22; color: #fff; border: 1px solid var(--border); cursor: pointer; font-size: 15px;
}
#fs-gallery-viewer .gv-close:hover { background: var(--accent-red, #e0245e); }

.empty-state {
  text-align: center; color: var(--text-tertiary); padding: 40px 20px; font-size: 13px;
}
.empty-state .em-ico { font-size: 34px; opacity: 0.35; margin-bottom: 10px; }

.row-gap { display: flex; gap: 10px; align-items: center; }
.mt12 { margin-top: 12px; }
.mb16 { margin-bottom: 16px; }
.flex1 { flex: 1; }

/* ── Accounts redesign: stat cards, account grid, usage stats (added later 16e) ── */
.stat-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin:18px 0 24px; }
.stat-card { background:var(--bg-card); border:1px solid var(--border-soft); border-radius:16px; padding:16px 18px; }
.stat-card .stat-label { font-size:11px; font-weight:800; letter-spacing:.08em; color:var(--text-secondary); text-transform:uppercase; }
.stat-card .stat-value { font-size:30px; font-weight:900; margin-top:6px; color:var(--text-primary,#fff); }
.stat-card .stat-value.accent { color:var(--accent); }
.stat-card .stat-value.green  { color:var(--accent-green); }
.stat-card .stat-value.amber  { color:var(--accent-amber); }
.stat-card .stat-value.red    { color:var(--accent-red); }

.acc-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:16px; }
@media (max-width:900px){ .acc-grid,.stat-grid{ grid-template-columns:1fr 1fr; } }
.acc-card2 { background:var(--bg-card); border:1px solid var(--border-soft); border-radius:18px; padding:18px; display:flex; flex-direction:column; gap:14px; }
.acc-card2 .acc2-head { display:flex; align-items:center; gap:12px; }
.acc-card2 .acc2-id { flex:1; min-width:0; }
.acc-card2 .acc2-id .nm { font-weight:800; display:flex; align-items:center; gap:8px; }
.acc-rename-btn { flex:none; background:none; border:none; padding:2px 4px; margin:0; font-size:12px; line-height:1; color:var(--text-secondary); cursor:pointer; border-radius:6px; opacity:0; transition:opacity .12s, color .12s, background .12s; }
.acc-card2:hover .acc-rename-btn { opacity:.6; }
.acc-rename-btn:hover { opacity:1 !important; color:var(--text-primary); background:var(--bg-hover, rgba(255,255,255,.08)); }
.acc-card2 .acc2-id .em { font-size:12px; color:var(--text-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.acc-card2 .acc2-meta { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.acc-card2 .acc2-meta .k { font-size:9px; font-weight:800; letter-spacing:.06em; color:var(--text-secondary); text-transform:uppercase; }
.acc-card2 .acc2-meta .v { font-size:13px; font-weight:700; margin-top:3px; }
.acc-card2 .acc2-actions { display:flex; gap:8px; }
.sb-lowcredit { background:rgba(239,159,39,.15); color:var(--accent-amber); }

.usage-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
@media (max-width:900px){ .usage-grid{ grid-template-columns:1fr; } }
.usage-card { background:var(--bg-card); border:1px solid var(--border-soft); border-radius:16px; padding:16px 18px; }
.usage-head { display:flex; justify-content:space-between; align-items:baseline; }
.usage-head span { font-size:11px; font-weight:800; letter-spacing:.06em; color:var(--text-secondary); }
.usage-head b { font-size:24px; font-weight:900; }
.usage-head b.accent { color:var(--accent); }
.usage-sub { font-size:12px; color:var(--text-secondary); margin-top:6px; }
.usage-note { font-size:11px; color:var(--text-secondary); margin-top:10px; padding-top:10px; border-top:1px solid var(--border-soft); }
.usage-cap { font-size:11px; font-weight:800; letter-spacing:.06em; color:var(--text-secondary); text-transform:uppercase; margin-bottom:10px; }
.usage-row { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:6px 0; font-size:13px; border-bottom:1px solid var(--border-soft); }
.usage-row:last-child { border-bottom:none; }
.usage-row b { font-weight:800; }
/* ----------------------------------------------------------------- Scroll Navigation */
.q-scroll-nav {
  position: fixed;
  bottom: 24px;
  right: 32px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated, rgba(22, 22, 31, 0.85));
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.q-scroll-nav .btn {
  font-size: 12px;
  padding: 6px 10px;
  height: auto;
}

/* ----------------------------------------------------------------- Live Task Log Tracking */
.q-log-container {
  width: 100%;
  order: 3;
  margin-top: 8px;
}
.q-log-toggle {
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  display: inline-block;
  font-weight: 600;
}
.q-log-toggle:hover {
  color: var(--text-primary);
}
.q-log-drawer {
  margin-top: 4px;
  background: #141418;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.q-log-step {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  line-height: 1.4;
}
.q-log-step .time {
  color: var(--text-tertiary);
  flex: none;
}
.q-log-step .icon {
  flex: none;
  width: 14px;
  text-align: center;
}
.q-log-step .msg {
  flex: 1;
  word-break: break-word;
}
.q-log-step.info { color: var(--text-secondary); }
.q-log-step.info .icon { color: var(--accent); }
.q-log-step.run { color: var(--text-primary); }
.q-log-step.run .icon { display: inline-block; animation: ga-spin 1s linear infinite; color: var(--accent); }
.q-log-step.done { color: var(--text-secondary); }
.q-log-step.done .icon { color: var(--accent-green); }
.q-log-step.fail { color: var(--accent-red); }

/* Windows Performance Overrides: Disable heavy GPU backdrop-filter */
body.os-win32 * {
  backdrop-filter: none !important;
}
body.os-win32 .g-hover,
body.os-win32 #fs-gallery-viewer .gv-backdrop,
body.os-win32 .q-scroll-nav {
  background-color: rgba(10, 10, 15, 0.98) !important;
}
body.os-win32 .g-thumb .g-play::before {
  background-color: rgba(0, 0, 0, 0.8) !important;
}

/* ── Image Fixer (policy-fail rescue modal) ─────────────────────────────── */
.qh-act-fix { color: var(--accent-amber, #e0a860); border-color: rgba(224,168,96,.4); }
.ifx-overlay {
  position: fixed; inset: 0; z-index: 700; background: rgba(6,8,14,.72);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ifx-panel {
  background: var(--bg-panel, #14161f); border: 1px solid var(--border, #2a2d3a);
  border-radius: 12px; width: min(1040px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.ifx-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border, #2a2d3a); }
.ifx-title { font-weight: 700; font-size: 15px; }
.ifx-hint { color: var(--text-secondary, #9aa0ad); font-size: 12px; flex: 1; }
.ifx-x { background: none; border: none; color: var(--text-secondary, #9aa0ad); font-size: 18px; cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.ifx-x:hover { background: var(--bg-input, #1e2029); color: var(--text-primary, #fff); }
.ifx-thumbs { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; border-bottom: 1px solid var(--border, #2a2d3a); }
.ifx-thumb { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--bg-input, #1e2029); border: 2px solid transparent; border-radius: 8px; padding: 4px; cursor: pointer; }
.ifx-thumb.on { border-color: var(--accent, #7cc4ff); }
.ifx-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 5px; display: block; }
.ifx-thumb span { font-size: 10px; color: var(--text-secondary, #9aa0ad); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ifx-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border, #2a2d3a); }
.ifx-tool { background: var(--bg-input, #1e2029); border: 1px solid var(--border, #2a2d3a); color: var(--text-primary, #e8e8ec); border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.ifx-tool:hover { border-color: var(--accent, #7cc4ff); }
.ifx-tool.on { background: var(--accent, #7cc4ff); color: #0b0d14; border-color: var(--accent, #7cc4ff); font-weight: 600; }
.ifx-sep { width: 1px; align-self: stretch; background: var(--border, #2a2d3a); margin: 0 4px; }
.ifx-slider { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary, #9aa0ad); }
.ifx-slider input[type=range] { width: 90px; }
.ifx-select { background: var(--bg-input, #1e2029); border: 1px solid var(--border, #2a2d3a); color: var(--text-primary, #e8e8ec); border-radius: 7px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.ifx-select:hover { border-color: var(--accent, #7cc4ff); }
.ifx-stage { flex: 1; min-height: 260px; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 12px; background: repeating-conic-gradient(#1a1c24 0% 25%, #14161f 0% 50%) 50% / 24px 24px; }
.ifx-canvas-wrap { position: relative; line-height: 0; }
.ifx-canvas-wrap canvas { display: block; border-radius: 4px; }
#ifx-canvas { box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
#ifx-overlay-canvas { position: absolute; left: 0; top: 0; cursor: crosshair; }
.ifx-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border, #2a2d3a); }
.ifx-foot-note { font-size: 12px; color: var(--text-secondary, #9aa0ad); }

/* ── Accounts: per-card "Tạo trên" (gen-target) toggle ──────────────────── */
.acc-card2.gensel-on { border-color: rgba(80,200,140,.5); box-shadow: inset 0 0 0 1px rgba(80,200,140,.22); }
.acc-gensel {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-bottom: 10px; padding: 6px 8px; border-radius: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  cursor: pointer; border: 1px solid var(--border, #2a2d3a);
  background: var(--bg-input, #1e2029); color: var(--text-secondary, #9aa0ad);
  transition: background .12s, border-color .12s, color .12s;
}
.acc-gensel:hover { border-color: rgba(80,200,140,.4); color: var(--text-primary, #e8e8ec); }
.acc-gensel.on { background: rgba(80,200,140,.14); border-color: rgba(80,200,140,.5); color: var(--accent-green, #50c88c); }
.acc-gensel-ic { font-size: 13px; line-height: 1; }

/* ── Image Fixer: prompt-rewrite panel ──────────────────────────────────── */
.ifx-promptbox { padding: 10px 16px; border-bottom: 1px solid var(--border, #2a2d3a); display: flex; flex-direction: column; gap: 6px; }
.ifx-promptbar { display: flex; align-items: center; gap: 10px; }
.ifx-prompt-lbl { font-size: 12px; font-weight: 700; color: var(--text-secondary, #9aa0ad); }
.ifx-rewrite-status { font-size: 11px; color: var(--accent-green, #50c88c); }
.ifx-prompt-text { width: 100%; min-height: 60px; max-height: 140px; resize: vertical; background: var(--bg-input, #1e2029); border: 1px solid var(--border, #2a2d3a); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5; color: var(--text-primary, #e8e8ec); outline: none; font-family: inherit; }
.ifx-prompt-text:focus { border-color: var(--accent, #7cc4ff); }
.ifx-noimg { padding: 8px 16px; font-size: 12px; color: var(--accent-amber, #e0a860); background: rgba(224,168,96,.08); border-bottom: 1px solid var(--border, #2a2d3a); }

/* ============================================================ N6: Nguồn gen Flow ⇄ API
   body.gen-api-mode = đang dùng API providers: ẩn NGUYÊN sidebar (chốt Victor) + tabbar +
   account switcher; nút ☰ (#nav-burger) mở tạm sidebar dạng overlay để chuyển trang —
   FS.go() bỏ class sidebar-peek sau khi điều hướng. */
#nav-burger { display: none; position: fixed; top: 10px; left: 10px; z-index: 9500;
  width: 34px; height: 34px; align-items: center; justify-content: center;
  background: var(--surface-2, #17171f); color: var(--text-primary, #e8e8ec);
  border: 1px solid var(--border, #2a2d3a); border-radius: 8px; font-size: 16px; cursor: pointer; }
#nav-burger:hover { border-color: var(--accent, #7b61ff); }
body.gen-api-mode #nav-burger { display: flex; }
body.gen-api-mode .sidebar { display: none; }
body.gen-api-mode #tabbar, body.gen-api-mode #tb-acc-select { display: none !important; }
body.gen-api-mode.sidebar-peek .sidebar { display: flex; position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 9400; box-shadow: 8px 0 32px rgba(0,0,0,.45); background: var(--bg-app, #0b0b10); }

/* Toggle "Nguồn" + chip AI trên #ws-bar */
.gen-src-seg { display: inline-flex; border: 1px solid var(--border, #2a2d3a); border-radius: 8px;
  overflow: hidden; flex: none; }
.gen-src-seg button { border: 0; background: transparent; color: var(--text-secondary, #9a9ab0);
  font-size: 11px; font-weight: 700; padding: 4px 10px; cursor: pointer; }
.gen-src-seg button.on { background: var(--accent, #7b61ff); color: #fff; }
.ai-chip { display: inline-flex; align-items: center; gap: 4px; flex: none;
  border: 1px solid var(--border, #2a2d3a); border-radius: 8px; padding: 2px 6px;
  font-size: 11px; color: var(--text-secondary, #9a9ab0); }
.ai-chip select { background: var(--bg-input, #1e2029); color: var(--text-primary, #e8e8ec);
  border: 1px solid var(--border, #2a2d3a); border-radius: 6px; font-size: 11px; padding: 1px 4px; }

/* ============================================================ N3: trang License & Gói */
.lic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.lic-card { background: var(--surface-1, #121218); border: 1px solid var(--border, #2a2d3a);
  border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lic-card.current { border-color: var(--accent, #7b61ff); }
.lic-card .lic-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.lic-card .lic-cur-badge { font-size: 10px; font-weight: 700; color: #fff; background: var(--accent, #7b61ff);
  border-radius: 999px; padding: 2px 8px; }
.lic-card .lic-feats { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-secondary, #9a9ab0);
  display: flex; flex-direction: column; gap: 3px; }
.lic-term-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--panel-line, var(--border, #2a2d3a)); padding-top: 8px; }
.lic-term-row .lic-price { font-weight: 700; }

/* ============================================================ N9+N10: chip license / hệ thống + panel */
.lic-chip { display: inline-flex; align-items: center; gap: 4px; flex: none; cursor: pointer;
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border, #2a2d3a); background: var(--bg-input, #1e2029);
  color: var(--text-secondary, #9a9ab0); }
.lic-chip.lock { border-color: rgba(224,82,96,.55); color: #ff8d97; background: rgba(224,82,96,.10); }
.lic-chip.warn { border-color: rgba(239,159,39,.55); color: #f3b95d; background: rgba(239,159,39,.10); }
.lic-chip.ok   { border-color: rgba(29,158,117,.45); color: #4ecf9d; background: rgba(29,158,117,.08); }
.lic-chip:hover { filter: brightness(1.15); }

/* Card tài khoản + gói ở sidebar (góp ý Victor 2026-07-13) — click → License & Gói */
.side-account { display: flex; align-items: center; gap: 9px; margin: 0 10px 12px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--panel-line, var(--border, #2a2d3a));
  background: var(--bg-input, rgba(255,255,255,.03)); }
.side-account:hover { border-color: var(--accent, #7B61FF); }
.side-account .sa-ava { flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, #7B61FF, #d16be6); }
.side-account .sa-info { min-width: 0; flex: 1; }
.side-account .sa-mail { font-size: 11.5px; font-weight: 600; color: var(--text, #e8e8f0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-account .sa-plan { font-size: 10.5px; font-weight: 700; margin-top: 2px; }
.side-account .sa-plan.ok { color: #4ecf9d; }
.side-account .sa-plan.warn { color: #f3b95d; }
.side-account .sa-plan.lock { color: #ff8d97; }
/* sidebar thu gọn (class trên body): chỉ còn avatar */
body.sidebar-collapsed .side-account { padding: 6px; justify-content: center; margin: 0 6px 12px; }
body.sidebar-collapsed .side-account .sa-info { display: none; }

/* X8 — khung chat hỗ trợ trong panel */
#support-panel #sp-msgs { max-height: 46vh; min-height: 120px; overflow: auto; padding: 4px 8px; }
#support-panel .sp-msg { margin: 6px 0; padding: 7px 10px; border-radius: 10px; font-size: 12.5px;
  line-height: 1.5; white-space: pre-wrap; background: var(--bg-input, #1e2029);
  border: 1px solid var(--border, #2a2d3a); }
#support-panel .sp-msg.user { background: rgba(123,97,255,.10); border-color: rgba(123,97,255,.35); }
#support-panel .sp-msg.admin { border-color: rgba(29,158,117,.45); }
#support-panel .sp-who { display: block; font-size: 10px; font-weight: 700; opacity: .65; margin-bottom: 2px; }

#sys-panel, #xu-panel, #support-panel { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 9600;
  width: 480px; max-width: calc(100vw - 24px); background: var(--surface-1, #121218);
  border: 1px solid var(--border, #2a2d3a); border-radius: 12px; padding: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5); font-size: 13px; }
#sys-panel .sys-head, #xu-panel .sys-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#sys-panel .sys-row, #xu-panel .sys-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0;
  border-top: 1px solid var(--panel-line, var(--border, #2a2d3a)); }
#sys-panel .sys-txt, #xu-panel .sys-txt { flex: 1; min-width: 0; }
#sys-panel .sys-txt .em, #xu-panel .sys-txt .em { color: var(--text-secondary, #9a9ab0); font-size: 12px; margin-top: 2px; }
#sys-panel .sys-act, #xu-panel .sys-act { flex: none; }
