/* Tool Hamid Valad - design system (UI/UX Pro Max: "Minimalism & Swiss Style", education palette).
   One stylesheet for every public page; tokens first, then base, components, article prose. RTL-first. */

/* ---------- fonts (self-hosted Vazirmatn variable, SIL OFL 1.1 - see fonts/vazirmatn/OFL.txt) ---------- */
@font-face {
  font-family: "Vazirmatn"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/vazirmatn/vazirmatn-arabic-wght-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E,
                 U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Vazirmatn"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/vazirmatn/vazirmatn-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
                 U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Vazirmatn"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/vazirmatn/vazirmatn-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;          /* brand indigo (continues the site's former #667eea), 6.3:1 with white */
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --link: #4338ca;
  --on-primary: #ffffff;
  --accent: #b45309;           /* featured / highlights, on --accent-soft 5.6:1 */
  --accent-soft: #fef3c7;
  --success: #047857;
  --success-soft: #d1fae5;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-bar: #1e293b;
  --inline-code-bg: #eef2ff;
  --inline-code-text: #3730a3;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 6px 20px rgb(15 23 42 / 8%);
  --radius: 14px;
  --radius-sm: 8px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --container: 1200px;
  --prose: 760px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1a2333;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #243045;
    --border-strong: #334155;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #1e2246;
    --link: #a5b4fc;
    --on-primary: #0b1120;
    --accent: #fbbf24;
    --accent-soft: #3a2a07;
    --success: #34d399;
    --success-soft: #0b3b2c;
    --code-bg: #0a0f1c;
    --code-bar: #151d2e;
    --inline-code-bg: #1e2246;
    --inline-code-text: #c7d2fe;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 6px 20px rgb(0 0 0 / 45%);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 1rem; line-height: 1.75;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.45; margin: 0 0 var(--space-3); font-weight: 800; letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-4); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--primary); color: var(--on-primary); }
.container { width: min(100% - 32px, var(--container)); margin-inline: auto; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: 16px; top: -100px; z-index: 100;
  background: var(--primary); color: var(--on-primary); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: var(--space-5); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.brand img { width: 32px; height: 32px; }
.site-nav { display: flex; gap: var(--space-1); flex: 1; }
.site-nav a {
  color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); white-space: nowrap;
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.header-search { display: flex; align-items: center; position: relative; }
.header-search input { width: 220px; }

/* ---------- forms & buttons ---------- */
.input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 14px; min-height: 44px; width: 100%;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input::placeholder { color: var(--text-muted); opacity: 1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.search-field { position: relative; }
.search-field .icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-field .input { padding-inline-start: 42px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 10px 20px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-outline { background: transparent; color: var(--link); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-soft); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.badge-soon { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--text-muted); background: var(--surface-2); padding: 6px 12px; border-radius: 999px; }

/* ---------- layout blocks ---------- */
main { display: block; }
.page { padding-block: var(--space-6) var(--space-8); }
.section { padding-block: var(--space-7) 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); margin: 0; }
.section-head p { margin: var(--space-1) 0 0; color: var(--text-muted); }
.section-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none; }
.grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.grid-2 { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }

/* ---------- hero (home) ---------- */
.hero { padding-block: var(--space-8) var(--space-6); border-bottom: 1px solid var(--border); background:
  radial-gradient(1200px 400px at 50% -10%, var(--primary-soft), transparent 70%); }
.hero-inner { max-width: 760px; margin-inline: auto; text-align: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 4px 12px; border-radius: 999px; margin-bottom: var(--space-4); }
.hero h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3rem); font-weight: 900; margin-bottom: var(--space-3); }
.hero .lead { font-size: clamp(1.02rem, .95rem + .4vw, 1.2rem); color: var(--text-muted); margin-bottom: var(--space-6); }
.hero-search { display: flex; gap: var(--space-2); max-width: 600px; margin-inline: auto; }
.hero-search .search-field { flex: 1; }
.hero-search .input { min-height: 52px; font-size: 1.02rem; border-radius: 12px; }
.hero-search .btn { min-height: 52px; border-radius: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; margin-top: var(--space-5); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: .9rem;
  transition: border-color .2s var(--ease), color .2s var(--ease), background-color .2s var(--ease);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip .count { font-size: .8rem; opacity: .8; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-top: var(--space-7); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); text-align: center; }
.stat dd { margin: 0; }
.stat strong { display: block; font-size: 1.6rem; font-weight: 900; color: var(--text); line-height: 1.3; }
.stat span { color: var(--text-muted); font-size: .9rem; }

/* ---------- cards ---------- */
.card {
  position: relative; display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-5); box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.card:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card:focus-within { border-color: var(--primary); }
.card h3 { font-size: 1.08rem; margin: 0; line-height: 1.6; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); } /* whole card clickable, one link */
.card h3 a:focus-visible { outline: none; }
.card h3 a:focus-visible::after { outline: 3px solid var(--primary); outline-offset: 2px; }
.card p { color: var(--text-muted); margin: 0; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-top { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 10px; border-radius: 999px; }
.tag-featured { color: var(--accent); background: var(--accent-soft); }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); color: var(--text-muted); font-size: .85rem; margin-top: auto; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.tool-card .tool-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.tool-card .tool-icon .icon { width: 24px; height: 24px; }
.course-card ul { list-style: none; padding: 0; margin: 0 0 var(--space-2); display: grid; gap: var(--space-2); }
.course-card li { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--text); font-size: .95rem; }
.course-card li .icon { color: var(--success); margin-top: 4px; }
.course-card .actions { margin-top: auto; }
.course-card p { -webkit-line-clamp: unset; }

/* ---------- listing ---------- */
.page-head { padding-block: var(--space-6) var(--space-5); border-bottom: 1px solid var(--border); margin-bottom: var(--space-6); }
.page-head h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); margin-bottom: var(--space-2); }
.page-head p { color: var(--text-muted); margin: 0; }
.list-tools { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.list-tools .chips { justify-content: flex-start; margin: 0; }
.list-tools form { min-width: min(100%, 320px); }
.pagination { display: flex; justify-content: center; align-items: center; gap: var(--space-2); margin-top: var(--space-7); flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 700;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination [aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.empty-state { text-align: center; padding: var(--space-8) var(--space-4); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state .icon { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: var(--space-3); }
.empty-state h2 { font-size: 1.3rem; }
.empty-state p { color: var(--text-muted); }

/* ---------- breadcrumb ---------- */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 var(--space-4); font-size: .88rem; color: var(--text-muted); }
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "‹"; color: var(--border-strong); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }

/* ---------- article page ---------- */
.article-header { padding-block: var(--space-6) var(--space-5); }
.article-header h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); font-weight: 900; max-width: 900px; }
.article-header .subtitle { font-size: clamp(1.02rem, .95rem + .4vw, 1.2rem); color: var(--text-muted); max-width: 820px; }
.article-header .meta { margin-top: var(--space-4); font-size: .9rem; }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-7); align-items: start; }
.article-main { min-width: 0; }
.article-aside { position: sticky; top: 88px; display: grid; gap: var(--space-4); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); }
.panel h2 { font-size: 1rem; margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.toc ul, .toc .nav-pills-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; text-align: start !important; }
.toc a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text-muted); text-decoration: none; font-size: .92rem; line-height: 1.6; border-inline-start: 2px solid transparent; }
.toc a:hover { color: var(--text); background: var(--surface-2); }
.toc a.active { color: var(--primary); border-inline-start-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.toc-mobile { display: none; margin-bottom: var(--space-5); padding: var(--space-1) var(--space-4); }
.toc-mobile summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: 44px; }
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile[open] summary { margin-bottom: var(--space-2); }
.promo { display: grid; gap: var(--space-2); }
.promo h3 { font-size: 1rem; margin: 0; }
.promo p { color: var(--text-muted); font-size: .92rem; margin: 0 0 var(--space-2); }
.promo .btn { width: 100%; }
.promo-links { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-1); }
.promo-links a { display: block; padding: 6px 0; text-decoration: none; font-weight: 600; }
.share { margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.share h2 { font-size: 1.05rem; margin-bottom: var(--space-3); }
.share-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.share-btn { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 600; }
.share-btn:hover { border-color: var(--primary); color: var(--primary); }
.share-btn svg { width: 18px; height: 18px; }
.share-btn.is-done { color: var(--success); border-color: var(--success); background: var(--success-soft); }
.related { margin-top: var(--space-7); }

/* ---------- article prose (HTML stored in the database) ---------- */
.prose { font-size: 1.06rem; line-height: 2; max-width: var(--prose); overflow-wrap: anywhere; }
.prose > article { display: block; }
.prose section { margin-bottom: var(--space-7); scroll-margin-top: 88px; }
.prose h2 { font-size: clamp(1.3rem, 1.15rem + .6vw, 1.6rem); margin: var(--space-7) 0 var(--space-4); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
.prose section:first-child h2, .prose > article > section:first-child > h2 { margin-top: 0; }
.prose h3 { font-size: 1.18rem; margin: var(--space-6) 0 var(--space-3); }
.prose h4, .prose h5 { font-size: 1.05rem; margin: var(--space-5) 0 var(--space-2); }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-4); }
.prose ul, .prose ol { padding-inline-start: 1.5rem; }
.prose ol { list-style-type: persian; }
.prose li { margin-bottom: var(--space-2); }
.prose li::marker { color: var(--primary); }
.prose strong { font-weight: 800; color: var(--text); }
.prose a, .prose a.link { color: var(--link); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; }
.prose a[style*="color"] { color: var(--link) !important; } /* older articles hard-coded white links for the former dark theme */
.prose img { border-radius: 10px; margin-block: var(--space-4); }
.prose blockquote { margin: var(--space-5) 0; padding: var(--space-3) var(--space-5); border-inline-start: 4px solid var(--primary); background: var(--surface-2); border-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-5); font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: start; }
.prose th { background: var(--surface-2); }
.prose :not(pre) > code {
  font-family: var(--mono); font-size: .88em; background: var(--inline-code-bg); color: var(--inline-code-text);
  padding: 2px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; white-space: break-spaces;
}
/* code: always LTR, never wrapped by the RTL text flow */
.prose pre {
  direction: ltr; text-align: left; unicode-bidi: isolate; margin: 0 0 var(--space-5);
  background: var(--code-bg); color: var(--code-text); border-radius: 12px; padding: var(--space-4) var(--space-5);
  overflow-x: auto; font-family: var(--mono); font-size: .9rem; line-height: 1.75; tab-size: 4;
}
.prose pre code { font-family: inherit; background: none; color: inherit; padding: 0; font-size: inherit; white-space: pre; }
.prose .code-block { margin: 0 0 var(--space-5); border-radius: 12px; overflow: hidden; border: 1px solid var(--code-bar); background: var(--code-bg); }
.prose .code-block pre { margin: 0; border-radius: 0; }
.prose .code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 6px 10px 6px 14px; background: var(--code-bar); direction: ltr; }
.prose .code-toolbar .badge { font-family: var(--mono); font-size: .78rem; font-weight: 700; color: #a5b4fc; letter-spacing: .02em; }
.prose .copy-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; cursor: pointer;
  font: 600 .82rem var(--font); color: #e2e8f0; background: transparent; border: 1px solid #334155; border-radius: 6px;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.prose .copy-btn:hover { background: #334155; }
.prose .copy-btn.is-done { color: #6ee7b7; border-color: #047857; }
.prose .copy-btn svg { width: 16px; height: 16px; }
/* callout-style blocks used by the article generator */
.prose :is(.note, .point, .technique, .summary-card, .troubleshooting, .technical-points, .technical-details,
           .skills-learned, .optimization-tips, .learning-outcomes, .final-note, .extension-ideas, .code-warning, .article-card) {
  background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: var(--space-4) var(--space-5); margin: 0 0 var(--space-5);
}
.prose :is(.code-warning, .troubleshooting) { border-inline-start-color: var(--accent); }
.prose :is(.final-note, .learning-outcomes, .skills-learned) { border-inline-start-color: var(--success); }
.prose :is(.note, .point, .technique, .summary-card) > :last-child { margin-bottom: 0; }
.prose :is(.note, .point, .technique, .summary-card) h3:first-child, .prose :is(.note, .point) h4:first-child { margin-top: 0; }
.prose .summary-grid, .prose .color-palette, .prose .game-images { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-bottom: var(--space-5); }
.prose .image-item { text-align: center; }
.prose .image-item img { margin-inline: auto; }
.prose .color-item { display: flex; align-items: center; gap: var(--space-3); }
.prose .color-box { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.prose .repo-link { display: inline-flex; align-items: center; gap: 6px; }
.hidden-watermark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); color: transparent; font-size: 0; user-select: none; pointer-events: none; }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding-block: var(--space-8) var(--space-6); }
.not-found .code { font-size: clamp(4rem, 3rem + 6vw, 7rem); font-weight: 900; line-height: 1; color: var(--primary); }
.not-found p { color: var(--text-muted); max-width: 560px; margin-inline: auto; }
.not-found form { max-width: 520px; margin: var(--space-5) auto; display: flex; gap: var(--space-2); }
.not-found form .search-field { flex: 1; }

/* ---------- footer ---------- */
.site-footer { margin-top: var(--space-8); border-top: 1px solid var(--border); background: var(--surface); padding-block: var(--space-6); color: var(--text-muted); font-size: .92rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); list-style: none; padding: 0; margin: 0; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.footer-links a:hover { color: var(--primary); }
.site-footer p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-aside { position: static; }
  .article-aside .toc { display: none; }
  .toc-mobile { display: block; }
  .header-search { display: none; }
}
@media (max-width: 768px) {
  .site-header .container { flex-wrap: wrap; gap: 0; padding-block: var(--space-2) 0; min-height: 0; }
  .site-nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: var(--space-2); margin-inline: -4px; }
  .site-nav::-webkit-scrollbar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero { padding-block: var(--space-7) var(--space-5); }
  .hero-search .btn span { display: none; }
  .prose { font-size: 1.02rem; line-height: 1.95; }
  .prose pre { font-size: .84rem; padding: var(--space-3) var(--space-4); }
  .prose :is(.note, .point, .technique, .summary-card, .troubleshooting, .technical-points, .technical-details,
             .skills-learned, .optimization-tips, .learning-outcomes, .final-note, .extension-ideas, .code-warning, .article-card) { padding: var(--space-3) var(--space-4); }
  .prose img[style*="60%"] { width: 100% !important; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
}
@media print {
  .site-header, .site-footer, .article-aside, .share, .related, .toc-mobile, .copy-btn { display: none !important; }
  .article-layout { display: block; }
  .prose pre { white-space: pre-wrap; }
}
