: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) auto;
  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;
}

.conversation {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 22px;
  scrollbar-width: thin;
}

.collab-view {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 28px;
}

.nitka-view {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 28px;
}

.nitka-content {
  width: min(100%, 860px);
  min-height: 100%;
  margin: 0 auto;
}

.nitka-intro {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.nitka-intro h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 27px;
}

.nitka-muted {
  max-width: 620px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 19px;
}

.nitka-refresh {
  color: var(--muted);
}

.nitka-refresh svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nitka-new {
  margin-top: 17px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.nitka-new-toggle {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}

.nitka-new-toggle:hover,
.nitka-new-toggle:focus-visible {
  background: var(--accent-soft);
}

.nitka-new-form {
  padding: 4px 4px 4px;
  border-top: 1px solid var(--border);
}

.nitka-new-form > label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.nitka-new-row {
  margin-top: 7px;
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.5fr) auto;
  gap: 6px;
}

.nitka-new input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.nitka-new input:focus {
  border-color: var(--accent);
}

.nitka-layout {
  min-width: 0;
  min-height: 470px;
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(175px, 230px) minmax(0, 1fr);
  gap: 10px;
}

.nitka-sessions,
.nitka-workspace {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.nitka-sessions {
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
}

.nitka-session-count {
  color: var(--muted);
  font-size: 11px;
}

.nitka-session-list {
  margin-top: 8px;
  display: grid;
  gap: 5px;
}

.nitka-session-item {
  width: 100%;
  min-width: 0;
  padding: 9px 9px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nitka-session-item:hover,
.nitka-session-item:focus-visible,
.nitka-session-item.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.nitka-session-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
}

.nitka-session-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nitka-session-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--muted);
}

.nitka-session-dot.running {
  background: #2ca46f;
  box-shadow: 0 0 0 3px rgba(44, 164, 111, 0.14);
}

.nitka-session-dot.error {
  background: var(--danger);
}

.nitka-session-meta {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nitka-session-empty,
.nitka-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.nitka-session-empty {
  padding: 7px 2px;
}

.nitka-workspace {
  min-height: 0;
  overflow: hidden;
}

.nitka-empty {
  height: 100%;
  min-height: 470px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.nitka-empty strong {
  color: var(--text);
  font-size: 14px;
}

.nitka-session-panel {
  height: 100%;
  min-height: 470px;
  display: flex;
  flex-direction: column;
}

.nitka-session-head {
  min-width: 0;
  padding: 11px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.nitka-session-head h3 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 19px;
  white-space: nowrap;
}

.nitka-session-head .nitka-session-meta {
  max-width: 440px;
}

.nitka-transcript {
  flex: 1 1 auto;
  min-height: 250px;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.nitka-transcript-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.nitka-row {
  width: min(100%, 680px);
  margin-bottom: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nitka-row.user {
  margin-left: auto;
  align-items: flex-end;
}

.nitka-row.assistant {
  margin-right: auto;
}

.nitka-row-label {
  padding: 0 3px;
  color: var(--muted);
  font-size: 10px;
}

.nitka-bubble {
  max-width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.nitka-row.user .nitka-bubble {
  background: var(--user);
  border-color: transparent;
}

.nitka-bubble.streaming::after {
  content: "▍";
  margin-left: 2px;
  color: var(--accent);
  animation: nitka-caret 0.9s steps(1) infinite;
}

@keyframes nitka-caret {
  50% { opacity: 0; }
}

.nitka-thought,
.nitka-event {
  margin: 6px 0;
  padding: 8px 9px;
  border-left: 3px solid var(--border);
  background: var(--bg);
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.nitka-thought {
  border-left-color: #d69b25;
  color: var(--muted);
}

/* Карточка инструмента: свёрнута по умолчанию, шапка = имя + первые слова
   аргументов + статус; тап по шапке раскрывает args+result (06.09, портянка). */
.nitka-tool {
  margin: 6px 0;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  overflow: hidden;
}

.nitka-tool.pending {
  border-left-color: var(--muted);
}

.nitka-tool.error {
  border-left-color: var(--danger);
}

.nitka-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 9px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.4;
}

.nitka-tool-chevron {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  transition: transform 0.15s;
}

.nitka-tool.open .nitka-tool-chevron {
  transform: rotate(90deg);
}

.nitka-tool-title {
  flex: 0 1 auto;
  overflow: hidden;
  color: var(--text);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nitka-tool-args {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nitka-tool-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.nitka-tool.error .nitka-tool-status,
.nitka-tool.error .nitka-tool-title {
  color: var(--danger);
}

.nitka-tool-body {
  display: none;
  padding: 0 9px 8px;
}

.nitka-tool.open .nitka-tool-body {
  display: block;
}

.nitka-tool-result {
  max-height: 140px;
  margin-top: 5px;
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.nitka-tool-result:first-child {
  margin-top: 0;
}

.nitka-event {
  color: var(--muted);
}

.nitka-event.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.nitka-compose-status {
  min-height: 22px;
  padding: 0 12px 5px;
  color: var(--muted);
  font-size: 11px;
}

.nitka-composer {
  min-width: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 5px;
  border-top: 1px solid var(--border);
}

.nitka-composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 20px;
  resize: vertical;
}

.nitka-composer textarea:focus {
  border-color: var(--accent);
}

.nitka-composer .send-button {
  border: 0;
}

.collab-content {
  width: min(100%, 760px);
  margin: 0 auto;
}

.collab-intro h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 27px;
}

.collab-muted {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 19px;
}

.collab-start {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.collab-start > label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.collab-start textarea,
.collab-message textarea {
  width: 100%;
  min-width: 0;
  margin-top: 7px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 21px;
  resize: vertical;
}

.collab-start textarea:focus,
.collab-message textarea:focus {
  border-color: var(--accent);
}

.collab-start-row {
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rounds-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

select {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.primary-button,
.text-button,
.danger-button,
.small-danger {
  min-height: 36px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.primary-button {
  padding: 0 15px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
}

.collab-section {
  margin-top: 22px;
}

.section-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading h3 {
  font-size: 15px;
  line-height: 20px;
}

.text-button {
  padding: 0 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.collab-tasks {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.collab-task {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.collab-task:hover,
.collab-task:focus-visible,
.collab-task.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.collab-task-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.collab-task-meta,
.collab-status {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}

.collab-empty {
  padding: 11px 0;
  color: var(--muted);
  font-size: 13px;
}

.collab-detail {
  margin-top: 22px;
}

.danger-button,
.small-danger {
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
}

.danger-button {
  padding: 0 10px;
}

.small-danger {
  min-height: 30px;
  padding: 0 8px;
  font-size: 11px;
}

.danger-button:hover,
.danger-button:focus-visible,
.small-danger:hover,
.small-danger:focus-visible {
  background: var(--danger);
  color: white;
}

.role-grid {
  margin-top: 11px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.role-panel {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.role-panel.executor {
  border-top: 3px solid #2ca46f;
}

.role-panel.critic {
  border-top: 3px solid #d69b25;
}

.role-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
}

.role-heading strong {
  font-size: 13px;
}

.role-heading span {
  color: var(--muted);
  font-size: 11px;
}

.role-panel p {
  max-height: 150px;
  margin-top: 8px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.role-panel .small-danger {
  margin-top: 9px;
}

.collab-final {
  margin-top: 11px;
  padding: 11px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.collab-transcript {
  max-height: 270px;
  margin-top: 11px;
  padding: 8px 10px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.transcript-event {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.transcript-event:last-child {
  border-bottom: 0;
}

.transcript-meta {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
}

.collab-message {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 44px;
  align-items: end;
  gap: 5px;
}

.collab-message select {
  min-width: 0;
  max-width: 145px;
}

.collab-message textarea {
  min-height: 42px;
  margin-top: 0;
  resize: none;
}

.collab-message .send-button {
  border: 0;
}

.welcome {
  width: 100%;
  max-width: 740px;
  margin: 8px auto 20px;
}

.welcome-kicker {
  color: var(--accent);
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
}

.welcome h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 27px;
  font-weight: 700;
}

.quick-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-actions button {
  min-width: 0;
  max-width: 100%;
  position: relative;
  min-height: 46px;
  padding: 11px 34px 11px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.quick-actions button::after {
  content: "›";
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-54%);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.quick-actions button:hover,
.quick-actions button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.messages {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  min-width: 0;
  width: fit-content;
  max-width: min(82%, 650px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.bubble {
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  background: var(--user);
  border-color: transparent;
}

.message-meta {
  padding: 0 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
}

.message-files {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  margin-bottom: 5px;
}

.message-images {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.message-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: contain;
}

.message-files span,
.file-chip {
  max-width: 260px;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.typing {
  width: min(100%, 740px);
  min-height: 24px;
  margin: 15px auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

/* Живая лента активности: мысли/инструменты агента (06.09.2026) */
.activity-feed {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 7px;
  max-height: 168px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  font-size: 12px;
  line-height: 1.45;
}

.activity-feed div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 8px;
  border-left: 2px solid var(--surface);
  color: var(--muted);
}

.activity-feed div:last-child {
  border-left-color: var(--accent, #7c8cff);
  color: var(--text, inherit);
}

.typing[hidden] {
  display: none;
}

.typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
.typing em {
  margin-left: 4px;
  font-size: 12px;
  font-style: normal;
}

@keyframes pulse {
  0%, 70%, 100% { opacity: 0.3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.composer-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 9px 13px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pending-files {
  width: min(100%, 760px);
  margin: 0 auto 7px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.pending-files[hidden] {
  display: none;
}

.file-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
}

.file-chip button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
}

.composer {
  width: 100%;
  max-width: 760px;
  min-height: 50px;
  min-width: 0;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.composer:focus-within {
  border-color: var(--accent);
}

.composer textarea {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  max-height: 128px;
  min-height: 40px;
  padding: 9px 7px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 21px;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.attach {
  color: var(--muted);
}

.send-button {
  background: var(--accent);
  color: white;
}

.send-button:hover,
.send-button:focus-visible {
  background: var(--accent-strong);
}

.send-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 8;
  max-width: min(90vw, 460px);
  padding: 10px 13px;
  transform: translateX(-50%);
  border-radius: 7px;
  background: #24272c;
  color: white;
  font-size: 13px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
}

dialog {
  width: min(90vw, 390px);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

dialog h2 {
  font-size: 19px;
}

dialog p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.dialog-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
}

.dialog-actions .danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

@media (max-width: 560px) {
  .topbar {
    min-height: 62px;
    padding-left: 11px;
    padding-right: 9px;
  }

  .mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 17px;
  }

  .conversation {
    padding: 14px 11px 18px;
  }

  .welcome {
    margin-top: 4px;
  }

  .welcome h2 {
    font-size: 20px;
    line-height: 27px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .quick-actions button:nth-child(n+4) {
    display: none;
  }

  .message {
    max-width: 91%;
  }

  .bubble {
    font-size: 14px;
  }

  .composer-wrap {
    padding-left: 8px;
    padding-right: 8px;
  }

  .collab-view {
    padding-left: 11px;
    padding-right: 11px;
  }

  .nitka-view {
    padding-left: 11px;
    padding-right: 11px;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .collab-message {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .collab-message select {
    grid-column: 1 / -1;
    max-width: none;
  }

  .nitka-new-row {
    grid-template-columns: 1fr;
  }

  .nitka-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .nitka-sessions {
    max-height: 320px;
  }

  .nitka-workspace,
  .nitka-session-panel,
  .nitka-empty {
    min-height: 430px;
  }

}

@media (min-width: 921px) {
  body {
    background: #e9ebee;
  }

  .app-shell {
    max-width: 920px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .conversation.is-empty {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  .conversation.is-empty .welcome {
    width: 100%;
    max-width: 620px;
    margin: 0 auto 10px;
  }

  .conversation.is-empty .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 300px));
  }
}

/* --- 20260906-8: UX улучшения (копирование, «вниз», повтор) --- */
.message .bubble {
  position: relative;
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-action {
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  align-self: flex-start;
  transition: color 0.15s, border-color 0.15s;
}

.msg-action:hover {
  color: var(--text);
  border-color: var(--muted);
}

.msg-action.retry {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.msg-action.retry:disabled {
  opacity: 0.5;
  cursor: default;
}

.scroll-down {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 4px 14px rgba(20, 27, 38, 0.14);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.scroll-down[hidden] {
  display: none;
}

.scroll-down svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scroll-down:active {
  transform: scale(0.94);
}

/* Кнопка удаления завершённой задачи в списке (collab) */
.collab-task-delete {
  margin-left: auto;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--danger, #e5484d);
  border: 1px solid var(--danger, #e5484d);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.collab-task-delete:active {
  background: var(--danger, #e5484d);
  color: #fff;
}
