@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap");

:root {
  --brand: #d90217;
  --brand-ink: #ffffff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #14171f;
  --muted: #5b6475;
  --border: #e3e7ee;
  --soft: #fdecee;
  --radius: 24px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12;
    --surface: #14171f;
    --text: #f2f4f8;
    --muted: #a3abba;
    --border: #262b35;
    --soft: #2a1114;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }

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

.bar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font: 800 22px/1 "Fraunces", Georgia, serif;
  margin-right: auto;
}

.brand img { width: 34px; height: 34px; border-radius: 9px; }

nav.links { display: flex; gap: 4px; flex-wrap: wrap; }

nav.links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 999px;
}

nav.links a:hover { color: var(--text); background: var(--surface); }
nav.links a[aria-current="page"] { color: var(--brand); background: var(--soft); }

.hero {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 16px 8px;
}

.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; line-height: 1.15; letter-spacing: -0.01em; }

h1 { font-size: clamp(34px, 6vw, 52px); font-weight: 800; margin: 0 0 12px; }

.lede { color: var(--muted); font-size: 19px; max-width: 680px; margin: 0; }

.meta { color: var(--muted); font-size: 14px; margin-top: 16px; }

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.layout.single { grid-template-columns: minmax(0, 760px); justify-content: start; }

aside.toc {
  position: sticky;
  top: 88px;
  font-size: 14px;
}

aside.toc p { font-weight: 700; margin: 0 0 8px; }
aside.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
aside.toc a { display: block; padding: 5px 0 5px 14px; color: var(--muted); text-decoration: none; margin-left: -2px; border-left: 2px solid transparent; }
aside.toc a:hover { color: var(--text); border-left-color: var(--brand); }

article { min-width: 0; }

article section { scroll-margin-top: 96px; }

article h2 { font-size: 28px; margin: 40px 0 12px; }
article section:first-child h2 { margin-top: 0; }
article h3 { font-size: 20px; margin: 24px 0 8px; }
article ul, article ol { padding-left: 22px; }
article li { margin: 6px 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 16px 0;
}

.callout { background: var(--soft); border-color: transparent; }
.callout strong { color: var(--brand); }

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

.grid .card { margin: 0; }
.grid .card h3 { margin-top: 0; }

.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; background: var(--surface); }
th, td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { font-weight: 700; background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
tr:last-child td { border-bottom: 0; }

.button {
  display: inline-block;
  background: var(--brand);
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 999px;
  margin: 8px 8px 0 0;
}

.button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.button:hover { filter: brightness(1.05); text-decoration: none; }

.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 48px; margin: 16px 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 15px;
}

details { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 4px 18px; margin: 10px 0; }
details summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 24px 0; }
.app-card { display: flex; gap: 14px; align-items: center; }
.app-card .dot { width: 46px; height: 46px; border-radius: 12px; flex: none; display: grid; place-items: center; font: 800 22px/1 "Fraunces", serif; }
.app-card h3 { margin: 0; font-size: 18px; }
.app-card p { margin: 2px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

footer.site { border-top: 1px solid var(--border); }
footer.site .bar { color: var(--muted); font-size: 14px; padding-top: 24px; padding-bottom: 32px; }
footer.site a { color: var(--muted); }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  aside.toc { position: static; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
  .hero { padding-top: 32px; }
  body { font-size: 16px; }
}

@media print {
  header.site, aside.toc, footer.site { display: none; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
}

/* Interactive layer */
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #14171f;
  --text: #f2f4f8;
  --muted: #a3abba;
  --border: #262b35;
  --soft: #2a1114;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.theme-toggle, .chip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
}
.theme-toggle:hover, .chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 20; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--brand); transform: scaleX(0); transform-origin: left; }

aside.toc a[aria-current="true"] { color: var(--brand); border-left-color: var(--brand); font-weight: 700; }

.anchor {
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 0.7em "DM Sans", sans-serif;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
h2:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--brand); background: var(--soft); }
@media (hover: none) { .anchor { opacity: 0.6; } }

.to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 15;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { border-color: var(--brand); color: var(--brand); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.search, .field input, .field select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  font: inherit;
  min-height: 48px;
}
.search { flex: 1 1 260px; border-radius: 999px; }
.search:focus, .field input:focus, .field select:focus { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.search-count { color: var(--muted); font-size: 14px; min-height: 22px; margin: 0 0 8px; }

.filter-label { color: var(--muted); font-size: 14px; margin: 16px 0 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.request-form { display: grid; gap: 14px; }
.request-form h3 { margin: 0; }
.request-form .button { border: 0; margin: 4px 0 0; justify-self: start; }
.field { display: grid; gap: 6px; font-weight: 500; }
.field span { font-size: 15px; }
.form-note { color: var(--muted); font-size: 14px; margin: 0; }

a.card { transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; display: block; }
a.card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12); }

details summary { transition: color 0.15s; }
details summary:hover { color: var(--brand); }

.theme-toggle { order: 2; }
nav.links { order: 3; }

@media (max-width: 820px) {
  header.site { position: static; }
  nav.links { flex-basis: 100%; }
  nav.links a { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .progress, .to-top, .toast, .theme-toggle, .anchor, .tools, .chips, .filter-label, .request-form { display: none !important; }
}
