/* ============================================================
   VOID AI — Telegram Mini App
   Палитра: холодный графит с бирюзовым уклоном
   Акцент #42A8AE взят прямо из знака.
   ============================================================ */

:root {
  --paper:       #0F1417;
  --surface:     #161D21;
  --surface-2:   #1D262A;
  --surface-3:   #273338;
  --ink:         #E7EDEF;
  --ink-2:       #97A6AA;
  --ink-3:       #7C8C90;
  --line:        #232E32;
  --line-strong: #35454A;
  --accent:      #42A8AE;
  --accent-hi:   #5BC3C9;
  --accent-dim:  #2F7F84;
  --accent-wash: #12292C;
  --good:        #7BC46B;
  --warn:        #D8A445;
  --bad:         #EA7E73;

  --font-display: Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --r: 10px;
  --r-lg: 14px;
  --sidebar-w: 268px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.sm { font-size: 13px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   SHELL
   ============================================================ */

.app { display: flex; min-height: 100%; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

.brand-text { flex: 1; min-width: 0; }
.brand-name { font-family: var(--font-display); font-size: 17px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 14.5px;
  text-align: left;
  transition: background .12s, color .12s;
}

.nav-item:hover { background: var(--surface-2); color: var(--ink); }

.nav-item.is-active {
  background: var(--accent-wash);
  color: var(--ink);
}

.nav-item.is-active .ni { color: var(--accent); }

.ni {
  width: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  flex-shrink: 0;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }

.quota-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 13px;
  cursor: pointer;
  transition: border-color .12s;
}
.quota-card:hover { border-color: var(--line-strong); }

.quota-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 9px;
}

.quota-plan { font-family: var(--font-display); font-size: 16px; }
.quota-cta { font-size: 12px; color: var(--accent); }

.quota-rows { display: flex; flex-direction: column; gap: 7px; }

.qrow { display: flex; flex-direction: column; gap: 4px; }

.qrow-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
}
.qrow-top b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }

.qbar {
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.qbar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.qbar.empty > i { background: var(--ink-3); }

.quota-rows.lg .qrow-top { font-size: 13.5px; }
.quota-rows.lg { gap: 13px; }
.quota-rows.lg .qbar { height: 5px; }

/* ---------- topbar ---------- */

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 17px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 17px;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.burger, .burger::before, .burger::after {
  display: block;
  width: 16px; height: 1.5px;
  background: currentColor;
  border-radius: 2px;
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; }
.burger::after { top: 5px; }

.pill-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: border-color .12s, color .12s;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- screens ---------- */

.screens { flex: 1; min-height: 0; position: relative; }

.screen {
  display: none;
  padding: 28px 32px 48px;
  max-width: 1180px;
  animation: fade .18s ease;
}
.screen.is-active { display: block; }

.screen-flush { padding: 0; max-width: none; height: 100%; }
.screen-flush.is-active { display: flex; flex-direction: column; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.hero { margin-bottom: 26px; display: flex; flex-direction: column; gap: 9px; }

h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 32px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 { font-family: var(--font-display); font-size: 21px; font-weight: 400; }

.lede { color: var(--ink-2); max-width: 58ch; font-size: 15px; }

/* ---------- layout helpers ---------- */

.col2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.field { display: flex; flex-direction: column; gap: 9px; }

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- controls ---------- */

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 13px;
  color: var(--ink);
  font-size: 15px;
  resize: vertical;
  transition: border-color .12s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--accent-dim); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #06181A; }
.btn-primary:hover { background: var(--accent-hi); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost { border: 1px solid var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-lg { padding: 13px 20px; font-size: 15.5px; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 40px; height: 40px; padding: 0; flex-shrink: 0; font-size: 17px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  padding: 7px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 100px;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: all .12s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.is-active {
  background: var(--accent-wash);
  border-color: var(--accent-dim);
  color: var(--ink);
}

.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 3px;
  gap: 3px;
}

.seg {
  flex: 1;
  padding: 8px 6px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: center;
  transition: background .12s, color .12s;
  position: relative;
}
.seg:hover { color: var(--ink); }
.seg.is-active { background: var(--surface-3); color: var(--ink); }
.seg small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 1px;
}
.seg.is-active small { color: var(--accent); }
.seg.is-locked { opacity: .45; cursor: not-allowed; }

/* ---------- dropzone ---------- */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--accent-dim); background: var(--surface-2); }
.dropzone-sm { min-height: 104px; }

.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 20px; text-align: center; }
.dz-icon { font-size: 26px; color: var(--accent); line-height: 1; }
.dz-title { font-size: 14.5px; }
.dz-hint { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }

.dz-preview { display: none; width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.dropzone.has-file .dz-inner { display: none; }
.dropzone.has-file .dz-preview { display: block; }
.dropzone.has-file { border-style: solid; border-color: var(--line); }

/* ---------- кабинеты: плитки, таблицы ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.tile { background: var(--surface); padding: 15px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.tile-value { font-family: var(--font-display); font-size: 25px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 12px; color: var(--ink-2); }
.tile-note.up { color: var(--good); }
.tile-note.down { color: var(--bad); }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; margin: 30px 0 14px;
  padding-bottom: 9px; border-bottom: 1px solid var(--line-strong);
}
.section-head h2 { font-size: 20px; }

.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tw table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tw th {
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .07em;
  text-transform: uppercase; font-weight: 500; color: var(--ink-3);
  text-align: right; padding: 9px 13px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.tw th:first-child { text-align: left; }
.tw td {
  padding: 10px 13px; text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line);
}
.tw td:first-child { text-align: left; white-space: normal; }
.tw tr:last-child td { border-bottom: none; }
.tw tr.total td { background: var(--surface-2); font-weight: 600; }
.tw .mono { font-size: 12.5px; color: var(--ink-2); }
.tw .empty-cell { color: var(--ink-3); }

.pill {
  display: inline-block; font-family: var(--font-mono); font-size: 11px;
  padding: 2px 8px; border-radius: 4px; font-variant-numeric: tabular-nums;
}
.p-good { background: #17301F; color: var(--good); }
.p-warn { background: #33270F; color: var(--warn); }
.p-bad  { background: #341A18; color: var(--bad); }

/* ---------- результат генерации ---------- */

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: start;
}
.result[hidden] { display: none; }

.result-media {
  width: 100%;
  max-height: 72vh;
  border-radius: var(--r-lg);
  background: #000;
  border: 1px solid var(--line);
  display: block;
  object-fit: contain;
}

.result-side { display: flex; flex-direction: column; gap: 11px; }
.result-title { font-family: var(--font-display); font-size: 23px; }
.result-text { color: var(--ink-2); font-size: 14.5px; margin-bottom: 4px; }
.result-note { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.result-side .btn { width: 100%; text-decoration: none; }

@media (max-width: 860px) {
  .result { grid-template-columns: 1fr; gap: 16px; }
  .result-media { max-height: 56vh; }
}

/* ---------- партнёрка: экран для неподключённых ---------- */

.pt-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  max-width: 520px;
  margin: 0 auto;
}
.pt-locked[hidden] { display: none; }
.pt-locked-icon { font-size: 30px; color: var(--accent); }
.pt-locked-title { font-family: var(--font-display); font-size: 22px; }
.pt-locked-text { color: var(--ink-2); max-width: 40ch; font-size: 14.5px; }
.pt-locked-btn { width: auto; min-width: 260px; margin-top: 8px; text-decoration: none; }
.pt-locked-note { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.tg-mark { font-size: 15px; }

a.link-row { text-decoration: none; }

/* ---------- рефералка ---------- */

.ref-progress { display: flex; flex-direction: column; gap: 10px; }
.ref-dots { display: flex; gap: 7px; }
.ref-dot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
}
.ref-dot.is-on { background: var(--accent); }
.ref-progress-text { font-size: 13.5px; color: var(--ink-2); }
.ref-progress-text b { color: var(--ink); }

.ref-rules {
  display: flex; flex-direction: column; gap: 8px;
  padding-left: 18px; margin: 0;
  font-size: 14px; color: var(--ink-2);
}
.ref-rules b { color: var(--ink); font-weight: 600; }

/* ---------- переключатель режимов видео ---------- */

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.mode {
  padding: 13px 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-lg);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .12s, background .12s;
}
.mode:hover { border-color: var(--line-strong); }
.mode.is-active { border-color: var(--accent-dim); background: var(--accent-wash); }

.mode-t { font-size: 14.5px; color: var(--ink-2); }
.mode.is-active .mode-t { color: var(--ink); font-weight: 500; }
.mode-s { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.mode.is-active .mode-s { color: var(--accent); }

@media (max-width: 520px) {
  .mode-switch { grid-template-columns: 1fr; gap: 6px; }
  .mode { flex-direction: row; align-items: baseline; justify-content: space-between; padding: 11px 14px; }
}

/* ---------- слоты исходных фото (до трёх) ---------- */

.ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ref-slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.ref-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ref-slot .ref-del {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(9,13,15,.78);
  backdrop-filter: blur(4px);
  color: var(--ink);
  font-size: 11px;
  line-height: 1;
}
.ref-slot .ref-del:hover { background: var(--bad); color: #2A0F0C; }

.ref-slot .ref-num {
  position: absolute;
  left: 5px; bottom: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(9,13,15,.72);
  backdrop-filter: blur(4px);
  color: var(--ink-2);
}

.ref-add {
  aspect-ratio: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 11.5px;
  transition: border-color .12s, background .12s, color .12s;
}
.ref-add:hover { border-color: var(--accent-dim); background: var(--surface-2); color: var(--ink-2); }
.ref-add i { font-style: normal; font-size: 21px; color: var(--accent); line-height: 1; }

/* ---------- cost card ---------- */

.cost-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--ink-2);
}
.cost-row b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.cost-row.muted b { color: var(--ink-2); }

.cost-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.cost-note.warn { color: var(--warn); }

/* ---------- panels & stats ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.panel-title { font-family: var(--font-display); font-size: 22px; }
.panel-title.sm { font-size: 17px; }
.panel-foot { font-size: 12px; color: var(--ink-3); padding-top: 4px; border-top: 1px solid var(--line); }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14.5px;
  color: var(--ink-2);
  cursor: pointer;
  padding: 2px 0;
}
.toggle-row input { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }

.link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14.5px;
  color: var(--ink-2);
  padding: 7px 0;
  text-align: left;
  width: 100%;
}
.link-row:hover { color: var(--ink); }
.link-row span { color: var(--ink-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stat { background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.stat-value { font-family: var(--font-display); font-size: 28px; font-variant-numeric: tabular-nums; }

.ref-link {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 9px 9px 13px;
}
.ref-link .mono { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   CHAT
   ============================================================ */

.chat-layout { display: flex; flex: 1; min-height: 0; }

.chat-list {
  width: 264px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.chat-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.dialogs { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.dialog {
  padding: 10px 11px;
  border-radius: var(--r);
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background .12s;
}
.dialog:hover { background: var(--surface-2); }
.dialog.is-active { background: var(--accent-wash); }
.dialog-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-prev { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog.is-archived .dialog-title { color: var(--ink-3); }

.chat-list-foot {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

.chat-thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.thread-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.thread-title { font-family: var(--font-display); font-size: 16px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg { max-width: 68ch; display: flex; flex-direction: column; gap: 4px; }
.msg-bubble {
  padding: 11px 14px;
  border-radius: var(--r-lg);
  font-size: 14.5px;
  line-height: 1.5;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .msg-bubble { background: var(--accent-wash); border: 1px solid var(--accent-dim); border-bottom-right-radius: 4px; }
.msg.bot .msg-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); padding: 0 4px; }

/* приветственный экран пустого диалога */
.chat-intro {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  text-align: center;
}
.chat-intro[hidden] { display: none; }

.chat-intro-mark { width: 54px; height: 54px; opacity: .9; margin-bottom: 2px; }
.chat-intro-title { font-family: var(--font-display); font-size: 23px; }
.chat-intro-text { color: var(--ink-2); max-width: 42ch; font-size: 14.5px; }
.chat-intro .chips { justify-content: center; margin-top: 10px; max-width: 560px; }

.composer {
  display: flex;
  gap: 9px;
  padding: 12px 16px 6px;
  border-top: 1px solid var(--line);
  align-items: flex-end;
}
.composer .input { max-height: 140px; }
.composer-note { padding: 0 16px 12px; font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); }

/* ============================================================
   GALLERY & WORKS
   ============================================================ */

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-row-sub { margin-top: -10px; }
.filter-row-sub .chip { padding: 5px 11px; font-size: 12.5px; }
.filter-row:empty { display: none; }

/* Кладка колонками: ролики разной формы соседствуют без обрезки.
   Пропорция каждой плитки приходит из данных через --ar. */
.grid-gallery {
  columns: 4;
  column-gap: 14px;
}
.grid-gallery > * { break-inside: avoid; margin-bottom: 14px; }

@media (max-width: 1180px) { .grid-gallery { columns: 3; } }
@media (max-width: 700px)  { .grid-gallery { columns: 2; column-gap: 10px; } .grid-gallery > * { margin-bottom: 10px; } }
@media (max-width: 400px)  { .grid-gallery { columns: 2; } }

.card-video {
  position: relative;
  aspect-ratio: var(--ar, 9 / 16);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color .14s, transform .14s;
}
.card-video:hover { border-color: var(--accent-dim); transform: translateY(-2px); }

.card-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

/* плитка-видео: постером служит первый кадр самого файла */
video.card-thumb { pointer-events: none; }

.card-video.is-loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.6);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.card-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10,11,16,.92) 0%, rgba(10,11,16,.35) 42%, transparent 70%);
}

.card-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card-title { font-size: 13.5px; line-height: 1.3; }
.card-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-2); }

.card-play {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: rgba(17,19,27,.72);
  backdrop-filter: blur(6px);
  border-radius: 50%;
  font-size: 9px;
  color: var(--ink);
}

.card-badge {
  position: absolute;
  top: 10px; left: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(17,19,27,.72);
  backdrop-filter: blur(6px);
  color: var(--ink-2);
}
.card-badge.pending { background: var(--warn); color: #1A1405; }

/* работы — та же кладка, что и в галерее: фото и ролики разной формы */
.grid-works { columns: 4; column-gap: 14px; }
.grid-works > * { break-inside: avoid; margin-bottom: 14px; }
@media (max-width: 1180px) { .grid-works { columns: 3; } }
@media (max-width: 700px)  { .grid-works { columns: 2; column-gap: 10px; }
                             .grid-works > * { margin-bottom: 10px; } }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
}
.empty-icon { font-size: 30px; color: var(--ink-3); }
.empty-title { font-family: var(--font-display); font-size: 19px; }
.empty-text { color: var(--ink-2); max-width: 34ch; font-size: 14px; }
.empty .btn { margin-top: 6px; }

/* ============================================================
   PLANS
   ============================================================ */

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(222px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: border-color .14s;
}
.plan:hover { border-color: var(--line-strong); }

.plan.is-featured { border-color: var(--accent-dim); background: linear-gradient(180deg, var(--accent-wash) 0%, var(--surface) 58%); }
.plan.is-current { border-color: var(--good); }

.plan-tag {
  position: absolute;
  top: -9px; left: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--accent);
  color: #06181A;
}
.plan-tag.current { background: var(--good); color: #0A1806; }

.plan-name { font-family: var(--font-display); font-size: 21px; }

.plan-price { display: flex; align-items: baseline; gap: 5px; }
.plan-price b { font-family: var(--font-display); font-size: 32px; font-weight: 400; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 13px; color: var(--ink-3); font-family: var(--font-mono); }

.plan-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.plan-item { display: flex; gap: 9px; font-size: 14px; color: var(--ink-2); align-items: baseline; }
.plan-item b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; min-width: 26px; }
.plan-item.off { color: var(--ink-3); }
.plan-item.off b { color: var(--ink-3); }

.plan-value {
  font-size: 12px;
  color: var(--good);
  font-family: var(--font-mono);
  padding-top: 2px;
}

.plans-note {
  margin-top: 22px;
  padding: 16px 18px;
  border-left: 2px solid var(--accent);
  background: var(--accent-wash);
  border-radius: 0 var(--r) var(--r) 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

/* ============================================================
   SHEETS / TABBAR / TOAST
   ============================================================ */

.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(6,7,12,.66); backdrop-filter: blur(3px); }

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  animation: rise .22s ease;
  max-height: 92vh;
  overflow-y: auto;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.sheet-handle { width: 38px; height: 4px; background: var(--line-strong); border-radius: 3px; margin: 9px auto 0; }

.sheet-body {
  padding: 20px 22px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.sheet-body.center { align-items: center; text-align: center; }
.sheet-body p { color: var(--ink-2); font-size: 14.5px; }
.sheet-eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }

.sheet-plans { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }

.sheet-plan {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  text-align: left;
  width: 100%;
  transition: border-color .12s;
}
.sheet-plan:hover { border-color: var(--accent-dim); }
.sheet-plan.is-featured { border-color: var(--accent-dim); }
.sp-name { font-family: var(--font-display); font-size: 16px; }
.sp-desc { font-size: 12.5px; color: var(--ink-3); }
.sp-price { font-family: var(--font-mono); font-size: 15px; white-space: nowrap; }

.spinner {
  width: 34px; height: 34px;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar { width: 100%; height: 4px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .5s ease; }

.tabbar { display: none; }

/* ---------- плеер ---------- */

.player-wrap {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.player-wrap[hidden] { display: none; }

.player-scrim { position: absolute; inset: 0; background: rgba(5,6,10,.86); backdrop-filter: blur(6px); }

.player {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise .2s ease;
}
.player.is-wide { max-width: 860px; }
@media (prefers-reduced-motion: reduce) { .player { animation: none; } }

.player-video {
  width: 100%;
  min-height: 0;
  flex: 1;
  border-radius: var(--r-lg);
  background: #000;
  border: 1px solid var(--line);
  object-fit: contain;
}

.player-close {
  position: absolute;
  top: -6px; right: -4px;
  transform: translateY(-100%);
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 14px;
}
.player-close:hover { color: var(--ink); border-color: var(--accent); }

.player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
}
.player-title { font-family: var(--font-display); font-size: 17px; }
.player-sub { font-size: 12px; color: var(--ink-3); }

@media (max-width: 860px) {
  .player-wrap { padding: 14px; align-items: flex-end; }
  .player { max-width: none; padding-bottom: var(--safe-b); }
  .player-meta { flex-direction: column; align-items: stretch; gap: 10px; }
  .player-meta .btn { width: 100%; }
  .player-close { top: -8px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 90;
  white-space: nowrap;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

.scrim { display: none; }
.mobile-only { display: none; }
.drawer-only { display: none; }

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 860px) {

  .mobile-only { display: grid; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 50;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .sidebar.is-open { transform: none; }
  .drawer-only { display: grid; }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(6,7,12,.6);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
  }
  .scrim.is-open { opacity: 1; pointer-events: auto; }

  .screen { padding: 20px 16px calc(28px + var(--tabbar-h) + var(--safe-b)); }
  .screen-flush { padding: 0; }

  .col2 { grid-template-columns: 1fr; gap: 20px; }

  .hero { margin-bottom: 20px; }

  .tabbar {
    display: flex;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(12px);
    position: sticky;
    bottom: 0;
    z-index: 30;
    flex-shrink: 0;
  }

  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    color: var(--ink-3);
    transition: color .12s;
  }
  .tab .ti { font-size: 13px; }
  .tab.is-active { color: var(--accent); }

  /* чат: список ↔ тред */
  .chat-layout { position: relative; }
  .chat-list {
    width: 100%;
    border-right: none;
  }
  .chat-thread {
    position: absolute;
    inset: 0;
    background: var(--paper);
    transform: translateX(100%);
    transition: transform .22s ease;
    z-index: 5;
  }
  .chat-layout.thread-open .chat-thread { transform: none; }


  .plans { grid-template-columns: 1fr; }
  .plan { padding: 18px 16px; }

  .sheet { max-width: none; }
}

@media (max-width: 380px) {
  .tab { font-size: 9.5px; }
  .screen { padding-left: 13px; padding-right: 13px; }
}
