/*
 * The browser extension's design language (browser_extension/src/ui/ui.css) scaled up to a
 * full page: one ink, one paper, hairline rules, 1px black borders, pill chips, monospace for
 * anything a machine produced. Same tokens, same radii, same button shapes — deliberately no
 * accent colour, because the extension has none either.
 */

:root {
  --ink: #000;
  --paper: #fff;
  --muted: #666;
  --line: #e6e6e6;
  --wash: #fafafa;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --page: 1080px;
  --prose: 760px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  /* Anchored doc headings must clear the sticky header. */
  scroll-padding-top: 90px;
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

/* ---------- Layout ---------- */

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

.section {
  padding: 72px 0;
  border-top: 1px solid var(--line);
}

.section--flush {
  border-top: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack--lg {
  gap: 28px;
}

.stack--sm {
  gap: 8px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Header ---------- */

.hd {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}

.hd-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
}

.hd-logo {
  width: 26px;
  height: 26px;
  display: block;
  flex: 0 0 auto;
}

.hd-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.hd-spacer {
  flex: 1;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav a:hover {
  border-color: var(--line);
}

.nav a[aria-current="page"] {
  border-color: var(--ink);
}

/* ---------- Typography ---------- */

.hero-title {
  font-size: clamp(34px, 6vw, 60px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.04;
  max-width: 14ch;
}

h1 {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

p {
  font-size: 15px;
  line-height: 1.65;
}

.lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 62ch;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.prose {
  max-width: var(--prose);
}

.prose p + p {
  margin-top: 12px;
}

.prose ul,
.prose ol {
  margin: 4px 0 0 20px;
  font-size: 15px;
  line-height: 1.65;
}

.prose li + li {
  margin-top: 6px;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.5px 5px;
  word-break: break-word;
}

/* Inside a block, the <pre> already draws the frame — the inline chrome would box the
   first line only, since <code> is an inline box spanning every line. */
pre code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
  word-break: normal;
}

/* ---------- Pills & chips ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--paper);
  color: var(--ink);
  white-space: nowrap;
}

.pill--inverted {
  background: var(--ink);
  color: var(--paper);
}

.pill--muted {
  border-color: var(--line);
  color: var(--muted);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: #1f1f1f;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.btn--ghost {
  background: var(--paper);
  color: var(--ink);
}

.btn--ghost:hover {
  background: #f2f2f2;
}

.btn--sm {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */

.card {
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
}

.card--hair {
  border-color: var(--line);
}

.card--wash {
  background: var(--wash);
  border-color: var(--line);
}

.addr {
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  line-height: 1.5;
}

/* Inverted notice — the extension uses this shape for anything the user must not miss. */
.err {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 15px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  line-height: 1.45;
}

.err code {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  color: inherit;
}

.note {
  border: 1px solid var(--ink);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* ---------- Code blocks ---------- */

.code {
  position: relative;
  border: 1px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--wash);
}

.code-name {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.code pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
}

.code-copy {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.code-copy:hover {
  background: #f2f2f2;
}

/* ---------- Steps ---------- */

.steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.step-n {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex: 0 0 auto;
}

.step--done .step-n {
  background: var(--ink);
  color: var(--paper);
}

.step--idle .step-n {
  border-color: var(--line);
  color: var(--muted);
}

.step--idle .step-title {
  color: var(--muted);
}

.step-title {
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Key/value rows (ported from the approval window) ---------- */

.kv {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.kv:first-of-type {
  border-top: none;
}

.kv-k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  flex: 0 0 auto;
}

.kv-v {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  word-break: break-all;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 700;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  border: 1px solid var(--ink);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: var(--mono);
  background: var(--paper);
  color: var(--ink);
}

/* ---------- Tables ---------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 13.5px;
}

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

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
  background: var(--wash);
}

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

td code {
  white-space: nowrap;
}

/* ---------- Docs shell ---------- */

.docs {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  padding: 44px 0 96px;
}

.toc {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc a {
  text-decoration: none;
  font-size: 13.5px;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 8px;
  border-left: 2px solid var(--line);
}

.toc a:hover {
  color: var(--ink);
  background: var(--wash);
}

.doc-section {
  scroll-margin-top: 88px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--line);
}

.doc-section:last-child {
  border-bottom: none;
}

.doc-section + .doc-section {
  padding-top: 40px;
}

/* ---------- Footer ---------- */

.ft {
  border-top: 2px solid var(--ink);
  padding: 32px 0 44px;
}

.ft-inner {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.ft-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .toc a {
    border-left: none;
    border: 1px solid var(--line);
  }

  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .page {
    padding: 0 16px;
  }

  .section {
    padding: 48px 0;
  }

  .grid--2,
  .grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .hd-title {
    font-size: 15px;
  }

  .nav a {
    padding: 6px 10px;
    font-size: 13px;
  }

  .kv {
    flex-direction: column;
    gap: 3px;
  }

  .kv-v {
    text-align: left;
  }
}
