:root {
  --bg: #0b0a09;
  --surface: #151412;
  --surface-2: #1d1c19;
  --surface-3: #262420;
  --text: #f2efea;
  --text-2: #d8d4ce;
  --muted: #98948e;
  --muted-2: #6f6c67;
  --accent: #cc785c;
  --accent-soft: rgba(204, 120, 92, .14);
  --cream: #f4eadc;
  --green: #67c98a;
  --red: #e7777e;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-bottom, 0px));
  --font: Inter, "Arial Rounded MT Bold", Arial, sans-serif;
  --font-ai: "Archivo Black", "Arial Black", Inter, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
html { color-scheme: dark; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; font-family: var(--font); font-weight: 600; -webkit-font-smoothing: antialiased; }
button, textarea, input { border: 0; border-radius: 0; outline: 0; color: inherit; font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible { filter: brightness(1.16); }
textarea:focus-visible, input:focus-visible { background: rgba(255, 255, 255, .025); }
[hidden] { display: none !important; }

.boot-splash {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
  opacity: 1;
  transition: opacity .28s var(--ease), visibility 0s linear .28s;
}
.boot-splash.is-leaving { visibility: hidden; opacity: 0; }
.boot-brand { display: grid; justify-items: center; gap: 4px; transform: translateY(-2vh); }
.boot-brand img, .empty-brand {
  display: block;
  width: 190px;
  height: 190px;
  object-fit: contain;
  -webkit-mask-image: url("/ai/dev-logo.jpg?v=1027");
  -webkit-mask-mode: luminance;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("/ai/dev-logo.jpg?v=1027");
  mask-mode: luminance;
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
}
.boot-brand img { animation: bootBrand 1.35s cubic-bezier(.2, .8, .2, 1) infinite alternate; }
.boot-brand span { margin-top: -22px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
@keyframes bootBrand {
  from { opacity: .72; transform: translate3d(0, 4px, 0) scale(.975); }
  to { opacity: 1; transform: translate3d(0, -3px, 0) scale(1.015); }
}

/* Official Lucide 1.31.0 icon assets, vendored locally under the ISC license. */
.ui-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--ui-icon) center / contain no-repeat;
  mask: var(--ui-icon) center / contain no-repeat;
}
[data-icon="arrow-up"] { --ui-icon: url("/ai/icons/lucide/arrow-up.svg?v=1020"); }
[data-icon="badge-dollar-sign"] { --ui-icon: url("/ai/icons/lucide/badge-dollar-sign.svg?v=1020"); }
[data-icon="bot"] { --ui-icon: url("/ai/icons/lucide/bot.svg?v=1020"); }
[data-icon="camera"] { --ui-icon: url("/ai/icons/lucide/camera.svg?v=1020"); }
[data-icon="chevron-down"] { --ui-icon: url("/ai/icons/lucide/chevron-down.svg?v=1020"); }
[data-icon="chevron-right"] { --ui-icon: url("/ai/icons/lucide/chevron-right.svg?v=1020"); }
[data-icon="circle-user-round"] { --ui-icon: url("/ai/icons/lucide/circle-user-round.svg?v=1020"); }
[data-icon="code-2"] { --ui-icon: url("/ai/icons/lucide/code-2.svg?v=1020"); }
[data-icon="copy"] { --ui-icon: url("/ai/icons/lucide/copy.svg?v=1020"); }
[data-icon="download"] { --ui-icon: url("/ai/icons/lucide/download.svg?v=1020"); }
[data-icon="ellipsis-vertical"] { --ui-icon: url("/ai/icons/lucide/ellipsis-vertical.svg?v=1020"); }
[data-icon="external-link"] { --ui-icon: url("/ai/icons/lucide/external-link.svg?v=1020"); }
[data-icon="file"] { --ui-icon: url("/ai/icons/lucide/file.svg?v=1020"); }
[data-icon="gauge"] { --ui-icon: url("/ai/icons/lucide/gauge.svg?v=1020"); }
[data-icon="history"] { --ui-icon: url("/ai/icons/lucide/history.svg?v=1020"); }
[data-icon="image"] { --ui-icon: url("/ai/icons/lucide/image.svg?v=1020"); }
[data-icon="menu"] { --ui-icon: url("/ai/icons/lucide/menu.svg?v=1020"); }
[data-icon="mic"] { --ui-icon: url("/ai/icons/lucide/mic.svg?v=1020"); }
[data-icon="paperclip"] { --ui-icon: url("/ai/icons/lucide/paperclip.svg?v=1020"); }
[data-icon="pencil"] { --ui-icon: url("/ai/icons/lucide/pencil.svg?v=1020"); }
[data-icon="play"] { --ui-icon: url("/ai/icons/lucide/play.svg?v=1020"); }
[data-icon="plus"] { --ui-icon: url("/ai/icons/lucide/plus.svg?v=1020"); }
[data-icon="rotate-ccw"] { --ui-icon: url("/ai/icons/lucide/rotate-ccw.svg?v=1020"); }
[data-icon="search"] { --ui-icon: url("/ai/icons/lucide/search.svg?v=1020"); }
[data-icon="send"] { --ui-icon: url("/ai/icons/lucide/send.svg?v=1020"); }
[data-icon="settings"] { --ui-icon: url("/ai/icons/lucide/settings.svg?v=1020"); }
[data-icon="share-2"] { --ui-icon: url("/ai/icons/lucide/share-2.svg?v=1020"); }
[data-icon="sliders-horizontal"] { --ui-icon: url("/ai/icons/lucide/sliders-horizontal.svg?v=1020"); }
[data-icon="sparkles"] { --ui-icon: url("/ai/icons/lucide/sparkles.svg?v=1020"); }
[data-icon="square"] { --ui-icon: url("/ai/icons/lucide/square.svg?v=1020"); }
[data-icon="thumbs-down"] { --ui-icon: url("/ai/icons/lucide/thumbs-down.svg?v=1020"); }
[data-icon="thumbs-up"] { --ui-icon: url("/ai/icons/lucide/thumbs-up.svg?v=1020"); }
[data-icon="trash-2"] { --ui-icon: url("/ai/icons/lucide/trash-2.svg?v=1020"); }
[data-icon="upload"] { --ui-icon: url("/ai/icons/lucide/upload.svg?v=1020"); }
[data-icon="volume-2"] { --ui-icon: url("/ai/icons/lucide/volume-2.svg?v=1020"); }
[data-icon="wand-sparkles"] { --ui-icon: url("/ai/icons/lucide/wand-sparkles.svg?v=1020"); }
[data-icon="x"] { --ui-icon: url("/ai/icons/lucide/x.svg?v=1020"); }

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: var(--tg-viewport-stable-height, 100dvh);
  min-height: 100dvh;
  overflow: hidden;
}

.workspace { position: relative; min-height: 0; overflow: hidden; }
.workspace > main { height: 100%; }

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(74px + var(--safe-top));
  padding: calc(18px + var(--safe-top)) 14px 8px;
  background: rgba(11, 10, 9, .93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.icon-button, .sheet-close {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  background: transparent;
}
.icon-button svg, .sheet-close svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}
.ab-burger {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  transition: background .15s var(--ease), transform .22s cubic-bezier(.22, 1, .36, 1);
}
.ab-burger .ui-icon { width: 23px; height: 23px; }
.ab-burger:active { transform: translate3d(0, 1px, 0) scale(.988); background: transparent; }
.limits-button { display: grid; width: 42px; height: 42px; padding: 0; place-items: center; color: var(--text); background: transparent; }
.limits-button svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.limits-button .ui-icon { width: 27px; height: 27px; }

.chat-viewport {
  position: relative;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 18px 28px;
  scrollbar-color: var(--surface-3) transparent;
}
.empty-state {
  display: flex;
  min-height: 100%;
  max-width: 620px;
  margin: 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 10px 84px;
  text-align: center;
}
.empty-brand { width: clamp(170px, 48vw, 238px); height: clamp(170px, 48vw, 238px); margin-bottom: -30px; }
.ai-signature { display: grid; width: 54px; height: 54px; margin-bottom: 24px; place-items: center; overflow: hidden; border-radius: 18px; background: var(--accent); box-shadow: 0 16px 34px rgba(193, 91, 60, .28); }
.ai-signature img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(26, 16, 13, .24)); }
.empty-state h1 { margin: 0; font-family: var(--font); font-size: clamp(29px, 8vw, 42px); font-weight: 600; letter-spacing: -.045em; line-height: 1.05; }

.message-list { display: flex; width: 100%; max-width: 740px; min-width: 0; margin: 0 auto; flex-direction: column; gap: 30px; padding-top: 2px; }
.message { display: flex; min-width: 0; flex-direction: column; }
.message-user { align-items: flex-end; }
.message-user .message-body { max-width: min(88%, 570px); padding: 12px 15px; border-radius: 18px 18px 5px 18px; background: var(--surface-2); font-size: 14px; line-height: 1.48; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-attachments { display: grid; width: min(88%, 570px); max-width: 100%; min-width: 0; justify-items: end; gap: 8px; margin-bottom: 7px; }
.message-image-attachment { width: min(100%, 320px); max-width: 100%; margin: 0; overflow: hidden; border-radius: 18px 18px 5px 18px; background: var(--surface-2); }
.message-image-open { display: block; width: 100%; padding: 0; border-radius: inherit; background: transparent; cursor: zoom-in; }
.message-image-attachment img { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #11100f; }
.message-file-attachment { display: flex; width: min(100%, 320px); max-width: 100%; min-width: 0; min-height: 58px; align-items: center; gap: 11px; overflow: hidden; padding: 10px 13px; border-radius: 17px 17px 5px 17px; color: var(--text-2); background: var(--surface-2); }
.message-file-mark { min-width: 36px; flex: none; color: #f1e8d8; font-family: var(--font-mono); font-size: 9px; font-weight: 800; text-align: center; }
.message-file-copy { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.message-file-copy b, .message-file-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-file-copy b { font-size: 11px; font-weight: 700; }
.message-file-copy small { margin-top: 4px; color: var(--muted); font-family: var(--font-mono); font-size: 8px; }
.message-assistant { align-items: stretch; }
.message-assistant .message-body { min-width: 0; color: #ebe6df; font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 1.62; overflow-wrap: anywhere; }
.message-body p { margin: 0 0 14px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body h2, .message-body h3 { margin: 24px 0 10px; color: var(--text); font-family: var(--font); font-weight: 800; letter-spacing: -.025em; }
.message-body h2 { font-size: 18px; }
.message-body h3 { font-size: 16px; }
.message-body ul, .message-body ol { display: grid; gap: 8px; margin: 11px 0 16px; padding-left: 23px; }
.message-body li { padding-left: 2px; }
.message-body a { color: #e49b82; text-decoration: underline; text-decoration-color: rgba(228, 155, 130, .35); text-underline-offset: 3px; }
.message-body strong { color: var(--text); font-family: var(--font); font-size: .91em; }
.message-body code { padding: 2px 5px; border-radius: 5px; color: var(--text); background: var(--surface-2); font-family: var(--font-mono); font-size: .78em; }
.message-body pre { margin: 15px 0; overflow: auto; padding: 15px; border-radius: 14px; background: #11100f; }
.message-body pre code { padding: 0; background: transparent; font-size: 12px; line-height: 1.55; }

.activity-card { position: relative; display: grid; gap: 6px; margin: 0 0 15px; padding: 2px 0 2px 12px; color: var(--muted); font-family: var(--font); }
.activity-card::before { position: absolute; inset: 1px auto 1px 0; width: 2px; border-radius: 2px; background: var(--accent); content: ""; }
.activity-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; }
.activity-dots { display: inline-flex; gap: 3px; }
.activity-dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); animation: thinkDot 1.1s ease-in-out infinite; }
.activity-dots i:nth-child(2) { animation-delay: .14s; }
.activity-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes thinkDot { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.activity-meta { display: flex; flex-wrap: wrap; gap: 0; color: var(--muted-2); font-family: var(--font-mono); font-size: 9px; }
.activity-meta span + span::before { content: "·"; padding: 0 6px; }
.activity-card.is-done::before { background: rgba(204, 120, 92, .45); }
.activity-card.is-done .activity-dots i { animation: none; opacity: .6; }
.activity-card.is-error { color: var(--red); }
.activity-card.is-error::before { background: var(--red); }
.assistant-process-live.is-stopped { min-height: 30px; color: var(--text-2); }
.assistant-process-live.is-stopped .ui-icon { width: 20px; height: 20px; }

.source-list { display: flex; gap: 7px; margin-top: 13px; overflow-x: auto; scrollbar-width: none; }
.source-list::-webkit-scrollbar { display: none; }
.source-list a { display: block; min-width: 150px; max-width: 210px; padding: 10px 11px; border-radius: 12px; color: var(--text-2); background: var(--surface-2); font-family: var(--font); text-decoration: none; }
.source-list b { display: block; overflow: hidden; font-size: 10px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.source-list small { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.composer-wrap { position: relative; z-index: 25; padding: 8px 12px calc(9px + var(--safe-bottom)); background: var(--bg); }
.composer { max-width: 740px; min-height: 148px; margin: 0 auto; padding: 17px 11px 10px 16px; border-radius: 27px; background: var(--surface); box-shadow: 0 14px 36px rgba(0, 0, 0, .25); }
.composer:focus-within { background: #191816; }
.composer textarea { display: block; width: 100%; min-height: 72px; max-height: 180px; resize: none; padding: 3px 4px 15px; background: transparent; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--muted-2); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-tools { display: flex; min-width: 0; align-items: center; gap: 4px; }
.attach-button { display: grid; width: 42px; height: 42px; flex: none; padding: 0; place-items: center; border-radius: 50%; color: var(--text-2); background: #11100f; }
.attach-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.45; }
.attach-button .ui-icon { width: 24px; height: 24px; }
.attachment-list { display: flex; gap: 7px; margin: 0 0 10px; overflow-x: auto; padding: 1px 0; scrollbar-width: none; }
.attachment-list::-webkit-scrollbar { display: none; }
.attachment-chip { display: flex; min-width: 0; max-width: 230px; height: 46px; flex: 0 0 auto; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 13px; background: var(--surface-2); }
.attachment-preview { display: grid; width: 36px; height: 36px; flex: none; place-items: center; overflow: hidden; border-radius: 9px; color: var(--accent); background: var(--surface-3); font-family: var(--font-mono); font-size: 8px; font-weight: 800; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; }
.attachment-copy { min-width: 0; }
.attachment-copy b { display: block; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.attachment-remove { display: grid; width: 25px; height: 25px; flex: none; margin-left: 2px; padding: 0; place-items: center; border-radius: 8px; color: var(--muted); background: transparent; font-size: 17px; line-height: 1; }
.mode-chip { display: flex; min-width: 0; max-width: min(220px, 53vw); height: 42px; align-items: center; gap: 8px; padding: 0 13px; border-radius: 21px; color: var(--text-2); background: #11100f; font-size: 13px; font-weight: 700; }
.mode-chip > img { width: 20px; height: 20px; flex: none; filter: brightness(0) invert(93%) sepia(11%) saturate(367%) hue-rotate(343deg) brightness(101%) contrast(91%); }
.mode-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-chip svg { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; }
.mode-chip .ui-icon { width: 15px; height: 15px; }
.composer-actions { display: flex; flex: none; align-items: center; gap: 7px; }
.voice-button, .send-button { display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border-radius: 50%; }
.voice-button { color: var(--text-2); background: #11100f; }
.voice-button.is-listening { color: #1a100d; background: var(--cream); }
.voice-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.voice-button .ui-icon { width: 23px; height: 23px; }
.send-button { color: #1a100d; background: var(--accent); }
.send-button.is-stop { color: var(--text); background: var(--surface-3); }
.send-button.is-routing { opacity: 1; }
.send-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.send-button .ui-icon { width: 22px; height: 22px; }
.request-dots { display: flex; gap: 3px; }
.request-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: requestDot 1s ease-in-out infinite; }
.request-dots i:nth-child(2) { animation-delay: .14s; }
.request-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes requestDot { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.builder-viewport { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; padding: 10px 14px 30px; }
.builder-shell { width: min(100%, 720px); margin: 0 auto; }
.builder-head { padding: 14px 5px 20px; }
.builder-head h1 { margin: 0; font-family: var(--font-ai); font-size: clamp(34px, 9vw, 50px); line-height: .98; letter-spacing: -.06em; }
.builder-loading { display: grid; min-height: 330px; place-items: center; align-content: center; gap: 18px; border-radius: 26px; background: var(--surface); }
.builder-loading > span { display: flex; gap: 7px; }
.builder-loading i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: builderDot 1s ease-in-out infinite; }
.builder-loading i:nth-child(2) { animation-delay: .14s; }
.builder-loading i:nth-child(3) { animation-delay: .28s; }
.builder-loading strong { font-family: var(--font-ai); font-size: 30px; letter-spacing: -.045em; }
@keyframes builderDot { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-7px); } }
.builder-result { padding: 16px; border-radius: 26px; background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .24); }
.builder-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.builder-result-head h2 { min-width: 0; margin: 0; align-self: center; font-size: 21px; letter-spacing: -.035em; }
.builder-result-head em { padding: 8px 11px; border-radius: 11px; color: var(--text-2); background: var(--surface-2); font-size: 11px; font-style: normal; font-weight: 800; }
.builder-result-tools { display: grid; flex: none; justify-items: end; gap: 8px; }
.site-preview { position: relative; overflow: hidden; border-radius: 19px; background: #fff; box-shadow: 0 14px 34px rgba(0, 0, 0, .24); }
.site-preview::after { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; color: var(--text); background: #11100f; font-size: 14px; font-weight: 750; opacity: 0; pointer-events: none; transition: opacity .16s ease; content: "Обновляю превью"; }
.site-preview.is-loading::after { opacity: 1; }
.preview-browser { display: flex; height: 34px; align-items: center; gap: 5px; padding: 0 10px; background: #2b2926; }
.preview-browser i { width: 6px; height: 6px; border-radius: 50%; background: #716b64; }
.preview-browser span { min-width: 0; overflow: hidden; margin-left: 5px; color: #d2cbc3; font-family: var(--font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.site-preview iframe { display: block; width: 100%; height: min(56dvh, 520px); min-height: 340px; border: 0; background: #fff; }
.bot-ready { display: grid; min-height: 300px; place-items: center; align-content: center; gap: 18px; border-radius: 19px; background: var(--surface-2); }
.bot-ready-icon { display: grid; width: 92px; height: 92px; place-items: center; border-radius: 30px; color: #1a100d; background: var(--accent); transform: rotate(-4deg); }
.bot-ready-icon svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transform: rotate(4deg); }
.bot-ready > strong { font-family: var(--font-ai); font-size: 30px; letter-spacing: -.045em; }
.builder-deploy-actions { display: flex; justify-content: flex-end; gap: 9px; }
.deploy-icon-button, .open-project-button { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 17px; color: #1a100d; background: var(--accent); box-shadow: 0 12px 28px rgba(204, 120, 92, .25); }
.open-project-button { color: var(--text); background: var(--surface-2); box-shadow: none; }
.deploy-icon-button svg, .open-project-button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.deploy-icon-button:disabled { opacity: .42; }
.builder-projects { margin-top: 24px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .06); }
.builder-projects #builderProjectList { display: grid; gap: 7px; }
.builder-project-card { display: grid; min-height: 76px; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 20px; color: var(--text); background: var(--surface); text-align: left; }
.builder-project-card b, .builder-project-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.builder-project-card b { font-size: 15px; }
.builder-project-card small { margin-top: 5px; color: var(--muted); font-size: 12px; }
.project-state { display: flex; align-items: center; gap: 7px; }
.project-state em { color: var(--accent); font-size: 11px; font-style: normal; font-weight: 800; }
.project-state .ui-icon { width: 17px; height: 17px; color: var(--muted); }
.credit-rate { margin-top: 10px; }

.sheet-layer { position: fixed; z-index: 100; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; background: rgba(0, 0, 0, .68); animation: scrimIn .22s ease both; }
.sheet { position: relative; width: min(100%, 620px); max-height: min(89dvh, 820px); overflow: auto; padding: 21px 18px calc(22px + var(--safe-bottom)); border-radius: 27px 27px 0 0; background: #1b1a18; box-shadow: 0 -18px 60px rgba(0, 0, 0, .55); animation: sheetIn .32s var(--ease) both; }
.sheet-layer.is-closing .sheet { animation: sheetOut .22s ease both; }
.sheet-layer.is-closing .sheet-scrim { animation: scrimOut .22s ease both; }

.image-viewer-layer { align-items: center; padding: max(12px, var(--safe-top)) 12px max(12px, var(--safe-bottom)); }
.image-viewer { position: relative; z-index: 1; display: grid; width: min(100%, 920px); height: min(92dvh, 840px); min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto auto; overflow: hidden; border-radius: 26px; background: #151412; box-shadow: 0 28px 90px rgba(0, 0, 0, .62); animation: imageViewerIn .25s var(--ease) both; }
.image-viewer-layer.is-closing .image-viewer { animation: imageViewerOut .18s ease both; }
.image-viewer-head { display: grid; min-height: 62px; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; padding: 7px 9px; }
.image-viewer-head h2 { margin: 0; overflow: hidden; font-size: 16px; font-weight: 750; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer-close { display: grid; width: 48px; height: 48px; padding: 0; place-items: center; color: var(--text); background: transparent; }
.image-viewer-close .ui-icon { width: 25px; height: 25px; }
.image-viewer-stage { display: grid; min-width: 0; min-height: 0; overflow: auto; padding: 0 12px; place-items: center; overscroll-behavior: contain; }
.image-viewer-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 16px; background: #0b0a09; }
.image-viewer-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 12px 12px 4px; }
.image-viewer-actions button { display: flex; min-width: 0; min-height: 48px; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; border-radius: 15px; color: var(--text-2); background: var(--surface-2); }
.image-viewer-actions .ui-icon { width: 20px; height: 20px; }
.image-viewer-actions button > span:last-child { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer-state { min-height: 0; margin: 0; padding: 7px 16px calc(10px + var(--safe-bottom)); color: var(--muted); font-size: 11px; text-align: center; }
.image-viewer-state:empty { display: none; }
@keyframes imageViewerIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes imageViewerOut { to { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes sheetIn { from { transform: translateY(100%); opacity: .75; } to { transform: none; opacity: 1; } }
@keyframes sheetOut { to { transform: translateY(100%); opacity: .65; } }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scrimOut { to { opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-head > div > span { color: var(--accent); font-family: var(--font-mono); font-size: 8px; font-weight: 750; letter-spacing: .14em; }
.sheet-head h2 { margin: 4px 0 0; font-family: var(--font-ai); font-size: 27px; font-weight: 900; letter-spacing: -.045em; }
.sheet-close { width: 40px; height: 40px; flex: none; }

.nav-drawer-layer { position: fixed; z-index: 130; inset: 0; overflow: hidden; }
.nav-drawer-scrim { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; background: rgba(0, 0, 0, .58); opacity: 1; transition: opacity .18s ease; }
.nav-drawer { position: absolute; z-index: 1; top: 0; left: 0; display: grid; width: min(88vw, 390px); height: 100%; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; padding: calc(18px + var(--safe-top)) 16px calc(14px + var(--safe-bottom)); background: #12110f; box-shadow: 22px 0 56px rgba(0, 0, 0, .42); transform: translate3d(0, 0, 0); transition: transform .2s var(--ease); }
.nav-drawer-layer.is-opening .nav-drawer, .nav-drawer-layer.is-closing .nav-drawer { transform: translate3d(-100%, 0, 0); }
.nav-drawer-layer.is-opening .nav-drawer-scrim, .nav-drawer-layer.is-closing .nav-drawer-scrim { opacity: 0; }
.nav-drawer-head { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 0 2px; }
.nav-drawer-head h2 { margin: 0; font-size: 27px; font-weight: 720; letter-spacing: -.04em; }
.nav-drawer-head .sheet-close,
.nav-drawer-head .sheet-close:hover,
.nav-drawer-head .sheet-close:active { color: var(--text-2); background: transparent; }
.drawer-create, .library-create { display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: center; gap: 10px; border-radius: 18px; color: #1a100d; background: var(--accent); font-size: 14px; font-weight: 800; }
.drawer-create .ui-icon, .library-create .ui-icon { width: 20px; height: 20px; }
.nav-drawer-list { display: grid; align-content: start; gap: 5px; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 16px 0 12px; overscroll-behavior: contain; scrollbar-width: none; }
.nav-drawer-list::-webkit-scrollbar { display: none; }
.nav-drawer-list button { display: grid; width: 100%; min-height: 60px; grid-template-columns: 34px minmax(0, 1fr) 18px; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 17px; color: var(--text-2); background: transparent; text-align: left; }
.nav-drawer-list button:active { background: var(--surface); }
.drawer-nav-icon { display: grid; width: 34px; height: 42px; place-items: center; color: var(--cream); background: transparent; }
.drawer-nav-icon .ui-icon { width: 23px; height: 23px; }
.nav-drawer-list button > span:nth-child(2) { min-width: 0; }
.nav-drawer-list b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-drawer-list b { font-size: 15px; font-weight: 720; letter-spacing: -.015em; }
.nav-drawer-list button > .ui-icon { width: 17px; height: 17px; color: var(--muted-2); }
.drawer-user { display: grid; min-width: 0; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 10px; padding: 12px 2px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.drawer-avatar { position: relative; display: grid; width: 44px; height: 44px; place-items: center; overflow: hidden; border-radius: 50%; color: #1a100d; background: var(--cream); }
.drawer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.drawer-avatar b { font-size: 16px; font-weight: 900; }
.drawer-user-copy { min-width: 0; }
.drawer-user-copy strong, .drawer-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-user-copy strong { font-size: 14px; }
.drawer-user-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
#drawerSettings { display: grid; width: 44px; height: 44px; place-items: center; color: var(--text-2); background: transparent; }
#drawerSettings .ui-icon { width: 23px; height: 23px; }

.new-chat-button, .primary-button, .secondary-button, .text-button { width: 100%; min-height: 50px; border-radius: 15px; font-size: 13px; font-weight: 800; }
.new-chat-button { display: flex; align-items: center; justify-content: center; gap: 7px; margin-bottom: 12px; color: #1a100d; background: var(--accent); }
.new-chat-button span { font-size: 19px; line-height: 1; }
.chat-history-list { display: grid; gap: 8px; }
.chat-history-list button { display: grid; grid-template-columns: 46px minmax(0, 1fr) 24px; gap: 12px; align-items: center; min-height: 72px; padding: 10px 12px; border-radius: 20px; color: var(--text-2); background: var(--surface); text-align: left; }
.chat-history-list button.is-active { background: var(--surface-2); }
.chat-history-list b { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-list small { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.library-item-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 15px; color: var(--cream); background: var(--surface-3); }
.library-item-icon .ui-icon { width: 22px; height: 22px; }
.library-item-copy { min-width: 0; }
.library-item-end { display: grid; width: 24px; height: 32px; place-items: center; color: var(--muted); }
.library-item-end .ui-icon { width: 18px; height: 18px; }
.library-item-end i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.sheet-empty { padding: 24px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.library-sheet-layer { align-items: center; justify-content: center; padding: max(14px, var(--safe-top)) 14px max(14px, var(--safe-bottom)); }
.library-sheet-layer .sheet-scrim { background: rgba(0, 0, 0, .58); }
.library-sheet { align-self: center; width: min(100%, 680px); height: min(92dvh, 860px); max-height: none; margin: 0; overflow-x: hidden; overflow-y: auto; border-radius: 30px; padding: 20px 20px calc(20px + var(--safe-bottom)); background: #151412; box-shadow: 0 28px 90px rgba(0,0,0,.58); }
.library-sheet .sheet-head { position: sticky; z-index: 2; top: -20px; margin: -20px -20px 16px; padding: 18px 20px 12px; background: rgba(21,20,18,.98); }
.library-head > div { display: flex; min-width: 0; align-items: center; gap: 12px; }
.library-head-icon { display: grid; width: 42px; height: 42px; flex: none; place-items: center; border-radius: 14px; color: var(--cream); background: var(--surface-2); }
.library-head-icon .ui-icon { width: 22px; height: 22px; }
.library-sheet .sheet-head h2 { margin: 0; font-family: var(--font); font-size: 25px; font-weight: 740; }
.library-create { margin-bottom: 16px; }
.library-sheet .chat-history-list { gap: 8px; }
.library-sheet .chat-history-list button { min-height: 72px; padding: 10px 12px; border-radius: 20px; background: var(--surface); }
.library-sheet .chat-history-list button.is-active { background: var(--surface-3); }
.library-sheet .chat-history-list b { font-size: 15px; }
.library-sheet .chat-history-list small { font-size: 12px; }
.library-sheet .builder-projects { margin: 0; padding: 0; border: 0; }
.library-sheet #builderProjectList { display: grid; gap: 8px; }

.model-list { display: grid; gap: 6px; }
.model-list button { position: relative; display: grid; min-width: 0; min-height: 62px; grid-template-columns: 34px minmax(0, 1fr) 14px; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 17px; color: var(--text-2); background: var(--surface); text-align: left; transition: transform .16s var(--ease), background .16s ease; }
.model-list button:active { transform: scale(.975); }
.model-list button b { display: block; overflow: hidden; font-size: 15px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.model-list button > img, .settings-model-row > img { width: 27px; height: 27px; filter: brightness(0) invert(93%) sepia(11%) saturate(367%) hue-rotate(343deg) brightness(101%) contrast(91%); }
.model-list button i { width: 13px; height: 13px; border: 2px solid #56514b; border-radius: 50%; }
.model-list button.is-active { color: var(--text); background: var(--surface-3); }
.model-list button.is-active i { border-color: var(--accent); background: var(--accent); box-shadow: none; }

.compact-sheet { padding-bottom: calc(18px + var(--safe-bottom)); }
.mode-sheet .sheet-head h2, .compact-sheet .sheet-head h2, .limits-sheet .sheet-head h2 { font-family: var(--font); font-size: 24px; font-weight: 750; letter-spacing: -.035em; }
.attachment-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.attachment-menu button { display: grid; min-height: 104px; place-items: center; align-content: center; gap: 9px; padding: 10px 5px; border-radius: 18px; color: var(--text-2); background: var(--surface); }
.attachment-menu svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.attachment-menu .ui-icon { width: 27px; height: 27px; }
.attachment-menu span { font-size: 12px; font-weight: 700; }
.setting-row, .settings-model-row, .setting-choice-row { display: grid; width: 100%; min-height: 58px; align-items: center; gap: 12px; margin-top: 8px; padding: 0 14px; border-radius: 17px; color: var(--text); background: var(--surface); text-align: left; }
.setting-row { grid-template-columns: minmax(0, 1fr) auto; }
.setting-row > span, .settings-model-row > span { font-size: 14px; font-weight: 700; }
.setting-row > i { position: relative; display: block; width: 46px; height: 27px; border-radius: 14px; background: var(--surface-3); }
.setting-row > i > b { position: absolute; top: 4px; left: 4px; width: 19px; height: 19px; border-radius: 50%; background: var(--muted); transition: transform .17s var(--ease), background .17s ease; }
.setting-row[aria-checked="true"] > i { background: var(--accent); }
.setting-row[aria-checked="true"] > i > b { background: #1a100d; transform: translateX(19px); }
.settings-model-row { grid-template-columns: 27px minmax(0, 1fr) auto 18px; }
.settings-model-row > img { width: 25px; height: 25px; }
.settings-model-row > b { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.settings-model-row > svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.settings-model-row > .ui-icon { width: 18px; height: 18px; }
.setting-choice-row { grid-template-columns: minmax(0, 1fr) auto 18px; }
.setting-choice-row > span { font-size: 14px; font-weight: 700; }
.setting-choice-row > b { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.setting-choice-row > svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.setting-choice-row > .ui-icon { width: 18px; height: 18px; }
.limit-list { display: grid; gap: 9px; }
.limit-meter { padding: 17px 16px; border-radius: 18px; background: var(--surface); }
.limit-meter > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.limit-meter strong { font-size: 14px; font-weight: 700; }
.limit-meter b { color: var(--cream); font-family: var(--font-mono); font-size: 13px; }
.limit-meter > span { display: block; height: 8px; margin-top: 14px; overflow: hidden; border-radius: 8px; background: var(--surface-3); }
.limit-meter > span > i { display: block; width: 0%; height: 100%; border-radius: inherit; background: var(--cream); transition: width .28s var(--ease); }
.primary-button { color: #1a100d; background: var(--accent); box-shadow: 0 10px 23px rgba(204, 120, 92, .24); }
.secondary-button { color: var(--text); background: var(--surface-3); }
.text-button { min-height: 42px; margin-top: 5px; color: var(--text-2); background: transparent; font-size: 11px; }

.deploy-sheet form { display: grid; gap: 18px; }
.deploy-field > span { display: block; margin-bottom: 9px; color: var(--text); font-size: 14px; font-weight: 850; }
.deploy-domain-input { display: flex; min-height: 56px; align-items: center; overflow: hidden; border-radius: 17px; background: var(--surface); }
.deploy-domain-input input { min-width: 0; height: 56px; flex: 1; padding: 0 5px 0 15px; background: transparent; font-family: var(--font-mono); font-size: 15px; }
.deploy-domain-input b { flex: none; padding-right: 15px; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.deploy-field > input { width: 100%; height: 56px; padding: 0 15px; border-radius: 17px; background: var(--surface); font-family: var(--font-mono); font-size: 14px; }
.deploy-field input::placeholder { color: var(--muted-2); }
.deploy-field-state { display: block; min-height: 18px; margin: 8px 2px 0; color: var(--muted); font-size: 12px; }
.deploy-field.is-ok .deploy-field-state { color: var(--green); }
.deploy-field.is-error .deploy-field-state { color: var(--red); }
.deploy-submit { margin-top: 2px; }

.subscription-current { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; padding: 15px 16px; border-radius: 18px; background: var(--surface); }
.subscription-current > span { color: var(--muted); font-size: 13px; font-weight: 700; }
.subscription-current > strong { font-size: 18px; letter-spacing: -.025em; }
.subscription-current > b { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 650; }
.subscription-plans { display: grid; gap: 8px; margin-top: 12px; }
.subscription-plans > button { display: grid; min-height: 76px; grid-template-columns: minmax(0, 1fr) auto 18px; align-items: center; gap: 12px; padding: 12px 15px; border-radius: 18px; color: var(--text); background: var(--surface); text-align: left; transition: transform .16s var(--ease), background .16s ease; }
.subscription-plans > button:active { transform: scale(.982); }
.subscription-plans > button span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.subscription-plans > button b { font-size: 18px; letter-spacing: -.03em; }
.subscription-plans > button strong { color: var(--cream); font-size: 15px; }
.subscription-plans > button em { color: var(--muted); font-size: 12px; font-style: normal; }
.subscription-plans > button i { width: 17px; height: 17px; border: 2px solid #56514b; border-radius: 50%; }
.subscription-plans > button.is-active { background: var(--surface-3); }
.subscription-plans > button.is-active i { border-color: var(--accent); background: var(--accent); }
.subscription-plans > button.is-current::after { grid-column: 1 / -1; color: var(--accent); font-size: 12px; font-weight: 800; content: "Текущий тариф"; }
.subscription-plan-details { display: grid; grid-column: 1 / -1; gap: 7px; padding: 11px 0 2px; color: var(--text-2); }
.subscription-plan-details span { position: relative; display: block !important; padding-left: 20px; font-size: 12px; line-height: 1.35; }
.subscription-plan-details span::before { position: absolute; top: .15em; left: 1px; color: var(--accent); content: "✓"; font-weight: 900; }
.subscription-plans > button.is-active { min-height: 132px; }
.balance-hero { display: flex; min-height: 116px; flex-direction: column; justify-content: center; padding: 18px; border-radius: 18px; background: var(--surface); }
.balance-hero > span { color: var(--muted); font-size: 10px; }
.balance-hero strong { margin-top: 5px; font-size: 30px; letter-spacing: -.045em; }
.balance-hero strong b { color: var(--accent); }
.topup-section { margin-top: 18px; }
.section-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--text-2); font-size: 10px; font-weight: 750; }
.section-label button { padding: 4px 0; color: var(--accent); background: transparent; font-size: 9px; }
.pay-wallet-list { display: grid; gap: 4px; }
.wallet-list-row { min-width: 0; min-height: 68px; padding: 4px 2px; border-radius: 14px; transition: background .12s var(--ease); }
.wallet-list-row.is-active { background: var(--surface-2); }
.wlr-pick { display: grid; width: 100%; min-width: 0; min-height: 60px; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 6px; background: transparent; text-align: left; }
.wlr-pick:active { background: rgba(255, 255, 255, .035); }
.wlr-ic { display: grid; width: 40px; height: 40px; min-width: 40px; place-items: center; font-size: 0; }
.wlr-wallet-icon { display: block; width: 28px; height: 28px; object-fit: contain; filter: brightness(0) saturate(100%) invert(93%) sepia(11%) saturate(367%) hue-rotate(343deg) brightness(101%) contrast(91%); }
.wlr-info { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; overflow: hidden; }
.wlr-copy { display: grid; min-width: 0; gap: 4px; }
.wlr-name { display: flex; min-width: 0; align-items: center; gap: 6px; overflow: hidden; font-size: 14px; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.wlr-addr { min-width: 0; overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: 11px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.wlr-connected { display: inline-flex; flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; color: var(--muted); background: var(--surface-3); font-size: 8px; font-weight: 750; line-height: 1.2; }
.wlr-balance { align-self: center; color: #f4f1ea; font-size: 13px; font-weight: 850; line-height: 1; letter-spacing: -.025em; text-align: right; white-space: nowrap; }
.skeleton-row { height: 60px; border-radius: 14px; background: var(--surface-2); }
.wallet-load-error { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-radius: 14px; color: var(--muted); background: var(--surface); font-size: 11px; }
.wallet-load-error button { min-height: 34px; padding: 0 12px; border-radius: 10px; color: #1a100d; background: var(--accent); font-size: 10px; font-weight: 800; }
.amount-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.amount-presets button { min-height: 39px; border-radius: 11px; color: var(--text-2); background: var(--surface); font-size: 11px; font-weight: 750; }
.amount-presets button.is-active { color: #1a100d; background: var(--accent); }
.amount-input { display: flex; height: 50px; align-items: center; gap: 10px; margin-top: 8px; padding: 0 14px; border-radius: 14px; background: var(--surface); }
.amount-input input { min-width: 0; flex: 1; background: transparent; font-size: 19px; font-weight: 800; }
.amount-input span { color: var(--accent); font-size: 11px; font-weight: 850; }
.subscription-actions { position: relative; isolation: isolate; display: grid; gap: 8px; margin-top: 18px; }
.subscription-actions > * { position: relative; margin: 0; }
.invoice-state { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: center; margin-bottom: 4px; padding: 12px; border-radius: 14px; background: var(--surface); }
.invoice-state strong { display: block; font-size: 13px; }
.invoice-spinner { display: flex; width: 23px; height: 23px; align-items: center; justify-content: center; gap: 3px; }
.invoice-spinner i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: invoiceDot 1s ease-in-out infinite; }
.invoice-spinner i:nth-child(2) { animation-delay: .14s; }
.invoice-spinner i:nth-child(3) { animation-delay: .28s; }
.invoice-state.is-done .invoice-spinner { display: grid; place-items: center; border-radius: 50%; background: var(--green); }
.invoice-state.is-done .invoice-spinner i { display: none; }
.invoice-state.is-done .invoice-spinner::after { content: "✓"; color: #07160d; font-size: 13px; font-weight: 950; }
@keyframes invoiceDot { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.ton-wallet-list { display: grid; gap: 6px; }
.ton-wallet-list button { display: grid; width: 100%; min-height: 60px; grid-template-columns: 42px minmax(0, 1fr) 20px; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 16px; color: var(--text); background: var(--surface); text-align: left; }
.ton-wallet-list img, .ton-wallet-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; object-fit: contain; background: var(--surface-3); }
.ton-wallet-list b { display: block; font-size: 14px; }
.ton-wallet-list small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.ton-wallet-list .ui-icon { width: 18px; height: 18px; color: var(--muted); }

.section-label small { color: var(--muted-2); font-size: 9px; font-weight: 700; }

.auth-state { position: fixed; z-index: 200; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg); text-align: center; }
.auth-state h1 { max-width: 360px; margin: 0; font-family: var(--font-ai); font-size: 38px; font-weight: 900; line-height: 1.04; letter-spacing: -.045em; }
.auth-state p { max-width: 330px; color: var(--muted); font-size: 13px; line-height: 1.48; }
.auth-state a { display: grid; width: min(100%, 330px); min-height: 50px; place-items: center; border-radius: 15px; color: #1a100d; background: var(--accent); font-weight: 800; text-decoration: none; }
.scroll-anchor { height: 1px; }

@media (min-width: 700px) {
  .topbar { padding-inline: 24px; }
  .chat-viewport { padding-inline: 24px; }
  .composer-wrap { padding-inline: 20px; }
}
@media (max-width: 360px) {
  .chat-viewport { padding-inline: 13px; }
  .composer-wrap { padding-inline: 9px; }
  .sheet { padding-inline: 14px; }
  .composer { min-height: 140px; padding-inline: 12px 9px; }
  .mode-chip { max-width: 48vw; padding-inline: 10px; font-size: 12px; }
  .voice-button, .send-button { width: 42px; height: 42px; }
  .model-list button { padding-inline: 11px; }
  .wallet-load-error { align-items: stretch; flex-direction: column; }
}

@media (max-width: 640px) {
  .image-viewer-layer { padding: 0; }
  .image-viewer { width: 100%; height: 100%; border-radius: 0; }
  .image-viewer-head { padding-top: max(7px, var(--safe-top)); }
  .image-viewer-actions button { padding-inline: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .image-viewer, .image-viewer-layer.is-closing .image-viewer { animation: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* M248: conversation-first answers and embedded project workspace. */
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.topbar-chat-button { display: grid; width: 42px; height: 42px; padding: 0; place-items: center; color: var(--text); background: transparent; }
.topbar-chat-button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.topbar-chat-button .ui-icon { width: 25px; height: 25px; }

.message-assistant { gap: 13px; }
.message { animation: messageEnter .28s var(--ease) both; }
@keyframes messageEnter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.message-assistant .message-body { width: 100%; padding: 0 2px; color: #ebe6df; font-size: 16px; font-weight: 600; line-height: 1.64; }
.assistant-process-live { display: flex; min-height: 30px; align-items: center; gap: 10px; padding: 0 2px; color: var(--muted); font-size: 13px; font-weight: 700; }
.assistant-process-trigger { width: max-content; max-width: 100%; min-height: 35px; padding: 0 2px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; text-align: left; }
.assistant-process-trigger::before { display: inline-block; width: 7px; height: 7px; margin-right: 12px; border-radius: 50%; background: var(--muted-2); content: ""; vertical-align: 1px; }
.message-assistant.is-streaming .message-body:empty { display: none; }
.assistant-footer { display: grid; gap: 10px; }
.assistant-actions { display: flex; min-height: 42px; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.assistant-actions::-webkit-scrollbar { display: none; }
.assistant-actions > button { display: grid; width: 42px; height: 42px; flex: none; padding: 0; place-items: center; border-radius: 12px; color: var(--muted); background: transparent; transition: none; }
.assistant-actions > button.is-selected { color: #fff; background: transparent; }
.assistant-actions > button.is-playing { color: #1a100d; background: var(--cream); }
.assistant-actions svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.assistant-actions .ui-icon { width: 23px; height: 23px; }
.assistant-actions .assistant-publish { display: flex; width: auto; min-width: 42px; gap: 7px; margin-left: auto; padding: 0 11px; color: #1a100d; background: var(--accent); font-size: 11px; font-weight: 850; white-space: nowrap; }
.assistant-actions .assistant-publish svg { width: 20px; height: 20px; }
.assistant-actions .assistant-publish .ui-icon { width: 20px; height: 20px; }
.assistant-disclaimer { display: grid; grid-template-columns: 29px minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 4px; padding: 0 2px; }
.assistant-disclaimer img { width: 27px; height: 27px; filter: none; }
.assistant-disclaimer small { max-width: 330px; justify-self: end; color: var(--muted-2); font-size: 8px; font-weight: 650; line-height: 1.35; text-align: right; }

html.compact-messages .message-list { gap: 20px; }
html.compact-messages .message-assistant { gap: 8px; }
html.compact-messages .message-assistant .message-body { font-size: 15px; line-height: 1.52; }
html.animations-off *, html.animations-off *::before, html.animations-off *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .boot-brand img { animation: none; }
  .boot-splash { transition-duration: .01ms; }
}

.message-project-slot:empty { display: none; }
.message-project-card { display: grid; width: 100%; min-height: 100px; grid-template-columns: 58px minmax(0, 1fr) 18px; align-items: center; gap: 14px; overflow: hidden; padding: 12px 15px; border-radius: 20px; color: var(--text); background: var(--surface); text-align: left; box-shadow: inset 0 0 0 1px rgba(255,255,255,.075); }
.message-project-icon { display: grid; width: 58px; height: 72px; place-items: center; border-radius: 17px 17px 4px 17px; color: var(--text-2); background: var(--surface-3); font-family: var(--font-mono); font-size: 17px; font-weight: 800; transform: rotate(-4deg); }
.message-project-card b, .message-project-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-project-card b { font-size: 16px; letter-spacing: -.025em; }
.message-project-card small { margin-top: 7px; color: var(--muted); font-size: 12px; }
.message-project-card > i { color: var(--muted); font-size: 26px; font-style: normal; }

.builder-viewport { position: fixed; z-index: 80; inset: 0; display: grid; height: var(--tg-viewport-stable-height, 100dvh) !important; padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom)); place-items: center; }
.project-viewer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; background: rgba(0, 0, 0, .72); animation: projectBackdropIn .2s ease both; }
.project-viewer-panel { position: relative; z-index: 1; display: grid; width: min(100%, 1040px); height: min(100%, 860px); min-height: 0; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 26px; background: var(--bg); box-shadow: 0 28px 90px rgba(0, 0, 0, .58); animation: projectPreviewIn .28s var(--ease) both; }
.builder-viewport.is-closing .project-viewer-backdrop { animation: projectBackdropOut .18s ease both; }
.builder-viewport.is-closing .project-viewer-panel { animation: projectPreviewOut .18s ease both; }
@keyframes projectBackdropIn { from { opacity: 0; } }
@keyframes projectBackdropOut { to { opacity: 0; } }
@keyframes projectPreviewIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes projectPreviewOut { to { opacity: 0; transform: translateY(12px) scale(.99); } }
.project-viewer-head { position: relative; z-index: 3; display: grid; min-height: calc(66px + var(--safe-top)); grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; padding: calc(8px + var(--safe-top)) 10px 8px; background: rgba(21,20,18,.97); }
.project-viewer-head strong { overflow: hidden; font-size: 16px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.project-viewer-close, .project-viewer-menu { display: grid; width: 48px; height: 48px; padding: 0; place-items: center; color: var(--text); background: transparent; }
.project-viewer-close svg, .project-viewer-menu svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.project-viewer-close .ui-icon, .project-viewer-menu .ui-icon { width: 25px; height: 25px; }
.project-viewer-body { min-height: 0; overflow: hidden; }
.project-viewer-body .site-preview { height: 100%; border-radius: 0; box-shadow: none; }
.project-viewer-body .site-preview iframe { height: 100%; min-height: 100%; }

.bot-preview { display: grid; height: 100%; min-height: 0; grid-template-rows: auto minmax(0,1fr) auto; background: #11171d; }
.bot-preview > header { display: flex; min-height: 66px; align-items: center; gap: 11px; padding: 10px 15px; background: #1b2732; }
.bot-preview-avatar { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 50%; color: #1a100d; background: var(--accent); font-size: 12px; font-weight: 900; }
.bot-preview header strong, .bot-preview header small { display: block; }
.bot-preview header strong { font-size: 15px; }
.bot-preview header small { margin-top: 3px; color: #8d9cab; font-size: 10px; }
.bot-preview-thread { display: flex; min-height: 0; flex-direction: column; gap: 9px; overflow: auto; padding: 18px 13px; background: #101820; }
.bot-preview-message { max-width: 84%; align-self: flex-start; padding: 10px 12px; border-radius: 15px 15px 15px 4px; color: #edf3f7; background: #213242; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.bot-preview-message.is-user { align-self: flex-end; border-radius: 15px 15px 4px 15px; background: #295343; }
.bot-preview-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.bot-preview-suggestions button { min-height: 36px; padding: 0 11px; border-radius: 12px; color: #e9f0f5; background: #213242; font-size: 11px; }
.bot-preview-composer { display: grid; min-height: 66px; grid-template-columns: minmax(0,1fr) 46px; align-items: center; gap: 8px; padding: 8px 11px calc(8px + var(--safe-bottom)); background: #1b2732; }
.bot-preview-composer input { height: 44px; padding: 0 14px; border-radius: 22px; color: #edf3f7; background: #243543; font-size: 13px; }
.bot-preview-composer button { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; color: #1a100d; background: var(--accent); }
.bot-preview-composer svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linejoin: round; stroke-width: 1.8; }
.bot-preview-composer .ui-icon { width: 22px; height: 22px; }

.action-menu-list { display: grid; gap: 3px; }
.action-menu-list button { display: grid; min-height: 56px; grid-template-columns: 28px minmax(0,1fr); align-items: center; gap: 13px; padding: 0 13px; border-radius: 15px; color: var(--text); background: var(--surface); text-align: left; }
.action-menu-list button.is-danger { color: var(--red); }
.action-menu-list svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.action-menu-list .ui-icon { width: 23px; height: 23px; }
.simple-sheet-form { display: grid; gap: 12px; }
.simple-sheet-form input, .simple-sheet-form textarea { width: 100%; padding: 14px 15px; border-radius: 17px; color: var(--text); background: var(--surface); font-size: 15px; }
.simple-sheet-form input { height: 55px; }
.simple-sheet-form textarea { min-height: 135px; resize: vertical; line-height: 1.5; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.danger-button { min-height: 50px; border-radius: 15px; color: #fff; background: #7d343a; font-size: 13px; font-weight: 800; }
.process-sheet { min-height: min(72dvh, 620px); }
.process-timeline { display: grid; gap: 0; }
.process-timeline > div { position: relative; display: grid; min-height: 64px; grid-template-columns: 28px minmax(0,1fr); align-items: center; gap: 11px; color: var(--text-2); font-size: 14px; }
.process-timeline > div::before { position: absolute; top: 42px; bottom: -22px; left: 13px; width: 1px; background: var(--surface-3); content: ""; }
.process-timeline > div:last-child::before { display: none; }
.process-timeline i { width: 10px; height: 10px; justify-self: center; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--surface-2); }
.deploy-field-state.is-ok { color: var(--green); }
.deploy-field-state.is-error { color: var(--red); }
.inline-form-state { min-height: 20px; margin: -4px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.inline-form-state.is-error { color: var(--red); }
.inline-form-state.is-success { color: var(--cream); }
.deployed-project-link { display: grid; min-height: 50px; place-items: center; border-radius: 15px; color: var(--text); background: var(--surface-3); font-size: 13px; font-weight: 800; text-decoration: none; }
.publish-success-sheet { overflow: hidden; }
.publish-success-link { display: grid; min-width: 0; min-height: 66px; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 12px; padding: 0 16px; border-radius: 18px; color: var(--text); background: var(--surface); text-decoration: none; }
.publish-success-link .ui-icon { width: 22px; height: 22px; color: var(--cream); }
.publish-success-link strong { min-width: 0; overflow: hidden; font-family: var(--font-mono); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.publish-success-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.publish-success-actions > a, .publish-success-actions > button { display: flex; min-width: 0; min-height: 50px; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; text-decoration: none; }
.publish-success-actions .ui-icon { width: 19px; height: 19px; }
.publish-success-actions span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .builder-viewport { padding: 0; }
  .project-viewer-panel { width: 100%; height: 100%; border-radius: 0; }
  .library-sheet-layer { padding: 0; }
  .library-sheet { width: 100%; height: 100%; border-radius: 0; padding-inline: 16px; }
  .library-sheet .sheet-head { margin-inline: -16px; padding-inline: 16px; }
}

@media (max-width: 360px) {
  .assistant-actions { gap: 0; }
  .assistant-actions > button { width: 38px; height: 40px; }
  .assistant-actions .assistant-publish { width: auto; padding-inline: 9px; }
  .message-project-card { grid-template-columns: 52px minmax(0,1fr) 14px; padding-inline: 11px; }
  .message-project-icon { width: 52px; }
}
