/* ===== Tokens ===== */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, ui-monospace, monospace;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --topbar: 48px;
  --composer: 432px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e11;
  --bg-2: #111216;
  --panel: #15161b;
  --panel-2: #1b1c22;
  --panel-3: #22232a;
  --line: #24262d;
  --line-2: #30323a;
  --text: #ececef;
  --text-2: #a3a6ae;
  --text-3: #6b6e78;
  --primary: #f3f3f1;
  --primary-ink: #0d0e11;
  --primary-hover: #ffffff;
  --focus: #8db4ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --img: #6aa8ff;
  --vid: #ff8f5a;
  --aud: #47d69a;
  --ok: #47d69a;
  --warn: #f2c14e;
  --danger: #ff6464;
  --danger-bg: rgba(255, 100, 100, 0.1);
  --scrim: rgba(5, 6, 8, 0.72);
  --tile: #101115;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --bg-2: #efefec;
  --panel: #ffffff;
  --panel-2: #f7f7f5;
  --panel-3: #eeeeeb;
  --line: #e4e4df;
  --line-2: #d6d6d0;
  --text: #18181b;
  --text-2: #55565d;
  --text-3: #8a8b92;
  --primary: #141416;
  --primary-ink: #ffffff;
  --primary-hover: #000000;
  --focus: #2f6fe4;
  --shadow: 0 18px 50px rgba(20, 20, 30, 0.16), 0 2px 8px rgba(20, 20, 30, 0.08);
  --img: #2f7de0;
  --vid: #e0662c;
  --aud: #18a56c;
  --ok: #18a56c;
  --warn: #b98a10;
  --danger: #d93a3a;
  --danger-bg: rgba(217, 58, 58, 0.08);
  --scrim: rgba(20, 20, 24, 0.45);
  --tile: #ececE8;
}

body[data-mode="image"] { --mode: var(--img); }
body[data-mode="video"] { --mode: var(--vid); }
body[data-mode="audio"] { --mode: var(--aud); }

/* ===== Base ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
textarea, input, .selectable { user-select: text; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--focus); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12px; }
.icon { display: inline-flex; flex: none; }
.icon svg { display: block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--focus) 35%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Top bar ===== */
.topbar {
  height: var(--topbar);
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 12px;
  align-items: center;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  -webkit-app-region: drag;
  position: relative;
  z-index: 5;
}
body.platform-darwin .topbar { padding-left: 84px; }
body.platform-win32 .topbar, body.platform-linux .topbar { padding-right: 148px; }
.topbar button, .topbar nav, .topbar .provider-pills { -webkit-app-region: no-drag; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background:
    radial-gradient(circle at 30% 30%, var(--img) 0 28%, transparent 30%),
    radial-gradient(circle at 72% 40%, var(--vid) 0 24%, transparent 26%),
    radial-gradient(circle at 45% 76%, var(--aud) 0 24%, transparent 26%),
    var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.brand-name { font-family: var(--font-display); font-weight: 650; font-size: 13.5px; letter-spacing: 0.02em; white-space: nowrap; }
@media (max-width: 1180px) { .brand-name { display: none; } }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

.mode-switch {
  justify-self: center;
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
}
.mode-tab {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 14px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); cursor: pointer; font-weight: 550;
  transition: background 0.15s, color 0.15s;
}
.mode-tab:hover { color: var(--text); background: var(--panel-2); }
.mode-tab[aria-selected="true"] { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.2); }
.mode-tab[data-type="image"][aria-selected="true"] .icon { color: var(--img); }
.mode-tab[data-type="video"][aria-selected="true"] .icon { color: var(--vid); }
.mode-tab[data-type="audio"][aria-selected="true"] .icon { color: var(--aud); }

.provider-pills { display: flex; gap: 6px; margin-right: 4px; }
.provider-pill {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text-2); font-size: 12px; cursor: pointer; white-space: nowrap; flex: none;
}
.provider-pill .faint { font-variant-numeric: tabular-nums; }
@media (max-width: 1500px) {
  .provider-pill:not(.assistant-pill) .pp-name { display: none; }
  .provider-pill:not(.assistant-pill) .pp-short { display: inline; }
}
.pp-short { display: none; font-weight: 600; }
.provider-pill:hover { color: var(--text); border-color: var(--line-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ===== Layout ===== */
.layout { display: grid; grid-template-columns: var(--composer) 1fr; height: calc(100vh - var(--topbar)); }
.composer {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--bg-2);
}
.composer-scroll { flex: 1; overflow-y: auto; padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 18px; }
.composer-foot { padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 10px; }

.section { display: flex; flex-direction: column; gap: 8px; }
.section-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field-label .req { color: var(--mode); margin-left: 2px; }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; }
.field-row > .field.wide { grid-column: 1 / -1; }

/* ===== Inputs ===== */
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input, .select { height: 34px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.textarea.mono { font-family: var(--mono); font-size: 12px; }
.select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select option { background: var(--panel); color: var(--text); }

.prompt-box {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prompt-box:focus-within { border-color: color-mix(in srgb, var(--mode) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode) 14%, transparent); }
.prompt-box textarea {
  display: block; width: 100%; min-height: 132px; max-height: 340px; resize: none; border: 0; outline: none;
  background: transparent; padding: 12px 14px 34px; font-size: 14px; line-height: 1.55; color: var(--text);
}
.prompt-box textarea::placeholder { color: var(--text-3); }
.prompt-meta { position: absolute; left: 12px; right: 10px; bottom: 7px; display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-3); pointer-events: none; }
.prompt-meta .btn { pointer-events: auto; }

.pills { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pill {
  flex: 1 1 auto; min-width: 40px; height: 27px; padding: 0 10px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.pill:hover { background: var(--panel-2); color: var(--text); }
.pill[aria-pressed="true"] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; min-height: 34px; }
.switch-label { color: var(--text-2); font-size: 12.5px; }
.toggle { position: relative; width: 32px; height: 18px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background 0.15s; pointer-events: none; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.18s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.toggle input:checked + span { background: var(--mode, var(--focus)); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap input[type="range"] { flex: 1; accent-color: var(--mode); }
.range-wrap .range-val { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); height: 34px; }
.stepper button { width: 30px; height: 100%; border: 0; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.stepper button:hover { color: var(--text); background: var(--panel-2); }
.stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper .val { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
  font-weight: 550; transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-md { height: 32px; padding: 0 12px; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; border-radius: var(--radius); }
.btn-icon-only.btn-md { width: 32px; padding: 0; }
.btn-icon-only.btn-sm { width: 26px; padding: 0; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--panel-3); border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--focus); }

.generate-btn {
  width: 100%; height: 46px; font-size: 14.5px; border-radius: 11px; position: relative; overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mode) 35%, transparent), 0 8px 24px -10px color-mix(in srgb, var(--mode) 70%, transparent);
}
.generate-btn .kbd { margin-left: 6px; opacity: 0.55; font-size: 11.5px; font-weight: 500; }
.foot-gen { display: flex; gap: 8px; }
.foot-gen .generate-btn { flex: 1; width: auto; }
.compare-btn { width: 46px; height: 46px; flex: none; border-radius: 11px; border: 1px solid var(--line); padding: 0; justify-content: center; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.foot-row .faint { font-size: 12px; }

/* ===== Model picker ===== */
.model-trigger {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: left;
}
.model-trigger:hover { border-color: var(--line-2); background: var(--panel-2); }
.model-glyph {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--mode) 14%, var(--panel-2)); color: var(--mode);
}
.model-text { flex: 1; min-width: 0; }
.model-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-desc { font-size: 12px; color: var(--text-3); line-height: 1.45; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--panel-3); color: var(--text-2); white-space: nowrap;
}
.badge.kie { background: color-mix(in srgb, #a78bfa 16%, transparent); color: #b9a4ff; }
.badge.higgsfield { background: color-mix(in srgb, #f472b6 15%, transparent); color: #f59ccb; }
:root[data-theme="light"] .badge.kie { color: #6d4ad6; }
:root[data-theme="light"] .badge.higgsfield { color: #c0347e; }
.badge.mode-tag { text-transform: none; letter-spacing: 0; font-weight: 550; }

.popover {
  position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.14s, transform 0.14s var(--ease);
}
.popover.show { opacity: 1; transform: none; }
.popover-search { padding: 10px; border-bottom: 1px solid var(--line); }
.popover-list { overflow-y: auto; padding: 6px; }
.popover-group { padding: 10px 8px 4px; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.popover-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; text-align: left; color: var(--text);
}
.popover-item:hover, .popover-item.active { background: var(--panel-2); }
.popover-item[aria-selected="true"] { background: color-mix(in srgb, var(--mode) 12%, var(--panel-2)); }
.popover-item .pi-text { flex: 1; min-width: 0; }
.popover-item .pi-name { font-weight: 550; }
.popover-item .pi-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popover-empty { padding: 24px; text-align: center; color: var(--text-3); }

/* ===== Media drop ===== */
.dropzone {
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--panel);
  padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 72px;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag { border-color: var(--mode); background: color-mix(in srgb, var(--mode) 7%, var(--panel)); }
.thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; background: var(--tile); flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--text-3); padding: 4px; text-align: center; word-break: break-all; }
.thumb .thumb-x {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,0.65); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 0.12s;
}
.thumb:hover .thumb-x { opacity: 1; }
.drop-add {
  width: 60px; height: 60px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text-2); display: grid; place-items: center; cursor: pointer; flex: none;
}
.drop-add:hover { color: var(--text); border-color: var(--line-2); }
.drop-hint { flex: 1; min-width: 140px; font-size: 12px; color: var(--text-3); line-height: 1.4; }
.drop-hint a { font-size: 12px; }

/* ===== Collapsible ===== */
.collapse-head { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--text-3); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.collapse-head:hover { color: var(--text-2); }
.collapse-head .icon { transition: transform 0.15s; }
.collapse-head[aria-expanded="true"] .icon { transform: rotate(90deg); }

/* ===== Output card ===== */
.output-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.output-path { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 2px 2px; }
.output-path .icon { color: var(--text-3); }
.output-path .path-text { flex: 1; min-width: 0; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.output-actions { display: flex; gap: 6px; }
.notice { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; line-height: 1.45; }
.notice .icon { margin-top: 1px; color: var(--text-3); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.notice.warn .icon { color: var(--warn); }

/* ===== Library ===== */
.library { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.lib-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.lib-head .lib-search { min-width: 140px; }
.lib-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-right: 6px; }
.lib-count { color: var(--text-3); font-weight: 500; margin-left: 4px; }
.chips { display: flex; gap: 4px; }
.chip { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--panel-3); color: var(--text); border-color: var(--line-2); }
.chip .n { color: var(--text-3); font-variant-numeric: tabular-nums; }
.lib-search { margin-left: auto; position: relative; width: 240px; }
.lib-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.lib-search .input { padding-left: 32px; height: 30px; border-radius: 999px; }
.lib-body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }

.card {
  position: relative; border-radius: var(--radius-lg); background: var(--panel); border: 1px solid var(--line);
  overflow: hidden; display: flex; flex-direction: column; transition: border-color 0.15s, transform 0.18s var(--ease), box-shadow 0.18s;
  animation: cardIn 0.28s var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }
.card:hover { border-color: var(--line-2); box-shadow: 0 10px 30px -14px rgba(0,0,0,0.5); }
.card-media { position: relative; aspect-ratio: 1 / 1; background: var(--tile); cursor: zoom-in; overflow: hidden; }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .multi { position: absolute; left: 8px; top: 8px; }
.card-type { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 5px; }
.type-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 6px; background: rgba(10,10,12,0.66); color: #fff; font-size: 11px; font-weight: 600; backdrop-filter: blur(8px); }
.type-badge.image .icon { color: #9cc6ff; }
.type-badge.video .icon { color: #ffb08a; }
.type-badge.audio .icon { color: #82e8bd; }
.card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transform: translateY(-3px); transition: opacity 0.14s, transform 0.14s; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; transform: none; }
.card-actions .btn { background: rgba(10,10,12,0.66); color: #fff; backdrop-filter: blur(8px); border: 0; }
.card-actions .btn:hover { background: rgba(10,10,12,0.85); color: #fff; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.card-prompt { font-size: 12.5px; color: var(--text); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); min-width: 0; }
.card-meta .model { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.card-meta .sep { opacity: 0.5; }
.card-meta .drive { color: var(--ok); display: inline-flex; }
.card-meta .warn-ic { color: var(--warn); display: inline-flex; margin-left: auto; }

/* running / failed tile states */
.tile-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; }
.tile-running {
  background:
    linear-gradient(110deg, transparent 30%, color-mix(in srgb, var(--tc) 14%, transparent) 50%, transparent 70%) 0 0 / 250% 100%,
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--tc) 16%, transparent), transparent 65%),
    var(--tile);
  animation: shimmer 2.2s linear infinite;
}
@keyframes shimmer { to { background-position: -250% 0, 0 0, 0 0; } }
.tile-running .spinner { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--tc) 25%, transparent); border-top-color: var(--tc); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tile-status { font-weight: 600; font-size: 13px; }
.tile-sub { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.progress { width: 70%; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--tc) 18%, transparent); overflow: hidden; }
.progress > div { height: 100%; background: var(--tc); border-radius: 4px; transition: width 0.4s var(--ease); }
.tile-failed { background: var(--danger-bg); }
.tile-failed .icon { color: var(--danger); }
.tile-failed .tile-err { font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; user-select: text; }
.tile-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tile-canceled { background: var(--tile); color: var(--text-3); }
.card[data-type="image"] { --tc: var(--img); }
.card[data-type="video"] { --tc: var(--vid); }
.card[data-type="audio"] { --tc: var(--aud); }

.audio-tile { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 0 22px; background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--aud) 12%, transparent), transparent 70%), var(--tile); }
.audio-tile .bar { width: 4px; border-radius: 3px; background: color-mix(in srgb, var(--aud) 70%, var(--text-3)); opacity: 0.85; }
.audio-play {
  position: absolute; width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink); cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  left: 50%; top: 50%; transform: translate(-50%, -50%); transition: transform 0.15s var(--ease);
}
.audio-play:hover { transform: translate(-50%, -50%) scale(1.06); }
.video-glyph { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(10,10,12,0.55); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); pointer-events: none; transition: opacity 0.15s; }
.card-media:hover .video-glyph { opacity: 0; }

/* empty state */
.empty { max-width: 560px; margin: 8vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-art { width: 92px; height: 92px; border-radius: 26px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--mode); box-shadow: 0 20px 40px -20px color-mix(in srgb, var(--mode) 60%, transparent); }
.empty h3 { font-size: 18px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 10px; text-align: left; }
.step { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.step .num { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-3); font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.step.done .num { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.step b { font-size: 12.5px; }
.step span { font-size: 12px; color: var(--text-3); }

/* ===== Overlay / modal ===== */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center; opacity: 0; transition: opacity 0.18s; backdrop-filter: blur(3px); }
.overlay.show { opacity: 1; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); max-height: calc(100vh - 64px); display: flex; flex-direction: column; transform: translateY(6px) scale(0.99); transition: transform 0.2s var(--ease); }
.overlay.show .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-head h2 { font-size: 16px; }
.modal-head p { margin-top: 3px; font-size: 12.5px; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.confirm-msg { color: var(--text-2); line-height: 1.55; }

/* settings */
.settings { display: grid; grid-template-columns: 180px 1fr; min-height: 520px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px 16px 0; border-right: 1px solid var(--line); }
.settings-nav button { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; text-align: left; font-weight: 500; }
.settings-nav button:hover { background: var(--panel-2); color: var(--text); }
.settings-nav button[aria-selected="true"] { background: var(--panel-3); color: var(--text); }
.settings-pane { padding: 4px 0 8px 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.settings-pane h3 { font-size: 14px; }
.settings-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--panel-2); }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-card-head .title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; }
.key-row { display: flex; gap: 8px; }
.key-row .input { flex: 1; font-family: var(--mono); font-size: 12px; }
.status-line { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--text-2); min-height: 18px; }
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--danger); }
.tokens { display: flex; flex-wrap: wrap; gap: 5px; }
.token { font-family: var(--mono); font-size: 11.5px; padding: 2px 7px; border-radius: 5px; background: var(--panel-3); color: var(--text-2); cursor: pointer; border: 0; }
.token:hover { color: var(--text); }
.steps-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.7; }
.steps-list code, .code-inline { font-family: var(--mono); font-size: 11.5px; padding: 1px 5px; border-radius: 4px; background: var(--panel-3); color: var(--text); user-select: text; }

/* drive browser */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 10px; }
.crumbs button { border: 0; background: none; color: var(--text-2); cursor: pointer; padding: 3px 6px; border-radius: 5px; }
.crumbs button:hover { background: var(--panel-2); color: var(--text); }
.crumbs .icon { color: var(--text-3); }
.folder-list { border: 1px solid var(--line); border-radius: var(--radius); min-height: 260px; max-height: 360px; overflow-y: auto; padding: 4px; }
.folder-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); cursor: pointer; text-align: left; }
.folder-item:hover { background: var(--panel-2); }
.folder-item .icon { color: var(--text-3); }
.folder-empty { padding: 40px; text-align: center; color: var(--text-3); }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 45; background: var(--scrim); backdrop-filter: blur(10px); display: grid; grid-template-columns: 1fr 380px; opacity: 0; transition: opacity 0.18s; }
.lightbox.show { opacity: 1; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 64px 40px 40px; min-width: 0; min-height: 0; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); background: var(--tile); }
.lb-stage audio { width: min(560px, 90%); }
.lb-audio { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.lb-audio .wave { display: flex; align-items: center; gap: 4px; height: 140px; }
.lb-audio .wave .bar { width: 5px; border-radius: 3px; background: var(--aud); opacity: 0.75; }
.lb-close { position: absolute; top: 14px; left: 16px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-thumbs { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.lb-thumbs button { width: 42px; height: 42px; padding: 0; border-radius: 7px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--tile); }
.lb-thumbs button[aria-pressed="true"] { border-color: var(--primary); }
.lb-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.lb-side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.lb-side-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.lb-side-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; }
.lb-prompt { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; user-select: text; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; user-select: text; }
.file-row { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.file-row .name { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; color: var(--text-2); }
.err-box { border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-bg); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; user-select: text; white-space: pre-wrap; word-break: break-word; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: 420px; padding: 10px 14px;
  border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s var(--ease); cursor: pointer;
}
.toast.show { opacity: 1; transform: none; }
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: var(--ok); }
.toast-error .icon { color: var(--danger); }
.toast-info .icon { color: var(--focus); }
.toast-msg { line-height: 1.45; user-select: text; }

@media (max-width: 1180px) {
  :root { --composer: 392px; }
  .lightbox { grid-template-columns: 1fr 320px; }
  .lib-search { width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Library / References switch ---------- */
.view-switch { display: flex; gap: 2px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; margin-right: 6px; flex: none; }
.view-tab { height: 26px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display); }
.view-tab:hover { color: var(--text); }
.view-tab[aria-selected="true"] { background: var(--panel-3); color: var(--text); }
.view-tab .n { font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- References ---------- */
.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 8px 20px; border-bottom: 1px solid var(--line); font-size: 12px; }
.tag-bar > .faint { margin-right: 4px; }
.tag { height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.tag:hover { color: var(--text); border-color: var(--line-2); }
.tag[aria-pressed="true"] { background: color-mix(in srgb, var(--focus) 16%, var(--panel-2)); border-color: color-mix(in srgb, var(--focus) 45%, var(--line)); color: var(--text); }
.tag .n { color: var(--text-3); font-size: 11px; }
.refs-body { transition: background 0.15s, box-shadow 0.15s; }
.refs-body.drag { background: color-mix(in srgb, var(--focus) 6%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--focus) 55%, transparent); }
.refs-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.ref-card { cursor: grab; }
.ref-card:active { cursor: grabbing; }
.ref-card .card-media { cursor: pointer; }
.ref-card .card-prompt { min-height: 0; -webkit-line-clamp: 1; font-weight: 550; }
.ref-tags { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.ref-use {
  position: absolute; right: 8px; bottom: 8px; height: 26px; padding: 0 10px; border-radius: 7px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650;
  background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(3px); transition: opacity 0.14s, transform 0.14s;
}
.ref-card:hover .ref-use, .ref-card:focus-within .ref-use { opacity: 1; transform: none; }
.ref-audio { flex-direction: column; gap: 10px; color: var(--aud); padding: 18px; text-align: center; }
.ref-audio span { color: var(--text-2); font-size: 12px; word-break: break-word; }
body.ref-dragging .dropzone { border-color: color-mix(in srgb, var(--mode) 60%, var(--line)); background: color-mix(in srgb, var(--mode) 5%, var(--panel)); }

.ref-detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.ref-preview { background: var(--tile); border-radius: 10px; overflow: hidden; display: grid; place-items: center; min-height: 220px; max-height: 460px; }
.ref-preview img, .ref-preview video { max-width: 100%; max-height: 460px; display: block; }
.ref-preview audio { width: 92%; }
.ref-form { display: flex; flex-direction: column; gap: 12px; }

.ref-picker { max-height: 380px; }
.ref-pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; overflow-y: auto; }
.ref-pick-grid .popover-empty { grid-column: 1 / -1; }
.ref-pick { position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--tile); padding: 0; cursor: pointer; overflow: hidden; aspect-ratio: 1 / 1; color: var(--text-2); }
.ref-pick:hover { border-color: var(--line-2); }
.ref-pick.picked { border-color: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 40%, transparent); }
.ref-pick img, .ref-pick video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-pick .ref-audio, .ref-pick .tile-state { position: absolute; inset: 0; }
.ref-pick > span { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 5px; font-size: 10.5px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }

/* ---------- provider badges ---------- */
.badge.magnific { background: color-mix(in srgb, #fbbf24 16%, transparent); color: #fcd34d; }
.badge.claude { background: color-mix(in srgb, #e8875a 16%, transparent); color: #f0a47e; }
.badge.openai { background: color-mix(in srgb, #4ade80 14%, transparent); color: #7ee2a8; }
:root[data-theme="light"] .badge.magnific { color: #a16207; }
:root[data-theme="light"] .badge.claude { color: #b4532a; }
:root[data-theme="light"] .badge.openai { color: #15803d; }

/* ---------- prompt tools ---------- */
.prompt-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ptool {
  height: 26px; padding: 0 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  font-size: 12px; font-weight: 550; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ptool:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.ptool .icon { color: var(--mode); }
.ptool:disabled { opacity: 0.6; cursor: progress; }
.ptool.busy .icon { animation: spin 0.9s linear infinite; }
.ptool-conn { margin-left: auto; font-size: 11px; color: var(--text-3); white-space: nowrap; }
.plan-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.plan-indicator .icon { color: #7ee2a8; }
.plan-indicator a { font-size: 11.5px; }

/* ---------- assistant review / variations ---------- */
.ai-review { display: flex; flex-direction: column; gap: 10px; }
.ai-review .textarea { min-height: 150px; font-size: 13.5px; }
.ai-orig summary { cursor: pointer; color: var(--text-3); font-size: 12px; }
.ai-orig .lb-prompt { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.ai-variations { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-var { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-var-title { font-weight: 650; font-size: 13px; }
.ai-var-text { font-size: 12.5px; line-height: 1.5; color: var(--text-2); flex: 1; user-select: text; white-space: pre-wrap; }
.ai-var-actions { display: flex; justify-content: flex-end; gap: 6px; }
.ai-guide { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; }
.ai-guide .icon { color: var(--primary); flex: none; }
.ai-guide a { font-size: 11.5px; }

/* ---------- assistant chat panel ---------- */
.assistant-panel {
  position: fixed; top: var(--topbar); right: 0; bottom: 0; width: min(420px, 92vw); z-index: 30;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(0,0,0,0.28);
  display: flex; flex-direction: column; transform: translateX(16px); opacity: 0; transition: transform 0.18s var(--ease), opacity 0.18s;
}
.assistant-panel.show { transform: none; opacity: 1; }
.chat-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; align-items: center; gap: 7px; font-weight: 650; font-family: var(--font-display); }
.chat-title .icon { color: var(--mode); }
.chat-conn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); border-radius: 999px; height: 24px; padding: 0 9px; font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.chat-conn:hover { color: var(--text); }
.chat-plan { flex-basis: 100%; }
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 20px 10px; }
.chat-empty p { font-size: 12.5px; max-width: 320px; }
.chat-suggest { border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-size: 12.5px; width: 100%; text-align: left; }
.chat-suggest:hover { color: var(--text); border-color: var(--line-2); }
.msg { max-width: 92%; border-radius: 12px; padding: 9px 12px; font-size: 13px; line-height: 1.55; display: flex; flex-direction: column; gap: 8px; user-select: text; }
.msg.user { align-self: flex-end; background: color-mix(in srgb, var(--mode) 16%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--mode) 25%, var(--line)); }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg.typing .msg-text { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-err { color: var(--danger); font-size: 12px; }
.msg-imgs { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-imgs img { width: 64px; height: 64px; object-fit: cover; border-radius: 7px; }
.msg-prompt { border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel); overflow: hidden; }
.msg-prompt-text { padding: 9px 11px; font-size: 12.5px; white-space: pre-wrap; color: var(--text); }
.msg-prompt-actions { display: flex; justify-content: flex-end; gap: 4px; padding: 5px 6px; border-top: 1px solid var(--line); background: var(--panel-2); }
.msg-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.msg-act-title { display: flex; align-items: center; gap: 6px; padding: 8px 11px 0; font-weight: 650; font-size: 12.5px; }
.msg-act-title .icon { color: var(--primary); }
.msg-act-why { padding: 3px 11px 0; font-size: 12px; color: var(--text-2); }
.msg-actions .ai-chips { padding: 6px 11px 0; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); }
.ai-var-why { font-size: 12.5px; color: var(--text-2); }

/* ---------- Review with Genie ---------- */
.gr { display: flex; flex-direction: column; gap: 14px; }
.gr-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.gr-media { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.gr-brief { display: flex; flex-direction: column; gap: 6px; }
.gr-prompt { max-height: 140px; overflow: auto; font-size: 12.5px; color: var(--text-2); }
.gr-wait { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; padding: 8px 0; }
.gr-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--primary); animation: spin 0.9s linear infinite; flex: none; }
.gr-result { display: flex; flex-direction: column; gap: 12px; }
.gr-frames { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.gr-frames figure { margin: 0; }
.gr-frames img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }
.gr-frames figcaption { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 3px; }
.gr-summary { margin: 0; font-size: 13.5px; line-height: 1.55; }
.gr-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; }
.gr-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.5; }
.gr-list li { display: flex; gap: 7px; align-items: flex-start; }
.gr-list li .icon { flex: none; margin-top: 3px; color: var(--warn); }
.gr-list.ok li .icon { color: var(--ok); }
.gr-revised { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
@media (max-width: 760px) { .gr-top, .gr-cols { grid-template-columns: 1fr; } }
.chat-compose { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.chat-attach { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-attach:empty { display: none; }
.chat-input { width: 100%; resize: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13px; line-height: 1.5; outline: none; }
.chat-input:focus { border-color: color-mix(in srgb, var(--mode) 55%, var(--line)); }
.chat-compose-row { display: flex; align-items: center; gap: 8px; }

/* ---------- settings: assistant & MCP ---------- */
.seg { display: inline-flex; flex-wrap: nowrap; }
.seg .pill { display: inline-flex; align-items: center; gap: 6px; }
.settings-card.active-card { border-color: color-mix(in srgb, var(--focus) 45%, var(--line)); }
.muted.small, .small { font-size: 12.5px; }
.usage-box { display: flex; flex-direction: column; gap: 5px; border-top: 1px dashed var(--line); padding-top: 10px; }
.usage-row { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.usage-row .icon { margin-top: 2px; flex: none; }
.usage-row.faint { color: var(--text-3); }
.usage-row.warn { color: var(--warn); }
.usage-table { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px 16px; font-size: 12.5px; align-items: center; }
.usage-table .ut-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.code-block { position: relative; font-family: var(--mono); font-size: 11.5px; background: var(--panel-3); border-radius: 8px; padding: 10px 40px 10px 12px; word-break: break-all; user-select: text; color: var(--text); }
.code-block.pre { white-space: pre-wrap; }
.code-block .btn { position: absolute; top: 6px; right: 6px; }
.chatgpt-btn { background: #0d0d0d; color: #fff; border: 1px solid #2a2a2a; }
.chatgpt-btn:hover:not(:disabled) { background: #000; }
:root[data-theme="light"] .chatgpt-btn { background: #0d0d0d; color: #fff; }
.assistant-pill .icon { color: var(--focus); }
.seg { width: fit-content; max-width: 100%; }
.seg .pill { flex: none; }

.badge.elevenlabs { background: color-mix(in srgb, #e5e7eb 14%, transparent); color: #e5e7eb; }
:root[data-theme="light"] .badge.elevenlabs { color: #27272a; background: color-mix(in srgb, #27272a 10%, transparent); }
.voice-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 12px; }
.voice-chips .tag { height: 22px; font-size: 11.5px; }

/* ---------- sign-in pages (web app) ---------- */
body.auth-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--img) 10%, transparent), transparent 60%), var(--bg); overflow: auto; }
.auth-shell { width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 18px; padding: 40px 0; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.auth-card h1 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.auth-card > .muted { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .field { display: flex; flex-direction: column; gap: 6px; }
.auth-form .input { height: 40px; font-size: 14px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }
.auth-error { font-size: 13px; color: var(--danger); background: var(--danger-bg); border-radius: 8px; padding: 8px 10px; white-space: pre-line; }
.auth-notice { font-size: 13px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.auth-link { font-size: 13px; text-align: center; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-trust { margin-top: 2px; }
.code-input { font-family: var(--mono); font-size: 24px !important; letter-spacing: 10px; text-align: center; height: 52px !important; }
.auth-foot { text-align: center; font-size: 12px; color: var(--text-3); }
.btn-link:disabled { color: var(--text-3); cursor: default; }

/* ---------- user menu (web app) ---------- */
.user-btn { -webkit-app-region: no-drag; border: 0; background: none; padding: 0 2px; cursor: pointer; }
.user-btn .avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; background: color-mix(in srgb, var(--img) 30%, var(--panel-3)); color: var(--text); }
.user-menu { min-width: 240px; padding: 6px; }
.user-menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; }
.user-menu-head .faint { font-size: 11.5px; }
.upload-progress { position: fixed; left: 18px; bottom: 18px; z-index: 85; padding: 9px 14px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 12.5px; }

/* ---------- Library (items) ---------- */
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 20px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.filter-select, .chip-select { height: 28px; font-size: 12.5px; width: auto; max-width: 220px; padding: 0 26px 0 10px; border-radius: 999px; }
.items-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.item-card .card-media { cursor: pointer; }
.item-card.selected { outline: 2px solid var(--focus); outline-offset: 1px; }
.select-box { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px; background: rgba(10,10,12,0.6); border: 1.5px solid rgba(255,255,255,0.7); display: grid; place-items: center; color: #fff; }
.item-card.selected .select-box { background: var(--focus); border-color: var(--focus); }
.shared-badge { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 6px; background: rgba(10,10,12,0.66); color: #9fd7ff; font-size: 11px; font-weight: 600; backdrop-filter: blur(8px); }
.shared-badge.pending { color: #f2c14e; }
.fav-btn { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(10,10,12,0.5); color: rgba(255,255,255,0.75); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 0.14s; }
.item-card:hover .fav-btn, .fav-btn.on { opacity: 1; }
.fav-btn.on { color: #f2c14e; }
.fav-btn.on svg { fill: currentColor; }
.bulk-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--panel); box-shadow: 0 -10px 30px rgba(0,0,0,0.2); }
.load-more { display: flex; justify-content: center; padding: 18px; }
.btn.active { background: var(--panel-3); color: var(--text); }
.item-preview { min-height: 280px; }
.item-prompt { max-height: 140px; overflow-y: auto; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.input-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.input-thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.library { display: flex; flex-direction: column; min-height: 0; }

/* ---------- team admin ---------- */
.team-body { display: flex; flex-direction: column; gap: 14px; }
.people { display: flex; flex-direction: column; }
.person { display: grid; grid-template-columns: minmax(0, 1.6fr) auto auto minmax(0, 1fr) minmax(0, 0.9fr) auto; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); font-size: 12.5px; }
.person:first-child { border-top: 0; }
.person.off { opacity: 0.6; }
.person-main { display: flex; flex-direction: column; min-width: 0; }
.person-main b, .person-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-main span { font-size: 11.5px; }
.person-usage, .person-seen { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-3); color: var(--text-2); }
.status-chip.active { color: var(--ok); }
.status-chip.locked, .status-chip.invited { color: var(--warn); }
.status-chip.disabled { color: var(--danger); }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-top: 1px solid var(--line); font-size: 12.5px; }
.mini-row:first-child { border-top: 0; }
.mini-row > span:first-child { flex: 1; min-width: 0; }
.mini-row .faint { font-size: 11.5px; white-space: nowrap; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.usage-table.team { grid-template-columns: 1.5fr repeat(4, auto); }
.ut-head { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.manage-user .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.manage-user .field-row.three { grid-template-columns: repeat(3, 1fr); }

/* ===== Identities (reference sets) ===== */
.id-section { display: flex; flex-direction: column; gap: 8px; }
.id-use { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 1px dashed var(--line-2); border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; text-align: left; }
.id-use:hover { color: var(--text); border-color: var(--text-3); }
.id-use .faint { margin-left: auto; font-size: 11.5px; }
.id-chip { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.id-chip.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.id-chip-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.id-chip-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-chip-text .faint { font-size: 11.5px; }
.id-cover { width: 36px; height: 36px; flex: none; border-radius: 8px; overflow: hidden; background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.id-cover img { width: 100%; height: 100%; object-fit: cover; }
.id-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.id-notes li { display: flex; gap: 6px; font-size: 11.8px; line-height: 1.4; color: var(--text-2); }
.id-notes li .icon { flex: none; margin-top: 1px; color: var(--ok); }
.id-notes li.warn .icon { color: var(--warn); }
.id-hint-toggle { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.id-hint-toggle input { margin-top: 2px; }
.id-pop { padding: 0; }
.id-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.id-pick-list { max-height: 300px; overflow-y: auto; padding: 4px; }
.id-pick .id-cover { width: 32px; height: 32px; }
.id-new { color: var(--text-2); }
.id-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.id-card { display: flex; flex-direction: column; gap: 3px; padding: 0 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: left; overflow: hidden; color: var(--text); }
.id-card:hover { border-color: var(--line-2); }
.id-card b, .id-card .faint { padding: 0 10px; font-size: 12.5px; }
.id-card .faint { font-size: 11.5px; }
.id-card-art { display: grid; grid-template-columns: 1fr 1fr; aspect-ratio: 4 / 3; background: var(--panel-2); margin-bottom: 6px; align-items: center; justify-items: center; color: var(--text-3); overflow: hidden; }
.id-card-art img { width: 100%; height: 100%; object-fit: cover; }
.id-card-art img:only-child { grid-column: 1 / -1; grid-row: 1 / 3; }
.id-editor { display: flex; flex-direction: column; gap: 14px; }
.id-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.id-strip { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.id-pic { position: relative; width: 84px; height: 84px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.id-pic img { width: 100%; height: 100%; object-fit: cover; }
.id-pic-first { position: absolute; left: 4px; bottom: 4px; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: rgba(0, 0, 0, 0.65); color: #fff; }
.id-pic-tools { position: absolute; top: 3px; right: 3px; display: flex; gap: 3px; }
.id-pic-tools button { width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer; padding: 0; line-height: 1; font-size: 13px; }
.id-add { display: flex; gap: 6px; flex-wrap: wrap; }
.id-settings { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.lab-identity { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.lab-ref-x.static { position: static; width: 18px; height: 18px; background: var(--panel-3); color: var(--text-2); }

/* ===== Provider health card ===== */
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.ph-pop { padding: 12px; }
.ph-body { display: flex; flex-direction: column; gap: 10px; }
.ph-head { display: flex; align-items: center; gap: 8px; }
.ph-head .faint { margin-left: auto; font-size: 12px; }
.ph-kv { font-size: 12px; }
.ph-err { font-size: 12px; }
.ph-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* Top bar: step down as the window narrows (8 workspaces + provider status). */
@media (max-width: 1720px) {
  .mode-tab { padding: 0 10px; gap: 6px; }
}
@media (max-width: 1700px) {
  .provider-pill .faint { display: none; }
}
@media (max-width: 1620px) {
  .mode-tab:not([aria-selected="true"]):is([data-type="studio"], [data-type="flows"], [data-type="projects"], [data-type="lab"], [data-type="publish"]) .mt-label { display: none; }
  .mode-tab:not([aria-selected="true"]):is([data-type="studio"], [data-type="flows"], [data-type="projects"], [data-type="lab"], [data-type="publish"]) { padding: 0 9px; }
}
@media (max-width: 1240px) {
  .mode-tab:not([aria-selected="true"]) .mt-label { display: none; }
  .mode-tab:not([aria-selected="true"]) { padding: 0 9px; }
}
