/* t3codedocs.com — single stylesheet, no framework */

:root {
  --bg: #0b0b10;
  --bg-soft: #12121a;
  --bg-card: #16161f;
  --line: #262633;
  --line-soft: #1e1e29;
  --text: #e6e6ef;
  --muted: #9a9ab0;
  --dim: #6e6e85;
  --accent: #a970ff;
  --accent-2: #6c5cff;
  --accent-soft: rgba(169, 112, 255, 0.14);
  --green: #45d483;
  --amber: #ffbe4d;
  --red: #ff6b6b;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-soft: #f7f7fb;
    --bg-card: #fbfbfe;
    --line: #e3e3ee;
    --line-soft: #ececf4;
    --text: #16161f;
    --muted: #5a5a70;
    --dim: #85859b;
    --accent: #6d3fd4;
    --accent-2: #5a3fd4;
    --accent-soft: rgba(109, 63, 212, 0.09);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.68 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: #fff; padding: 10px 16px; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- banner + header ---------- */

.banner {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #fff; text-align: center; font-size: 13px; padding: 7px 16px;
}
.banner a { color: #fff; text-decoration: underline; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff; font-weight: 800; font-size: 14px;
  display: grid; place-items: center; letter-spacing: -0.5px;
}
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-size: 11px; color: var(--dim); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.search-wrap { position: relative; display: block; }
#search {
  width: 260px; padding: 8px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text); font: inherit; font-size: 14px;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

#results {
  position: absolute; top: calc(100% + 8px); right: 0; width: 420px; max-width: 88vw;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4); overflow: hidden; display: none; z-index: 60;
  max-height: 60vh; overflow-y: auto;
}
#results.open { display: block; }
#results a { display: block; padding: 11px 15px; border-bottom: 1px solid var(--line-soft); color: var(--text); }
#results a:last-child { border-bottom: 0; }
#results a:hover, #results a.sel { background: var(--accent-soft); text-decoration: none; }
#results b { display: block; font-size: 14px; }
#results span { display: block; font-size: 12.5px; color: var(--muted); }
#results .empty { padding: 14px 15px; color: var(--muted); font-size: 14px; }

.ghost {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; color: var(--text);
}
.ghost:hover { border-color: var(--accent); text-decoration: none; }

.menu-toggle {
  display: none; margin-left: auto; padding: 8px 13px; font: inherit; font-size: 14px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}

/* ---------- layout ---------- */

.shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr) 220px;
  gap: 40px;
  max-width: 1340px; margin: 0 auto; padding: 30px 28px 70px;
  align-items: start;
}

.sidebar {
  position: sticky; top: 82px; max-height: calc(100vh - 100px);
  overflow-y: auto; padding-right: 8px; font-size: 14px;
}
.nav-group { margin-bottom: 22px; }
.nav-title {
  margin: 0 0 7px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.sidebar li a {
  display: block; padding: 5px 12px; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--muted); line-height: 1.45;
}
.sidebar li a:hover { color: var(--text); text-decoration: none; }
.sidebar li a.active {
  color: var(--accent); border-left-color: var(--accent);
  background: var(--accent-soft); font-weight: 600;
}

.toc {
  position: sticky; top: 82px; font-size: 13px;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.toc-title {
  margin: 0 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 12px; color: var(--muted); border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc .toc-l3 a { padding-left: 24px; font-size: 12.5px; }

/* ---------- prose ---------- */

.crumbs { font-size: 13px; color: var(--dim); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-hidden] { margin: 0 6px; }

.prose { max-width: 760px; }
.prose h1 { font-size: 2.35rem; line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.022em; }
.lede { font-size: 1.09rem; color: var(--muted); margin: 0 0 10px; }
.meta { font-size: 12.5px; color: var(--dim); margin: 0 0 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }

.prose h2 {
  font-size: 1.55rem; margin: 46px 0 14px; letter-spacing: -0.015em;
  scroll-margin-top: 90px;
}
.prose h3 { font-size: 1.19rem; margin: 32px 0 10px; scroll-margin-top: 90px; }
.prose h4 { font-size: 1.02rem; margin: 24px 0 8px; color: var(--muted); scroll-margin-top: 90px; }

.anchor { margin-left: 8px; color: var(--line); opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; color: var(--accent); }

.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose li::marker { color: var(--accent); }

.prose code {
  font: 0.875em var(--mono); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 5px; padding: 1.5px 5px;
}

.code-block { position: relative; margin: 0 0 20px; }
.code-block pre {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
}
.code-block pre code {
  background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6; color: var(--text);
}
.code-lang {
  position: absolute; top: 9px; right: 66px; font: 11px var(--mono);
  color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em;
}
.code-block .copy {
  position: absolute; top: 7px; right: 8px; padding: 4px 10px;
  font: 11.5px var(--sans); background: var(--bg-card); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.code-block:hover .copy, .code-block .copy:focus { opacity: 1; }
.code-block .copy:hover { color: var(--accent); border-color: var(--accent); }

blockquote {
  margin: 0 0 18px; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent); color: var(--muted);
}
blockquote p { margin: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 38px 0; }

.table-wrap { overflow-x: auto; margin: 0 0 22px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tbody tr:hover { background: var(--bg-soft); }

.callout {
  margin: 0 0 20px; padding: 14px 17px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--bg-soft);
}
.callout p:last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 5px; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.callout-warn { border-left-color: var(--amber); }
.callout-warn .callout-title { color: var(--amber); }
.callout-tip { border-left-color: var(--green); }
.callout-tip .callout-title { color: var(--green); }
.callout-danger { border-left-color: var(--red); }
.callout-danger .callout-title { color: var(--red); }

/* ---------- cards / home ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 13px; margin: 0 0 24px; }
.card {
  display: block; padding: 15px 17px; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card b { display: block; margin-bottom: 4px; font-size: 15px; }
.card span { display: block; font-size: 13.2px; color: var(--muted); line-height: 1.5; }

.related { margin-top: 52px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line); background: var(--bg-soft);
  padding: 34px 28px; font-size: 13.5px; color: var(--muted);
}
.site-footer > div { max-width: 1340px; margin: 0 auto; }
.site-footer p { margin: 0 0 10px; }
.site-footer .fine { font-size: 12.5px; color: var(--dim); }
.foot-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .shell { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .site-header { flex-wrap: wrap; padding: 12px 18px; gap: 12px; }
  .menu-toggle { display: block; }
  .header-right { width: 100%; margin-left: 0; order: 3; }
  #search { width: 100%; }
  .search-wrap { flex: 1; }
  #results { right: auto; left: 0; width: 100%; }
  .shell { grid-template-columns: minmax(0, 1fr); padding: 22px 18px 60px; gap: 0; }
  .sidebar {
    display: none; position: static; max-height: none;
    margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line);
  }
  .sidebar.open { display: block; }
  .prose h1 { font-size: 1.85rem; }
}
