@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg-top: #f6f4ec;
  --bg-bottom: #e7eef2;
  --panel: #fffdf7;
  --panel-strong: #ffffff;
  --line: #cad4db;
  --ink: #14202b;
  --muted: #526273;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --highlight: #b45309;
  --danger: #c2410c;
  --success: #15803d;
  --ring: #0f766e;
  --shadow: 0 14px 40px rgba(16, 24, 40, 0.09);
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --mono: "IBM Plex Mono", Consolas, Menlo, monospace;
  --sans: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 100% -5%, rgba(17, 94, 89, 0.14), transparent 55%),
    radial-gradient(900px 520px at -8% 0%, rgba(180, 83, 9, 0.1), transparent 48%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  font-family: var(--sans);
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100%;
  z-index: 40;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  top: 14px;
}

.page-shell {
  width: min(1400px, 96vw);
  margin: 1.25rem auto 2rem;
}

.masthead {
  padding: 1.15rem 1.2rem 1.3rem;
  border: 1px solid rgba(20, 32, 43, 0.12);
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 253, 247, 0.88));
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 700;
}

h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.7rem, 2.2vw, 2.4rem);
  line-height: 1.1;
}

.lead {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 72ch;
}

.help-strip {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.85rem;
  border-left: 4px solid var(--highlight);
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.1);
  font-size: 0.96rem;
}

.origin-form {
  margin-top: 0.95rem;
  max-width: 980px;
}

.connection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.field-group .hint {
  margin-bottom: 0;
}

.origin-input {
  width: 100%;
  margin-top: 0.33rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.63rem 0.72rem;
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.console-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.engagement-panel {
  grid-column: 1 / -1;
}

.engagement-header {
  align-items: center;
}

.engagement-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.engagement-grid {
  padding: 0 0.95rem 0.8rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.metric-card {
  border: 1px solid rgba(20, 32, 43, 0.14);
  border-radius: 12px;
  background: #ffffff;
  padding: 0.6rem 0.65rem 0.55rem;
}

.metric-card-wide {
  grid-column: span 3;
}

.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.metric-value {
  margin: 0.32rem 0 0;
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(1rem, 1.8vw, 1.32rem);
  line-height: 1.15;
}

.metric-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.column {
  display: grid;
  gap: 0.9rem;
}

.section-title {
  margin: 0.35rem 0 0.1rem;
  font-size: 1.06rem;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
}

.console-card {
  border: 1px solid rgba(20, 32, 43, 0.14);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  box-shadow: 0 6px 20px rgba(20, 32, 43, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 0.95rem 0.55rem;
}

.card-header h3 {
  margin: 0;
  font-size: 1.03rem;
}

.endpoint {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.endpoint code {
  font-family: var(--mono);
  font-size: 0.83rem;
}

.status-badge {
  border-radius: 999px;
  border: 1px solid transparent;
  min-width: 68px;
  text-align: center;
  padding: 0.22rem 0.56rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.idle {
  color: #4b5563;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.status-badge.loading {
  color: #8a4b00;
  border-color: #facc15;
  background: #fef9c3;
}

.status-badge.success {
  color: #166534;
  border-color: #86efac;
  background: #dcfce7;
}

.status-badge.error {
  color: #9a3412;
  border-color: #fdba74;
  background: #ffedd5;
}

.api-form {
  padding: 0 0.95rem 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1f3041;
}

.json-editor {
  width: 100%;
  min-height: 188px;
  margin-top: 0.42rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.72rem;
  resize: vertical;
  background: #f8fafc;
  color: #111827;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
}

.inline-fields {
  display: grid;
  gap: 0.32rem;
}

.mode-select {
  width: 100%;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.52rem 0.6rem;
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
}

.form-actions {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
}

button {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.52rem 0.88rem;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
}

.button-run {
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.button-ghost {
  border-color: #cbd5e1;
  background: #fff;
  color: #1e293b;
}

.response-panel {
  border-top: 1px solid rgba(20, 32, 43, 0.1);
  padding: 0.7rem 0.95rem 0.95rem;
}

.response-title {
  margin: 0 0 0.45rem;
  font-size: 0.83rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.json-output {
  margin: 0;
  min-height: 130px;
  max-height: 330px;
  overflow: auto;
  padding: 0.72rem;
  border: 1px solid rgba(20, 32, 43, 0.12);
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.42;
}

.hint {
  margin: 0.42rem 0 0.58rem;
  color: var(--muted);
  font-size: 0.85rem;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

@media (max-width: 1040px) {
  .console-grid {
    grid-template-columns: 1fr;
  }

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

  .metric-card-wide {
    grid-column: span 2;
  }

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

@media (max-width: 700px) {
  .page-shell {
    width: min(100%, 100vw);
    margin: 0;
    padding: 0.7rem;
  }

  .masthead {
    padding: 1rem;
  }

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

  .engagement-actions {
    width: 100%;
  }

  .engagement-actions .button-run {
    flex: 1;
  }

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

  .metric-card-wide {
    grid-column: span 1;
  }
}

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