:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #e9ebef;
  --text: #17191c;
  --muted: #737983;
  --border: #dfe2e7;
  --accent: #2b6de5;
  --accent-strong: #1857c4;
  --accent-soft: #e8f0ff;
  --user: #dce9ff;
  --danger: #c9363e;
  --shadow: 0 -1px 8px rgba(20, 27, 38, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #1b1e22;
    --surface-2: #292d33;
    --text: #f1f3f5;
    --muted: #979da6;
    --border: #30343a;
    --accent: #75a7ff;
    --accent-strong: #9abbff;
    --accent-soft: #202f49;
    --user: #253a5b;
    --danger: #ff747c;
    --shadow: 0 -1px 8px rgba(0, 0, 0, 0.22);
  }
}

* {
  box-sizing: border-box;
}

/* display:X в наших классах перебивает UA-правило [hidden]{display:none} —
   грабля: «скрытая» панель nitka раздувала рабочую область (191230 shot). */
[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

.booting .app-shell,
.booting .access-gate {
  visibility: hidden;
}

.outside-max .app-shell {
  display: none;
}

.access-gate {
  width: 100%;
  min-height: 100dvh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.access-gate[hidden] {
  display: none;
}

.gate-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 24px;
  font-weight: 750;
}

.access-gate h1 {
  max-width: 360px;
  margin-top: 18px;
  font-size: 21px;
  line-height: 28px;
}

.access-gate p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.access-gate a {
  min-height: 44px;
  margin-top: 20px;
  padding: 11px 18px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  text-decoration: none;
}

.app-shell {
  width: 100%;
  max-width: 920px;
  height: 100dvh;
  min-height: 480px;
  margin: 0 auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--bg);
}

.topbar {
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  z-index: 2;
}

.identity {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 11px;
}

.mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 19px;
  font-weight: 750;
}

.identity-text {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 21px;
  font-weight: 700;
}

.model-line {
  max-width: 100%;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #d69b25;
}

.status-dot.online {
  background: #2ca46f;
}

.status-dot.offline {
  background: var(--danger);
}

.icon-button,
.send-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--surface-2);
}

.icon-button svg,
.send-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-tabs {
  min-width: 0;
  padding: 7px 13px 0;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.mode-tab {
  min-width: 0;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.mode-tab:hover,
.mode-tab:focus-visible {
  color: var(--text);
}

.mode-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.view-stack {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
}

.conversation,
.collab-view,
.nitka-view {
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 0;
}

/* ── Коллапс-блоки (сворачиваемые секции главного меню) ── */
.collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}

.collapse-toggle:hover,
.collapse-toggle:focus-visible {
  color: var(--text);
}

.collapse-toggle .collapse-chevron {
  font-size: 12px;
  color: var(--muted);
}

.collapse-body {
  padding: 6px 4px 4px;
}

.nitka-intro.collapsible {
  display: block;
}

.nitka-sessions.collapsible {
  display: block;
}
