:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #666666;
  --line: #d8d2c8;
  --accent: #111111;
  --dev: #0f5132;
  --dev-bg: #d1e7dd;
  --dev-border: #badbcc;
  --prod: #842029;
  --prod-bg: #f8d7da;
  --prod-border: #f5c2c7;
  --shadow: 0 12px 40px rgba(17, 17, 17, 0.08);
  --radius: 18px;
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(17, 17, 17, 0.05), transparent 30%),
    radial-gradient(circle at bottom right, rgba(17, 17, 17, 0.03), transparent 25%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: rgba(17, 17, 17, 0.06);
  padding: 0.12em 0.35em;
  border-radius: 6px;
}

.page {
  width: min(960px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.hero {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.5rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

h2 {
  font-size: 1.1rem;
}

.lede {
  max-width: 54rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

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

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.status {
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #efefef;
  border: 1px solid transparent;
}

.status.ok {
  background: var(--dev-bg);
  color: var(--dev);
  border-color: var(--dev-border);
}

.status.bad {
  background: var(--prod-bg);
  color: var(--prod);
  border-color: var(--prod-border);
}

.mode-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem;
  align-items: center;
}

.mode-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
}

.mode-badge--dev {
  background: var(--dev-bg);
  color: var(--dev);
  border-color: var(--dev-border);
}

.mode-badge--prod {
  background: var(--prod-bg);
  color: var(--prod);
  border-color: var(--prod-border);
}

.mode-copy p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ece7de;
  color: var(--ink);
}

.btn-dev {
  background: var(--dev);
}

.btn-prod {
  background: var(--prod);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.key-grid {
  display: grid;
  gap: 0.85rem;
}

.key-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.85rem;
  align-items: center;
}

.key-row label {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 500;
}

#local-editor {
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.55;
  tab-size: 2;
}

.code-block {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: #111;
  color: #f5f5f5;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.auth-gate {
  border-color: #111;
}

.auth-copy {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
}

.auth-form label {
  color: var(--ink);
}

.auth-error {
  margin: 0.85rem 0 0;
  color: var(--prod);
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  z-index: 100;
}

@media (max-width: 720px) {
  .page {
    padding-top: 1.5rem;
  }

  .mode-panel,
  .key-row {
    grid-template-columns: 1fr;
  }

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

  .panel-actions,
  .mode-actions {
    width: 100%;
  }

  .mode-actions .btn,
  .panel-actions .btn {
    flex: 1;
  }
}
