:root {
  --bg: #f0f0f0;
  --ink: #191919;
  --muted: #6a6a6a;
  --accent: #2b2b2b;
  --accent-dark: #1f1f1f;
  --surface: #ffffff;
  --stroke: #ded4c8;
  --shadow: 0 18px 40px rgba(18, 26, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 17px;
  overflow-y: scroll;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 60px 28px 80px;
}

.page--editor {
  padding-bottom: 240px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 48px;
}

.brand__title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 40px;
  font-weight: 600;
}

.cloud {
  display: inline-block;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
}


.topbar__actions {
  display: flex;
  gap: 12px;
}

.conn-badge {
  align-self: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

.conn-badge--ok {
  color: #1c5f33;
  border-color: rgba(28, 95, 51, 0.25);
  background: rgba(235, 247, 239, 0.8);
}

.conn-badge--bad {
  color: #7a2f2f;
  border-color: rgba(197, 75, 75, 0.35);
  background: rgba(255, 235, 235, 0.85);
}

.error-state {
  margin: 30px 0 0;
  padding: 22px 20px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.error-state h3 {
  margin: 0 0 8px;
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 22px;
  font-weight: 600;
}

.error-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

button {
  border: none;
  font-family: "Space Grotesk", system-ui, sans-serif;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

button.primary {
  background: #2b2b2b;
  color: #f7efe6;
  box-shadow: 0 10px 20px rgba(43, 43, 43, 0.22);
}

button.primary:hover {
  background: #1f1f1f;
}

button.danger {
  background: #c54b4b;
  color: #f7efe6;
  box-shadow: 0 10px 20px rgba(197, 75, 75, 0.22);
}

button.danger:hover {
  background: #a73f3f;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--ink);
}

button.ghost.run-btn {
  background: #2b2b2b;
  color: #f7efe6;
  border-color: #2b2b2b;
}

button.ghost.run-btn:hover {
  background: #1f1f1f;
}

.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid #bcbcbc;
  padding-top: 0;
  padding-bottom: 10px;
  margin: 0 0 18px;
}

.tab {
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  position: relative;
  text-decoration: none;
  display: inline-block;
  outline: none;
}

.tab--active {
  color: var(--ink);
}

.tab--active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 28px;
  border-bottom: 1px solid var(--stroke);
}

.hero h1 {
  font-size: 28px;
  margin: 0 0 8px;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.hero__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 22px;
}

.editor-hero h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 24px;
  font-weight: 400;
  margin: 6px 0 8px;
  background: #e6e6e6;
  padding: 6px 12px;
  border-radius: 0;
}


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

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 26px 0 10px;
}

.toolbar__actions {
  display: flex;
  gap: 26px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  color: var(--muted);
  background: #fdf9f3;
  font-size: 13px;
}

.chip--active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.list--header {
  margin-top: 14px;
  padding: 0 8px;
  display: grid;
  grid-template-columns: 1.7fr 0.9fr 20px 1.2fr 1.4fr;
  column-gap: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.group {
  margin-top: 18px;
  margin-bottom: 0;
}

.group__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-top: 18px;
  margin-bottom: 32px;
  padding-top: 8px;
  background: #e6e6e6;
  padding: 10px 12px;
  border-radius: 0;
}

.group__header h2 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-weight: 600;
  margin: 0;
  font-size: 21px;
}


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

.row {
  display: grid;
  grid-template-columns: 1.7fr 0.9fr 20px 1.2fr 1.4fr;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.35s ease forwards;
}

.row__title {
  margin: 0;
  font-size: 18px;
  font-weight: 400;
}


.row__cell {
  color: var(--ink);
  font-size: 15px;
}

.row__actions {
  display: flex;
  gap: 26px;
  justify-content: flex-end;
  align-items: center;
  justify-self: end;
}

.list--header span:last-child {
  text-align: right;
}

.row__toggle {
  display: flex;
  justify-content: center;
}

.row__voice {
  text-align: center;
  font-size: 16px;
}

.list--header span {
  text-align: center;
}

.list--header span:first-child {
  text-align: left;
}

.row__main {
  text-align: left;
}


.switch {
  position: relative;
  width: 34px;
  height: 20px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  background: #e1dbd1;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch input:checked + .switch__track {
  background: #2b2b2b;
}

.switch input:checked + .switch__track::after {
  transform: translateX(14px);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 18, 0.45);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.modal__panel {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  width: min(520px, 100%);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.modal__panel--confirm {
  width: min(380px, 100%);
  text-align: left;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--stroke);
}

.modal__panel--confirm p {
  margin: 0;
  color: var(--muted);
}

#confirm-title {
  font-size: 18px;
}

#confirm-message {
  font-size: 14px;
}

.modal__title {
  margin: 0;
}

.modal label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.modal input,
.modal textarea,
.modal select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-family: inherit;
  color: var(--ink);
  background-color: #fff;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal--open {
  opacity: 1;
  pointer-events: auto;
}

.danger-zone {
  border-top: 1px solid var(--stroke);
  padding-top: 16px;
  display: grid;
  gap: 8px;
}

.danger-zone p {
  margin: 0;
  color: #7b2f2f;
  font-size: 13px;
}

.editor {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.editor-body {
  display: grid;
  grid-template-columns: 600px auto;
  gap: 32px;
  align-items: start;
}

.editor[data-active-tab="research"] .editor-body {
  grid-template-columns: 1fr;
}

.editor[data-active-tab="research"] .editor__main {
  max-width: 1400px;
}

.editor-tabs {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0;
  padding: 8px 0 16px;
  max-width: 720px;
  width: 720px;
  justify-self: start;
  --step-size: 42px;
}

.editor-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  flex: 1;
}

.editor-tab--active {
  color: var(--ink);
}

.editor-tabs::before {
  content: "";
  position: absolute;
  left: calc(var(--step-size) / 2);
  right: calc(var(--step-size) / 2);
  top: calc(var(--step-size) / 2 + 3px);
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
}

.step-index {
  width: var(--step-size);
  height: var(--step-size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 2px solid var(--ink);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  z-index: 1;
  transform: translateY(-4px);
}

.editor-tab--active .step-index {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.step-label {
  display: block;
  text-align: center;
  color: inherit;
  font-size: 11px;
}


.editor__main {
  display: grid;
  gap: 24px;
  max-width: 600px;
  width: 100%;
  padding-top: 18px;
  padding-bottom: 0;
}

.editor-action {
  display: flex;
  justify-content: flex-start;
  align-self: start;
  padding-top: 12px;
}

.module-add-button.is-hidden {
  display: none;
}

.editor__section {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 24px 22px 42px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 26px;
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: grid;
}

.section__header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.section__header--with-action {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section__header--with-action > div {
  flex: 1;
}

.research-remove {
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
}

.module-add-button {
  align-self: flex-start;
}

.research-stack {
  gap: 24px;
}

.research-stack.tab-panel--active {
  column-gap: 32px;
  row-gap: 28px;
}

.research-stack[data-cols="1"].tab-panel--active {
  grid-template-columns: 600px max-content;
}

.research-stack[data-cols="2"].tab-panel--active {
  grid-template-columns: 600px 600px max-content;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 24px;
}

.field-full {
  display: grid;
  gap: 8px;
}

.editor__section label {
  display: grid;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
}

.editor__section input,
.editor__section textarea,
.editor__section select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
}

.editor__section input.is-locked {
  background: #f2f2f2;
  color: var(--muted);
  pointer-events: none;
}

.editor__section input.is-locked:focus,
.editor__section input.is-locked:focus-visible {
  outline: none;
  box-shadow: none;
}

.editor__section select,
.module-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

select option {
  background-color: #fff;
  color: var(--ink);
}

.selectx {
  position: relative;
  width: 100%;
}

.module-provider .selectx {
  width: 260px;
}

.selectx__native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.selectx__button {
  width: 100%;
  text-align: left;
  padding: 10px 40px 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background-color: #fff;
  position: relative;
}

.selectx__button::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}

.selectx__button:focus-visible {
  outline: 2px solid rgba(43, 43, 43, 0.25);
  outline-offset: 2px;
}

.selectx__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  max-height: 360px;
  overflow: hidden;
  display: none;
  z-index: 50;
}

.selectx--open .selectx__menu {
  display: block;
}

.selectx__search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  margin: 0 0 8px;
}

.selectx__options {
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.selectx__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  border: none;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}

.selectx__option:hover {
  background: #f3f3f3;
}

.selectx__option[aria-selected="true"] {
  background: rgba(105, 163, 201, 0.22);
}

.selectx__option.selectx__option--active {
  background: #f1f1f1;
}

.selectx__option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.module-row {
  display: grid;
  grid-template-columns: max-content;
  gap: 12px;
  align-items: end;
}

.module-row--single {
  grid-template-columns: max-content;
}

.module-provider select {
  width: 260px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a524b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 38px;
}

.module-row label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.module-row input,
.module-row select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-family: inherit;
  color: var(--ink);
  background-color: #fff;
}

.module-actions {
  display: flex;
  justify-content: flex-end;
}

.module-remove {
  align-self: center;
}


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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink);
}

.editor__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 10px;
}

.editor__note {
  font-size: 13px;
  color: var(--muted);
}

.editor__buttons {
  display: flex;
  gap: 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #2b2b2b;
  color: #f7efe6;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  font-size: 13px;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 800px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

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

  .list--header {
    display: none;
  }

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

  .row__actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .editor-body {
    grid-template-columns: 1fr;
  }

  .editor-action {
    padding-top: 0;
  }

  .editor-tabs {
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    row-gap: 18px;
  }

  .editor-tabs::before {
    display: none;
  }
}

@media (max-width: 1380px) {
  .editor[data-active-tab="research"] .editor__main {
    max-width: 600px;
  }

  .research-stack.tab-panel--active {
    grid-template-columns: 1fr;
  }

  .research-stack .editor-action {
    grid-column: auto;
  }
}
