.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 {
  margin: 6px 0;
  padding: 0;
  border-left: 3px solid #d69b25;
  background: var(--bg);
  overflow: hidden;
}

.nitka-thought .nitka-tool-title {
  color: var(--muted);
  font-weight: 500;
}

/* Карточка инструмента: свёрнута по умолчанию, шапка = имя + первые слова
   аргументов + статус; тап по шапке раскрывает 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,
.nitka-thought.open .nitka-tool-body {
  display: block;
}

/* Плавающая «↓»: видна, когда низ ленты ушёл из кадра (follow отклеен);
   тап — прыжок вниз и повторное приклеивание авто-скролла. */
.nitka-session-panel {
  position: relative;
}

.nitka-down {
  position: absolute;
  right: 12px;
  bottom: 108px;
  z-index: 5;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(20, 27, 38, 0.18);
  cursor: pointer;
}

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

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

/* Стоп у композера — всегда в кадре во время хода (в шапке терялся за
   внешним скроллом вкладки, 06.09). */
.stop-button {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--danger);
  border-radius: 7px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

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


@media (max-width: 640px) {
  .nitka-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .nitka-sessions {
    max-height: 210px;
  }
}
