:root {
  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --surface-3: #ececec;
  --hover: rgba(0, 0, 0, .05);
  --active: rgba(0, 0, 0, .08);
  --text: #0d0d0d;
  --text-2: #5d5d5d;
  --text-3: #8f8f8f;
  --border: rgba(0, 0, 0, .1);
  --border-strong: rgba(0, 0, 0, .15);
  --accent: #0d0d0d;
  --accent-text: #ffffff;
  --blue: #2b7fff;
  --danger: #e02e2a;
  --danger-bg: rgba(224, 46, 42, .08);
  --code-bg: #f9f9f9;
  --shadow-composer: 0 0 0 1px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --shadow-pop: 0 0 0 1px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .14);
  --radius: 12px;
  --sidebar-w: 260px;
  --panel-w: 324px;
  --topbar-h: 52px;
  --caption-w: 138px;
  --thread-w: 768px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #212121;
  --sidebar: #181818;
  --surface: #303030;
  --surface-2: #303030;
  --surface-3: #3a3a3a;
  --hover: rgba(255, 255, 255, .06);
  --active: rgba(255, 255, 255, .1);
  --text: #ececec;
  --text-2: #b4b4b4;
  --text-3: #8a8a8a;
  --border: rgba(255, 255, 255, .1);
  --border-strong: rgba(255, 255, 255, .16);
  --accent: #ececec;
  --accent-text: #0d0d0d;
  --danger: #ff6b67;
  --danger-bg: rgba(255, 107, 103, .1);
  --code-bg: #171717;
  --shadow-composer: 0 0 0 1px rgba(255, 255, 255, .06), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .08), 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
kbd { font-family: inherit; }
::selection { background: rgba(43, 127, 255, .25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, .28); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(128, 128, 128, .45); }
::-webkit-scrollbar-track { background: transparent; }

.drag { -webkit-app-region: drag; }
.no-drag, .drag button, .drag input { -webkit-app-region: no-drag; }
.grow { flex: 1; }

.i { width: 20px; height: 20px; flex: none; display: block; }
.i.sm { width: 16px; height: 16px; }
.i.xs { width: 13px; height: 13px; }
.i.xl { width: 40px; height: 40px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-grid; place-items: center;
  color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.round { border-radius: 50%; border: 1px solid var(--border); }
.icon-btn.on { color: var(--blue); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg);
  font-size: 14px; font-weight: 500;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { opacity: .88; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid transparent;
  transition: margin-left .2s ease;
}
html[data-theme="dark"] .sidebar { border-right-color: rgba(255, 255, 255, .04); }
.app.sb-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.sb-head { height: var(--topbar-h); display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.sb-brand { flex: 1; font-size: 18px; font-weight: 600; padding-left: 6px; letter-spacing: -.01em; }

.sb-nav { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-item {
  width: 100%; height: 38px; padding: 0 10px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  font-size: 14px;
}
.sb-item span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item:hover, .sb-item.active { background: var(--hover); }
.sb-item kbd { font-size: 12px; color: var(--text-3); opacity: 0; transition: opacity .12s; }
.sb-item:hover kbd { opacity: 1; }

.sb-search {
  margin: 0 8px 8px; height: 38px; border-radius: 10px; padding: 0 4px 0 10px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-3);
}
.sb-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--text); }

.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.cl-group { font-size: 13px; color: var(--text-3); padding: 16px 10px 6px; font-weight: 500; }
.cl-item {
  position: relative; height: 36px; border-radius: 10px;
  display: flex; align-items: center; padding: 0 6px 0 10px; gap: 6px;
  font-size: 14px; cursor: pointer;
}
.cl-item:hover, .cl-item.menu-open { background: var(--hover); }
.cl-item.active { background: var(--active); }
.cl-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item .cl-snippet { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item.has-snippet { height: auto; padding-top: 6px; padding-bottom: 6px; }
.cl-item .cl-text { flex: 1; min-width: 0; }
.cl-more { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); opacity: 0; }
.cl-item:hover .cl-more, .cl-item.menu-open .cl-more, .cl-item.active .cl-more { opacity: 1; }
.cl-more:hover { color: var(--text); }
.cl-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-3); border-top-color: transparent; animation: spin .8s linear infinite; flex: none; }
.cl-rename { flex: 1; min-width: 0; border: 1px solid var(--blue); border-radius: 6px; padding: 2px 6px; background: var(--bg); outline: 0; font-size: 14px; }
.cl-empty { color: var(--text-3); font-size: 13px; padding: 16px 10px; }

.sb-foot { padding: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.balance-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 10px; border-radius: 10px; text-align: left;
  cursor: pointer;
}
.balance-card:hover { background: var(--hover); }
.bal-btn {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; color: var(--text-3);
  transition: background .12s, color .12s;
}
.bal-btn .i { width: 17px; height: 17px; }
.bal-btn:hover { background: var(--active); color: var(--text); }
.bal-btn.pay { color: #7c5cff; }
.bal-btn.pay:hover { background: rgba(124, 92, 255, .12); color: #6a4cf0; }
html[data-theme="dark"] .bal-btn.pay { color: #a28cff; }
.balance-card.loading .bal-btn.refresh .i { animation: spin .8s linear infinite; }
.update-card {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-align: left;
  background: rgba(124, 92, 255, .1); margin-bottom: 4px;
}
.update-card:hover { background: rgba(124, 92, 255, .16); }
.upd-icon { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #7c5cff, #2b7fff); }
.upd-icon .i { width: 17px; height: 17px; }
.update-card:not(.busy) .upd-icon { animation: updPulse 2.4s ease-in-out infinite; }
@keyframes updPulse { 50% { box-shadow: 0 0 0 6px rgba(124, 92, 255, .18); } }
.upd-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.upd-title { font-size: 14px; font-weight: 600; }
.upd-sub { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: linear-gradient(90deg, #7c5cff, #2b7fff); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform .2s; }
.upd-notes { margin: 0 0 12px; padding-left: 20px; font-size: 14px; color: var(--text); }
.upd-notes li + li { margin-top: 4px; }
.upd-hint { font-size: 13px !important; color: var(--text-3) !important; }

.bal-icon {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #2b7fff);
}
.bal-icon .i { width: 17px; height: 17px; }
.bal-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.bal-label { font-size: 12px; color: var(--text-3); }
.bal-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.low-balance .bal-value, .balance-pill.low { color: var(--danger); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 4px; padding: 0 0 0 8px; }
.caption-spacer { width: var(--caption-w); flex: none; }

/* macOS: кнопки окна («светофор») слева, справа места под системные кнопки не нужно. */
html.platform-mac { --caption-w: 12px; --traffic-w: 84px; }
html.platform-mac .sb-head { padding-left: var(--traffic-w); }
html.platform-mac .app.sb-collapsed .topbar { padding-left: var(--traffic-w); }
html.platform-mac.fullscreen { --traffic-w: 8px; }
.model-btn {
  height: 40px; padding: 0 10px 0 12px; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 18px; font-weight: 500; letter-spacing: -.01em;
}
.model-btn .i { color: var(--text-3); }
.model-btn:hover { background: var(--hover); }
.balance-pill {
  height: 32px; padding: 0 12px; border-radius: 999px; margin-right: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  border: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.balance-pill:hover { background: var(--hover); color: var(--text); }
.balance-pill .i { color: #7c5cff; }

.body-row { flex: 1; min-height: 0; display: flex; }
.main { flex: 1; min-width: 0; position: relative; display: flex; }

/* ---------------------------------------------------------------- chat */

.chat-view { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
.thread { max-width: calc(var(--thread-w) + 48px); margin: 0 auto; padding: 12px 24px 32px; }

.chat-view.is-empty .scroller { flex: 0 0 auto; }
.chat-view.is-empty { justify-content: center; padding-bottom: 12vh; }
.empty { text-align: center; padding: 0 24px 28px; }
.empty h1 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -.02em; }

.msg { margin: 0 0 28px; position: relative; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  background: var(--surface-2); border-radius: 22px;
  padding: 10px 18px; max-width: 72%;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble .img-tag { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.msg-atts { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 8px; margin-bottom: 8px; max-width: 80%; }
.msg-atts .att-img { width: 180px; height: 180px; border-radius: 16px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.msg-atts.many .att-img { width: 110px; height: 110px; border-radius: 12px; }
.msg-atts .att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.file-card {
  display: flex; align-items: center; gap: 10px;
  width: 240px; padding: 8px 12px 8px 8px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg); text-align: left;
  position: relative;
}
.file-card .fc-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none; font-size: 10px; font-weight: 700; }
.file-card .fc-text { min-width: 0; line-height: 1.3; }
.file-card .fc-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .fc-meta { font-size: 12px; color: var(--text-3); }
button.file-card:hover { background: var(--hover); }

.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; min-height: 32px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg-user .msg-actions { justify-content: flex-end; }
.msg-actions .icon-btn { width: 32px; height: 32px; }
.msg-actions .i { width: 18px; height: 18px; }
.msg-meta { font-size: 12px; color: var(--text-3); margin-left: 8px; white-space: nowrap; }

.edit-box { width: 100%; background: var(--surface-2); border-radius: 22px; padding: 12px 16px; }
.edit-box textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 15px; line-height: 1.5; min-height: 48px; max-height: 50vh; }
.edit-box .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* assistant markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 24px 0 10px; font-weight: 600; letter-spacing: -.01em; }
.md h1 { font-size: 26px; }
.md h2 { font-size: 22px; }
.md h3 { font-size: 18px; }
.md h4 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 26px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0 0 6px; }
.md ol > li::marker { font-weight: 600; }
.md strong { font-weight: 600; }
.md a { color: var(--blue); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.md blockquote { margin: 0 0 14px; padding: 2px 0 2px 16px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md :not(pre) > code {
  font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace; font-size: .86em;
  background: var(--surface-3); padding: 2px 5px; border-radius: 5px;
}
html[data-theme="dark"] .md :not(pre) > code { background: #424242; }
.md table { border-collapse: collapse; margin: 0 0 16px; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; }
.md th, .md td { border-bottom: 1px solid var(--border); padding: 8px 14px 8px 0; text-align: left; vertical-align: top; }
.md th { font-weight: 600; border-bottom-color: var(--border-strong); }
.md img { max-width: 100%; border-radius: 12px; }

.codeblock { margin: 0 0 16px; border-radius: 16px; background: var(--code-bg); overflow: hidden; border: 1px solid var(--border); }
html[data-theme="dark"] .codeblock { border-color: transparent; }
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 0 16px; font-size: 12px; color: var(--text-2);
  font-family: "Segoe UI", system-ui, sans-serif;
}
.codeblock-head .lang { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.code-copy { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border-radius: 7px; font-size: 12px; color: var(--text-2); }
.code-copy:hover { background: var(--hover); color: var(--text); }
.code-copy .i { width: 15px; height: 15px; }
.codeblock pre { margin: 0; padding: 12px 16px 16px; overflow-x: auto; }
.codeblock code {
  font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
  font-size: 13.5px; line-height: 1.55; background: transparent !important; padding: 0 !important;
}

.status-line { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 15px; height: 28px; }
/*
 * Анимации ожидания. Сообщения перерисовываются во время стрима и опроса статуса,
 * поэтому фаза задаётся отрицательной задержкой от общих часов (--ph-*, см. syncPhases в app.js):
 * новый элемент продолжает движение с того же места, без рывков.
 */
.shimmer {
  background: linear-gradient(90deg,
    var(--text-3) 0%, var(--text-3) 38%, var(--text) 50%, var(--text-3) 62%, var(--text-3) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2.2s cubic-bezier(.45, .05, .55, .95) infinite;
  animation-delay: var(--ph-shimmer, 0ms);
}
.status-line .i {
  width: 17px; height: 17px; color: var(--text-3);
  animation: glow 2.2s ease-in-out infinite;
  animation-delay: var(--ph-shimmer, 0ms);
}
.cursor-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--text); vertical-align: middle; margin-left: 2px; animation: pulse 1s ease-in-out infinite; }

.reasoning { margin: 0 0 12px; }
.reasoning summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 14px; user-select: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary .i { width: 14px; height: 14px; transition: transform .15s; transform: rotate(-90deg); }
.reasoning[open] summary .i { transform: none; }
.reasoning .r-body { margin-top: 8px; padding-left: 14px; border-left: 2px solid var(--border); color: var(--text-2); font-size: 14px; }
.reasoning .r-body p { margin-bottom: 8px; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  height: 28px; padding: 0 10px 0 4px; border-radius: 999px;
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}
.source-chip:hover { background: var(--surface-3); color: var(--text); }
.source-chip .fav { width: 20px; height: 20px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--text-2); flex: none; }
.source-chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.error-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 14px; background: var(--danger-bg); color: var(--danger);
  font-size: 14px; margin-top: 4px;
}
.error-card .grow { color: var(--text); }
.error-card .btn { flex: none; }
.stopped-note { font-size: 13px; color: var(--text-3); margin-top: 6px; }

/* image generation */
.gen-card { max-width: 520px; }
.gen-params { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.gen-param { font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.gen-placeholder {
  position: relative; width: 100%; max-height: 520px; border-radius: 20px; overflow: hidden;
  background: var(--surface-2); isolation: isolate;
}
/* Мягкие цветные пятна медленно плывут по кругу — только transform, без перерисовки. */
.gen-placeholder::before {
  content: ""; position: absolute; inset: -40%;
  background:
    radial-gradient(closest-side at 30% 35%, rgba(124, 92, 255, .38), transparent),
    radial-gradient(closest-side at 70% 62%, rgba(43, 127, 255, .32), transparent),
    radial-gradient(closest-side at 55% 25%, rgba(236, 72, 153, .16), transparent);
  animation: genDrift 16s linear infinite;
  animation-delay: var(--ph-drift, 0ms);
  will-change: transform;
}
html[data-theme="dark"] .gen-placeholder::before { opacity: .75; }
/* Световая полоса проходит слева направо и делает паузу. */
.gen-placeholder::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 55%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .42) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-130%) skewX(-14deg);
  animation: genSweep 3s cubic-bezier(.45, .05, .55, .95) infinite;
  animation-delay: var(--ph-sweep, 0ms);
  will-change: transform;
}
html[data-theme="dark"] .gen-placeholder::after { background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .09) 50%, rgba(255, 255, 255, 0) 100%); }
.gen-label { position: absolute; left: 16px; bottom: 14px; z-index: 1; font-size: 14px; }
.gen-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--blue); z-index: 1; transition: width .4s; }

.gen-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.gen-grid.multi { grid-template-columns: 1fr 1fr; max-width: 680px; }
.gen-img { position: relative; border-radius: 20px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.gen-img img { display: block; width: 100%; height: auto; max-height: 640px; object-fit: contain; }
.gen-img.checker { background-color: #fff; background-image: linear-gradient(45deg, #e8e8e8 25%, transparent 25%), linear-gradient(-45deg, #e8e8e8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e8e8e8 75%), linear-gradient(-45deg, transparent 75%, #e8e8e8 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.img-tools {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.gen-img:hover .img-tools, .g-item:hover .img-tools { opacity: 1; }
.img-tools button {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px);
}
.img-tools button:hover { background: rgba(0, 0, 0, .78); }
.img-tools .i { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- composer */

.composer-dock { flex: none; padding: 0 24px 10px; position: relative; }
.composer {
  max-width: var(--thread-w); margin: 0 auto;
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-composer);
  padding: 10px 10px 10px 12px;
  transition: box-shadow .15s;
}
.composer.image-mode { box-shadow: 0 0 0 1.5px rgba(124, 92, 255, .55), 0 4px 16px rgba(124, 92, 255, .12); }
.composer textarea {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  padding: 6px 8px 8px; font-size: 15.5px; line-height: 1.5; max-height: 40vh; min-height: 36px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.att-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 8px; }
.att { position: relative; flex: none; }
.att-thumb { width: 64px; height: 64px; border-radius: 14px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; display: block; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att .file-card { width: 220px; height: 64px; }
.att-remove {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); display: grid; place-items: center;
  opacity: 0; transition: opacity .12s; box-shadow: 0 0 0 2px var(--surface);
}
.att:hover .att-remove { opacity: 1; }
.att-remove .i { width: 12px; height: 12px; }
.att-state {
  position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center;
  background: rgba(0, 0, 0, .35); color: #fff;
}
.att-state.error { background: rgba(224, 46, 42, .5); cursor: pointer; }
.att-state .spinner { width: 22px; height: 22px; border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.att.unsupported .file-card { opacity: .45; }

.tool-chips { display: flex; gap: 6px; }
.chip {
  height: 36px; padding: 0 8px 0 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--blue); background: rgba(43, 127, 255, .1);
}
.chip.violet { color: #7c5cff; background: rgba(124, 92, 255, .12); }
.chip.muted { color: var(--text-3); background: var(--surface-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.chip .x { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.chip .x:hover { background: rgba(0, 0, 0, .08); }
.chip .x .i { width: 12px; height: 12px; }
.chip > .i { width: 17px; height: 17px; }

.image-opts { display: flex; gap: 4px; }
.pill-select {
  height: 36px; padding: 0 8px 0 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; color: var(--text-2);
}
.pill-select:hover { background: var(--hover); color: var(--text); }
.pill-select .i { width: 16px; height: 16px; }

.send-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  transition: opacity .12s, background .12s;
}
.send-btn:disabled { background: var(--surface-3); color: var(--text-3); }
html[data-theme="dark"] .send-btn:disabled { background: #5a5a5a; color: #2a2a2a; }
.send-btn:not(:disabled):hover { opacity: .85; }

.scroll-down {
  position: absolute; left: 50%; top: -52px; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08); z-index: 5;
}
.scroll-down:hover { color: var(--text); }
.chat-view.is-empty .scroll-down { display: none; }
.scroll-down .i { width: 18px; height: 18px; }

.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px auto 0; max-width: var(--thread-w); }
.suggestion {
  height: 40px; padding: 0 16px 0 12px; border-radius: 999px; border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2);
}
.suggestion:hover { background: var(--hover); color: var(--text); }
.suggestion .i { width: 18px; height: 18px; }

.disclaimer { text-align: center; font-size: 12px; color: var(--text-3); padding-top: 8px; }
.chat-view.is-empty .disclaimer { display: none; }

/* ---------------------------------------------------------------- gallery */

.gallery-view { flex: 1; overflow-y: auto; padding: 8px 32px 32px; }
.gallery-head { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; margin: 0 auto 20px; }
.gallery-head h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.gallery-grid { max-width: 1200px; margin: 0 auto; columns: 4 220px; column-gap: 8px; }
.g-item { break-inside: avoid; margin-bottom: 8px; position: relative; border-radius: 14px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.g-item img { width: 100%; display: block; }
.g-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65)); color: #fff; font-size: 12px;
  opacity: 0; transition: opacity .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.g-item:hover .g-caption { opacity: 1; }
.gallery-empty { text-align: center; color: var(--text-3); padding-top: 18vh; }
.gallery-empty .i { margin: 0 auto 12px; }

/* ---------------------------------------------------------------- panel */

.panel { width: var(--panel-w); flex: none; border-left: 1px solid var(--border); overflow-y: auto; background: var(--bg); }
.panel-inner { padding: 8px 18px 28px; }
.p-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.p-section:last-child { border-bottom: 0; }
.p-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); margin-bottom: 10px; }
.p-row .p-label { margin-bottom: 0; }
.p-row { display: flex; align-items: center; justify-content: space-between; min-height: 36px; font-size: 14px; }
.p-sub { font-size: 13.5px; color: var(--text); margin: 10px 0 8px; }
.p-note { font-size: 12.5px; color: var(--text-3); margin: 6px 0 0; line-height: 1.45; }
.p-note code { font-size: 11.5px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.p-select {
  width: 100%; height: 42px; padding: 0 12px 0 14px; border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); font-size: 14px; font-weight: 500;
}
.p-select:hover { background: var(--surface-3); }

.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.seg.wrap { grid-template-columns: repeat(4, 1fr); }
.seg.col { grid-template-columns: 1fr; }
.seg button {
  height: 36px; border-radius: 9px; font-size: 12.5px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); border: 1.5px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px;
}
.seg button:hover { color: var(--text); }
.seg button.on { border-color: var(--blue); color: var(--blue); background: rgba(43, 127, 255, .08); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }

.switch { position: relative; width: 40px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .15s; }
html[data-theme="dark"] .switch span { background: #4a4a4a; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(16px); }

.key-row { display: flex; gap: 6px; }
.key-row input {
  flex: 1; min-width: 0; height: 32px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg); padding: 0 10px; outline: 0; font-size: 13px;
}
.key-row input:focus { border-color: var(--blue); }
.link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--blue); margin-top: 8px; }
.link-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- popups */

.menu {
  position: fixed; z-index: 100; min-width: 200px; max-width: 340px; max-height: 78vh; overflow-y: auto;
  background: var(--bg); border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 6px; animation: pop .12s ease-out;
}
html[data-theme="dark"] .menu { background: #353535; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; text-align: left; font-size: 14px; min-height: 38px;
}
.menu-item:hover, .menu-item.focus { background: var(--hover); }
.menu-item .mi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.menu-item .mi-sub { font-size: 12px; color: var(--text-3); }
.menu-item .mi-check { color: var(--text); width: 18px; height: 18px; }
.menu-item.danger { color: var(--danger); }
.menu-item .i { color: var(--text-2); }
.menu-item.danger .i { color: var(--danger); }
.menu-item:disabled { opacity: .4; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.menu-title { font-size: 12px; color: var(--text-3); padding: 6px 10px 4px; }
.menu-item .switch { pointer-events: none; }

.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: calc(100vw - 160px); max-height: calc(100vh - 130px); object-fit: contain; border-radius: 8px; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 16px 0 24px; }
.lb-prompt { flex: 1; color: rgba(255, 255, 255, .75); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-actions { display: flex; gap: 4px; }
.lightbox .icon-btn { color: rgba(255, 255, 255, .8); }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .1); display: grid; place-items: center; }
.lb-nav:hover { background: rgba(255, 255, 255, .2); }
.lb-nav.prev { left: 24px; }
.lb-nav.next { right: 24px; }

.modal-back { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .45); display: grid; place-items: center; animation: fade .12s; }
.modal { width: min(460px, calc(100vw - 48px)); background: var(--bg); border-radius: 20px; padding: 22px 24px 20px; box-shadow: var(--shadow-pop); }
html[data-theme="dark"] .modal { background: #2a2a2a; }
.modal h3 { margin: 0 0 10px; font-size: 18px; font-weight: 600; }
.modal p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.modal input[type="text"], .modal input[type="password"] {
  width: 100%; height: 42px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--bg); padding: 0 12px; outline: 0; font-size: 14px;
}
.modal input:focus { border-color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* top-up */
.topup {
  --topup-bg: #ffffff;
  position: relative; width: min(720px, calc(100vw - 48px)); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--topup-bg); border-radius: 24px; padding: 30px 28px 22px; box-shadow: var(--shadow-pop);
  animation: pop .16s ease-out;
}
html[data-theme="dark"] .topup { --topup-bg: #2a2a2a; }
.topup-close { position: absolute; top: 14px; right: 14px; }
.topup-head { text-align: center; margin-bottom: 26px; }
.topup-icon {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #2b7fff);
  box-shadow: 0 8px 24px rgba(124, 92, 255, .35);
}
.topup-icon .i { width: 26px; height: 26px; }
.topup-head h3 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.topup-head p { margin: 0; color: var(--text-2); font-size: 14px; }
.topup-head b { color: var(--text); font-variant-numeric: tabular-nums; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr; } }
.plan {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 26px 16px 16px; border-radius: 20px; text-align: center;
  border: 1px solid var(--border-strong); background: var(--topup-bg);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.plan:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0, 0, 0, .1); border-color: rgba(124, 92, 255, .5); }
html[data-theme="dark"] .plan:hover { box-shadow: 0 12px 28px rgba(0, 0, 0, .45); }
.plan.featured {
  border: 2px solid transparent;
  background: linear-gradient(var(--topup-bg), var(--topup-bg)) padding-box, linear-gradient(135deg, #7c5cff, #2b7fff) border-box;
  padding-top: 25px;
}
.plan-tag {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  height: 22px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}
.plan.featured .plan-tag { background: linear-gradient(135deg, #7c5cff, #2b7fff); color: #fff; }
.plan-gem { color: #7c5cff; margin-bottom: 10px; }
.plan-gem .i { width: 24px; height: 24px; }
.plan-credits { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.plan-unit { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.plan-bonus { min-height: 22px; margin-top: 8px; font-size: 12.5px; font-weight: 600; color: #1f9d55; }
html[data-theme="dark"] .plan-bonus { color: #4cc38a; }
.plan-price { font-size: 16px; font-weight: 500; margin: 10px 0 14px; font-variant-numeric: tabular-nums; }
.plan-cta {
  width: 100%; height: 38px; border-radius: 999px; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.plan-cta .i { width: 16px; height: 16px; }
.plan.featured .plan-cta { background: linear-gradient(135deg, #7c5cff, #2b7fff); color: #fff; }
.plan:hover .plan-cta { opacity: .92; }
.topup-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 20px 0 0; font-size: 13px; color: var(--text-3); text-align: center;
}
.topup-note .i { color: #2aabee; flex: none; }

.error-card .btn + .btn { margin-left: -4px; }

/* checkbox in dialogs */
.check { display: inline-flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  display: grid; place-items: center; color: transparent;
  border: 1.5px solid var(--border-strong); background: var(--bg);
  transition: background .12s, border-color .12s, color .12s;
}
.check-box .i { width: 14px; height: 14px; }
.check input:checked + .check-box { background: var(--blue); border-color: var(--blue); color: #fff; }
.check input:focus-visible + .check-box { box-shadow: 0 0 0 3px rgba(43, 127, 255, .3); }
.check:hover { color: var(--text); }
.modal .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* context memory */
#pCompressionBox.disabled { opacity: .45; }
.memory-divider {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: -8px 0 28px;
  color: var(--text-3); font-size: 12.5px;
}
.memory-divider::before, .memory-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.memory-divider span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; }
.memory-divider:hover span { background: var(--hover); color: var(--text); }
.memory-divider .i { width: 15px; height: 15px; }
.summary-box {
  max-height: 50vh; overflow-y: auto; font-size: 13.5px; line-height: 1.5;
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
}
.summary-box h1, .summary-box h2, .summary-box h3, .summary-box h4 { font-size: 14px; margin: 12px 0 4px; }
.summary-box ul { padding-left: 20px; margin-bottom: 8px; }
.modal:has(.summary-box) { width: min(640px, calc(100vw - 48px)); }

.drop-overlay { position: absolute; inset: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 80%, transparent); display: grid; place-items: center; pointer-events: none; animation: fade .1s; }
.drop-box { text-align: center; padding: 40px 56px; border-radius: 28px; border: 2px dashed var(--blue); background: var(--bg); }
.drop-box .i { margin: 0 auto 10px; color: var(--blue); }
.drop-title { font-size: 20px; font-weight: 600; }
.drop-sub { color: var(--text-2); font-size: 14px; margin-top: 4px; max-width: 300px; }

.toasts { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--accent); color: var(--accent-text); padding: 9px 16px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow-pop); animation: pop .15s ease-out; max-width: 520px;
}
.toast.error { background: var(--danger); color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }
/* Блик уходит за края в начале и в конце цикла, поэтому повтор незаметен. */
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0% 0; } }
@keyframes glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes genDrift {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  25% { transform: translate3d(7%, -5%, 0) rotate(90deg) scale(1.06); }
  50% { transform: translate3d(0, -9%, 0) rotate(180deg) scale(1); }
  75% { transform: translate3d(-7%, -4%, 0) rotate(270deg) scale(1.06); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg) scale(1); }
}
@keyframes genSweep { 0% { transform: translateX(-130%) skewX(-14deg); } 65%, 100% { transform: translateX(300%) skewX(-14deg); } }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .6; } 50% { transform: scale(1); opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1100px) {
  .panel { position: absolute; right: 0; top: var(--topbar-h); bottom: 0; z-index: 40; box-shadow: var(--shadow-pop); }
}

/* ---------------------------------------------------------------- видео */

.gen-video { border-radius: 20px; overflow: hidden; background: #000; max-height: 560px; }
.gen-video video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }

/* Кнопка «i» в меню выбора модели */
.menu-row { display: flex; align-items: center; gap: 2px; }
.menu-row .menu-item { flex: 1; min-width: 0; }
.menu-info {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-3);
}
.menu-info:hover { background: var(--hover); color: var(--text); }
.menu-info .i { width: 17px; height: 17px; }

/* Описание модели */
.info-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; margin-top: 14px; }
.info-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.info-row { display: flex; gap: 10px; margin-top: 10px; font-size: 14px; line-height: 1.45; }
.info-row .info-label { flex: none; width: 112px; margin-top: 2px; }
.info-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }

/* Форма видеомодели в поле ввода */
.video-form { display: flex; flex-direction: column; gap: 14px; padding: 12px 14px 4px; max-height: 54vh; overflow-y: auto; }
.vf-head { display: flex; align-items: center; gap: 6px; }
.vf-title { font-size: 14px; font-weight: 600; }
.vf-head .link-btn { margin: 0 0 0 auto; }
.vf-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.vf-off { font-weight: 400; color: var(--text-3); }
.vf-field.off { opacity: .45; pointer-events: none; }
.vf-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.4; }
.vf-slots { display: flex; gap: 10px; }
.vf-slot {
  position: relative; flex: 1; min-height: 78px; border-radius: 14px;
  border: 1px dashed var(--border); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; color: var(--text-3); overflow: hidden;
}
.vf-slot:hover { border-color: var(--text-3); color: var(--text-2); }
.vf-slot .i { width: 20px; height: 20px; }
.vf-slot.filled { border-style: solid; padding: 0; }
.vf-slot.filled img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vf-slot.filled span { position: relative; z-index: 1; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 999px; padding: 2px 10px; margin-top: auto; margin-bottom: 8px; }
.vf-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.vf-tile {
  position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
}
.vf-tile img { width: 100%; height: 100%; object-fit: cover; }
.vf-tile.add {
  border-style: dashed; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--text-3);
}
.vf-tile.add:hover { border-color: var(--text-3); color: var(--text-2); }
.vf-x {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.vf-x .i { width: 12px; height: 12px; }
.vf-video { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); border-radius: 12px; padding: 8px 10px; position: relative; }
.vf-vname { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-num { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.vf-num input { width: 56px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 0 8px; font-size: 13px; }
.vf-sec { font-size: 12px; color: var(--text-3); }
.vf-video .vf-x { position: static; background: none; color: var(--text-3); }
.vf-video .vf-x:hover { color: var(--text); }
.vf-pick {
  height: 38px; padding: 0 14px; border-radius: 12px; border: 1px dashed var(--border);
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2);
}
.vf-pick:hover { border-color: var(--text-3); color: var(--text); }
.opts-note { font-size: 12px; color: var(--text-3); align-self: center; }
.composer.video-mode { box-shadow: 0 0 0 1.5px rgba(124, 92, 255, .55), 0 4px 16px rgba(124, 92, 255, .12); }
.menu-title.cat { font-size: 13px; font-weight: 600; color: var(--text); padding-top: 8px; }

/* Библиотека: видео рядом с картинками */
.gallery-head { gap: 10px; }
.gallery-head .seg { margin-left: 8px; display: inline-flex; flex: none; }
.gallery-head .seg button { padding: 0 14px; }
.gallery-head .btn + .btn { margin-left: 8px; }
.g-item video { width: 100%; display: block; background: #000; }
.g-item .g-play {
  position: absolute; top: 10px; left: 10px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; display: flex; align-items: center; justify-content: center;
}
.g-item .g-play .i { width: 15px; height: 15px; }
.lightbox video { max-width: 92vw; max-height: 82vh; border-radius: 12px; background: #000; }

/* Переключатели, ползунки и раскадровка в форме видеомодели */
.vf-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.vf-toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vf-tlabel { font-size: 13px; font-weight: 600; color: var(--text); }
.vf-toggle .vf-hint { margin-top: 0; }
.vf-slider { display: flex; align-items: center; gap: 12px; }
.vf-slider input[type="range"] { flex: 1; accent-color: #7c5cff; height: 20px; }
.vf-value { flex: none; min-width: 42px; text-align: right; font-size: 13px; color: #7c5cff; font-variant-numeric: tabular-nums; }
.vf-total { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 10px; }
.vf-total span { display: block; height: 100%; background: #7c5cff; border-radius: 999px; transition: width .15s ease; }
.vf-shots { display: flex; flex-direction: column; gap: 10px; }
.vf-shot { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: var(--surface-2); }
.vf-shot-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.vf-shot-n {
  width: 20px; height: 20px; border-radius: 50%; background: #7c5cff; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
}
.vf-shot-head .vf-x { position: static; margin-left: auto; background: none; color: var(--text-3); }
.vf-shot-head .vf-x:hover { color: var(--text); }
.vf-shot-prompt {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
  padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical; margin-bottom: 8px;
}
.vf-shot-prompt:focus { outline: none; border-color: #7c5cff; }

/* Свёрнутая форма и раздел «Дополнительно» */
.video-form.folded { padding-bottom: 10px; }
.vf-fold { width: 24px; height: 24px; border-radius: 8px; color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; }
.vf-fold:hover { background: var(--hover); color: var(--text); }
.vf-fold .i { width: 16px; height: 16px; transition: transform .15s ease; }
.video-form.folded .vf-fold .i { transform: rotate(-90deg); }
.vf-summary { margin-left: auto; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-body { display: flex; flex-direction: column; gap: 14px; }
.vf-extra { border-top: 1px solid var(--border); padding-top: 10px; }
.vf-extra-head {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--text-2); padding: 4px 0;
}
.vf-extra-head:hover { color: var(--text); }
.vf-extra-head .i { width: 14px; height: 14px; transition: transform .15s ease; transform: rotate(-90deg); }
.vf-extra.open .vf-extra-head .i { transform: none; }
.vf-extra-body { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.vf-files { display: flex; flex-direction: column; gap: 6px; }
.vf-file {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border-radius: 10px; padding: 7px 10px; font-size: 13px;
}
.vf-file .i { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.vf-fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-fsize { font-size: 12px; color: var(--text-3); flex: none; }
.vf-file .vf-x { position: static; background: none; color: var(--text-3); }
.vf-file .vf-x:hover { color: var(--text); }
.vf-files:empty { display: none; }
.vf-toggle .pill-select { flex: none; }

/* Кнопка «Обновление» в шапке */
.update-pill {
  height: 32px; padding: 0 12px; border-radius: 999px; margin-right: 6px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap;
  background: linear-gradient(135deg, #7c5cff, #2b7fff);
  box-shadow: 0 2px 10px rgba(124, 92, 255, .35);
}
.update-pill:hover { filter: brightness(1.08); }
.update-pill .i { color: #fff; }

/* Просмотр: кнопки управления не прячутся под системными кнопками окна */
html.platform-win .lb-top { padding-right: calc(var(--caption-w) + 12px); }
html.platform-mac .lb-top { padding-left: calc(var(--traffic-w) + 8px); }
