[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --card: #ffffff;
  --line: #d7e0da;
  --ink: #10231d;
  --muted: #52615b;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --danger: #b42318;
  --shadow: 0 4px 24px rgba(16, 35, 29, 0.07);
  --radius: 18px;
  --ring: rgba(15, 118, 110, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(900px 600px at 80% -200px, rgba(20, 184, 166, 0.12), transparent 60%),
    radial-gradient(700px 500px at 10% -180px, rgba(15, 118, 110, 0.08), transparent 60%),
    linear-gradient(180deg, #fbfdfc 0%, var(--bg) 100%);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3 {
  letter-spacing: -0.02em;
}

/* ── Site header ─────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: transparent;
  padding: 14px 16px 8px;
}

.site-header-inner {
  max-width: 1160px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 8px rgba(16, 35, 29, 0.06);
}

.site-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.site-header-lockup {
  height: 18px;
  width: auto;
  color: var(--ink);
}

.site-header-product {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.site-header-spacer {
  flex: 1;
}

.site-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header-email {
  font-size: 13px;
  color: var(--muted);
}

/* ── Shell ───────────────────────────────────────────────── */

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

.shell--narrow {
  width: min(780px, calc(100vw - 32px));
}

/* ── Hero ────────────────────────────────────────────────── */

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1;
}

.lede {
  margin: 0;
  max-width: 700px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

/* ── Grid / Cards ────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.card,
.guide,
.step {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.card--full {
  grid-column: 1 / -1;
}

.card h2 {
  margin-top: 0;
}

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

.card-header h2 {
  margin: 0;
}

/* ── Typography helpers ──────────────────────────────────── */

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

/* ── Form fields ─────────────────────────────────────────── */

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

input,
textarea,
button,
a.button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #c7d4cc;
  border-radius: 12px;
  background: #fcfefd;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

textarea {
  resize: vertical;
}

.two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

/* ── Buttons ─────────────────────────────────────────────── */

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: #e3ece7;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.button:hover:not(:disabled),
button:hover:not(:disabled) {
  opacity: 0.85;
}

.button--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
}

.button--primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
  opacity: 1;
}

.button--danger {
  background: #fef3f2;
  color: var(--danger);
}

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

/* ── Spinner ─────────────────────────────────────────────── */

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ── Auth split layout ───────────────────────────────────── */

.auth-split {
  position: fixed;
  inset: 0;
  display: flex;
  z-index: 100;
  background:
    radial-gradient(900px 600px at 80% -200px, rgba(20, 184, 166, 0.10), transparent 60%),
    linear-gradient(180deg, #fbfdfc 0%, var(--bg) 100%);
}

.auth-brand {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 40px;
  background: rgba(15, 118, 110, 0.05);
  border-right: 1px solid var(--line);
}

.auth-mark {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.auth-lockup {
  height: 22px;
  width: auto;
  color: var(--ink);
}

.auth-tagline {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  max-width: 200px;
}

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  overflow-y: auto;
}

.auth-form-inner {
  width: 100%;
  max-width: 380px;
}

.auth-form-inner h2 {
  margin-top: 0;
  font-size: 26px;
}

/* ── Stack / Guide builder ───────────────────────────────── */

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

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

.guide__steps {
  display: grid;
  gap: 12px;
}

/* ── Payload preview ─────────────────────────────────────── */

.preview {
  max-height: 380px;
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #dbeafe;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 14px;
}

code {
  font-family: Consolas, monospace;
}

/* ── Page mark (run.html / connect.html) ─────────────────── */

.page-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

/* ── Select ──────────────────────────────────────────────── */

select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #c7d4cc;
  border-radius: 12px;
  background: #fcfefd;
  color: var(--ink);
  font: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2352615b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

/* ── Status bar ──────────────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.status-bar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.status-bar__text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Status dot ──────────────────────────────────────────── */

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
  transition: background 0.4s;
}

.status-dot--connected {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.status-dot--error {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.status-dot--checking {
  background: #f59e0b;
  animation: dot-pulse 1.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Unsaved badge ───────────────────────────────────────── */

.unsaved-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.unsaved-badge.visible {
  opacity: 1;
}

/* ── Tab navigation ──────────────────────────────────────── */

.tab-nav {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover:not(:disabled) {
  color: var(--ink);
  background: transparent;
  opacity: 1;
}

.tab-btn[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* ── Tab badge (guide count) ─────────────────────────────── */

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.tab-badge:empty {
  display: none;
}

/* ── Tab panels ──────────────────────────────────────────── */

.tab-panel[hidden] {
  display: none !important;
}

/* ── Step badge ──────────────────────────────────────────── */

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Guide header layout ─────────────────────────────────── */

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

.guide__header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.guide__header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.guide__meta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Guide collapse toggle ───────────────────────────────── */

.guide__toggle-btn {
  min-height: unset;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.guide__toggle-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--ink);
  opacity: 1;
}

.guide__body[hidden] {
  display: none !important;
}

/* ── Toast notification ──────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 300;
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 32px rgba(16, 35, 29, 0.22);
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s;
  pointer-events: none;
  max-width: 320px;
}

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

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .auth-split {
    flex-direction: column;
  }

  .auth-brand {
    width: 100%;
    flex-direction: row;
    padding: 20px 24px;
    gap: 16px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    justify-content: flex-start;
  }

  .auth-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 18px;
  }

  .auth-tagline {
    display: none;
  }

  .site-header-email {
    display: none;
  }

  .status-bar {
    gap: 10px;
  }

  .status-bar__right {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .two-up {
    grid-template-columns: 1fr;
  }
}
