/* TechTutorZone public site. Light by default, dark via system setting or the
   header toggle (html[data-theme]). System fonts only; no external requests. */
:root {
  --bg: #ffffff;
  --bg-2: #f6f8fa;
  --bg-code: #f6f8fa;
  --text: #1f2328;
  --muted: #59636e;
  --line: #d0d7de;
  --link: #0b5cad;
  --link-hover: #083f78;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --focus: #e36209;
  --tk-c: #6a737d; --tk-s: #0a3069; --tk-k: #a21d50; --tk-n: #0550ae; --tk-t: #116329; --tk-a: #953800; --tk-p: #0550ae; --tk-v: #116329;
  --radius: 6px;
  --wrap: 1080px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --bg-2: #161a21; --bg-code: #161a21; --text: #e6e8eb; --muted: #a3acb8; --line: #2b313b;
    --link: #7cb8ff; --link-hover: #a9d0ff; --accent: #2563eb; --accent-ink: #ffffff; --focus: #ffb454;
    --tk-c: #8b949e; --tk-s: #a5d6ff; --tk-k: #ff7b72; --tk-n: #79c0ff; --tk-t: #7ee787; --tk-a: #ffa657; --tk-p: #79c0ff; --tk-v: #7ee787;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --bg-2: #161a21; --bg-code: #161a21; --text: #e6e8eb; --muted: #a3acb8; --line: #2b313b;
  --link: #7cb8ff; --link-hover: #a9d0ff; --accent: #2563eb; --accent-ink: #ffffff; --focus: #ffb454;
  --tk-c: #8b949e; --tk-s: #a5d6ff; --tk-k: #ff7b72; --tk-n: #79c0ff; --tk-t: #7ee787; --tk-a: #ffa657; --tk-p: #79c0ff; --tk-v: #7ee787;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 1.0625rem; line-height: 1.6; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img, svg { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); margin: 2.2rem 0 .8rem; }
h3 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
p, ul, ol { margin: 0 0 1.1rem; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; border-radius: var(--radius); z-index: 100; }
.skip:focus { left: 8px; }
.meta { color: var(--muted); font-size: .9rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.bar { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--text); margin-right: auto; }
.brand::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-right: .4em; background: var(--accent); border-radius: 2px; transform: rotate(45deg); }
.nav { display: flex; gap: .2rem; }
.nav a { color: var(--text); text-decoration: none; padding: .45rem .7rem; border-radius: var(--radius); font-weight: 500; }
.nav a:hover { background: var(--bg-2); }
.nav a[aria-current="page"] { color: var(--link); font-weight: 700; }
.bar-actions { display: flex; gap: .3rem; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: var(--radius); width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--bg-2); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 60px; background: var(--bg); border-bottom: 1px solid var(--line); flex-direction: column; padding: .5rem 16px 1rem; }
  .nav.open { display: flex; }
  .nav a { padding: .7rem .5rem; }
}

/* breadcrumbs */
.crumbs { margin: 1rem 0 0; font-size: .9rem; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .3rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: .3rem; color: var(--line); }
.crumbs a { color: var(--muted); }

/* home */
.hero { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.search { display: flex; gap: .5rem; max-width: 560px; margin: 1.2rem 0 .8rem; }
.search input { flex: 1; min-width: 0; font: inherit; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.search button, .btn { font: inherit; font-weight: 600; padding: .6rem 1rem; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.search button:hover, .btn:hover { filter: brightness(1.1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.card, .cat-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; background: var(--bg); display: flex; flex-direction: column; }
.cat-card { text-decoration: none; color: inherit; }
.cat-card:hover, .card:hover { border-color: var(--accent); }
.card h3, .cat-card h3 { margin: .2rem 0 .4rem; font-size: 1.1rem; }
.card h3 a { text-decoration: none; color: var(--text); }
.card h3 a:hover { color: var(--link); text-decoration: underline; }
.card p { margin: 0 0 .5rem; font-size: .96rem; }
.card .meta, .cat-card .meta { margin-top: auto; }
.cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--link); margin: 0 0 .2rem; }
.cat a { text-decoration: none; }
.more { font-weight: 600; }
.tool-list li { margin-bottom: .4rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; text-decoration: none; color: var(--text); font-size: .9rem; }
.chip:hover, .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* article */
.post { max-width: 72ch; margin: 1rem auto 2rem; }
.post.wide { max-width: var(--wrap); }
.post-head { margin: 1rem 0 1.5rem; }
.post-head .meta { margin-top: .5rem; }
.prose > p, .prose li { max-width: 72ch; }
.prose h2 { padding-top: .3rem; border-top: 1px solid var(--line); margin-top: 2.4rem; padding-top: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: .35rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.2rem; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-2); }
.prose blockquote { margin: 0 0 1.1rem; padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.note { border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--bg-2); padding: .8rem 1rem; border-radius: var(--radius); margin: 0 0 1.2rem; }
.note > :last-child { margin-bottom: 0; }
.exercise { border: 1px dashed var(--line); padding: .9rem 1.1rem; border-radius: var(--radius); margin: 0 0 1.2rem; }
.exercise h3 { margin-top: 0; }
code, kbd { font-family: var(--mono); font-size: .9em; background: var(--bg-code); border: 1px solid var(--line); padding: .05em .35em; border-radius: 4px; }
kbd { border-bottom-width: 2px; }
.code { position: relative; margin: 0 0 1.2rem; }
.code pre { margin: 0; background: var(--bg-code); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem 1rem; overflow-x: auto; line-height: 1.5; font-size: .9rem; }
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.code::before { content: attr(data-lang); position: absolute; top: .35rem; right: 3.4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.copy { position: absolute; top: .4rem; right: .5rem; font: inherit; font-size: .75rem; padding: .2rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--text); cursor: pointer; }
.copy:hover { border-color: var(--accent); }
.tk-c { color: var(--tk-c); font-style: italic; }
.tk-s { color: var(--tk-s); }
.tk-k { color: var(--tk-k); }
.tk-n { color: var(--tk-n); }
.tk-t { color: var(--tk-t); }
.tk-a { color: var(--tk-a); }
.tk-p { color: var(--tk-p); }
.tk-v { color: var(--tk-v); }
.toc { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 0 0 1.6rem; background: var(--bg-2); max-width: 72ch; }
.toc p { margin: 0 0 .4rem; font-weight: 700; font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; }
.toc ol { margin: 0; padding-left: 1.3rem; columns: 2; column-gap: 2rem; font-size: .95rem; }
.toc li { break-inside: avoid; margin-bottom: .2rem; }
@media (max-width: 600px) { .toc ol { columns: 1; } }
.related { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: .5rem; }

/* tools */
.tool { display: grid; gap: 1rem; margin: 0 0 1.5rem; }
.tool label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: .3rem; }
.tool input[type="text"], .tool input[type="number"], .tool textarea, .tool select { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.tool textarea { font-family: var(--mono); font-size: .9rem; min-height: 180px; resize: vertical; }
.tool .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.tool .out { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.tool .out pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .9rem; }
.tool .err { color: #b42318; font-weight: 600; }
:root[data-theme="dark"] .tool .err { color: #ff8a80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool .err { color: #ff8a80; } }
.tool .ok { color: #116329; font-weight: 600; }
:root[data-theme="dark"] .tool .ok { color: #7ee787; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool .ok { color: #7ee787; } }
.swatch { display: flex; gap: .6rem; align-items: center; }
.swatch input[type="color"] { width: 44px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: none; }
.preview { padding: 1rem; border-radius: var(--radius); border: 1px solid var(--line); }
.hl { background: rgba(255, 196, 0, .45); border-radius: 2px; }
/* <mark>'s default black text on the translucent amber was 1.2:1 in dark mode */
.hl { color: inherit; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hl { background: rgba(255, 196, 0, .3); } }
:root[data-theme="dark"] .hl { background: rgba(255, 196, 0, .3); }
.badges span { display: inline-block; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--line); margin: 0 .3rem .3rem 0; font-size: .9rem; }
.tool-list a, .foot-nav a { word-break: normal; }

/* footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0 2rem; color: var(--muted); font-size: .92rem; }
.foot { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }
.foot p { margin: 0; max-width: 60ch; }
.foot-nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.foot-nav a { color: var(--muted); }
