:root {
  --bg: #080b10;
  --sidebar: #070a0f;
  --surface: #0d1118;
  --surface-2: #121821;
  --surface-3: #171e29;
  --line: #202733;
  --line-soft: #171d26;
  --text: #eef2f7;
  --muted: #939cac;
  --faint: #697386;
  --purple: #6d3de9;
  --purple-2: #8b5cf6;
  --purple-soft: rgba(109, 61, 233, 0.18);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 60% -20%, rgba(109, 61, 233, 0.12), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.7);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line-soft);
  background: rgba(7, 10, 15, 0.96);
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 22px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.side-link.is-active {
  border-color: rgba(109, 61, 233, 0.38);
  background: var(--purple-soft);
  color: #ddd6fe;
}

.view-panel[hidden] {
  display: none;
}

.content {
  min-width: 0;
  padding: 30px 24px 28px;
}

.page-head,
.toolbar-row,
.pagination,
.page-controls,
.view-tools,
.modal-head,
.modal-status-row,
.editor-actions,
.left-actions,
.right-actions,
.editor-footer {
  display: flex;
  align-items: center;
}

.page-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 25px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.title-editor {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.title-editor h2 {
  max-width: min(480px, calc(100vw - 180px));
  overflow-wrap: anywhere;
}

.title-edit-btn {
  display: inline-flex;
  width: 34px;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.title-edit-btn:hover {
  border-color: var(--line);
  background: rgba(109, 61, 233, 0.12);
  color: #c4b5fd;
}

.title-edit-btn svg {
  width: 16px;
  height: 16px;
}

.title-input {
  width: min(480px, calc(100vw - 180px));
  min-height: 40px;
  border: 1px solid rgba(139, 92, 246, 0.55);
  border-radius: var(--radius);
  background: #111821;
  color: var(--text);
  padding: 0 12px;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.2;
}

.page-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-btn,
.ghost-btn,
.sort-btn,
.view-btn,
.page-btn,
.icon-btn,
.tool-btn,
.save-btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.9);
  color: var(--text);
  padding: 0 14px;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.primary-btn,
.save-btn {
  border-color: transparent;
  background: var(--purple);
  color: #fff;
}

.primary-btn:hover,
.save-btn:hover {
  background: var(--purple-2);
}

.sort-btn:hover,
.view-btn:hover,
.page-btn:hover,
.icon-btn:hover,
.tool-btn:hover {
  border-color: #334052;
  background: var(--surface-2);
}

.primary-btn:active,
.sort-btn:active,
.view-btn:active,
.page-btn:active,
.icon-btn:active,
.tool-btn:active,
.save-btn:active {
  transform: scale(0.98);
}

.toolbar {
  margin-bottom: 18px;
}

.search-box {
  display: flex;
  width: 344px;
  max-width: 100%;
  height: 40px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 20, 0.88);
  color: var(--muted);
  padding: 0 13px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.toolbar-row {
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.filter-row,
.view-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 18, 26, 0.72);
  color: var(--text);
  padding: 0 14px;
}

.filter-btn span {
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 12px;
}

.filter-btn.is-active {
  border-color: rgba(109, 61, 233, 0.7);
  background: var(--purple);
  color: #fff;
}

.filter-btn.is-active span {
  background: rgba(255, 255, 255, 0.18);
  color: #ddd6fe;
}

.sort-btn {
  min-width: 160px;
  color: var(--text);
}

.view-btn,
.page-btn,
.icon-btn {
  width: 38px;
  padding: 0;
}

.view-btn.is-active,
.page-btn.is-active {
  border-color: rgba(109, 61, 233, 0.8);
  background: var(--purple);
  color: #fff;
}

.faq-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 20, 0.56);
}

.table-head,
.faq-row {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 160px 210px 112px;
  align-items: center;
}

.table-head {
  min-height: 52px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.table-head span,
.faq-cell,
.row-actions {
  padding: 0 18px;
}

.table-body {
  display: grid;
}

.faq-row {
  min-height: 74px;
  border-bottom: 1px solid var(--line-soft);
}

.faq-row:last-child {
  border-bottom: 0;
}

.faq-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.doc-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  background: rgba(109, 61, 233, 0.22);
  color: #c4b5fd;
}

.faq-title {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.faq-description {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-pill.active {
  background: var(--green-soft);
  color: #77f2a6;
}

.status-pill.active::before {
  background: var(--green);
}

.status-pill.draft {
  background: rgba(109, 61, 233, 0.15);
  color: #c4b5fd;
}

.status-pill.draft::before {
  background: var(--purple-2);
}

.status-pill.review {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.status-pill.review::before {
  background: #f59e0b;
}

.date-text {
  color: var(--text);
  font-size: 13px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.row-actions button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.row-actions button:hover {
  color: var(--purple-2);
  background: rgba(109, 61, 233, 0.1);
}

.pagination {
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  padding: 24px 5px 0;
  font-size: 13px;
}

.page-controls {
  gap: 8px;
}

.page-btn {
  min-height: 36px;
}

.page-btn.muted {
  opacity: 0.45;
}

.editor-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 20;
  width: min(760px, calc(100vw - 40px));
  transform: translate(-50%, -48%);
  border: 1px solid #2a3340;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(19, 25, 34, 0.98), rgba(15, 20, 28, 0.98));
  box-shadow: var(--shadow);
  padding: 22px 24px 18px;
}

.editor-modal.is-hidden {
  display: none;
}

.editor-modal.is-new-mode .utility-action,
.editor-modal.is-new-mode .test-action {
  display: none;
}

.editor-modal.is-new-mode .editor-actions {
  justify-content: flex-end;
}

.modal-head {
  justify-content: space-between;
  gap: 16px;
}

.modal-kicker {
  display: block;
  margin-bottom: 10px;
  color: #a78bfa;
  font-size: 13px;
}

.modal-status-row {
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 22px;
}

.tab {
  position: relative;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
}

.tab.is-active {
  color: #c4b5fd;
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--purple-2);
}

.status-select {
  position: relative;
  display: flex;
  align-items: center;
}

.status-select select {
  min-height: 36px;
  min-width: 108px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 34px 0 30px;
}

.status-select span {
  position: absolute;
  left: 12px;
  z-index: 1;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-select.is-draft span {
  background: var(--purple-2);
}

.status-select.is-review span {
  background: #f59e0b;
}

.status-select svg {
  position: absolute;
  right: 12px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.editor-actions {
  justify-content: flex-end;
  gap: 14px;
  margin: 18px 0 12px;
}

.left-actions,
.right-actions {
  gap: 8px;
}

.code-frame {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111821;
}

.line-numbers {
  margin: 0;
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  color: var(--faint);
  padding: 14px 9px 14px 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 22px;
  text-align: right;
}

.line-numbers li {
  list-style: none;
}

#faqEditor,
.prompt-editor {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e5e7eb;
  padding: 14px 14px 18px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 22px;
  overflow-wrap: break-word;
  scrollbar-color: #4b5563 #111821;
  white-space: pre-wrap;
}

.editor-footer {
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  padding-top: 12px;
  font-size: 12px;
}

.history-panel {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111821;
  padding: 14px;
}

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

.version-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  padding: 12px;
}

.version-item strong,
.version-item span {
  display: block;
}

.version-item strong {
  margin-bottom: 4px;
}

.version-item span {
  color: var(--muted);
  font-size: 13px;
}

.version-pill {
  border-radius: 999px;
  background: var(--purple-soft);
  color: #ddd6fe;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
}

.empty-history {
  display: grid;
  min-height: 488px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.prompt-head {
  margin-bottom: 18px;
}

.prompt-tabs {
  display: flex;
  gap: 28px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}

.prompt-tab {
  position: relative;
  min-height: 46px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.prompt-tab.is-active {
  color: #c4b5fd;
}

.prompt-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--purple-2);
}

.prompt-card {
  border: 1px solid #2a3340;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(19, 25, 34, 0.82), rgba(15, 20, 28, 0.82));
  padding: 22px 24px 18px;
}

.prompt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.prompt-card-head h2 {
  margin-bottom: 8px;
}

.prompt-card-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.insert-variable {
  position: relative;
  display: flex;
  min-width: 170px;
  align-items: center;
}

.insert-variable select {
  width: 100%;
  min-height: 38px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.9);
  color: var(--text);
  padding: 0 38px 0 12px;
}

.insert-variable svg {
  position: absolute;
  right: 12px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.prompt-code-frame {
  height: 520px;
}

.connections-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(440px, 1.18fr);
  gap: 18px;
  margin-bottom: 18px;
}

.connection-panel,
.connection-flow {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(19, 25, 34, 0.72), rgba(11, 15, 22, 0.72));
}

.connection-panel {
  min-height: 500px;
  padding: 22px;
}

.panel-title {
  margin-bottom: 24px;
}

.panel-title h2,
.connection-flow h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.panel-title p,
.connection-flow small,
.connection-copy small,
.field-group small {
  color: var(--muted);
  font-size: 12px;
}

.connections-list {
  display: grid;
  gap: 12px;
}

.connection-item {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.78);
  padding: 10px 12px;
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.connection-item.is-selected {
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(109, 61, 233, 0.08);
}

.connection-item:hover {
  border-color: rgba(139, 92, 246, 0.42);
}

.connection-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--purple-soft);
  color: #a78bfa;
}

.connection-copy {
  min-width: 0;
}

.connection-copy strong,
.connection-copy small {
  display: block;
}

.connection-copy strong {
  margin-bottom: 5px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-item > button,
.connection-menu button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.connection-menu {
  position: absolute;
  right: 10px;
  top: 52px;
  z-index: 5;
  display: grid;
  width: 148px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101720;
  box-shadow: var(--shadow);
  padding: 6px;
}

.connection-menu[hidden] {
  display: none;
}

.connection-menu button {
  width: 100%;
  grid-template-columns: 18px 1fr;
  justify-content: flex-start;
  gap: 8px;
  color: var(--text);
  padding: 0 9px;
  text-align: left;
}

.connection-menu button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.connection-builder {
  min-height: 500px;
}

.connection-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.field-group {
  display: grid;
  gap: 7px;
  margin-bottom: 22px;
}

.field-group > span:first-child {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.channel-select,
.channel-picker-button {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.88);
  padding: 0 12px;
}

.channel-picker {
  position: relative;
}

.channel-picker-button {
  width: 100%;
  color: var(--text);
  text-align: left;
}

.channel-picker-button[aria-expanded="true"] {
  border-color: rgba(139, 92, 246, 0.55);
}

.channel-select select {
  width: 100%;
  min-width: 0;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.channel-select > svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.channel-picker-button > svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  justify-self: end;
}

.channel-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
  display: grid;
  overflow: hidden;
  border: 1px solid #334052;
  border-radius: var(--radius);
  background: #101720;
  box-shadow: var(--shadow);
  padding: 6px;
}

.channel-menu[hidden] {
  display: none;
}

.source-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.source-option:hover,
.source-option.is-selected {
  background: rgba(109, 61, 233, 0.16);
}

.source-option svg:last-child {
  width: 15px;
  height: 15px;
  color: var(--green);
}

.channel-brand {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
}

.channel-brand.manychat {
  background: rgba(14, 165, 233, 0.14);
  color: #38bdf8;
}

.channel-brand.instagram {
  background: linear-gradient(135deg, #f97316, #db2777 52%, #7c3aed);
}

.channel-brand.telegram {
  background: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
}

.channel-brand.whatsapp {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.channel-brand.site {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.channel-multi {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.88);
  padding: 7px;
}

.channel-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  padding: 0 10px 0 3px;
}

.channel-chip .channel-brand {
  width: 24px;
  height: 24px;
}

.channel-chip.is-selected {
  border-color: rgba(139, 92, 246, 0.34);
  background: rgba(109, 61, 233, 0.15);
  color: var(--text);
}

#connectionName {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.9);
  color: var(--text);
  padding: 0 12px;
}

.route-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.52);
  margin: -6px 0 22px;
  padding: 10px;
  color: var(--muted);
}

.route-preview > svg {
  width: 17px;
  height: 17px;
}

.route-node {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 0 10px 0 3px;
  font-size: 13px;
}

.switch-row {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #334052;
}

.switch-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform 180ms ease;
}

.switch-row input:checked + .switch-track {
  background: var(--purple);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(16px);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.connection-flow {
  padding: 22px;
}

.flow-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 42px minmax(200px, 1fr) 42px minmax(200px, 1fr);
  align-items: center;
  gap: 18px;
}

.flow-step {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 17, 24, 0.65);
  padding: 12px;
}

.flow-step strong,
.flow-step small {
  display: block;
}

.flow-step strong {
  margin-bottom: 5px;
  font-size: 13px;
}

.flow-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
}

.flow-icon.purple {
  background: var(--purple-soft);
  color: #a78bfa;
}

.flow-icon.green {
  background: var(--green-soft);
  color: #4ade80;
}

.flow-icon.blue {
  background: rgba(14, 165, 233, 0.14);
  color: #38bdf8;
}

.flow-arrow {
  color: var(--muted);
  justify-self: center;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.save-state svg {
  width: 17px;
  height: 17px;
  color: var(--green);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 44px));
  transform: translateY(140%);
  border-radius: var(--radius);
  background: #111827;
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: transform 200ms ease;
}

.toast.is-visible {
  transform: translateY(0);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .brand span:not(.brand-mark),
  .side-link {
    font-size: 0;
  }

  .side-link {
    justify-content: center;
    padding: 0;
  }

  .table-head,
  .faq-row {
    grid-template-columns: minmax(280px, 1fr) 120px 170px 88px;
  }

  .connections-grid,
  .flow-row {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    transform: rotate(90deg);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .brand {
    padding: 0;
  }

  .brand span:not(.brand-mark),
  .side-link {
    font-size: inherit;
  }

  .side-nav {
    width: auto;
  }

  .side-link {
    padding: 0 12px;
  }

  .content {
    padding: 22px 14px 24px;
  }

  .page-head,
  .toolbar-row,
  .pagination,
  .editor-actions,
  .modal-status-row,
  .prompt-card-head,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tools,
  .filter-row,
  .left-actions,
  .right-actions,
  .prompt-tabs {
    flex-wrap: wrap;
  }

  .table-head {
    display: none;
  }

  .faq-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .faq-cell,
  .row-actions {
    padding: 0;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .editor-modal {
    position: static;
    width: auto;
    transform: none;
    margin: 0 14px 24px;
  }

  .code-frame {
    height: 420px;
  }

  .history-panel {
    min-height: 360px;
  }

  .connection-panel {
    min-height: 0;
    padding: 18px;
  }

  .connection-form,
  .connection-flow {
    padding: 16px;
  }

  .connection-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .connection-item .status-pill,
  .connection-item > button {
    margin-left: 54px;
  }
}

@media (max-width: 520px) {
  .brand span:not(.brand-mark) {
    display: none;
  }

  .primary-btn,
  .sort-btn,
  .tool-btn,
  .save-btn {
    width: 100%;
  }

  .left-actions,
  .right-actions,
  .form-actions,
  .view-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .insert-variable {
    min-width: 0;
  }

  .connection-item .status-pill,
  .connection-item > button {
    margin-left: 0;
  }

  .connection-item {
    grid-template-columns: 1fr;
  }

  .connection-icon {
    width: 38px;
    height: 38px;
  }

  .channel-select {
    grid-template-columns: 30px minmax(0, 1fr) 18px;
  }

  h1 {
    font-size: 22px;
  }

  .code-frame {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .title-editor h2,
  .title-input {
    max-width: calc(100vw - 120px);
    width: calc(100vw - 120px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Settings view */
.settings-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 18px;
  align-items: start;
}

.settings-body .connection-panel {
  min-height: unset;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#settingsView select {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
