:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #0a0b0d;
  --text-secondary: #33373f;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-soft: #fef3c7;
  --accent-contrast: #1a1200;
  --code-bg: #0f1115;
  --code-text: #e8eaed;
  --status-idle: #9aa2ad;
  --status-ok: #16a34a;
  --status-err: #dc2626;
  --shadow: 0 1px 2px rgba(20, 22, 26, 0.06), 0 8px 24px rgba(20, 22, 26, 0.05);
  --radius: 10px;
  --max-width: 1080px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --bg-alt: #111418;
    --surface: #14171c;
    --border: #262b33;
    --text: #fbfbfc;
    --text-secondary: #d3d7dd;
    --accent: #f5a524;
    --accent-strong: #ffb84d;
    --accent-soft: rgba(245, 165, 36, 0.14);
    --accent-contrast: #1a1200;
    --code-bg: #0b0d10;
    --code-text: #e8eaed;
    --status-idle: #6b7280;
    --status-ok: #22c55e;
    --status-err: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  line-height: 1.2;
  font-weight: 700;
}

section[id] {
  scroll-margin-top: 84px;
}

a {
  color: var(--accent-strong);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  gap: 28px;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--text);
}

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle span {
  top: 17px;
}

.nav-toggle span::before {
  top: -6px;
}

.nav-toggle span::after {
  top: 6px;
}

.site-header.nav-open .nav-toggle span {
  background: transparent;
}

.site-header.nav-open .nav-toggle span::before {
  transform: translateY(6px) rotate(45deg);
}

.site-header.nav-open .nav-toggle span::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* Hero */

.hero {
  padding: 88px 0 64px;
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 24px;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}

.hero .lead {
  max-width: 620px;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 1.15rem;
}

.hero-actions {
  margin-top: 32px;
  display: flex;
  justify-content: center;
  gap: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.button-secondary:hover {
  border-color: var(--accent);
}

.button-sm {
  padding: 7px 14px;
  font-size: 0.88rem;
}

.button-secondary[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Sections */

.section {
  padding: 72px 0;
}

.section-alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 12px;
}

.section-flush {
  padding-top: 0;
}

.section-intro {
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 0 40px;
}

/* Pitch */

.pitch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.pitch-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.pitch-card h3 {
  font-size: 1.25rem;
  margin: 0 0 16px;
}

.pitch-card p {
  margin: 0 0 10px;
  color: var(--text-secondary);
}

.pitch-list {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.pitch-card .pitch-cmd {
  margin: 4px 0 16px;
}

.pitch-cmd code {
  font-size: 0.95rem;
}

.pitch-card .pitch-punch {
  margin: auto 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-weight: 600;
  color: var(--accent-strong);
}

/* Sequence diagram */

.diagram-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.diagram-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.lifeline {
  stroke: var(--border);
  stroke-width: 2;
  stroke-dasharray: 4 5;
}

.lifeline-label {
  fill: var(--text);
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
}

.msg-line {
  stroke: var(--accent-strong);
  stroke-width: 2;
  fill: none;
}

.msg-label {
  fill: var(--text-secondary);
  font-size: 12.5px;
  font-family: var(--font-mono);
}

.msg-arrowhead {
  fill: var(--accent-strong);
}

.activation {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.5;
}

/* Protocol table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  background: var(--bg-alt);
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Meaning column */
th:nth-child(4), td:nth-child(4) {
  min-width: 280px;
}

tbody tr:last-child td {
  border-bottom: none;
}

code {
  font-family: var(--font-mono);
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.88em;
}

.note {
  color: var(--text-secondary);
  margin-top: 20px;
  font-size: 0.95rem;
}

/* Tabs */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

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

.tab-panel p {
  color: var(--text-secondary);
}

.code-block {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 0 16px;
}

.code-block pre {
  margin: 0;
  padding: 20px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  font-size: 0.85rem;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.code-block .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #e8eaed;
  cursor: pointer;
}

.code-block .copy-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.code-block .file-label {
  position: absolute;
  top: 10px;
  left: 20px;
  font-size: 0.78rem;
  color: #9aa2ad;
  font-family: var(--font-mono);
}

.code-block .raw-link {
  position: absolute;
  top: 12px;
  right: 92px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #9aa2ad;
  text-decoration: none;
}

.code-block .raw-link:hover {
  color: #e8eaed;
}

.code-block pre {
  padding-top: 38px;
}

.example-note {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin: -6px 0 18px;
}

.example-steps {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin: -6px 0 18px;
  padding-left: 20px;
}

.example-steps li {
  margin: 2px 0;
}

/* Try it */

.try-uuid {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin-bottom: 24px;
}

.try-uuid label {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.try-uuid input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.try-uuid input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.try-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 16px;
}

.try-hint {
  margin: 0 0 40px;
  color: var(--text-secondary);
}

.term {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #9aa2ad;
}

.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--status-idle);
}

.term[data-state="connecting"] .term-dot {
  animation: term-blink 1s ease-in-out infinite;
}

.term[data-state="connected"] .term-dot {
  background: var(--status-ok);
}

.term[data-state="error"] .term-dot {
  background: var(--status-err);
}

@keyframes term-blink {
  50% { opacity: 0.3; }
}

.term-title {
  color: var(--code-text);
  font-weight: 600;
}

.term-status {
  margin-left: auto;
}

.term-log {
  margin: 0;
  padding: 14px;
  height: 200px;
  overflow: auto;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.term-out {
  color: #fbbf24;
}

.term-ready {
  color: #4ade80;
  font-weight: 600;
}

.term-meta {
  color: #9aa2ad;
}

.term-err {
  color: #f87171;
}

.term-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.try-nc-title {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.code-block-line pre {
  padding-right: 90px;
}

/* Contact */

.contact {
  text-align: center;
  border-bottom: none;
}

.contact-email {
  margin: 0;
  font-size: 1.15rem;
}

.contact-email a {
  color: var(--accent-strong);
  font-weight: 600;
}

/* Responsive */

@media (max-width: 760px) {
  .pitch-grid,
  .try-grid {
    grid-template-columns: 1fr;
  }

  .site-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    gap: 16px;
    display: none;
  }

  .site-header.nav-open .site-nav {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .hero {
    padding: 64px 0 48px;
  }

  /* Let the protocol table scroll edge-to-edge; the gutter shows only at the scroll ends */
  .table-wrap {
    margin: 0 -24px;
    padding: 0 24px;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  thead th:first-child {
    border-top-left-radius: calc(var(--radius) - 1px);
  }

  thead th:last-child {
    border-top-right-radius: calc(var(--radius) - 1px);
  }
}
