/* Тёмная тема в стиле сайта. Цвета задаются из config.js (переменные ниже перезаписываются в app.js). */
:root {
  --bg: #0a090d;
  --surface: #15131b;
  --surface2: #1e1b27;
  --text: #ece9f5;
  --muted: #9a95ab;
  --accent: #a78bfa;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  padding-top: var(--safe-top);
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 48px 20px; }
.small { font-size: 13px; }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--surface2);
}
.top h1 { font-size: 20px; margin: 0; }
.top .row { display: flex; align-items: center; gap: 10px; }
.top .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* вкладки входящих */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--surface2); background: var(--surface);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--accent); color: #120f18; border-color: var(--accent); font-weight: 600; }
.chip .n { opacity: .7; margin-left: 4px; }

.search { margin: 0 16px 8px; display: flex; gap: 8px; }
.search input { flex: 1; }

/* список */
.list { padding: 4px 12px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer; border: 1px solid transparent;
}
.item:active { border-color: var(--accent); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface2); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none;
}
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 14px; }
.item .last { font-size: 14px; margin-top: 4px; color: var(--text); opacity: .85; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.badge.accent { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.badge.danger { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }

/* карточка */
.card { padding: 0 12px calc(110px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.block { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 38% 1fr; gap: 6px 10px; font-size: 15px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  border: 0; border-radius: 12px; padding: 12px 14px; background: var(--surface2); cursor: pointer;
  min-height: 44px; font-weight: 600;
}
.btn.primary { background: var(--accent); color: #120f18; }
.btn.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--surface2); }
.btn:disabled { opacity: .5; }
.btn.wide { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* переключатель «Бот / Я» */
.seg { display: inline-flex; background: var(--surface2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: #120f18; }

/* поля */
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], textarea, select {
  width: 100%; background: var(--surface2); border: 1px solid transparent; border-radius: 12px; padding: 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 14px; }

/* переписка */
.chat { display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg.in { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border-bottom-right-radius: 4px; }
.msg.albert { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* поле ответа внизу */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--bg); border-top: 1px solid var(--surface2);
  padding: 8px 10px calc(8px + var(--safe-bottom)); display: flex; gap: 8px; align-items: flex-end;
}
.composer textarea { min-height: 44px; max-height: 140px; height: 44px; }

/* нижний лист (подтверждения) */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
.sheet .panel {
  width: 100%; max-height: 90vh; overflow: auto; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
}
.sheet h3 { margin: 0 0 10px; font-size: 18px; }
.preview { background: var(--surface2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; margin: 8px 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-bottom)); z-index: 30;
  background: var(--surface2); padding: 10px 16px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

@media (min-width: 760px) {
  .list, .card { max-width: 720px; margin: 0 auto; width: 100%; }
  .composer { max-width: 720px; margin: 0 auto; }
  .sheet { align-items: center; justify-content: center; }
  .sheet .panel { max-width: 520px; border-radius: 18px; }
}
