:root {
  --guide-muted: #4f6172;
  --guide-paper: #f6f8fa;
  --guide-accent: #a84808;
}

.guide-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  width: min(1240px, 94%);
  padding: clamp(1.5rem, 5vw, 4rem) 0 5rem;
  min-height: 72vh;
}

.guide-main { min-width: 0; }
.guide-main:focus { outline-offset: 5px; }

.guide-sidebar-wide {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 0 .65rem .5rem 0;
  border-right: 1px solid var(--line);
}

.guide-sidebar-small { display: none; }
.guide-nav, .guide-toc { display: block; }
.guide-nav ul, .guide-toc ul, .guide-catalog ul { list-style: none; padding: 0; margin: 0; }
.guide-nav p, .guide-toc p { margin: 1.2rem 0 .35rem; font-size: .75rem; font-weight: 700; color: var(--guide-muted); }
.guide-nav > a { font-weight: 700; }
.guide-nav a, .guide-toc a {
  display: block;
  padding: .36rem .6rem;
  line-height: 1.4;
  font-size: .83rem;
  border: 0;
  border-radius: .2rem;
}

.guide-nav a:hover, .guide-toc a:hover { background: var(--guide-paper); text-decoration: underline; }
.guide-nav a[aria-current], .guide-toc a[aria-current] {
  color: #8c3700;
  background: #fff1e5;
  box-shadow: inset 3px 0 var(--orange);
  font-weight: 700;
}

.guide-heading { padding: 0 0 1.5rem; border-bottom: 1px solid var(--line); }
.guide-heading > a { display: inline-block; margin-bottom: .5rem; font-size: .88rem; }
.guide-heading h1 {
  max-width: 26ch;
  font-size: clamp(2rem, 4.8vw, 3.5rem);
  font-weight: 650;
  letter-spacing: -.048em;
  overflow-wrap: anywhere;
}

.guide-heading p { max-width: 56ch; margin-top: .7rem; color: var(--guide-muted); }
.guide-reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9.5rem, 12rem);
  gap: clamp(1.2rem, 3vw, 2.6rem);
  align-items: start;
}

.guide-reading > article {
  grid-area: 1 / 1;
  width: 100%;
  min-width: 0;
  max-width: 76ch;
  margin: 0;
  padding: .55rem 0 0;
  overflow-wrap: break-word;
}

.guide-reading > article h2 { font-size: clamp(1.35rem, 2.3vw, 1.75rem); font-weight: 650; margin: 2rem 0 .7rem; }
.guide-reading > article h2:first-child { margin-top: 1.35rem; }
.guide-reading > article h3 { font-size: 1.17rem; font-weight: 650; margin-top: 1.55rem; }
.guide-reading > article :is(h2, h3, h4, h5, h6)[id] { scroll-margin-top: 1.25rem; }
.guide-reading > article :target { text-decoration: underline; text-decoration-color: #e7a267; text-underline-offset: .28em; }
.guide-reading > article ul, .guide-reading > article ol { padding-left: 1.3rem; }
.guide-reading > article li + li { margin-top: .35rem; }
.guide-reading > article blockquote { margin: 1rem 0; padding: .15rem .9rem; border-left: 3px solid var(--orange); background: #fff5eb; }
.guide-reading > article :not(pre) > code { background: #edf3f8; padding: .08em .24em; border-radius: .17rem; }

.guide-toc {
  grid-area: 1 / 2;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  margin-top: 1.1rem;
  overflow: auto;
  padding-left: .7rem;
  border-left: 1px solid var(--line);
}

.guide-toc p { margin: 0 0 .4rem .6rem; }
.guide-toc .heading-level-3 { margin-left: .7rem; }

.guide-code { margin: 1.15rem 0; border: 1px solid #293e53; border-radius: .35rem; background: #122940; color: #edf4fa; }
.guide-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  padding: .38rem .55rem .38rem .95rem;
  color: #c0d3e4;
  border-bottom: 1px solid #3a5268;
  font: 500 .76rem/1.4 Plex, monospace;
}

.guide-code [data-copy] {
  min-width: 3.4rem;
  padding: .28rem .65rem;
  border: 1px solid #738da2;
  border-radius: .23rem;
  background: transparent;
  color: #f3f7fb;
  font-size: .75rem;
}

.guide-code [data-copy][hidden] { display: none; }
.guide-code [data-copy]:hover { background: #304c65; }
.guide-copy-status { margin-left: auto; color: #ffe0bd; text-align: right; }
.guide-code pre { margin: 0; padding: .85rem .95rem 1rem; border: 0; background: transparent; color: inherit; font-size: .82rem; line-height: 1.65; }
.guide-code code { font-size: inherit; overflow-wrap: normal; }
.guide-table { margin: 1.2rem 0; overflow: auto; border: 1px solid var(--line); border-radius: .3rem; }
.guide-table table { min-width: 29rem; }
.guide-table th { background: #e9f0f6; }
.guide-table :is(th, td) { padding: .65rem .75rem; font-family: inherit; font-size: .88rem; }
.guide-table tr:last-child td { border: 0; }
.guide-table tbody tr:nth-child(even) { background: #f8fafc; }
.guide-table .guide-align-center { text-align: center; }
.guide-table .guide-align-right { text-align: right; }

.guide-catalog { grid-column: 1 / -1; margin-top: 1.15rem; }
.guide-search { margin-bottom: 1.3rem; max-width: 31rem; }
.guide-search label { display: block; margin-bottom: .35rem; font-size: .88rem; font-weight: 700; }
.guide-search input { border-color: #9aaebd; border-radius: .27rem; }
.guide-search p { color: var(--guide-muted); margin: .55rem 0 0; font-size: .85rem; }
.guide-search p:empty { display: none; }
.guide-catalog [hidden] { display: none; }
.guide-catalog section + section { margin-top: 1.9rem; }
.guide-catalog h2 { margin-bottom: .7rem; font-size: 1.2rem; font-weight: 680; }
.guide-catalog ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .6rem; }
.guide-catalog a {
  display: block;
  height: 100%;
  padding: .75rem .8rem;
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: .25rem;
  background: #fbfcfd;
}

.guide-catalog a:hover { border-color: var(--guide-accent); }
.guide-catalog a:hover strong { text-decoration: underline; }
.guide-catalog strong { display: block; color: var(--blue); font-weight: 700; line-height: 1.35; }
.guide-description { display: block; margin-top: .22rem; color: var(--guide-muted); font-size: .85rem; line-height: 1.5; }

@media (min-width: 1041px) {
  .guide-layout:has(.guide-catalog) .guide-heading { padding-right: 32%; }
}

@media (max-width: 1040px) {
  .guide-reading { display: block; }
  .guide-toc { position: static; max-height: none; margin: 1rem 0; padding: .75rem .5rem; border: 0; border-left: 3px solid #b7c9d7; background: var(--guide-paper); }
  .guide-toc ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
  .guide-toc .heading-level-3 { margin: 0; }
}

@media (max-width: 700px) {
  .guide-layout { display: block; width: min(94%, 32rem); padding-top: .9rem; }
  .guide-sidebar-wide { display: none; }
  .guide-sidebar-small { display: block; padding: .55rem .65rem; margin: 0 0 1.15rem; background: var(--guide-paper); border: 1px solid var(--line); border-radius: .25rem; }
  .guide-sidebar-small summary { font-size: .88rem; font-weight: 700; }
  .guide-sidebar-small .guide-nav { margin: .55rem 0 .25rem; }
  .guide-reading > article { padding-top: 0; }
}

@media print {
  .guide-layout, .guide-reading { display: block; padding: 0; }
  .guide-sidebar, .guide-toc, .guide-code [data-copy], .guide-search { display: none; }
  .guide-reading > article { max-width: none; }
  .guide-code { color: var(--ink); background: white; }
  .guide-code-bar { color: var(--ink); }
  .guide-code pre { white-space: pre-wrap; }
}
