:root{
  --brand-bg:#00a3ff;
  --brand-fg:#ffffff;
  --brand-accent:#ffc100;
  --page-bg:#ffffff;
  --text:#111111;
  --muted:#9594a3;
  --border:#eaeaea;
  --surface:#f7f7f8;
}

@media(prefers-color-scheme:dark){
  :root{
    --page-bg:#0d1117;
    --text:#e6edf3;
    --muted:#9da7b3;
    --border:#2a2f36;
    --surface:#161b22;
  }
}

body[data-theme=dark]{
  --page-bg:#0d1117;
  --text:#e6edf3;
  --muted:#9da7b3;
  --border:#2a2f36;
  --surface:#161b22;
}

*{box-sizing:border-box}
body{
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  line-height:1.6;margin:0;background:var(--page-bg);color:var(--text)
}

/* HEADER */
header{background:var(--brand-bg);color:var(--brand-fg);padding:20px}
.header-inner{max-width:980px;margin:0 auto;display:flex;gap:16px;align-items:center;justify-content:space-between;flex-wrap:wrap}
.brand{display:flex;gap:12px;align-items:center;min-width:0}
.brand img{height:44px;width:auto;border-radius:8px;display:block;background:#fff;flex:0 0 auto; padding:5px;}
.brand h1{margin:0;font-size:22px;line-height:1.2;word-break:break-word}
.header-meta{font-size:13px;opacity:.95;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}

/* TOGGLE BUTTON */
.theme-toggle{
  background:#ffffff;
  color:#9594a3;
  border:1px solid #9594a3;
  padding:8px 12px;border-radius:10px;cursor:pointer;font-weight:600;
  flex:0 0 auto
}
.theme-toggle:hover{background:#ffc100;color:#9594a3;border-color:#9594a3}

/* Dark-mode button + header */
body[data-theme=dark] .theme-toggle{background:#ffffff;color:#9594a3;border-color:#9594a3}
body[data-theme=dark] header{background:#ffffff;color:#9594a3}

/* MAIN */
main{max-width:900px;margin:0 auto;padding:28px 16px}
h2{margin-top:36px;border-top:1px solid var(--border);padding-top:18px;font-size:20px}
.toc{background:var(--surface);border:1px solid var(--border);padding:16px;border-radius:10px}
.toc h3{margin:0 0 6px 0}
.toc ul{margin:8px 0 0 18px}

/* LINKS */
a{color:#9594a3;text-decoration:none}
a:hover{text-decoration:underline}

/* MISC */
.backtop{font-size:12px;margin-top:8px}
footer{max-width:900px;margin:24px auto 60px auto;padding:0 16px;color:var(--muted);border-top:1px solid var(--border)}

/* ---------- Responsive Breakpoints ---------- */

/* Tablet and down */
@media (max-width: 900px){
  header{padding:16px}
  .brand img{height:40px}
  .brand h1{font-size:20px}
  .header-meta{font-size:12px}
  .theme-toggle{padding:8px 10px}
}

/* Phablet */
@media (max-width: 720px){
  .header-inner{gap:12px}
  .brand{flex:1 1 100%}
  .theme-toggle{margin-left:auto}
  .brand h1{font-size:19px}
}

/* Mobile */
@media (max-width: 520px){
  header{padding:14px}
  .brand{gap:10px}
  .brand img{height:32px}
  .brand h1{font-size:18px}
  .header-meta{display:none} /* hide cramped meta on small screens */
  .theme-toggle{padding:8px 12px;font-size:14px;border-radius:8px}
}

/* Extra small */
@media (max-width: 360px){
  .brand img{height:28px}
  .brand h1{font-size:16px}
  .theme-toggle{width:100%;text-align:center}
}