:root {
  --bg: #ffffff;
  --bg-soft: #f4f6f1;
  --bg-sunk: #eef1ea;
  --ink: #0e1424;
  --text: #3a4250;
  --muted: #5c6470;
  --line: #e3e7de;
  --line-strong: #cfd5c7;
  --link: #4e7a0c;
  --accent: #87be22;
  --accent-soft: #eef6df;
  --code-bg: #f4f6f1;
  --tip: #4e7a0c;      --tip-bg: #f1f7e6;
  --note: #2f5fb3;     --note-bg: #eef3fc;
  --warn: #9a5b00;     --warn-bg: #fdf4e3;
  --danger: #b3261e;   --danger-bg: #fcecea;
  --shadow: 0 1px 2px rgba(14,20,36,.06), 0 8px 24px rgba(14,20,36,.06);
  --top: 60px;
  --side: 280px;
  --tocw: 230px;
  --radius: 10px;
  --bezel: #0e1424;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111c; --bg-soft: #121a29; --bg-sunk: #172133; --ink: #f2f5ee; --text: #c6ccd6; --muted: #929aa8;
    --line: #222c3d; --line-strong: #2f3b50; --link: #a9d457; --accent: #a9d457; --accent-soft: #1d2a16; --code-bg: #141d2d;
    --tip: #a9d457; --tip-bg: #172313; --note: #8db4ff; --note-bg: #131f36; --warn: #f0b75a; --warn-bg: #2a2010; --danger: #ff8a80; --danger-bg: #2d1515;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3); --bezel: #3d4a60; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c111c; --bg-soft: #121a29; --bg-sunk: #172133; --ink: #f2f5ee; --text: #c6ccd6; --muted: #929aa8;
  --line: #222c3d; --line-strong: #2f3b50; --link: #a9d457; --accent: #a9d457; --accent-soft: #1d2a16; --code-bg: #141d2d;
  --tip: #a9d457; --tip-bg: #172313; --note: #8db4ff; --note-bg: #131f36; --warn: #f0b75a; --warn-bg: #2a2010; --danger: #ff8a80; --danger-bg: #2d1515;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3); --bezel: #3d4a60; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
img { max-width: 100%; height: auto; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
/* "Back to Themes Coder" chip: the TC icon in a dark circle; the name slides out on hover or focus */
.home-chip { display: inline-flex; align-items: center; flex-shrink: 0; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg-soft); color: var(--ink); text-decoration: none; transition: border-color .3s; }
.home-chip:hover, .home-chip:focus-visible { border-color: var(--accent); }
.home-chip-ico { display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: #0e1a14; box-shadow: 0 0 0 1px rgba(255,255,255,.1); transition: transform .5s; }
.home-chip-ico img { width: 15px; height: 15px; }
.home-chip-text { max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0; font-size: 13px; font-weight: 600; transition: max-width .45s, opacity .45s, margin .45s; }
.home-chip:hover .home-chip-ico { transform: rotate(-12deg); }
.home-chip:hover .home-chip-text, .home-chip:focus-visible .home-chip-text { max-width: 120px; opacity: 1; margin: 0 10px 0 8px; }
.brand-sep { width: 1px; height: 22px; flex-shrink: 0; background: var(--line-strong); }
@media (prefers-reduced-motion: reduce) { .home-chip-ico, .home-chip-text { transition: none; } }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
/* Imported guides hold long file paths and URLs without spaces. */
.chapter-body p, .chapter-body li, .chapter-body td, .chapter-body .callout { overflow-wrap: anywhere; }
.brand-tag { font-size: 12px; font-weight: 600; color: var(--link); background: var(--accent-soft); padding: 2px 8px; border-radius: 99px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-soft); border-color: var(--line); }
.menu-btn { display: none; }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: block; }
}
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; height: 38px; padding: 0 40px 0 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-soft); color: var(--ink); font: inherit; font-size: 14px; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { position: absolute; left: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.search-kbd { position: absolute; right: 10px; top: 9px; font: 500 11px/18px "JetBrains Mono", monospace; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; pointer-events: none; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; max-height: min(70vh, 520px); overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.search-results a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--bg-soft); }
.search-results .r-title { display: block; color: var(--ink); font-weight: 600; font-size: 14px; }
.search-results .r-path { display: block; color: var(--muted); font-size: 12px; }
.search-results .r-snip { display: block; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results mark { background: var(--accent-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.search-results .r-empty { padding: 14px; color: var(--muted); font-size: 14px; }
.top-links { display: flex; gap: 18px; font-size: 14px; font-weight: 500; }
.top-links a { color: var(--text); text-decoration: none; white-space: nowrap; }
.top-links a:hover { color: var(--link); }

/* Layout */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--tocw); max-width: 1480px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 22px 14px 40px 20px; border-right: 1px solid var(--line); scrollbar-width: thin; }
.version { font-size: 12px; color: var(--muted); padding: 0 10px 4px; }
.all-link { display: inline-block; font-size: 12.5px; font-weight: 500; padding: 0 10px 14px; text-decoration: none; }
.all-link:hover { text-decoration: underline; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink); padding: 0 10px 6px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 5px 10px; margin: 1px 0; border-radius: 7px; font-size: 14px; line-height: 1.45; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--bg-soft); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--link); font-weight: 600; }
.nav .pill { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--warn); background: var(--warn-bg); border-radius: 99px; padding: 1px 7px; white-space: nowrap; }
.scrim { display: none; }

.content { min-width: 0; padding: 36px 56px 60px; }
.toc { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 30px 20px 40px 8px; font-size: 13px; }
.toc-title { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink); margin-bottom: 8px; }
#toc a { display: block; padding: 4px 0 4px 12px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none; line-height: 1.4; }
#toc a.lvl-3 { padding-left: 24px; }
#toc a:hover { color: var(--ink); }
#toc a { transition: color .2s, border-color .2s; }
#toc a.active { color: var(--link); border-left-color: var(--accent); font-weight: 500; }

/* Smooth scrolling to headings, and a short glow on the one you land on */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .chapter :is(h2, h3):target { animation: target-glow 1.8s ease-out; }
}
@keyframes target-glow {
  0%, 25% { background: var(--accent-soft); box-shadow: -10px 0 0 var(--accent-soft), 10px 0 0 var(--accent-soft); }
  100% { background: transparent; box-shadow: -10px 0 0 transparent, 10px 0 0 transparent; }
}
.chapter :is(h2, h3) { border-radius: 6px; }

/* Chapters */
.chapter { max-width: 820px; padding-bottom: 28px; margin-bottom: 44px; border-bottom: 1px solid var(--line); }
.chapter:last-of-type { border-bottom: 0; }
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--link); letter-spacing: .02em; margin-bottom: 6px; }
.chapter h1 { font-size: clamp(28px, 4vw, 36px); line-height: 1.2; letter-spacing: -.02em; color: var(--ink); margin: 0 0 14px; }
.chapter h2 { font-size: 23px; line-height: 1.3; letter-spacing: -.01em; color: var(--ink); margin: 40px 0 12px; }
.chapter h3 { font-size: 18px; line-height: 1.4; color: var(--ink); margin: 28px 0 8px; }
.chapter h4 { font-size: 15.5px; color: var(--ink); margin: 22px 0 6px; }
.chapter :is(h2, h3, h4) .anchor { margin-left: 8px; color: var(--line-strong); text-decoration: none; font-weight: 400; opacity: 0; transition: opacity .15s; }
.chapter :is(h2, h3, h4):hover .anchor { opacity: 1; }
.chapter p, .chapter ul, .chapter ol { margin: 0 0 16px; }
.chapter li { margin: 4px 0; }
.chapter li > ul, .chapter li > ol { margin: 4px 0 0; }
.lead { font-size: 18px; color: var(--text); }
strong { color: var(--ink); font-weight: 600; }
code { font: 500 .86em/1.5 "JetBrains Mono", ui-monospace, monospace; background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink); overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow: auto; }
pre code { border: 0; padding: 0; background: none; }
kbd { font: 500 .82em "JetBrains Mono", monospace; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--bg); color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

/* Numbered steps */
.chapter ol { counter-reset: step; list-style: none; padding-left: 0; }
.chapter ol > li { counter-increment: step; position: relative; padding-left: 40px; margin: 10px 0; }
.chapter ol > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--link); font-size: 13px; font-weight: 700; }
.chapter ul { padding-left: 22px; }
.chapter ul li::marker { color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); color: var(--ink); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--ink); }
/* "At a glance" key/value tables (Markdown tables with an empty header row) */
.kv td:first-child { width: 1%; white-space: nowrap; background: var(--bg-soft); }
.kv tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) { .kv td:first-child { white-space: normal; width: 34%; } }

/* Callouts */
.callout { display: flex; gap: 12px; margin: 0 0 20px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; font-size: 15px; }
.callout > .c-ico { flex-shrink: 0; width: 20px; height: 20px; margin-top: 3px; }
.callout > div > :last-child { margin-bottom: 0; }
.callout > div > :first-child::before { font-weight: 700; margin-right: 6px; }
.callout-tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 30%, transparent); }
.callout-tip .c-ico, .callout-tip > div > :first-child::before { color: var(--tip); }
.callout-tip > div > :first-child::before { content: "Tip"; }
.callout-note { background: var(--note-bg); border-color: color-mix(in srgb, var(--note) 30%, transparent); }
.callout-note .c-ico, .callout-note > div > :first-child::before { color: var(--note); }
.callout-note > div > :first-child::before { content: "Note"; }
.callout-warning { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout-warning .c-ico, .callout-warning > div > :first-child::before { color: var(--warn); }
.callout-warning > div > :first-child::before { content: "Important"; }
.callout-soon { background: var(--bg-soft); border-color: var(--line-strong); border-style: dashed; }
.callout-soon .c-ico, .callout-soon > div > :first-child::before { color: var(--muted); }
.callout-soon > div > :first-child::before { content: "Coming soon"; }

/* Figures */
figure { margin: 4px 0 24px; }
figure img { display: block; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); cursor: zoom-in; background: var(--bg-soft); }
figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 4px 0 24px; }
.fig-row figure { margin: 0; }
.video-slot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: 0 0 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: 14px; }
.video-slot svg { flex-shrink: 0; color: var(--muted); }

/* Phone screenshots: real captures in a light device frame */
.phones { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; margin: 8px 0 28px; padding: 28px 16px 20px; border-radius: 14px; background: var(--bg-soft); }
.phones figure { margin: 0; width: min(230px, 100%); }
.phones img { width: 100%; border: 7px solid var(--bezel); border-radius: 30px; box-shadow: 0 18px 40px -18px rgba(14,20,36,.45); background: #fff; }
.phones figcaption { margin-top: 12px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 0 0 24px; }
.card { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--bg); transition: border-color .15s, transform .15s, box-shadow .15s; }
a.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card strong { display: block; margin-bottom: 4px; font-size: 15px; }
.card span { display: block; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 0 0 24px; }
.stat { padding: 14px 16px; border-radius: 12px; background: var(--bg-soft); }
.stat b { display: block; font-size: 26px; line-height: 1.1; color: var(--ink); letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--muted); }

/* Demo gallery */
.demo-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.demo-filter button { font: 500 13.5px Inter, sans-serif; padding: 6px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.demo-filter button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.demos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin: 0 0 24px; }
.demo { text-decoration: none; color: var(--text); }
.demo .d-img { display: block; aspect-ratio: 480 / 692; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.demo img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .4s; }
.demo:hover img { transform: scale(1.03); }
.demo .d-name { display: block; margin-top: 8px; font-weight: 600; font-size: 14px; color: var(--ink); }
.demo .d-cat { display: block; font-size: 12.5px; color: var(--muted); }

/* Badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1.6; padding: 0 8px; border-radius: 99px; background: var(--accent-soft); color: var(--link); vertical-align: 2px; }
.badge.paid { background: var(--note-bg); color: var(--note); }
.badge.soon { background: var(--warn-bg); color: var(--warn); }

/* Prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 36px; }
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; font-size: 12px; color: var(--muted); }
.pager span { font-weight: 600; color: var(--ink); font-size: 15px; }
.pager .next { text-align: right; grid-column: 2; }

.doc-footer { max-width: 820px; font-size: 13px; color: var(--muted); padding-top: 8px; }
.doc-footer p { margin: 4px 0; }

.to-top { position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; }
.to-top[hidden] { display: none; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(8,12,20,.86); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-height: 92vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox button { position: absolute; top: 14px; right: 18px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }

/* Responsive */
@media (max-width: 1240px) {
  .layout { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 32px 40px 56px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .top-links { display: none; }
  .sidebar { position: fixed; z-index: 50; top: var(--top); left: 0; width: min(310px, 86vw); background: var(--bg); transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 45; background: rgba(8,12,20,.4); }
  .scrim[hidden] { display: none; }
  .content { padding: 26px 16px 48px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-tag, .search-kbd { display: none; }
  /* Product names are longer than "Templeto": let the name shrink rather than push the buttons out. */
  .brand { flex-shrink: 1; min-width: 0; }
  .brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
  .home-chip { height: 34px; }
  .home-chip-ico { width: 26px; height: 26px; }
  .chapter h2 { font-size: 21px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  th, td { padding: 9px 11px; }
}
@media print {
  .topbar, .sidebar, .toc, .to-top, .pager { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
}
