/* Site styles: light and dark themes, readable on phones and desktops. */
:root {
  --bg: #ffffff; --bg-soft: #f5f7fa; --bg-code: #f0f2f5; --text: #1b1f24; --muted: #57606a; --line: #d8dee4;
  --link: #0a58ca; --link-hover: #063f91; --accent: #e8590c; --mark: #fff3bf; --ok: #1a7f37; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 8px; --max: 920px; --top: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1217; --bg-soft: #161b22; --bg-code: #1c2230; --text: #e6edf3; --muted: #9aa5b1; --line: #2d333b;
    --link: #6cb6ff; --link-hover: #a5d1ff; --accent: #ff8a3d; --mark: #4d3b00; --ok: #3fb950; --shadow: 0 1px 3px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1217; --bg-soft: #161b22; --bg-code: #1c2230; --text: #e6edf3; --muted: #9aa5b1; --line: #2d333b;
  --link: #6cb6ff; --link-hover: #a5d1ff; --accent: #ff8a3d; --mark: #4d3b00; --ok: #3fb950; --shadow: 0 1px 3px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 12px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: break-word; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--bg); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1240px; margin: 0 auto; min-height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; margin-right: auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
.nav a:hover { background: var(--bg-soft); }
.nav a[aria-current="page"] { background: var(--bg-soft); color: var(--accent); font-weight: 600; }
button { font: inherit; color: inherit; }
.theme-btn, .menu-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; cursor: pointer; min-height: 40px; }
.theme-btn:hover, .menu-btn:hover { border-color: var(--muted); }
.menu-btn { display: none; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: inline; } :root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .i-sun { display: inline; } :root[data-theme="auto"] .i-moon { display: none; } }

.crumbs { max-width: 1240px; margin: 0 auto; padding: 10px 16px 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs .sep { opacity: .6; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.wrap.has-toc { grid-template-columns: 240px minmax(0, 1fr); }
.content { max-width: var(--max); width: 100%; padding: 8px 0 48px; min-width: 0; }
.toc { position: sticky; top: calc(var(--top) + 16px); align-self: start; max-height: calc(100vh - var(--top) - 32px); overflow: auto; padding: 16px 0; font-size: 14px; }
.toc summary { font-weight: 600; cursor: pointer; margin-bottom: 6px; color: var(--muted); }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li a { display: block; padding: 4px 8px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none; }
.toc li a:hover { color: var(--text); }
.toc li a.active { border-left-color: var(--accent); color: var(--text); font-weight: 600; }
.toc li.l3 a { padding-left: 20px; }

/* content */
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .6em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin-top: .8em; }
.content > :first-child, .content > .skill-box + h1 { margin-top: .6em; }
h2 { font-size: 1.45rem; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.15rem; }
h2 .anchor, h3 .anchor { opacity: 0; margin-left: 6px; text-decoration: none; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: .7; }
p, ul, ol { margin: 0 0 1em; }
li + li { margin-top: .25em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
blockquote { margin: 0 0 1em; padding: 10px 16px; border-left: 4px solid var(--accent); background: var(--bg-soft); border-radius: 0 var(--radius) var(--radius) 0; }
blockquote > :last-child { margin-bottom: 0; }
img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
code { font: .9em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg-code); padding: .1em .35em; border-radius: 4px; }
pre { position: relative; background: var(--bg-code); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; margin: 0 0 1em; }
pre code { background: none; padding: 0; font-size: 14px; white-space: pre; overflow-wrap: normal; }
.copy-btn { position: absolute; top: 6px; right: 6px; font-size: 13px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; opacity: .85; }
.copy-btn:hover { opacity: 1; } .copy-btn.done { color: var(--ok); border-color: var(--ok); }
details { margin: 0 0 .8em; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--bg-soft); }
details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: 8px; }
.toc details { border: 0; padding: 0; background: none; }

.skill-box { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 1.4em; padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--bg-soft); }
.skill-box p { flex: 1 1 100%; margin: 0; color: var(--muted); }
.btn { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-decoration: none; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.08); color: inherit; } .btn.primary:hover { color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #111; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn.primary { color: #111; } }

/* tables: scroll sideways on small screens instead of squashing */
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
td { min-width: 4.5em; }
td:last-child { min-width: 12em; }
tr:last-child td { border-bottom: 0; }
td:first-child { overflow-wrap: normal; }
tbody tr:hover { background: var(--bg-soft); }

.filter { display: flex; gap: 8px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.filter input { flex: 1 1 220px; min-height: 42px; padding: 8px 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.filter input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.filter .count { color: var(--muted); font-size: 14px; }
.no-match { color: var(--muted); font-style: italic; padding: 8px 12px; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }

.foot { border-top: 1px solid var(--line); background: var(--bg-soft); }
.foot-inner { max-width: 1240px; margin: 0 auto; padding: 20px 16px; display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; }
.to-top { margin-left: auto; }

/* phones */
@media (max-width: 900px) {
  .wrap.has-toc { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { position: static; max-height: none; padding: 12px 0 0; }
  .toc details { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--bg-soft); }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .menu-btn { display: inline-flex; }
  .theme-label { display: none; }
  .nav { display: none; width: 100%; flex-direction: column; padding: 0 0 10px; }
  .nav.open { display: flex; }
  .nav a { padding: 12px 10px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .brand { font-size: 15px; white-space: normal; }
  h2 { font-size: 1.3rem; }
  pre code { font-size: 13px; }
  table { font-size: 14px; }
  th, td { padding: 8px 10px; }
  .to-top { margin-left: 0; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print { .top, .toc, .foot, .copy-btn, .filter { display: none !important; } }
