:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-strong: #10242f;
  --text: #18232d;
  --muted: #65717e;
  --line: #dce3ea;
  --line-strong: #b9c6d2;
  --accent: #047c73;
  --accent-soft: #e3f5f2;
  --accent-strong: #035f58;
  --danger: #c0392b;
  --warning: #99620d;
  --blue: #2563eb;
  --shadow: 0 16px 34px rgba(15, 31, 45, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body.login-page {
  min-height: 100vh;
  overflow: auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.ghost,
.tab-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

button.ghost:hover,
button.ghost.active,
.tab-button:hover,
.tab-button.active {
  background: var(--accent-soft);
  border-color: #9fcfca;
  color: var(--accent-strong);
}

.icon-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  height: 30px;
  min-height: 30px;
  padding: 0;
  width: 30px;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: #9fcfca;
  color: var(--accent-strong);
}

#sound-toggle.active {
  background: #ecfdf5;
  border-color: #9fd9c4;
  color: #08704f;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #8f1d14;
}

button.danger-lite {
  border-color: #e4b6b1;
  color: var(--danger);
}

button.danger-lite:hover {
  background: #fff1ef;
  border-color: #d38b84;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  line-height: 1.5;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.3;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(680px, 1fr) 292px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.mobile-session-rail {
  display: none;
}

body[data-view="flow"] .app-shell {
  grid-template-columns: 320px minmax(0, 1fr);
}

body[data-view="flow"] .inspector {
  display: none;
}

.sidebar,
.workspace,
.inspector {
  min-height: 0;
}

.sidebar,
.inspector {
  background: var(--panel);
}

.sidebar {
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.inspector {
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 18px 18px 13px;
}

.brand-mark {
  align-items: center;
  background: var(--panel-strong);
  border-radius: 7px;
  color: white;
  display: flex;
  font-size: 14px;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand p,
.section-label,
#active-meta,
.event-time,
.message-meta,
.conversation-meta,
.hint-text,
.tree-node small,
.child-node small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-label {
  font-weight: 800;
  margin-bottom: 7px;
}

.metrics {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px 18px 14px;
}

.metrics div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 9px;
}

.metrics strong {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px 18px;
}

.search-box {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
}

.conversation-list {
  border-top: 1px solid var(--line);
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.list-limit-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  padding: 10px 14px 16px;
  text-align: center;
}

.conversation-item {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  display: block;
  min-height: auto;
  padding: 12px 18px;
  text-align: left;
  width: 100%;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eff8f7;
}

.conversation-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.conversation-item.need-reply {
  background: #f0fdf8;
}

.conversation-item.need-reply.active {
  box-shadow: inset 3px 0 0 #10b981;
}

.conversation-main-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.avatar {
  align-items: center;
  background: var(--panel-strong);
  border-radius: 50%;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 900;
  height: 36px;
  justify-content: center;
  overflow: hidden;
  width: 36px;
}

.avatar-img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.conversation-copy {
  min-width: 0;
  width: 100%;
}

.conversation-title-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.conversation-title {
  font-size: 13px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  background: var(--danger);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  min-width: 22px;
  padding: 2px 7px;
  text-align: center;
}

.conversation-preview {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.state-chip {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 7px;
}

.state-chip.human,
.state-chip.need {
  background: #e6f6f0;
  border-color: #99d7c4;
  color: #08704f;
}

.state-chip.fake {
  background: #fff7e6;
  border-color: #e8cf96;
  color: #8a5b00;
}

.state-chip.bot {
  background: #edf3ff;
  border-color: #b8c9e8;
  color: #355f9c;
}

.state-chip.blocked {
  background: #fff1ef;
  border-color: #e2aba5;
  color: var(--danger);
}

.state-chip.agent {
  color: var(--text);
}

.workspace {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  display: grid;
  grid-template-rows: 58px 1fr;
  overflow: hidden;
}

.workspace-topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 10px 18px;
}

.workspace-tabs {
  display: flex;
  gap: 8px;
}

.mobile-list-toggle {
  display: none;
}

.tab-button {
  min-height: 34px;
}

.runtime-chip {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  max-width: 48%;
  overflow: hidden;
  padding: 8px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.panel-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 96px;
  padding: 16px 20px;
}

.active-heading {
  min-width: 0;
}

.active-heading h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-actions {
  display: grid;
  gap: 9px;
  justify-items: end;
  min-width: min(470px, 52vw);
}

.action-group {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  overflow: hidden;
  width: 100%;
}

.action-group summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  min-height: 36px;
  padding: 0 10px;
}

.action-group summary::-webkit-details-marker {
  display: none;
}

.action-group summary::after {
  color: var(--muted);
  content: "+";
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.action-group[open] summary {
  border-bottom: 1px solid var(--line);
}

.action-group[open] summary::after {
  content: "-";
}

.action-group summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.action-group summary strong {
  color: var(--text);
  font-size: 12px;
  margin-left: auto;
}

.mode-actions {
  display: flex;
  gap: 8px;
  padding: 8px;
}

.mode-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px;
}

.empty {
  color: var(--muted);
  padding: 28px 0;
  text-align: center;
}

.empty.compact {
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 16px;
}

.message {
  margin-bottom: 9px;
  max-width: min(72%, 680px);
  width: fit-content;
}

.message.inbound {
  margin-right: auto;
}

.message.outbound {
  margin-left: auto;
}

.message-bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-block;
  line-height: 1.42;
  max-width: 100%;
  padding: 7px 10px;
  white-space: pre-wrap;
}

.message.outbound .message-bubble {
  background: #ddf2ee;
  border-color: #b9ded8;
}

.message-meta {
  margin: 0 0 3px;
}

.message-attachment {
  background: rgba(11, 122, 117, 0.08);
  border: 1px dashed #8bc5bd;
  border-radius: 6px;
  color: var(--accent-strong);
  display: inline-block;
  font-size: 12px;
  margin-bottom: 6px;
  padding: 5px 7px;
}

.message-photo-link {
  background: transparent;
  border: 0;
  border-radius: 7px;
  display: block;
  margin: 0 0 7px;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  text-align: left;
}

.message-photo-link:hover {
  background: transparent;
}

.message-photo {
  border: 1px solid var(--line);
  border-radius: 7px;
  display: block;
  max-height: 360px;
  max-width: min(360px, 100%);
  object-fit: contain;
}

.image-preview-modal {
  align-items: center;
  background: rgba(15, 24, 32, 0.72);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 40;
}

.image-preview-modal.show {
  display: flex;
}

.image-preview-panel {
  background: #101820;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  color: #fff;
  display: grid;
  gap: 12px;
  max-height: min(92dvh, 920px);
  max-width: min(94vw, 1180px);
  padding: 12px;
  width: max-content;
}

.image-preview-panel header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-width: min(72vw, 560px);
}

.image-preview-panel header div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.image-preview-panel a {
  color: #9ee2d8;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.image-preview-panel img {
  border-radius: 6px;
  display: block;
  max-height: calc(92dvh - 82px);
  max-width: calc(94vw - 24px);
  object-fit: contain;
}

.reply-box {
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 11px;
  grid-template-columns: 1fr 86px;
  padding: 12px 16px;
}

.quick-reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.quick-reply-bar button {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 30px;
}

.profile-panel,
.events-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 12px;
  padding: 14px;
}

.profile-panel label,
.settings-panel label,
.test-panel label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 12px;
}

.profile-panel input,
.profile-panel select,
.profile-panel textarea {
  margin-top: 6px;
}

.profile-panel button {
  margin-top: 12px;
  width: 100%;
}

.hint-text {
  margin-top: 8px;
}

.event {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

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

.event-message {
  font-size: 13px;
  line-height: 1.45;
}

.tree-view,
.flow-view {
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.tree-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.tree-map {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.tree-map-head,
.tree-editor-head,
.child-editor-head,
.tree-replace-panel,
.fake-rule-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.tree-map-head button,
.child-editor-head button,
.fake-rule-head button {
  min-width: 88px;
}

.tree-node-list {
  overflow: auto;
  padding: 8px;
}

.tree-node-row {
  align-items: stretch;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 4px;
  padding-left: calc(var(--depth) * 18px);
}

.tree-node {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  display: grid;
  justify-content: stretch;
  min-height: 50px;
  padding: 8px 9px;
  text-align: left;
  width: 100%;
}

.tree-sort-actions {
  align-content: center;
  display: grid;
  gap: 4px;
  grid-template-columns: 30px;
}

.tree-node span,
.child-node span {
  font-size: 13px;
  font-weight: 800;
}

.tree-node:hover,
.tree-node-row.active .tree-node,
.child-node:hover {
  background: var(--accent-soft);
  border-color: #add7d2;
}

.tree-editor {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-height: 0;
  overflow: auto;
}

.tree-editor-actions {
  display: flex;
  gap: 8px;
}

.editor-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 16px;
}

.editor-grid label,
.answer-field {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
}

.answer-field {
  padding: 0 16px 16px;
}

.tree-replace-panel {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.tree-replace-panel h3,
.fake-rule-head span {
  font-size: 14px;
  font-weight: 900;
}

.tree-replace-controls {
  display: grid;
  flex: 1 1 380px;
  gap: 8px;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  min-width: 0;
}

.tree-replace-result {
  color: var(--muted);
  flex-basis: 100%;
  font-size: 12px;
  font-weight: 800;
}

.editor-grid input,
.answer-field textarea {
  margin-top: 7px;
}

.child-editor {
  border-top: 1px solid var(--line);
  min-height: 0;
}

.child-node-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  padding: 16px;
}

.child-node-row {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}

.child-node {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: grid;
  justify-content: stretch;
  min-height: 64px;
  padding: 10px;
  text-align: left;
}

.child-sort-actions {
  display: grid;
  gap: 4px;
  grid-template-columns: 30px;
}

.flow-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.flow-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.flow-board {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.flow-lane {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 14px;
}

.flow-lane.editable {
  background: #fff;
}

.flow-lane-head {
  align-items: flex-start;
  display: flex;
  gap: 11px;
}

.flow-lane-head p,
.flow-rule-list span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.flow-step {
  align-items: center;
  background: #dfeaf6;
  border-radius: 999px;
  color: #214c7d;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.flow-step.fake {
  background: #fff2cc;
  color: #8a5b00;
}

.flow-step.human {
  background: #dff4ea;
  color: #08704f;
}

.flow-step.quick {
  background: #f0e7ff;
  color: #65409a;
}

.flow-lane label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
}

.fake-rule-head {
  border: 0;
  padding: 0;
}

.fake-rule-list {
  display: grid;
  gap: 10px;
}

.fake-rule {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.fake-rule-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.flow-lane textarea {
  margin-top: 7px;
}

.flow-rule-list {
  display: grid;
  gap: 9px;
}

.flow-rule-list div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 3px;
  padding: 10px;
}

.flow-rule-list strong {
  font-size: 13px;
}

.toast {
  background: var(--panel-strong);
  border-radius: 8px;
  bottom: 20px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  left: 50%;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 22px;
}

.login-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 440px;
  overflow: hidden;
  width: 100%;
}

.login-brand {
  border-bottom: 1px solid var(--line);
  padding: 20px;
}

.login-brand p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px 20px 0;
}

.login-form label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 7px;
}

.login-form button {
  margin-top: 4px;
  width: 100%;
}

.login-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  min-height: 44px;
  padding: 14px 20px 20px;
}

.login-message.danger {
  color: var(--danger);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 310px 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .workspace {
    min-height: 760px;
  }

  .inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .mobile-session-rail {
    background: #0f2530;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: none;
    flex-direction: column;
    gap: 8px;
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
    padding: 9px 7px;
  }

  .rail-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #fff;
    flex: 0 0 auto;
    height: 40px;
    min-height: 40px;
    padding: 0;
    position: relative;
    width: 40px;
  }

  .rail-item:hover,
  .rail-item.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
  }

  .rail-avatar {
    align-items: center;
    background: rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    color: #fff;
    display: flex;
    font-size: 13px;
    font-weight: 900;
    height: 31px;
    justify-content: center;
    overflow: hidden;
    width: 31px;
  }

  .rail-dot {
    background: #ef4444;
    border: 2px solid #0f2530;
    border-radius: 999px;
    height: 11px;
    position: absolute;
    right: 4px;
    top: 4px;
    width: 11px;
  }

  .rail-dot.urgent {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22);
  }

  .sidebar,
  .inspector {
    border-width: 0 0 1px;
  }

  .sidebar {
    display: flex;
    height: 100dvh;
    min-height: 0;
  }

  .brand {
    padding: 12px 14px 9px;
  }

  .metrics {
    padding: 5px 14px 10px;
  }

  .metrics div {
    padding: 8px;
  }

  .metrics strong {
    font-size: 18px;
  }

  .toolbar,
  .search-box {
    padding-left: 14px;
    padding-right: 14px;
  }

  .conversation-list {
    flex: 1;
    max-height: none;
    min-height: 0;
  }

  .conversation-item {
    padding: 10px 14px;
  }

  .workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .workspace-topbar {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr);
    padding: 8px 10px;
    z-index: 10;
  }

  .mobile-list-toggle {
    display: inline-flex;
    min-height: 34px;
    padding: 0 10px;
  }

  .workspace-tabs {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-tabs .tab-button {
    font-size: 12px;
    min-height: 34px;
    min-width: 0;
    padding: 0 6px;
  }

  .runtime-chip {
    display: none;
  }

  .chat-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .panel-header {
    align-items: stretch;
    display: grid;
    gap: 8px;
    min-height: 0;
    padding: 9px 10px;
  }

  .section-label {
    margin-bottom: 2px;
  }

  .active-heading {
    display: grid;
    gap: 2px;
  }

  .active-heading h2 {
    font-size: 16px;
    white-space: normal;
  }

  .panel-actions {
    justify-items: stretch;
    margin-top: 0;
    min-width: 0;
  }

  .action-group {
    background: #f8fafc;
    border-radius: 6px;
  }

  .action-group summary {
    min-height: 32px;
    padding: 0 9px;
  }

  .action-group summary strong,
  .action-group summary span {
    font-size: 12px;
  }

  .mode-actions {
    gap: 6px;
    margin-top: 0;
  }

  .mode-actions {
    display: flex;
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .mode-actions button {
    font-size: 12px;
    min-height: 30px;
    padding: 0 9px;
    white-space: nowrap;
  }

  .mode-actions button {
    flex: 0 0 auto;
  }

  .messages {
    overflow: auto;
    padding: 10px;
  }

  .message {
    max-width: 96%;
  }

  .message-bubble {
    padding: 7px 9px;
  }

  .reply-box {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 76px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    z-index: 8;
  }

  .quick-reply-bar {
    flex-wrap: nowrap;
    gap: 6px;
    grid-column: 1 / -1;
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .quick-reply-bar button {
    flex: 0 0 auto;
    font-size: 12px;
    min-height: 28px;
  }

  .reply-box textarea {
    max-height: 92px;
    min-height: 58px;
  }

  #reply-submit {
    min-height: 58px;
    width: 100%;
  }

  body.mobile-workspace-focused .sidebar,
  body.mobile-workspace-focused .inspector,
  body.mobile-list-open .workspace,
  body.mobile-list-open .mobile-session-rail,
  body.mobile-list-open .inspector {
    display: none;
  }

  body.mobile-workspace-focused .app-shell {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
  }

  body.mobile-list-open .app-shell {
    display: block;
  }

  body.mobile-workspace-focused .mobile-session-rail {
    display: flex;
  }

  body.mobile-list-open .sidebar {
    border-bottom: 0;
    display: flex;
  }

  .tree-view,
  .flow-view {
    overflow: auto;
    padding: 10px;
  }

  .tree-shell {
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .tree-map {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 42dvh;
  }

  .tree-editor {
    display: block;
    overflow: visible;
  }

  .tree-map-head,
  .tree-editor-head,
  .child-editor-head,
  .flow-header {
    align-items: stretch;
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .tree-editor-actions {
    display: grid;
    gap: 7px;
    grid-template-columns: 1fr 1fr;
  }

  .editor-grid {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .answer-field {
    padding: 0 12px 12px;
  }

  .tree-replace-panel,
  .fake-rule-head {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .tree-replace-controls,
  .fake-rule-row {
    grid-template-columns: 1fr;
  }

  .child-node-list {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .flow-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  .flow-board {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    overflow: visible;
    padding: 10px;
  }

  .flow-lane {
    min-height: 0;
  }

  .inspector {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .profile-panel,
  .events-panel {
    margin-bottom: 0;
  }

  .toast {
    bottom: 12px;
    left: 12px;
    right: 12px;
    text-align: center;
    transform: translateY(12px);
  }

  .toast.show {
    transform: translateY(0);
  }

  .login-shell {
    align-items: start;
    min-height: 100dvh;
    padding: 12px;
  }

  .login-panel {
    margin-top: 8px;
  }
}
