/* Aria · panou — un singur fișier de stil, fără framework. Temă după sistem (închis / deschis). */

:root {
  --bg: #0f0e13;
  --surface: #17151d;
  --surface-2: #1f1c27;
  --surface-3: #282433;
  --border: #2c2837;
  --text: #ece9f1;
  --text-2: #b9b3c6;
  --muted: #8b849a;
  --accent: #ff6b94;
  --accent-2: #7d5cff;
  --accent-ink: #ff8fae;
  --grad: linear-gradient(135deg, #ff6b94 0%, #b05cff 60%, #7d5cff 100%);
  --good: #3ecf8e;
  --warn: #f5b14c;
  --bad: #ff5d6c;
  --bar: #c86cff;
  --bubble-in: #24212d;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f8;
    --surface: #ffffff;
    --surface-2: #f1eff5;
    --surface-3: #e7e4ee;
    --border: #e2dfe9;
    --text: #1b1822;
    --text-2: #4a4556;
    --muted: #7a7487;
    --accent-ink: #d63a6b;
    --bar: #9b4dff;
    --bubble-in: #eeecf3;
    --shadow: 0 10px 30px rgba(30, 20, 60, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
img, video { display: block; max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pornire ---------- */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- butoane și câmpuri ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.icon { width: 40px; padding: 0; }
.chat-head .back { display: none; }
@media (max-width: 899px) { .chat-head .back { display: inline-flex; } }
.btn.icon.sm { width: 32px; }
.btn.block { width: 100%; }

.input, .textarea, .select {
  width: 100%; min-height: 42px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(125, 92, 255, .2); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.textarea.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); cursor: pointer; transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + span { background: var(--accent-2); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(125, 92, 255, .35); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.manual { background: rgba(245, 177, 76, .16); color: var(--warn); }
.badge.paused { background: rgba(139, 132, 154, .18); color: var(--muted); }
.badge.money { background: rgba(62, 207, 142, .15); color: var(--good); }
.badge.accent { background: rgba(255, 107, 148, .15); color: var(--accent-ink); }

/* ---------- carcasa: meniu lateral (laptop) / bară jos (telefon) ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }

.mode-pill {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: left;
}
.mode-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(62, 207, 142, .15); flex: none; }
.mode-pill.manual .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 177, 76, .15); }
.mode-pill b { display: block; font-size: 14px; }
.mode-pill small { color: var(--muted); font-size: 12px; }

.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 8px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.on i { background: var(--good); }

.main { min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { flex: 1; overflow-y: auto; padding: 28px 32px 48px; -webkit-overflow-scrolling: touch; }
.page.flush { padding: 0; overflow: hidden; display: flex; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.bottom-nav { display: none; }

@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 14px 0;
    background: var(--surface); border-bottom: 1px solid var(--border); flex: none;
  }
  .topbar .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; }
  .topbar .mode-pill { width: auto; padding: 6px 12px; border-radius: 999px; gap: 8px; }
  .topbar .mode-pill small { display: none; }
  .topbar .mode-pill b { font-size: 13px; }
  .page { padding: 18px 14px calc(var(--nav-h) + var(--safe-b) + 24px); }
  .page.flush { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
  .page-head h1 { font-size: 22px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 11px; font-weight: 600; position: relative;
  }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--text); }
  .bottom-nav a.active svg { stroke: var(--accent-ink); }
  .bottom-nav .nav-count { position: absolute; top: 6px; left: 50%; margin-left: 6px; }
  /* chat deschis pe telefon: ecran întreg, fără bara de jos */
  body.in-chat .bottom-nav, body.in-chat .topbar { display: none; }
  body.in-chat .page.flush { padding-bottom: 0; }
}

/* ---------- carduri și dashboard ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 650; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 550; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.hero { background: var(--grad); border: none; color: #fff; }
.stat.hero .label, .stat.hero .sub { color: rgba(255,255,255,.85); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.stat.hero .delta { color: #fff; font-weight: 700; }
.dash-cols { grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 1100px) { .dash-cols { grid-template-columns: 1fr; } }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--border); cursor: pointer;
}
.list-row:first-child { border-top: none; }
.list-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }

/* grafic */
.chart-wrap { position: relative; }
.chart { width: 100%; height: 210px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--bar); }
.chart .bar.today { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { filter: brightness(1.25); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow);
}
.tooltip b { font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--text-2); font-weight: 550; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ---------- avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 15px; text-transform: uppercase;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

/* ---------- conversații ---------- */
.chats { display: grid; grid-template-columns: 360px minmax(0, 1fr); width: 100%; height: 100%; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.chat-list-head { padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.chat-list-head h1 { margin: 0; font-size: 22px; }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.chat-items { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.chat-item {
  display: flex; gap: 12px; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; align-items: center;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--surface-3); }
.chat-item .top { display: flex; align-items: baseline; gap: 8px; }
.chat-item .name { font-weight: 650; }
.chat-item .when { margin-left: auto; font-size: 12px; color: var(--muted); flex: none; }
.chat-item .last { font-size: 13.5px; color: var(--muted); }
.chat-item.unanswered .last { color: var(--text); font-weight: 550; }
.chat-item .flags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: calc(10px + var(--safe-t));
  background: var(--surface); border-bottom: 1px solid var(--border); flex: none;
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 16px; }
.chat-head .who span { font-size: 12.5px; color: var(--muted); }
.status-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex: none; flex-wrap: wrap;
}
.status-bar.manual { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; margin: 12px 0 6px; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; }
.msg { display: flex; flex-direction: column; max-width: min(78%, 560px); }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.msg .meta { font-size: 11px; color: var(--muted); margin: 2px 6px 6px; }
.msg.pending .bubble { outline: 2px dashed color-mix(in srgb, var(--warn) 60%, transparent); outline-offset: 1px; }
.msg.new .bubble { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }
.media-tag { font-style: italic; opacity: .9; }
.load-more { align-self: center; margin-bottom: 8px; }

.composer { flex: none; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px; padding-bottom: calc(10px + var(--safe-b)); }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--surface-3); color: var(--text); }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
.compose-row .textarea { min-height: 44px; max-height: 160px; resize: none; border-radius: 22px; padding: 11px 16px; }
.send-btn { width: 44px; height: 44px; border-radius: 50%; flex: none; padding: 0; }
.send-btn svg { width: 20px; height: 20px; }
.compose-note { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.draft-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.draft-box .textarea { min-height: 60px; background: var(--surface); }

.info-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 6;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease;
}
.info-panel.open { transform: none; }
.info-panel .body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.notes { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-cell {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); position: relative; cursor: pointer;
  display: grid; place-items: center; font-size: 22px;
}
.media-cell img, .media-cell video { width: 100%; height: 100%; object-fit: cover; }
.media-cell .kind { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 1px 6px; border-radius: 6px; }

@media (max-width: 899px) {
  .chats { grid-template-columns: minmax(0, 1fr); }
  .chats.has-chat .chat-list { display: none; }
  .chats:not(.has-chat) .chat-pane { display: none; }
  .msg { max-width: 86%; }
}

/* ---------- librărie ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; color: var(--text-2);
}
.dropzone.over { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.dropzone b { color: var(--text); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }
.photo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; position: relative;
}
.photo.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.photo .thumb { aspect-ratio: 4 / 5; background: var(--surface-2); position: relative; cursor: pointer; overflow: hidden; }
.photo .thumb img, .photo .thumb video { width: 100%; height: 100%; object-fit: cover; }
.photo .nr { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.photo .vid { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.photo .check {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,.45); border: 2px solid #fff; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px;
}
.photo.selected .check { background: var(--accent); border-color: var(--accent); }
.photo .info { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.price-btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-weight: 700;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.price-btn:hover { border-color: var(--accent-2); }
.photo .stats-line { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--grad); width: 0; transition: width .2s; }

/* ---------- personalitate ---------- */
.persona-cols { grid-template-columns: 1.3fr 1fr; align-items: start; }
@media (max-width: 1100px) { .persona-cols { grid-template-columns: 1fr; } }
.prompt-editor { min-height: 460px; }
.test-chat { display: flex; flex-direction: column; height: 520px; }
.test-chat .messages { background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 10px; }
.topic {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2);
}
.topic.off { opacity: .55; }
.topic .input, .topic .textarea { background: var(--surface); }
.topic .textarea { min-height: 64px; }
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 10px; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); text-align: center; display: flex; flex-direction: column; gap: 16px; }
.login-card .logo { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto; box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0 0; font-size: 24px; }
.login-card .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.login-card .or::before, .login-card .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.code-input { text-align: center; font-size: 26px; letter-spacing: .4em; font-variant-numeric: tabular-nums; font-weight: 700; }
#tg-widget { min-height: 44px; display: flex; justify-content: center; }

/* ---------- modal, toast, lightbox ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 10, .6); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.modal.wide { width: min(980px, 100%); }
.modal h3 { margin: 0; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: calc(20px + var(--safe-b)); }
}
#toasts {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(440px, calc(100% - 24px));
}
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
  box-shadow: var(--shadow); font-size: 14px; pointer-events: auto; animation: rise .2s ease-out; max-width: 100%;
}
.toast.err { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.toast.ok { border-color: color-mix(in srgb, var(--good) 50%, var(--border)); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 90dvh; border-radius: 10px; }
.lightbox .close { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; color: #fff; background: rgba(255,255,255,.12); border: 0; }

.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 46dvh; overflow-y: auto; padding: 2px; }
.offer-grid .photo .thumb { aspect-ratio: 1; }
.offer-grid .photo .info { padding: 6px 8px; font-size: 12px; }
.upload-list { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-list .media-cell { width: 72px; }

.settings-cols { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.setting-row:first-of-type { border-top: none; }
.setting-row .grow small { display: block; color: var(--muted); font-size: 12.5px; }
.callout { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; color: var(--text-2); }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
