:root {
  --font-sans: "Geist Variable", "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --background: oklch(0.99 0.002 95);
  --foreground: oklch(0.13 0 0);
  --card: oklch(1 0 0);
  --primary: oklch(0.580 0.172 253.7);
  --primary-foreground: oklch(0.99 0 0);
  --muted: oklch(0.96 0 0);
  --muted-foreground: oklch(0.50 0 0);
  --destructive: oklch(0.55 0.20 27);
  --destructive-foreground: oklch(0.99 0 0);
  --border: oklch(0.94 0 0);
  --input: oklch(0.91 0 0);
  --success: oklch(0.52 0.15 150);
  --warning: oklch(0.62 0.15 70);
  --human: oklch(0.52 0.09 45);
  --human-wash: oklch(0.52 0.09 45 / 0.07);
  --radius: 0.5rem;
  color-scheme: light;
}

html[data-theme="dark"] {
  --background: oklch(0.16 0.005 260);
  --foreground: oklch(0.985 0.004 85);
  --card: oklch(0.205 0.006 260);
  --primary: oklch(0.68 0.15 253.7);
  --primary-foreground: oklch(0.11 0.008 260);
  --muted: oklch(0.25 0.007 260);
  --muted-foreground: oklch(0.72 0.01 260);
  --destructive: oklch(0.70 0.18 27);
  --destructive-foreground: oklch(0.11 0.008 260);
  --border: oklch(1 0 0 / 0.12);
  --input: oklch(1 0 0 / 0.18);
  --success: oklch(0.70 0.14 150);
  --warning: oklch(0.78 0.13 78);
  --human: oklch(0.68 0.10 45);
  --human-wash: oklch(0.68 0.10 45 / 0.14);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --background: oklch(0.16 0.005 260);
    --foreground: oklch(0.985 0.004 85);
    --card: oklch(0.205 0.006 260);
    --primary: oklch(0.68 0.15 253.7);
    --primary-foreground: oklch(0.11 0.008 260);
    --muted: oklch(0.25 0.007 260);
    --muted-foreground: oklch(0.72 0.01 260);
    --destructive: oklch(0.70 0.18 27);
    --destructive-foreground: oklch(0.11 0.008 260);
    --border: oklch(1 0 0 / 0.12);
    --input: oklch(1 0 0 / 0.18);
    --success: oklch(0.70 0.14 150);
    --warning: oklch(0.78 0.13 78);
    --human: oklch(0.68 0.10 45);
    --human-wash: oklch(0.68 0.10 45 / 0.14);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, oklch(0.52 0.09 45 / 0.06), transparent 28rem),
    linear-gradient(180deg, oklch(1 0 0) 0%, var(--background) 14rem);
  color: var(--foreground);
  font-family: var(--font-sans);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, oklch(0.68 0.10 45 / 0.12), transparent 28rem),
    linear-gradient(180deg, oklch(0.22 0.006 260) 0%, var(--background) 14rem);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] body {
    background:
      radial-gradient(circle at top left, oklch(0.68 0.10 45 / 0.12), transparent 28rem),
      linear-gradient(180deg, oklch(0.22 0.006 260) 0%, var(--background) 14rem);
  }
}

a { color: inherit; }
code, pre, kbd, samp { font-family: var(--font-mono); }

/* ─── PDPP type scale (subset) ──────────────────────────────────────── */
.pdpp-display {
  font-size: 2.5rem; font-weight: 600; line-height: 1.08; letter-spacing: -0.025em;
}
.pdpp-heading {
  font-size: 1.25rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em;
}
.pdpp-title {
  font-size: 0.875rem; font-weight: 600; line-height: 1.4;
}
.pdpp-body-lg {
  font-size: 1.0625rem; font-weight: 400; line-height: 1.6;
}
.pdpp-body {
  font-size: 0.9375rem; font-weight: 400; line-height: 1.6;
}
.pdpp-label {
  font-size: 0.75rem; font-weight: 500; line-height: 1.4;
}
.pdpp-caption {
  font-size: 0.75rem; font-weight: 400; line-height: 1.5;
  color: var(--muted-foreground);
}
.pdpp-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* ─── Semantic surfaces (match base.css) ────────────────────────────── */
[data-surface="human"] {
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: 2px solid var(--human);
  background-image: linear-gradient(to bottom, var(--human-wash), transparent 35%);
  background-color: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.02);
  border-radius: 0.75rem;
}

[data-surface="protocol"] {
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: 2px solid var(--primary);
  background-image: linear-gradient(to right, oklch(0.580 0.172 253.7 / 0.04), transparent 70%);
  background-color: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.02);
  border-radius: 0.75rem;
}

/* ─── Hosted-ui layout ──────────────────────────────────────────────── */
.hosted-ui-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hosted-ui-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.25rem;
}

.hosted-ui-wordmark {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

.hosted-ui-provider {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.hosted-ui-mark { display: block; }

.hosted-ui-intro {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.hosted-ui-intro .pdpp-body-lg {
  color: var(--muted-foreground);
  max-width: 50ch;
}

.hosted-ui-surface {
  padding: 1.25rem 1.25rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hosted-ui-surface > * + * { margin-top: 0; }

.hosted-ui-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.375rem 1rem;
  margin: 0;
  padding: 0;
}
.hosted-ui-kv dt {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
}
.hosted-ui-kv dd {
  font-size: 0.875rem;
  margin: 0;
  color: var(--foreground);
  word-break: break-word;
}
.hosted-ui-kv code {
  font-size: 0.8125rem;
  color: var(--foreground);
}

.hosted-ui-streams {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.hosted-ui-streams li {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}
.hosted-ui-streams .hosted-ui-stream-name {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--foreground);
}
.hosted-ui-streams .hosted-ui-stream-meta {
  color: var(--muted-foreground);
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.hosted-ui-option-group {
  display: grid;
  gap: 0.625rem;
  margin: 0 0 1rem;
}

.hosted-ui-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: var(--card);
  cursor: pointer;
}

.hosted-ui-option:hover {
  background: var(--muted);
}

.hosted-ui-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.hosted-ui-option input {
  margin: 0.2rem 0 0;
  accent-color: var(--primary);
}

.hosted-ui-option-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hosted-ui-option-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--foreground);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.35rem;
}

.hosted-ui-connector-type {
  color: var(--foreground);
}

.hosted-ui-connection-name {
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.hosted-ui-connection-name::before {
  content: '·';
  margin-right: 0.35rem;
  color: var(--muted-foreground);
}

.hosted-ui-option-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}

.hosted-ui-option-source {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.25rem 0.75rem 0.75rem;
  margin: 0;
  background: var(--card);
}
.hosted-ui-option-source-legend {
  padding: 0 0.25rem;
  display: block;
  width: 100%;
}
.hosted-ui-option-source-legend .hosted-ui-option {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.5rem 0.25rem;
  margin: 0;
}
.hosted-ui-option-source-legend .hosted-ui-option:hover {
  background: transparent;
}
.hosted-ui-option-source-legend .hosted-ui-option:has(input:checked) {
  border: none;
  box-shadow: none;
}

.hosted-ui-option-streams {
  display: grid;
  gap: 0.375rem;
  padding: 0.5rem 0.25rem 0.25rem 1.75rem;
  border-top: 1px dashed var(--border);
}

.hosted-ui-option-streams-empty {
  margin: 0.5rem 0 0;
  padding: 0 0.25rem 0.25rem 1.75rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.hosted-ui-stream-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.625rem;
  align-items: start;
  font-size: 0.8125rem;
  padding: 0.25rem 0;
  cursor: pointer;
}
.hosted-ui-stream-option input {
  margin: 0.2rem 0 0;
  accent-color: var(--primary);
}
.hosted-ui-stream-option-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.hosted-ui-access-mode {
  display: grid;
  gap: 0.375rem;
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
}
.hosted-ui-access-mode-legend {
  padding: 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.hosted-ui-access-mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.625rem;
  align-items: start;
  padding: 0.375rem 0.25rem;
  cursor: pointer;
  font-size: 0.8125rem;
}
.hosted-ui-access-mode-option input {
  margin: 0.2rem 0 0;
  accent-color: var(--primary);
}
.hosted-ui-access-mode-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.hosted-ui-access-mode-label {
  font-weight: 600;
  color: var(--foreground);
}
.hosted-ui-access-mode-meta {
  color: var(--muted-foreground);
}

.hosted-ui-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.hosted-ui-button {
  appearance: none;
  border-radius: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  transition: background-color 150ms, border-color 150ms;
}
.hosted-ui-button:hover { background: var(--muted); }
.hosted-ui-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.hosted-ui-button[data-variant="primary"] {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}
.hosted-ui-button[data-variant="primary"]:hover {
  background: oklch(0.52 0.172 253.7);
}
.hosted-ui-button[data-variant="danger"] {
  color: var(--destructive);
  border-color: var(--border);
}
.hosted-ui-button[data-variant="danger"]:hover {
  background: oklch(0.55 0.20 27 / 0.08);
}

.hosted-ui-form { display: contents; }

.hosted-ui-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.hosted-ui-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
}
.hosted-ui-field input {
  font: inherit;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--input);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--foreground);
}
.hosted-ui-field input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.hosted-ui-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--primary);
}

.hosted-ui-error {
  border: 1px solid oklch(0.55 0.20 27 / 0.25);
  background: oklch(0.55 0.20 27 / 0.06);
  color: var(--destructive);
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.hosted-ui-warning {
  border: 1px solid oklch(0.78 0.16 78 / 0.45);
  background: oklch(0.78 0.16 78 / 0.08);
  color: var(--foreground);
  padding: 0.75rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.hosted-ui-warning-title {
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: oklch(0.45 0.12 60);
}
.hosted-ui-warning-body {
  color: var(--foreground);
}

.hosted-ui-result {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}
.hosted-ui-result-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}
.hosted-ui-result-mark[data-tone="success"] {
  background: oklch(0.52 0.15 150 / 0.14);
  color: var(--success);
}
.hosted-ui-result-mark[data-tone="neutral"] {
  background: var(--muted);
  color: var(--muted-foreground);
}
.hosted-ui-result-mark[data-tone="danger"] {
  background: oklch(0.55 0.20 27 / 0.12);
  color: var(--destructive);
}
.hosted-ui-result-body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.hosted-ui-footnote {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}
