/* IANST Blog — public reading styles. The accent comes from /assets/theme.css (blog settings). */
:root {
  --accent: #4f46e5;
  --bg: #ffffff;
  --side: #f7f8fa;
  --soft: #f1f3f6;
  --ink: #171a21;
  --ink-2: #3b414d;
  --muted: #646b78;
  --line: #e4e7ec;
  --code-bg: #14171d;
  --code-ink: #e6e8ee;
  --top-h: 60px;
  --side-w: 272px;
  --toc-w: 232px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --side: #13161b; --soft: #1a1e25; --ink: #e9ebef; --ink-2: #c4c9d2; --muted: #969dab; --line: #252a33; --code-bg: #0a0c10;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1115; --side: #13161b; --soft: #1a1e25; --ink: #e9ebef; --ink-2: #c4c9d2; --muted: #969dab; --line: #252a33; --code-bg: #0a0c10;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); text-rendering: optimizeLegibility; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 12px; }
.muted { color: var(--muted); }
.announce { background: var(--accent); color: #fff; text-align: center; font-size: 14px; padding: 8px 16px; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 30; height: var(--top-h); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line); }
.top-in { height: 100%; display: flex; align-items: center; gap: 18px; padding: 0 20px; max-width: 1480px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); position: relative; }
.mark::after { content: ""; position: absolute; inset: 7px 7px 7px 11px; border-left: 3px solid #fff; border-top: 3px solid #fff; border-radius: 2px 0 0 0; }
.search { position: relative; flex: 1; max-width: 420px; margin-left: 12px; }
.search input { width: 100%; height: 38px; border: 1px solid var(--line); background: var(--soft); color: var(--ink); border-radius: 9px; padding: 0 38px 0 14px; font: inherit; font-size: 14px; }
.search input:focus { outline: none; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search kbd { position: absolute; right: 10px; top: 9px; font: 12px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; background: var(--bg); }
.search.big { max-width: 640px; margin: 8px 0 24px; }
.search.big input { height: 48px; font-size: 16px; }
.links { display: flex; gap: 18px; margin-left: auto; }
.links a { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.theme-btn, .menu-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; flex: none; }
.theme-btn span { width: 16px; height: 16px; border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 2px solid var(--ink); }
.menu-btn { display: none; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px; position: relative; }
.menu-btn span::before, .menu-btn span::after { content: ""; position: absolute; left: 0; }
.menu-btn span::before { top: -5px; } .menu-btn span::after { top: 5px; }

/* ---------- three columns ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1480px; margin: 0 auto; min-height: calc(100vh - var(--top-h)); background: linear-gradient(90deg, var(--side) calc(var(--side-w) - 1px), var(--line) calc(var(--side-w) - 1px), var(--line) var(--side-w), transparent var(--side-w)); }
.shell.with-toc { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w); }
.sidebar { position: sticky; top: var(--top-h); align-self: start; height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 22px 14px 40px 20px; border-right: 1px solid var(--line); background: var(--side); font-size: 14px; }
.side-home { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink); font-weight: 600; margin-bottom: 10px; }
.side-home.on, .side-home:hover { background: var(--soft); text-decoration: none; }
.group { margin: 2px 0 6px; }
.group summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; font-weight: 600; color: var(--ink); }
.group summary::-webkit-details-marker { display: none; }
.group summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.group[open] summary::after { transform: rotate(45deg); }
.group summary:hover { background: var(--soft); }
.ico { width: 20px; text-align: center; }
.group ul { list-style: none; margin: 2px 0 8px 18px; padding: 0 0 0 10px; border-left: 1px solid var(--line); }
.group li a { display: block; padding: 5px 10px; color: var(--ink-2); border-radius: 6px; line-height: 1.4; position: relative; }
.group li a:hover { color: var(--ink); background: var(--soft); text-decoration: none; }
.group li a.on { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 9%, transparent); }
.group li a.on::before { content: ""; position: absolute; left: -11px; top: 6px; bottom: 6px; width: 2px; background: var(--accent); border-radius: 2px; }
.group li a.all { color: var(--muted); font-size: 13px; }
.main { min-width: 0; padding: 36px clamp(20px, 4vw, 56px) 80px; }
.toc { position: sticky; top: var(--top-h); align-self: start; max-height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 36px 20px 40px 8px; font-size: 13px; }
.toc-h { font-weight: 700; color: var(--ink); margin: 0 0 10px; font-size: 13px; }
.toc ol, .toc-mobile ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a, .toc-mobile li a { display: block; padding: 4px 0 4px 12px; color: var(--muted); margin-left: -1px; border-left: 2px solid transparent; line-height: 1.4; }
.toc li.l3 a, .toc-mobile li.l3 a { padding-left: 24px; }
.toc li a:hover { color: var(--ink); text-decoration: none; }
.toc li a.on { color: var(--accent); border-left-color: var(--accent); }
.toc-mobile { display: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 24px; }
.toc-mobile summary { cursor: pointer; font-weight: 600; }
.scrim { position: fixed; inset: var(--top-h) 0 0 0; background: rgb(0 0 0 / .35); z-index: 19; }

/* ---------- home ---------- */
.hero { max-width: 760px; padding: 18px 0 30px; }
.hero h1 { font-size: clamp(30px, 4.2vw, 46px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 14px; }
.hero p { font-size: 18px; color: var(--ink-2); margin: 0; max-width: 60ch; }
.sec { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.featured { margin: 8px 0 44px; }
.feat-grid { display: grid; grid-template-columns: 1.5fr 1fr; grid-template-rows: auto auto; gap: 22px; }
.feat-grid .card.big { grid-row: span 2; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 44px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 26px 22px; }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { display: flex; flex-direction: column; min-width: 0; }
.card .thumb { display: block; border-radius: var(--radius); overflow: hidden; background: var(--soft); aspect-ratio: 1200 / 630; margin-bottom: 12px; border: 1px solid var(--line); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.card:hover .thumb img { transform: scale(1.02); }
.card h3 { font-size: 17px; line-height: 1.35; margin: 4px 0 6px; letter-spacing: -0.01em; }
.card.big h3 { font-size: clamp(20px, 2.2vw, 26px); }
.card h3 a { color: var(--ink); }
.card .ex { color: var(--ink-2); font-size: 14.5px; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cat { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); font-size: 13px; margin: 0; }
.kind { font-size: 11.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--ink-2); border: 1px solid var(--line); }
.kind-tutorial { color: #0f766e; background: color-mix(in srgb, #14b8a6 12%, transparent); border-color: transparent; }
.kind-docs { color: #1d4ed8; background: color-mix(in srgb, #3b82f6 12%, transparent); border-color: transparent; }
.kind-news { color: #b45309; background: color-mix(in srgb, #f59e0b 14%, transparent); border-color: transparent; }
.kind-promo { color: #be185d; background: color-mix(in srgb, #ec4899 12%, transparent); border-color: transparent; }
:root[data-theme="dark"] .kind-tutorial, :root[data-theme="dark"] .kind-docs, :root[data-theme="dark"] .kind-news, :root[data-theme="dark"] .kind-promo { filter: brightness(1.6); }
.rail section { margin-bottom: 32px; }
.popular { margin: 0; padding: 0; list-style: none; counter-reset: p; }
.popular li { counter-increment: p; display: grid; grid-template-columns: 28px 1fr; gap: 6px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; line-height: 1.4; }
.popular li::before { content: counter(p); font-weight: 800; color: var(--accent); font-size: 18px; line-height: 1.1; }
.popular a { color: var(--ink); font-weight: 500; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { display: inline-flex; gap: 6px; align-items: center; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); font-size: 13.5px; }
.chips a span { color: var(--muted); font-size: 12px; }
.chips a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager { display: flex; gap: 18px; align-items: center; justify-content: center; margin: 36px 0 0; font-size: 14px; color: var(--muted); }
.pager a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }

/* ---------- lists ---------- */
.list-head { display: flex; gap: 18px; align-items: center; margin: 6px 0 22px; }
.list-head h1 { font-size: clamp(26px, 3.4vw, 36px); margin: 0 0 6px; letter-spacing: -0.02em; line-height: 1.15; }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 8px; line-height: 1.55; }
.rows { list-style: none; padding: 0; margin: 0; }
.row { border-bottom: 1px solid var(--line); padding: 16px 0; }
.row a { display: block; color: var(--ink); }
.row a:hover { text-decoration: none; }
.row a:hover .row-t { color: var(--accent); }
.row-t { display: block; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; line-height: 1.35; }
.row-x { display: block; color: var(--ink-2); font-size: 14.5px; margin-bottom: 8px; }
.avatar { border-radius: 50%; object-fit: cover; }
.avatar.big { width: 72px; height: 72px; }

/* ---------- article ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); }
.post { max-width: 760px; }
.post-head h1 { font-size: clamp(28px, 3.8vw, 42px); line-height: 1.15; letter-spacing: -0.025em; margin: 6px 0 14px; }
.byline { display: flex; gap: 12px; align-items: center; margin: 18px 0 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.who { font-weight: 650; color: var(--ink); font-size: 15px; }
.cover { margin: 0 0 30px; }
.cover img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; aspect-ratio: 1200 / 630; object-fit: cover; }
.cover figcaption, .prose figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }
.prose { font-size: 17px; line-height: 1.75; color: var(--ink); overflow-wrap: anywhere; }
.prose > * + * { margin-top: 1.1em; }
.prose p, .prose ul, .prose ol, .prose figure, .prose blockquote, .prose pre, .prose .table, .prose aside { margin-bottom: 0; margin-top: 1.1em; }
.prose h2 { font-size: 26px; line-height: 1.25; letter-spacing: -0.02em; margin: 2em 0 .6em; padding-top: .2em; }
.prose h3 { font-size: 20px; line-height: 1.3; margin: 1.7em 0 .5em; }
.prose h4 { font-size: 17px; margin: 1.5em 0 .4em; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.prose .anchor { position: absolute; left: -1em; width: 1em; color: var(--muted); opacity: 0; font-weight: 400; text-decoration: none; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 1; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--muted); }
.prose code { font: .88em var(--mono); background: var(--soft); border: 1px solid var(--line); padding: .1em .38em; border-radius: 5px; }
.prose pre { position: relative; background: var(--code-bg); color: var(--code-ink); border-radius: 10px; padding: 18px 18px; overflow-x: auto; font-size: 14px; line-height: 1.6; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 6px; right: 52px; font: 11px var(--mono); color: #8a93a3; text-transform: lowercase; }
.copy { position: absolute; top: 6px; right: 8px; font: 11px var(--font); color: #c8cdd6; background: #ffffff14; border: 1px solid #ffffff22; border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.prose blockquote { margin-left: 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--line); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
.prose figure { margin-left: 0; margin-right: 0; }
.prose figure img { border-radius: 10px; border: 1px solid var(--line); }
.prose .table { overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--soft); font-weight: 650; }
.hint { border-radius: 10px; padding: 14px 18px 14px 46px; position: relative; background: var(--soft); border: 1px solid var(--line); }
.hint::before { position: absolute; left: 16px; top: 15px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font); color: #fff; }
.hint > :first-child { margin-top: 0; }
.hint-note { background: color-mix(in srgb, #3b82f6 8%, var(--bg)); border-color: color-mix(in srgb, #3b82f6 30%, transparent); }
.hint-note::before { content: "i"; background: #3b82f6; }
.hint-tip { background: color-mix(in srgb, #10b981 8%, var(--bg)); border-color: color-mix(in srgb, #10b981 30%, transparent); }
.hint-tip::before { content: "✓"; background: #10b981; }
.hint-warning { background: color-mix(in srgb, #f59e0b 10%, var(--bg)); border-color: color-mix(in srgb, #f59e0b 35%, transparent); }
.hint-warning::before { content: "!"; background: #d97706; }
.hint-danger { background: color-mix(in srgb, #ef4444 8%, var(--bg)); border-color: color-mix(in srgb, #ef4444 30%, transparent); }
.hint-danger::before { content: "×"; background: #dc2626; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 36px 0 0; }
.tags a { font-size: 13.5px; padding: 4px 11px; border-radius: 999px; background: var(--soft); color: var(--ink-2); }
.author-box { margin: 32px 0 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; }
.author-box p { margin: 0 0 4px; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 36px 0 0; }
.pn { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
.pn:hover { border-color: var(--accent); text-decoration: none; }
.pn span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.pn strong { font-weight: 600; line-height: 1.35; display: block; }
.pn.next { text-align: right; grid-column: 2; }
.related { max-width: 760px; margin-top: 56px; }
.preview-bar { background: #fef3c7; color: #78350f; border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600; margin: 0 0 18px; }
.empty-state { max-width: 560px; padding: 40px 0; }
.empty-state .code { font: 700 14px var(--mono); color: var(--accent); margin: 0; }
.empty-state h1 { font-size: 32px; letter-spacing: -0.02em; margin: 6px 0 8px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--side); }
.foot-in { max-width: 1480px; margin: 0 auto; padding: 28px 20px 36px; display: grid; grid-template-columns: 1fr auto; gap: 14px 30px; font-size: 14px; }
.foot-in p { margin: 4px 0 0; color: var(--muted); }
.foot-in nav { display: flex; flex-wrap: wrap; gap: 16px; align-items: start; }
.foot-in nav a { color: var(--ink-2); }
.fine { grid-column: 1 / -1; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .shell.with-toc { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc { display: none; }
  .toc-mobile { display: block; }
  .home-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell, .shell.with-toc { grid-template-columns: minmax(0, 1fr); background: none; }
  .menu-btn { display: grid; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); z-index: 20; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 10px 40px rgb(0 0 0 / .15); }
  .sidebar.open { transform: none; }
  .links { display: none; }
  .search { margin-left: 0; }
  .search kbd { display: none; }
  .feat-grid { grid-template-columns: minmax(0, 1fr); }
  .feat-grid .card.big { grid-row: auto; }
  .foot-in { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .top-in { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  .main { padding: 24px 16px 60px; }
  .prose { font-size: 16.5px; }
  .prevnext { grid-template-columns: 1fr; }
  .pn.next { grid-column: 1; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .top, .sidebar, .toc, .toc-mobile, .foot, .related, .prevnext, .copy { display: none !important; }
  .shell { display: block; }
}
