/* Paper */
:root {
  color-scheme: light;
  --ground: #ececea;
  --surface: #fcfcfb;
  --ink: #1c1c1a;
  --muted: #575753;
  --amber: #985a0b;
  --terminal: #f5f5f4;
  --phone-screen: #dadad8;
  --phone-rim: #252526;
  --phone-edge: #545454;
  --wash-cool: #d8dede55;
  --wash-warm: #e5dfd67a;
  --wash-neutral: #cfcfcc48;
  --rule: color-mix(in srgb, var(--ink) 16%, transparent);
  --control: color-mix(in srgb, var(--ink) 6%, var(--ground));
  --control-hover: color-mix(in srgb, var(--ink) 11%, var(--ground));
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease: 180ms ease-out;
}

/* Graphite */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #111113;
  --surface: #1c1c1f;
  --ink: #ededef;
  --muted: #a2a2a8;
  --amber: #f1c177;
  --terminal: #161618;
  --phone-screen: #18181b;
  --phone-rim: #080809;
  --phone-edge: #4b4b50;
  --wash-cool: #23262d85;
  --wash-warm: #29262475;
  --wash-neutral: #32323660;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #111113;
    --surface: #1c1c1f;
    --ink: #ededef;
    --muted: #a2a2a8;
    --amber: #f1c177;
    --terminal: #161618;
    --phone-screen: #18181b;
    --phone-rim: #080809;
    --phone-edge: #4b4b50;
    --wash-cool: #23262d85;
    --wash-warm: #29262475;
    --wash-neutral: #32323660;
  }
}

* { box-sizing: border-box; }

html {
  scroll-padding-top: 80px;
  scrollbar-color: var(--muted) var(--ground);
}

body {
  margin: 0;
  background-color: var(--ground);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
  transition: background-color var(--ease), color var(--ease);
}

::selection { background: var(--ink); color: var(--ground); }

a {
  color: inherit;
  text-decoration-color: var(--muted);
  text-underline-offset: 0.2em;
}

a:hover { text-decoration-color: currentColor; }

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

button { font: inherit; }
button, summary { cursor: pointer; }

code {
  font-family: var(--mono);
  font-size: 0.87em;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 {
  line-height: 1.17;
  letter-spacing: -0.025em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-inline: 24px;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(18px);
  transition: background-color var(--ease);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1040px;
  min-height: 60px;
  margin-inline: auto;
}

.topbar a { text-decoration: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  font-size: 1.19rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand svg { width: 26px; height: 26px; }
.sparkle { fill: var(--amber); }

.nav-docs, .nav-github, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 14px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.nav-docs { color: var(--muted); }

.nav-github, .theme-toggle {
  border: 1px solid var(--rule);
  background: var(--control);
}

.theme-toggle {
  width: 44px;
  padding: 0;
}

.theme-toggle svg, .button svg { width: 16px; height: 16px; }

.sun, [data-theme="dark"] .moon { display: none; }
[data-theme="dark"] .sun { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .moon { display: none; }
  :root:not([data-theme="light"]) .sun { display: block; }
}

.nav-docs:hover,
.nav-docs[aria-current],
.nav-github:hover,
.theme-toggle:hover { background: var(--control-hover); color: var(--ink); }

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
  padding: clamp(56px, 8vh, 92px) 24px 64px;
  background-image:
    radial-gradient(ellipse at 50% 48%, var(--wash-cool), transparent 68%),
    radial-gradient(ellipse at 20% 75%, var(--wash-warm), transparent 66%),
    radial-gradient(ellipse at 85% 73%, var(--wash-neutral), transparent 60%);
  text-align: center;
}

.hero-copy { width: min(100%, 872px); }

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.06;
}

.hero-subtitle {
  max-width: 54ch;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.5;
  text-wrap: balance;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.prompt-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}

.prompt-bar code { font-size: 0.8125rem; }

.button {
  display: inline-flex;
  flex: none;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--control);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover { background: var(--control-hover); }

.primary {
  min-width: 149px;
  background: var(--ink);
  color: var(--ground);
}

.primary:hover { background: var(--muted); }

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(320px, 100%);
  aspect-ratio: 320 / 632;
  margin: 0;
  padding: 16px 9px 22px;
  border: 8px solid var(--phone-rim);
  border-radius: 50px;
  outline: 1px solid var(--phone-edge);
  outline-offset: -2px;
  background: var(--phone-screen);
  box-shadow: 0 14px 38px #0a0a0b30;
  font-variant-numeric: tabular-nums;
}

.phone::before {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 88px;
  height: 24px;
  border-radius: 999px;
  background: #090c10;
  transform: translateX(-50%);
  content: "";
}

.phone::after {
  width: 98px;
  height: 4px;
  margin: auto auto 0;
  border-radius: 999px;
  background: var(--rule);
  content: "";
}

.phone-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-inline: 13px;
  font-size: 0.8125rem;
  font-weight: 650;
}

.phone-installed {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
}

.update-alert {
  position: absolute;
  inset: 42% 9px auto;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
}

.alert-copy { padding: 16px 12px; }
.alert-copy p { margin: 0 0 2px; font-weight: 650; }
.alert-copy code { font-size: 0.75rem; color: var(--muted); }

.alert-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
}

.alert-actions > * { padding: 10px 6px; }
.alert-actions span { color: var(--muted); }
.alert-actions strong { border-left: 1px solid var(--rule); }

.overview {
  display: grid;
  gap: 88px;
  max-width: 920px;
  margin-inline: auto;
  padding: 24px 24px 88px;
}

.overview h2 {
  margin: 0 0 10px;
  font-size: clamp(1.625rem, 3.2vw, 2.25rem);
}

.overview p { margin: 0 0 24px; color: var(--muted); }
.overview section > a { display: inline-block; margin-top: 14px; font-size: 0.9375rem; }

.setup-list, pre {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--terminal);
}

.setup-list { padding-inline-start: 46px; }
.setup-list li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.8125rem; }

.channel-files { margin: 0; border-block: 1px solid var(--rule); }
.channel-files > div, .docs-index > div { padding: 12px 14px; }
.channel-files > div + div, .docs-index > div + div { border-top: 1px solid var(--rule); }

.channel-files > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 24px;
}

.channel-files dd, .docs-index dd { margin: 0; color: var(--muted); }

pre {
  max-width: 100%;
  white-space: break-spaces;
  overflow-wrap: anywhere;
  tab-size: 4;
  font: 0.875rem/1.6 var(--mono);
}

pre code { display: block; font-size: inherit; }
.syntax-keyword { font-weight: 700; }
.syntax-comment { color: var(--muted); }
.syntax-literal { color: var(--muted); font-style: italic; }

.docs {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  max-width: 960px;
  margin-inline: auto;
  padding: 38px 24px 88px;
}

.docs-sidebar { position: sticky; top: 84px; }

.chapter-links {
  display: grid;
  gap: 3px;
}

.chapter-links a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
  text-decoration: none;
}

.chapter-links a:hover, .chapter-links [aria-current] {
  background: var(--control-hover);
  color: var(--ink);
}

.chapter-links [aria-current] { font-weight: 650; }

.agent-index {
  display: block;
  margin-top: 18px;
  padding: 12px;
  border-top: 1px solid var(--rule);
  font: 0.8125rem/1.6 var(--mono);
}

.chapter-picker { display: none; }

.docs-article {
  min-width: 0;
  max-width: 68ch;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.docs-article h1 { margin: 0; font-size: clamp(2rem, 3.5vw, 2.625rem); }
.docs-article h2 { margin: 1.8em 0 0.55em; font-size: 1.625rem; }
.docs-article h3 { margin: 1.6em 0 0.5em; font-size: 1.25rem; }
.docs-article p, .docs-article ul, .docs-article ol { margin: 0 0 1em; }
.docs-article p, .docs-article li { text-wrap: pretty; }
.docs-article p, .docs-article ul, .docs-article ol { max-inline-size: 60ch; }
.docs-article h1 + p { margin-top: 1em; }

.chapter-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 22px;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

.chapter-actions .button { min-width: 100px; }
.docs-article pre, .table-scroll { margin: 1em 0 1.25em; }

.docs-article :not(pre) > code {
  padding: 0.1em 0.2em;
  border-radius: 4px;
  background: var(--terminal);
  box-decoration-break: clone;
}

.docs-article ul, .docs-article ol { padding-inline-start: 1.55em; }
.docs-article li + li { margin-top: 0.4em; }

.docs-article blockquote {
  margin: 1em 0;
  padding: 0.75em 1em;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}

.docs-article blockquote > :last-child { margin-bottom: 0; }

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

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

th { background: var(--surface); }
.align-center { text-align: center; }
.align-right { text-align: right; }

.docs-index { margin-block: 24px; border-block: 1px solid var(--rule); }
.docs-index dt { font-weight: 650; }

.site-footer {
  padding: 24px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  max-width: 1040px;
  margin-inline: auto;
}

.footer-inner p { margin: 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.copy-dialog {
  width: min(34rem, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}

.copy-dialog::backdrop { background: #090c1080; }
.copy-dialog h2 { margin: 0 0 12px; }

.copy-dialog textarea {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--rule);
  background: var(--terminal);
  color: var(--ink);
  font: 0.875rem/1.6 var(--mono);
  resize: vertical;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (width < 900px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 22px;
    padding: 16px 16px 64px;
  }

  .docs-sidebar { display: none; }

  .chapter-picker {
    display: block;
    width: min(100%, 68ch);
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: var(--surface);
  }

  .chapter-picker summary {
    min-height: 44px;
    padding: 10px 14px;
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chapter-picker .chapter-links { margin: 0 8px 8px; }
  .docs-article { width: 100%; }
}

@media (width < 600px) {
  .site-header { padding-inline: 16px; }
  .topbar { gap: 4px; }
  .brand { gap: 4px; }
  .nav-docs, .nav-github { padding-inline: 9px; }
  .hero { gap: 36px; padding: 34px 16px 48px; }
  .update-alert { inset-block-start: 40%; }
  .prompt-bar { padding-inline: 12px 8px; }
  .primary { min-width: 0; padding-inline: 12px; }
  .overview { gap: 64px; padding: 16px 16px 64px; }
  .channel-files > div { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  body, .site-header { transition: none; }
}
