:root {
  color-scheme: dark;
  --bg: #07110d;
  --panel: #0d1914;
  --panel-2: #12231c;
  --panel-3: #0a1511;
  --ink: #eef8f2;
  --muted: #8aa397;
  --line: #20382f;
  --line-strong: #2d5b49;
  --accent: #2ee59d;
  --accent-2: #119666;
  --accent-ink: #04100b;
  --danger: #ff7a7a;
  --warning: #e9c66b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(17, 150, 102, 0.16), transparent 340px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.topbar-actions,
.inline-row,
.sidebar-head,
.panel-head,
.panel-actions,
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 20, 15, 0.86);
  box-shadow: var(--shadow);
}

.tab {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  color: var(--accent-ink);
  border-color: rgba(46, 229, 157, 0.5);
  background: var(--accent);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.status {
  min-width: 104px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(13, 25, 20, 0.9);
  text-align: center;
}

.status.dirty {
  color: var(--warning);
  background: rgba(233, 198, 107, 0.12);
  border-color: rgba(233, 198, 107, 0.42);
}

.status.saved {
  color: var(--accent);
  background: rgba(46, 229, 157, 0.1);
  border-color: rgba(46, 229, 157, 0.36);
}

.status.error {
  color: var(--danger);
  background: rgba(255, 122, 122, 0.12);
  border-color: rgba(255, 122, 122, 0.42);
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel-2);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: #173127;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.button.danger,
.icon-button.danger {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.36);
  background: rgba(255, 122, 122, 0.08);
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 20px;
  font-weight: 900;
}

.auth-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(233, 198, 107, 0.42);
  border-radius: var(--radius);
  background: rgba(233, 198, 107, 0.1);
}

.auth-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--warning);
  font-weight: 800;
}

.hidden {
  display: none;
}

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

.settings-panel,
.debug-panel {
  margin-bottom: 18px;
}

.settings-page.active {
  display: grid;
  gap: 18px;
}

.sidebar,
.panel,
.editor.empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 25, 20, 0.92);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.sidebar-head,
.panel-head {
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact {
  padding-bottom: 12px;
}

.sidebar h2,
.panel h2,
.empty-state h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.rule-list {
  display: grid;
  gap: 3px;
  padding: 8px;
}

.rule-item {
  width: 100%;
  padding: 13px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.rule-item strong,
.rule-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.rule-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.rule-item.active {
  border-color: rgba(46, 229, 157, 0.46);
  background: rgba(46, 229, 157, 0.1);
}

.editor.empty {
  min-height: 520px;
  display: grid;
  place-items: center;
}

.empty-state {
  text-align: center;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.main-panel,
.json-panel {
  min-width: 0;
}

.json-panel {
  grid-column: 1;
}

.panel label,
.field-grid {
  display: grid;
  gap: 7px;
}

.panel label {
  padding: 0 16px 16px;
}

.panel label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.field-grid label {
  padding: 0 0 16px;
}

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

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

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 16px;
  color: var(--ink);
  font-weight: 800;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.muted-line {
  margin: 0;
  padding: 16px;
  color: var(--muted);
}

.debug-list {
  display: grid;
  gap: 1px;
  padding: 1px 0 0;
  background: var(--line);
}

.request-row {
  min-width: 0;
  background: var(--panel);
}

.request-row:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.request-row[open] {
  background: var(--panel-3);
}

.request-summary {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 10px 16px;
  list-style: none;
  cursor: pointer;
  transition: background 160ms ease;
}

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

.request-summary:hover {
  background: rgba(255, 255, 255, 0.025);
}

.request-status {
  display: grid;
  place-items: center;
  width: 42px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.request-status.success {
  color: var(--accent);
  border-color: rgba(46, 229, 157, 0.3);
  background: rgba(46, 229, 157, 0.07);
}

.request-status.error {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.34);
  background: rgba(255, 122, 122, 0.08);
}

.request-main,
.request-side {
  display: grid;
  min-width: 0;
}

.request-main {
  gap: 5px;
}

.request-main strong,
.request-main span,
.request-side span,
.request-side time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-main strong {
  font-size: 14px;
}

.request-main span,
.request-side {
  color: var(--muted);
  font-size: 12px;
}

.request-side {
  gap: 5px;
  justify-items: end;
  font-variant-numeric: tabular-nums;
}

.request-body {
  padding: 0 16px 16px 76px;
}

.request-copy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.request-copy > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.request-copy pre {
  min-height: 130px;
  max-height: 300px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #cfe5db;
  background: #06100c;
  font-family:
    ui-monospace,
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.request-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 10px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.request-facts div {
  min-width: 0;
  padding: 10px;
  background: var(--panel-2);
}

.request-facts dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.request-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #07130f;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #557066;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 260px;
  padding: 12px;
  line-height: 1.48;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 229, 157, 0.14);
}

.json-editor {
  min-height: 360px;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  color: #d7eee4;
  background: #06100c;
  font-family:
    ui-monospace,
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 13px;
}

@media (max-width: 980px) {
  .workspace,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1440px);
    padding: 16px 0;
  }

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

  .topbar-actions,
  .inline-row,
  .panel-actions,
  .tabs {
    align-items: stretch;
    flex-direction: column;
  }

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

  .request-copy-grid,
  .request-facts {
    grid-template-columns: 1fr;
  }

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

  .request-side {
    grid-column: 2;
    justify-items: start;
  }

  .request-body {
    padding-left: 16px;
  }
}
