:root {
  color-scheme: dark;
  --ink: #04121d;
  --ink-gradient: radial-gradient(circle at 75% 15%, rgba(43, 151, 171, 0.18), transparent 42%), linear-gradient(155deg, #061927 0%, #020910 100%);
  --ink-card: rgba(8, 26, 40, 0.75);
  --ink-card-solid: #092031;
  --paper: #f2f7f5;
  --dim: #8fa29d;
  --line: rgba(120, 208, 210, 0.22);
  --line-light: rgba(255, 255, 255, 0.08);
  --cyan: #78d0d2;
  --acid: #dfff00;
  --coral: #ff6b6b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --font-sans: "IBM Plex Sans", "Avenir Next", system-ui, -apple-system, sans-serif;
  --font-condensed: "Barlow Condensed", "Avenir Next Condensed", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  background-image: var(--ink-gradient);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.shell {
  min-height: 100svh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px clamp(20px, 4vw, 48px) 32px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 48px;
}

/* Masthead */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-light);
}

.wordmark {
  color: var(--paper);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.06em;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.wordmark span { color: var(--cyan); }

.environment {
  margin: 0;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(120, 208, 210, 0.1);
  border: 1px solid rgba(120, 208, 210, 0.25);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Typography & Eyebrow */
.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin-top: 0;
  font-family: var(--font-condensed);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

h1 {
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.lede {
  color: var(--dim);
  font-size: 16px;
  max-width: 580px;
  line-height: 1.55;
  margin-bottom: 0;
}

/* Wizard Section */
.wizard-hero {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 480px);
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
  padding: clamp(24px, 4vh, 60px) 0;
}

.wizard-header {
  align-self: center;
}

.wizard-card {
  background: var(--ink-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 36px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

/* Wizard Tabs (Create Account vs Sign In) */
.wizard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-pill);
  margin-bottom: 24px;
  border: 1px solid var(--line-light);
}

.tab-btn {
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--cyan);
  color: #031018;
  box-shadow: 0 2px 8px rgba(120, 208, 210, 0.3);
}

/* Step Indicator */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
  color: var(--dim);
}

.step-dot.active {
  background: var(--cyan);
  color: #031018;
  box-shadow: 0 0 10px rgba(120, 208, 210, 0.5);
}

.step-dot.completed {
  background: #34d399;
  color: #031018;
}

.step-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--dim);
  text-transform: uppercase;
}

/* Wizard Forms & Inputs */
.wizard-form {
  display: grid;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--paper);
}

.opt-label {
  font-weight: 400;
  color: var(--dim);
  font-size: 11px;
}

input, select {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(4, 18, 29, 0.85);
  color: var(--paper);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(120, 208, 210, 0.2);
}

input::placeholder {
  color: rgba(143, 162, 157, 0.55);
}

/* Buttons */
.primary-action, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--cyan);
  background: var(--cyan);
  color: #031018;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.primary-action:hover, .primary-button:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 16px rgba(120, 208, 210, 0.4);
}

.secondary-button, .secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.secondary-button:hover, .secondary-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--cyan);
}

.text-button, .text-action {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px;
  transition: color 0.15s ease;
}

.text-button:hover, .text-action:hover {
  color: var(--paper);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-light);
}

/* Alternative Auth */
.alt-actions {
  display: grid;
  gap: 10px;
}

.google-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.google-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.passkey-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-light);
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  cursor: not-allowed;
  opacity: 0.6;
}

.badge-soon {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--dim);
}

/* Dev Auth Form */
.dev-auth {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-light);
}

.dev-eyebrow {
  margin: 0 0 6px;
  color: var(--acid);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

/* Step 2: Sent State */
.sent-state {
  text-align: center;
  padding: 12px 0 6px;
}

.sent-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.sent-state h2 {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--paper);
}

.sent-desc {
  color: var(--dim);
  font-size: 14px;
  margin-bottom: 8px;
}

.sent-email-box {
  display: inline-block;
  padding: 8px 18px;
  background: rgba(120, 208, 210, 0.12);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--cyan);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 16px;
  word-break: break-all;
}

.sent-instructions {
  color: var(--paper);
  font-size: 14px;
  line-height: 1.5;
  max-width: 360px;
  margin: 0 auto 24px;
}

.wizard-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.tip-box {
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-light);
  font-size: 12px;
  color: var(--dim);
  text-align: left;
  line-height: 1.45;
}

/* Authenticated Account Hub */
.account {
  display: grid;
  gap: 36px;
  padding: clamp(20px, 4vh, 48px) 0;
}

.account-header h1 {
  font-size: clamp(38px, 6vw, 64px);
  margin-bottom: 6px;
}

.account-subtitle {
  color: var(--dim);
  font-size: 16px;
  margin: 0;
}

.identity-card {
  background: var(--ink-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 8px 24px;
}

.identity-card > div {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-light);
}

.identity-card > div:last-child {
  border-bottom: 0;
}

.identity-card span {
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.display-name-editor {
  display: flex;
  align-items: center;
  gap: 12px;
}

.code-badge {
  font-family: monospace;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line-light);
  word-break: break-all;
}

.status-active {
  color: #34d399;
}

.inline-edit-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

/* Launchpad */
.launchpad {
  background: var(--ink-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.launchpad-header h2 {
  font-size: clamp(24px, 4vw, 36px);
  margin-bottom: 18px;
}

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

.launch-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(5, 21, 32, 0.6);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.launch-card:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  background: rgba(120, 208, 210, 0.08);
}

.primary-launch {
  border-color: rgba(120, 208, 210, 0.4);
}

.card-icon {
  font-size: 28px;
  line-height: 1;
}

.card-info h3 {
  font-size: 20px;
  margin-bottom: 4px;
  color: var(--paper);
}

.card-info p {
  color: var(--dim);
  font-size: 13px;
  margin: 0;
  line-height: 1.4;
}

/* Devices Accordion */
.devices-accordion {
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.devices-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.devices-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.devices-panel {
  padding: 20px;
  border-top: 1px solid var(--line-light);
}

.device-form {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.device-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.device-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-light);
  font-size: 14px;
}

.device-list li:last-child {
  border-bottom: 0;
}

.device-list strong {
  display: block;
}

.device-list span {
  color: var(--dim);
  font-size: 12px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 8px;
}

/* Ecosystem Boundary Section */
.boundary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.3fr);
  gap: 40px;
  padding: 36px 0;
  border-top: 1px solid var(--line-light);
}

.boundary h2 {
  font-size: clamp(26px, 4vw, 42px);
  margin-bottom: 0;
}

.boundary ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.boundary li {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-light);
  font-size: 14px;
}

.boundary li span {
  color: var(--dim);
}

/* Footer */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--line-light);
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.feedback {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: #092031;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(10px);
}

.feedback.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Consent Shell (for /oauth/authorize) */
.consent-shell { grid-template-rows: auto 1fr auto; }
.consent { width: min(100%, 760px); align-self: center; padding: 60px 0; }
.consent h1 { font-size: clamp(40px, 6vw, 80px); }
.consent h1 span { color: var(--cyan); }
.scope-card { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 16px; }
.scope-card > p { margin: 0 0 10px; color: var(--dim); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.scope-card ul { margin: 0; padding: 0; list-style: none; }
.scope-card li { padding: 10px 0; border-bottom: 1px solid var(--line-light); font-size: 14px; }
.consent-actions { display: flex; align-items: center; gap: 16px; margin-top: 24px; }

/* Demo App Styles (demo.html) */
.demo-body { background: #e7e4db; color: #101211; }
.demo-shell { min-height: 100svh; padding: 24px clamp(24px, 5vw, 76px) 20px; display: grid; grid-template-rows: auto 1fr auto auto; }
.demo-body .wordmark, .demo-body a { color: #101211; }
.demo-body .environment, .demo-body .notice, .demo-body footer { color: #5f625e; }
.demo-body .eyebrow, .demo-mark span { color: #425cff; }
.demo-hero, .demo-result { align-self: center; padding: 60px 0; }
.demo-hero h1 { margin-bottom: 20px; font-size: clamp(54px, 10vw, 130px); }
.demo-body .lede { color: #5f625e; }
.demo-body .primary-button, .demo-body .primary-action { border-color: #101211; background: #101211; color: #f4f2eb; }
.demo-result h2 { font-size: clamp(40px, 6vw, 80px); }
.demo-result dl { width: min(100%, 760px); margin: 30px 0 0; border-top: 1px solid #a7a79f; }
.demo-result dl div { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid #a7a79f; }
.demo-result dd { margin: 0; overflow-wrap: anywhere; }
.demo-body footer { border-color: #a7a79f; }

/* Responsive */
@media (max-width: 840px) {
  .wizard-hero {
    grid-template-columns: 1fr;
    padding: 20px 0;
  }
  .boundary {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .identity-card > div {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .device-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .shell {
    padding: 16px;
    gap: 32px;
  }
  .wizard-card {
    padding: 20px 16px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .account-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}
