:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #202225;
  --muted: #666f78;
  --line: #d9ded8;
  --accent: #256f5a;
  --accent-dark: #1f5a49;
  --blue: #235d8e;
  --danger: #a23d3d;
  --code: #101418;
  --shadow: 0 10px 30px rgba(32, 34, 37, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(720px, 100%);
}

.auth-panel {
  display: grid;
  gap: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-panel h1 {
  margin: 6px 0 8px;
  font-size: 28px;
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  background: #f0f2ed;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  margin: 0 8px 20px;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
  background: #dfe8df;
}

.main {
  margin-left: 232px;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.examples-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.examples-side {
  position: sticky;
  top: 18px;
  min-height: calc(100vh - 56px);
  box-shadow: none;
}

.examples-side-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}

.side-eyebrow {
  color: #718096;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-title {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 800;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover {
  background: #eef3f0;
  border-color: #d8e1dc;
}

.example-name-list {
  display: grid;
  gap: 4px;
}

.example-name-row {
  display: block;
}

.example-name-item {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #344054;
  text-align: left;
  font-weight: 600;
}

.example-name-item:hover,
.example-name-item.active {
  border-color: #d9e2dd;
  background: #f5f8f6;
  color: #155eef;
}

.empty-list {
  color: var(--muted);
  padding: 10px 2px;
}

.examples-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.editor-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding: 14px 0 8px;
  border-bottom: 1px solid var(--line);
}

.editor-topbar h1 {
  font-size: 18px;
}

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

.danger-button {
  background: #fff1f1;
  color: var(--danger);
  border-color: #efcaca;
}

.danger-button:hover:not(:disabled) {
  background: #fbe4e4;
}

.version-select {
  width: 210px;
}

.version-select-native {
  display: none;
}

.version-dropdown {
  position: relative;
  width: 100%;
  min-width: 0;
}

.version-dropdown.open {
  z-index: 80;
}

.topbar-actions > .version-dropdown {
  width: 210px;
}

.version-dropdown-button {
  position: relative;
  width: 100%;
  min-height: 40px;
  padding: 9px 38px 9px 11px;
  border: 1px solid #cbd2ca;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-dropdown-button::after {
  content: "⌄";
  position: absolute;
  right: 12px;
  color: var(--muted);
}

.version-dropdown-button.marked {
  background: #fffaf0;
  border-color: #e5bf43;
}

.version-dropdown-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 5px;
}

.version-dropdown-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  border-radius: 6px;
}

.version-dropdown-option:hover,
.version-dropdown-option.active {
  background: #f5f8f6;
}

.version-option-star,
.version-option-label {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 6px 8px;
}

.version-option-star {
  color: #8a6a00;
  font-size: 17px;
}

.version-option-label {
  text-align: left;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-option-star:hover,
.version-option-label:hover {
  background: transparent;
}

.version-option-star:disabled,
.version-option-label:disabled {
  color: var(--muted);
}

.version-option-star:not(:disabled):hover {
  color: #ad7d00;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  min-height: 64px;
}

h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.subpanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: #3f464c;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd2ca;
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.mono,
.code-output,
.logs {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  background: #eef3f0;
  color: var(--accent-dark);
  border-color: #cbd8d1;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
}

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

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

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

.version-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
}

.version-row:hover {
  border-color: #9eb7aa;
  background: #f4f8f5;
}

.resource-title {
  font-weight: 750;
}

.resource-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eaf1ec;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.options-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.check input {
  width: auto;
}

.run-grid {
  align-items: start;
}

.status-line {
  color: var(--muted);
  margin-bottom: 12px;
}

.run-cost-line {
  color: var(--ink);
  font-weight: 650;
}

.conversation {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.message.user {
  border-left: 4px solid var(--blue);
}

.message.assistant {
  border-left: 4px solid var(--accent);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

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

.tool-call {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 8px;
}

.output-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.code-output {
  min-height: 460px;
  max-height: 720px;
  overflow: auto;
  margin: 0;
  color: #f0f5f1;
  background: var(--code);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
}

.code-output.compact {
  min-height: 260px;
  max-height: 520px;
}

.readable-preview {
  min-height: 260px;
  max-height: 680px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.preview-section + .preview-section {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.preview-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.preview-kv {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  padding: 6px 0;
  color: #344054;
}

.preview-kv strong {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.field-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.field-preview-table th,
.field-preview-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.field-preview-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8faf8;
}

.event-descriptions-editor {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
}

.event-description-row {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.event-name-cell {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.event-description-row textarea {
  min-height: 48px;
  resize: vertical;
}

.event-description-body {
  display: grid;
  gap: 12px;
}

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

.event-description-field span,
.event-param-section-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.event-param-section {
  display: grid;
  gap: 10px;
}

.event-param-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.event-param-section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.event-descriptions-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.event-param-list,
.event-preview-list,
.event-param-preview-list {
  display: grid;
  gap: 10px;
}

.event-param-card,
.event-preview-card,
.event-param-preview-item {
  border: 1px solid #e3e8e2;
  border-radius: 8px;
  background: #fbfcfa;
}

.event-param-card,
.event-preview-card {
  padding: 12px;
}

.event-param-preview-item {
  padding: 10px;
}

.event-param-head,
.event-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.event-param-head {
  margin-bottom: 8px;
}

.event-param-head .event-param-field {
  flex: 1;
  min-width: 0;
}

.event-param-footer {
  display: flex;
  justify-content: flex-start;
}

.event-preview-head {
  margin-bottom: 10px;
}

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

.event-param-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.event-param-name-field input {
  min-height: 40px;
}

.event-param-generate {
  white-space: nowrap;
}

.event-param-name,
.event-preview-name,
.event-param-preview-name {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.event-param-preview-name {
  margin-bottom: 6px;
}

.event-param-delete {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid #efcaca;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--danger);
  font-size: 20px;
  line-height: 1;
}

.event-param-delete:hover:not(:disabled) {
  background: #fbe4e4;
}

.event-param-add-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px dashed #cbd8d1;
  border-radius: 999px;
  background: #eef3f0;
  color: var(--accent-dark);
  font-size: 22px;
  line-height: 1;
}

.event-param-add-button:hover:not(:disabled) {
  background: #e4ece7;
}

.event-param-card textarea {
  min-height: 44px;
}

.run-picker-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.run-picker-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
  overflow: visible;
}

.run-picker-row:focus-within {
  z-index: 60;
}

.run-picker-check {
  margin: 0;
  min-width: 0;
}

.run-picker-check span {
  overflow-wrap: anywhere;
}

.runs-history-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.run-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.run-history-item.marked {
  border-color: #f4ca64;
  background: #fffaf0;
}

.run-history-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.run-history-title {
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.run-history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.danger-text {
  color: var(--danger);
}

.preview-step {
  border: 1px solid #e3e8e2;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.preview-step + .preview-step {
  margin-top: 12px;
}

.preview-step h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.preview-text {
  color: #344054;
  line-height: 1.58;
}

.preview-text h3,
.preview-text h4 {
  margin: 12px 0 6px;
  color: var(--ink);
}

.preview-text h3 {
  font-size: 14px;
}

.preview-text h4 {
  font-size: 13px;
}

.preview-spacer {
  height: 10px;
}

.logs {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfa;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #202225;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 20, 24, 0.38);
}

.modal-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

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

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

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

  .examples-side {
    position: static;
    min-height: auto;
  }

  .editor-topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .version-select {
    width: 100%;
  }

  .preview-kv {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .event-param-section-head,
  .event-param-section-actions,
  .event-param-head,
  .event-preview-head {
    flex-direction: column;
    align-items: stretch;
  }

  .event-descriptions-actions {
    justify-content: stretch;
  }

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

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