/* =============================================================
   mathsai.net — public theme
   Modern, gradient-heavy, dark-mode-first, fully responsive
============================================================= */

/* ---------- tokens ---------- */
:root {
  --bg:          #0b0d17;
  --bg-2:        #11141f;
  --surface:     #161a28;
  --surface-2:   #1c2031;
  --border:      rgba(255,255,255,0.08);
  --border-2:    rgba(255,255,255,0.14);
  --text:        #e7e9f3;
  --text-2:      #b3b7c8;
  --text-3:      #7a7f95;
  --primary:     #7c3aed;
  --primary-2:   #a855f7;
  --accent:      #06b6d4;
  --accent-2:    #3b82f6;
  --pink:        #ec4899;
  --green:       #10b981;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --grad-1:      linear-gradient(135deg, #7c3aed 0%, #ec4899 50%, #f97316 100%);
  --grad-2:      linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --grad-3:      linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   22px;
  --shadow-1:    0 6px 24px rgba(0,0,0,0.35);
  --shadow-2:    0 12px 48px rgba(124,58,237,0.18);
  --shadow-glow: 0 0 0 4px rgba(124,58,237,0.18);
  --transition:  200ms cubic-bezier(.4,0,.2,1);
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="light"] {
  --bg:        #f6f7fb;
  --bg-2:      #ffffff;
  --surface:   #ffffff;
  --surface-2: #f0f2f8;
  --border:    rgba(15,20,40,0.08);
  --border-2:  rgba(15,20,40,0.14);
  --text:      #14172a;
  --text-2:    #444963;
  --text-3:    #6b7088;
  --shadow-1:  0 6px 24px rgba(15,20,40,0.08);
}

/* ---------- base ---------- */
*,*::before,*::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124,58,237,0.15), transparent),
    radial-gradient(900px 600px at 90% 0%, rgba(6,182,212,0.10), transparent);
}
img,svg { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-2); }
h1,h2,h3,h4 { line-height: 1.2; font-weight: 700; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
code,pre,kbd { font-family: var(--font-mono); }
.lead { font-size: 1.15rem; color: var(--text-2); }
.muted { color: var(--text-3); }
.small { font-size: 0.85rem; }

/* Accessible keyboard path and consistent interactive focus. */
.skip-link {
  position: fixed; top: .75rem; inset-inline-start: 1rem; z-index: 1200;
  transform: translateY(-180%); padding: .65rem .9rem; border-radius: 8px;
  background: var(--text); color: var(--bg); font-weight: 700;
  transition: transform var(--transition);
}
.skip-link:focus { transform: translateY(0); color: var(--bg); }
:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(6,182,212,.8); outline-offset: 3px;
}

/* Arabic is a first-class reading direction, not a translated afterthought. */
.is-arabic { font-family: 'Noto Sans Arabic', var(--font); }
.is-arabic h1, .is-arabic h2, .is-arabic h3, .is-arabic h4,
.is-arabic button, .is-arabic input, .is-arabic textarea, .is-arabic select { font-family: inherit; }
.language-switch { display: inline-flex; align-items: center; gap: .35rem; }
[dir="rtl"] .hero-stats div { text-align: right; }
[dir="rtl"] .card-link i, [dir="rtl"] .btn i.fa-arrow-right { transform: rotate(180deg); }
[dir="rtl"] .float-card.c1 { left: auto; right: 5%; }
[dir="rtl"] .float-card.c2 { right: auto; left: 5%; }
[dir="rtl"] .float-card.c3 { left: auto; right: 0; }
[dir="rtl"] .float-card.c4 { right: auto; left: 15%; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }
.main { min-height: 70vh; padding-top: 80px; }
.grad-text {
  background: var(--grad-1);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); color: var(--text); }
.btn-primary { background: var(--grad-1); border: none; color: #fff; }
.btn-primary:hover { box-shadow: var(--shadow-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger:hover { color: var(--red); }
.btn-lg { padding: 0.9rem 1.6rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---------- header ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(11,13,23,0.7);
  backdrop-filter: saturate(150%) blur(20px);
  -webkit-backdrop-filter: saturate(150%) blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
[data-theme="light"] .site-header { background: rgba(246,247,251,0.85); }
.nav-wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 0.65rem;
  min-height: 82px; min-width: 0;
}
.brand {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  width: max-content; flex: 0 0 auto;
  font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em;
  color: var(--text);
}
.brand-mark { display: flex; align-items: center; gap: 0.6rem; line-height: 1; }
.brand-byline { display: block; width: 100%; margin-top: 0.12rem; color: var(--text-3); font-size: 0.48rem; line-height: 1; font-weight: 500; letter-spacing: 0.01em; text-align: center; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--grad-1); border-radius: 10px; color: #fff; font-size: 1.1rem;
  box-shadow: 0 6px 18px rgba(124,58,237,0.4);
}
.brand strong { background: var(--grad-1); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.site-nav {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.1rem; flex: 1; min-width: 0;
}
.site-nav a {
  padding: 0.42rem 0.58rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 0.82rem; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 0.4rem;
  transition: all var(--transition);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a.active { color: var(--text); background: var(--surface-2); }
.site-nav a.nav-cta { margin-left: 0.5rem; }
.language-switch { min-width: 3rem; justify-content: center; font-weight: 800 !important; letter-spacing: 0.02em; }
.search-trigger {
  background: var(--surface); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; color: var(--text-2);
  display: grid; place-items: center; transition: all var(--transition);
}
.search-trigger:hover { color: var(--text); border-color: var(--border-2); }
.header-language { flex: 0 0 auto; min-height: 40px; padding: .42rem .65rem; border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); font-size: .78rem; font-weight: 800; }
.header-language:hover { color: var(--text); background: var(--surface-2); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.nav-close { display: none; }
.nav-scrim { display: none; }

/* ---------- search overlay ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 8vh 1rem;
}
.search-overlay.open { display: flex; }
.search-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 640px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  animation: pop 200ms ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.search-input-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.search-input-wrap i { color: var(--text-3); }
.search-input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 1.05rem; font-family: inherit;
}
.search-input-wrap kbd {
  background: var(--surface-2); padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.8rem; color: var(--text-3);
}
.search-results { max-height: 60vh; overflow-y: auto; padding: 0.5rem; }
.search-result {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  text-decoration: none; transition: background var(--transition);
}
.search-result:hover { background: var(--surface-2); color: var(--text); }
.search-result .icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--primary-2);
}
.search-result .kind { font-size: 0.7rem; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.06em; }
.search-result .title { font-weight: 600; }
.search-result .sub { font-size: 0.85rem; color: var(--text-3); }
.search-empty { padding: 2rem; text-align: center; color: var(--text-3); }

/* ---------- hero ---------- */
.hero {
  padding: 4rem 0 3rem;
  position: relative;
}
.hero-grid {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.9rem; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); font-size: 0.85rem; font-weight: 500;
}
.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  line-height: 1.05; letter-spacing: -0.03em;
  margin: 1rem 0;
}
.hero-rotating-line {
  display: block;
  height: 1.05em;
  min-height: 1.05em;
  line-height: 1.05;
  white-space: nowrap;
  contain: layout;
}
.typewriter {
  display: inline-block;
  min-width: 8ch;
  white-space: nowrap;
  vertical-align: bottom;
  background: var(--grad-1); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 1.15rem; color: var(--text-2); max-width: 560px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border);
  max-width: 560px;
}
.hero-stats div { text-align: left; }
.hero-stats strong { display: block; font-size: 1.8rem; background: var(--grad-1); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-stats span { font-size: 0.8rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

.hero-art { position: relative; min-height: 380px; }
.orbit {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at center, rgba(124,58,237,0.15), transparent 50%),
    conic-gradient(from 0deg, transparent, rgba(124,58,237,0.18), transparent 30%, rgba(6,182,212,0.15), transparent 60%);
  filter: blur(40px);
  animation: spin 30s linear infinite;
  border-radius: 50%;
}
@keyframes spin { to { transform: rotate(360deg); } }
.float-card {
  position: absolute; padding: 0.85rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem;
  box-shadow: var(--shadow-1); backdrop-filter: blur(6px);
  animation: float 6s ease-in-out infinite;
}
.float-card i { color: var(--primary-2); font-size: 1.1rem; }
.float-card.c1 { top: 5%; left: 5%; animation-delay: 0s; }
.float-card.c2 { top: 18%; right: 5%; animation-delay: 1.5s; }
.float-card.c3 { bottom: 25%; left: 0; animation-delay: 3s; }
.float-card.c4 { bottom: 8%; right: 15%; animation-delay: 4.5s; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* Homepage task launcher: the first interaction is a decision, not a feed. */
.quick-actions {
  position: relative; z-index: 1; padding: 1.15rem 0 0;
}
.quick-actions .container {
  padding-block: 1.25rem 1.35rem;
  border-block: 1px solid var(--border);
}
.quick-actions-head {
  display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .9rem;
}
.quick-actions-head h2 { margin: .15rem 0 0; font-size: 1.35rem; }
.quick-actions-head p { margin: 0; color: var(--text-3); font-size: .9rem; }
.eyebrow { color: var(--primary-2); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.quick-actions-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
.quick-action {
  display: flex; align-items: center; gap: .65rem; min-height: 58px; padding: .75rem .85rem;
  background: color-mix(in srgb, var(--surface) 86%, var(--primary) 14%);
  border: 1px solid var(--border); border-radius: 12px; color: var(--text-2); font-size: .86rem; font-weight: 650;
  transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition);
}
.quick-action > i:first-child { color: var(--primary-2); font-size: 1rem; }
.quick-action .arrow { margin-inline-start: auto; color: var(--text-3); font-size: .75rem; }
.quick-action:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary-2) 50%, var(--border)); color: var(--text); background: var(--surface-2); }
.quick-action-accent { background: var(--grad-1); color: #fff; border-color: transparent; }
.quick-action-accent > i:first-child, .quick-action-accent .arrow { color: #fff; }

/* ---------- sections ---------- */
.section { padding: 4rem 0; position: relative; z-index: 1; }
.section-alt { background: linear-gradient(180deg, transparent, var(--bg-2) 30%, var(--bg-2) 70%, transparent); }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem;
  flex-wrap: wrap;
}
.section-title { font-size: clamp(1.5rem, 3vw, 2.1rem); display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; }
.see-all { color: var(--text-2); font-weight: 600; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 0.4rem; }
.see-all:hover { color: var(--primary-2); gap: 0.7rem; }

/* ---------- cards ---------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem;
}
.card-grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: all var(--transition);
  color: var(--text); text-decoration: none;
  position: relative;
}
.card:hover { transform: translateY(-4px); border-color: var(--border-2); box-shadow: var(--shadow-1); color: var(--text); }
.card:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-glow); }
.card-cover {
  height: 160px; background-size: cover; background-position: center;
  background-color: var(--surface-2);
  display: grid; place-items: center;
}
.motion-thumb {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-position: center;
  transition: background-position 1.2s cubic-bezier(.2,.8,.2,1), filter var(--transition);
}
.motion-thumb::before {
  content: '';
  position: absolute;
  inset: -35%;
  z-index: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.2), transparent 23%),
    linear-gradient(115deg, transparent 35%, rgba(255,255,255,.16) 50%, transparent 65%);
  transform: translateX(-35%) rotate(8deg);
  animation: thumbnail-sheen 9s ease-in-out infinite;
  pointer-events: none;
}
.motion-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.12), transparent 48%, rgba(236,72,153,.12));
  mix-blend-mode: screen;
  pointer-events: none;
}
.motion-thumb > * { position: relative; z-index: 1; }
.card:hover .motion-thumb { background-position: 54% 46%; filter: saturate(1.12) brightness(1.06); }
@keyframes thumbnail-sheen {
  0%, 55%, 100% { transform: translateX(-35%) rotate(8deg); opacity: 0; }
  65% { transform: translateX(35%) rotate(8deg); opacity: .8; }
  78% { transform: translateX(65%) rotate(8deg); opacity: 0; }
}
.card-cover-default { color: var(--text-3); font-size: 2.5rem; }
.card-cover-default.card-cover-game { color: var(--pink); }
.card-cover-default.card-cover-tutorial { color: var(--accent); }
.card-cover-default.card-cover-blog { color: var(--green); }
.prompt-card-cover { height: 145px; position: relative; background-image: linear-gradient(135deg, rgba(124,58,237,.65), rgba(236,72,153,.35)); }
.prompt-card-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 20%, rgba(10,12,28,.8)); }
.prompt-card-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: rgba(255,255,255,.16); color: #fff; font-size: 1.25rem; backdrop-filter: blur(4px); }
.repo-card-cover { height: 145px; position: relative; background-image: linear-gradient(135deg, rgba(15,23,42,.55), rgba(37,99,235,.45)); }
.repo-card-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 20%, rgba(10,12,28,.8)); }
.repo-card-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: rgba(255,255,255,.16); color: #fff; font-size: 1.35rem; backdrop-filter: blur(4px); }
.card-body { padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.card-title { font-size: 1.05rem; margin: 0 0 0.4rem; font-weight: 700; line-height: 1.35; }
.card-sub { font-size: 0.9rem; color: var(--text-2); margin: 0 0 0.6rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.card-text { font-size: 0.88rem; color: var(--text-3); margin: 0 0 0.8rem; flex: 1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }
.card-link { color: var(--primary-2); font-weight: 600; }
.card-views { color: var(--text-3); }
.card-views i + i { margin-left: 0.6rem; }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem; border-radius: 100px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 0.75rem; font-weight: 500;
}
.chip-pricing.chip-free { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.25); }
.chip-pricing.chip-freemium { background: rgba(6,182,212,0.12); color: #67e8f9; border-color: rgba(6,182,212,0.25); }
.chip-pricing.chip-paid { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.25); }
.chip-pricing.chip-open-source { background: rgba(124,58,237,0.12); color: #c4b5fd; border-color: rgba(124,58,237,0.25); }
.chip-difficulty.chip-beginner { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.25); }
.chip-difficulty.chip-intermediate { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.25); }
.chip-difficulty.chip-advanced { background: rgba(239,68,68,0.12); color: #fca5a5; border-color: rgba(239,68,68,0.25); }
.chip-model { background: rgba(124,58,237,0.12); color: #c4b5fd; border-color: rgba(124,58,237,0.25); }

.prompt-preview {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.75rem; font-size: 0.8rem; color: var(--text-2);
  white-space: pre-wrap; overflow: hidden; max-height: 110px;
  font-family: var(--font-mono);
}

/* Content-native card variants keep each section from becoming the same feed. */
.card-tool .card-cover { height: 145px; }
.card-prompt .card-cover { height: 132px; }
.card-prompt .prompt-preview { min-height: 86px; }
.card-tutorial .card-cover { height: 155px; }
.card-game .card-cover { height: 170px; }
.card-repo { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: stretch; }
.card-repo .card-cover { height: 100%; min-height: 210px; border-inline-end: 1px solid var(--border); }
.card-repo .card-body { min-width: 0; }
.card-repo .card-title { font-size: .98rem; overflow-wrap: anywhere; }
.card-repo .card-text { -webkit-line-clamp: 5; }
.card-blog .card-cover { height: 180px; }
.listing-blog .card-blog:first-child { border-color: color-mix(in srgb, var(--primary-2) 42%, var(--border)); }

/* Listing rhythm: filters belong near the page title and remain available while browsing. */
.listing-section { padding-top: .85rem; }
.listing-section .filter-bar { position: sticky; top: 82px; z-index: 15; margin-bottom: .75rem; box-shadow: 0 12px 30px rgba(0,0,0,.12); }
.listing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 32px; margin-bottom: 1rem; color: var(--text-3); font-size: .82rem; }
.result-count strong { color: var(--text); font-size: .95rem; }
.listing-hint { display: inline-flex; align-items: center; gap: .4rem; }
.listing-hint i { color: var(--primary-2); }

/* ---------- Maths Meems joke feed ---------- */
.meem-head { padding-bottom: 1.35rem; }
.meem-head .eyebrow { color: var(--accent); }
.meem-callout { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.15rem; border: 1px solid color-mix(in srgb, var(--primary-2) 35%, var(--border)); border-radius: var(--radius); background: linear-gradient(110deg, rgba(124,58,237,.15), rgba(6,182,212,.07)); }
.meem-callout p { margin: .25rem 0 0; color: var(--text-3); font-size: .86rem; }
.meem-callout-symbol { display: grid; place-items: center; width: 3rem; height: 3rem; flex: 0 0 3rem; border-radius: 1rem; background: var(--grad-1); font-size: 1.6rem; box-shadow: 0 8px 22px rgba(236,72,153,.2); }
.meem-count { margin-inline-start: auto; white-space: nowrap; color: var(--text-3); font-size: .82rem; }
.meem-count strong { color: var(--text); font-size: 1.25rem; }
.meem-filters { margin-bottom: .8rem; }
.meem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 1rem; }
.meem-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 28px rgba(0,0,0,.14); transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease; }
.meem-card:hover { transform: translateY(-4px) rotate(.25deg); border-color: color-mix(in srgb, var(--primary-2) 55%, var(--border)); box-shadow: 0 16px 34px rgba(124,58,237,.18); }
.meem-card-top { display: flex; align-items: center; justify-content: space-between; padding: .75rem .85rem .2rem; }
.meem-emoji { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .75rem; background: rgba(255,255,255,.1); font-size: 1.35rem; }
.meem-menu { color: var(--text-3); letter-spacing: .16rem; }
.meem-source-tag { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .5rem; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; color: var(--accent); font-size: .68rem; font-weight: 800; }
.meem-media { position: relative; display: block; height: 174px; margin: .2rem .85rem .35rem; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 1rem; background: #090b15; }
.meem-media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 260ms ease; }
.meem-media:hover img { transform: scale(1.04); }
.meem-media-source { position: absolute; right: .55rem; bottom: .55rem; padding: .28rem .5rem; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(7,10,24,.78); color: #fff; font-size: .68rem; font-weight: 700; }
.meem-visual { position: relative; display: grid; place-items: center; min-height: 132px; margin: .2rem .85rem .35rem; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 1rem; isolation: isolate; background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.18), transparent 35%), linear-gradient(135deg, #25114b, #102c42); }
.meem-visual::before, .meem-visual::after { content: ''; position: absolute; width: 8rem; height: 8rem; border: 1px solid rgba(255,255,255,.14); border-radius: 44% 56% 60% 40%; animation: meem-visual-spin 12s linear infinite; }
.meem-visual::after { width: 5rem; height: 5rem; border-color: rgba(255,255,255,.1); animation-direction: reverse; animation-duration: 8s; }
.meem-visual-character { position: relative; z-index: 2; display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 1.1rem; background: rgba(8,10,26,.62); font-size: 2rem; box-shadow: 0 8px 24px rgba(0,0,0,.24); animation: meem-visual-bob 3.4s ease-in-out infinite; }
.meem-visual-symbol { position: absolute; z-index: 2; top: 1rem; right: 1.15rem; color: #facc15; font: 800 1.6rem/1 var(--font-mono); animation: meem-visual-pop 2.5s ease-in-out infinite; }
.meem-visual-label { position: absolute; z-index: 2; bottom: .75rem; left: .8rem; max-width: calc(100% - 1.6rem); overflow: hidden; color: rgba(255,255,255,.72); font-size: .68rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.meem-visual-orbit { position: absolute; z-index: 1; width: .55rem; height: .55rem; border-radius: 50%; background: #fff; box-shadow: 0 0 15px currentColor; animation: meem-visual-orbit 5s linear infinite; }
.meem-visual-orbit.orbit-a { color: var(--accent); top: 1rem; left: 1rem; }
.meem-visual-orbit.orbit-b { color: var(--pink); right: 1rem; bottom: 1rem; animation-duration: 7s; animation-delay: -2s; }
.meem-visual-1 { background: radial-gradient(circle at 25% 25%, rgba(6,182,212,.45), transparent 46%), linear-gradient(135deg, #0c3048, #171536); }
.meem-visual-2 { background: radial-gradient(circle at 75% 25%, rgba(236,72,153,.45), transparent 46%), linear-gradient(135deg, #38143e, #161632); }
.meem-visual-3 { background: radial-gradient(circle at 50% 15%, rgba(245,158,11,.4), transparent 46%), linear-gradient(135deg, #3a2615, #1b1730); }
.meem-visual-4 { background: radial-gradient(circle at 25% 25%, rgba(16,185,129,.4), transparent 46%), linear-gradient(135deg, #12382f, #101e35); }
.meem-visual-5 { background: radial-gradient(circle at 75% 25%, rgba(59,130,246,.45), transparent 46%), linear-gradient(135deg, #102d51, #171631); }
.meem-visual-6 { background: radial-gradient(circle at 25% 25%, rgba(249,115,22,.42), transparent 46%), linear-gradient(135deg, #3d2018, #1b1835); }
.meem-visual-7 { background: radial-gradient(circle at 65% 25%, rgba(168,85,247,.44), transparent 46%), linear-gradient(135deg, #29134c, #121d39); }
.meem-joke { display: flex; min-height: 168px; flex-direction: column; justify-content: center; padding: .75rem 1rem 1.15rem; }
.meem-setup { margin: 0 0 .8rem; color: var(--text-2); font-size: .92rem; line-height: 1.5; }
.meem-punchline { position: relative; margin: 0; padding-top: .8rem; border-top: 1px solid var(--border); color: var(--text); font-size: 1.06rem; font-weight: 800; line-height: 1.45; }
.meem-punchline::before { content: '↳'; position: absolute; inset-inline-start: 0; top: .75rem; color: var(--primary-2); font-size: 1.05rem; }
.meem-punchline { padding-inline-start: 1.4rem; }
.meem-card-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .85rem; border-top: 1px solid var(--border); background: rgba(255,255,255,.025); }
.meem-family { color: var(--green); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.meem-card[data-tone="cyan"] { border-top: 3px solid var(--accent); }
.meem-card[data-tone="pink"] { border-top: 3px solid var(--pink); }
.meem-card[data-tone="amber"] { border-top: 3px solid var(--amber); }
.meem-card[data-tone="green"] { border-top: 3px solid var(--green); }
.meem-card[data-tone="blue"] { border-top: 3px solid var(--accent-2); }
.meem-card[data-tone="violet"] { border-top: 3px solid var(--primary-2); }
@keyframes meem-visual-bob { 0%,100% { translate: 0 3px; rotate: -2deg; } 50% { translate: 0 -5px; rotate: 2deg; } }
@keyframes meem-visual-spin { to { rotate: 360deg; } }
@keyframes meem-visual-orbit { from { translate: 0 0; } 50% { translate: 84px 24px; } to { translate: 0 0; } }
@keyframes meem-visual-pop { 0%,100% { opacity: .45; scale: .8; } 50% { opacity: 1; scale: 1.15; } }

/* The homepage uses rails for discovery; full listing pages retain the grid. */
.home-rail { grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); grid-template-columns: none; overflow-x: auto; padding: .15rem .2rem .75rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
.home-rail > * { scroll-snap-align: start; }

/* ---------- page heads ---------- */
.page-head {
  padding: 2.15rem 0 1.15rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .4rem;
}
.page-head h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin-bottom: 0.5rem; letter-spacing: -0.02em; }
.page-head p { font-size: 1.1rem; color: var(--text-2); }

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.5rem;
  padding: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-input {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.4rem 0.8rem; flex: 1; min-width: 220px;
}
.search-input input { background: none; border: none; outline: none; color: var(--text); flex: 1; font-size: 0.95rem; font-family: inherit; }
.search-input i { color: var(--text-3); }
.filter-bar select, .filter-bar .filter-input {
  padding: 0.55rem 0.85rem; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem; font-family: inherit;
}

/* ---------- detail pages ---------- */
.detail-page { padding: 2rem 0 4rem; }
.back-link { color: var(--text-2); font-size: 0.9rem; display: inline-flex; gap: 0.4rem; align-items: center; margin-bottom: 1.5rem; }
.back-link:hover { color: var(--primary-2); }
.detail-head { margin-bottom: 2rem; }
.detail-hero { height: 320px; border-radius: var(--radius-lg); background-size: cover; background-position: center; margin-bottom: 1.5rem; border: 1px solid var(--border); }
.prompt-detail-hero { height: 220px; background-position: center 35%; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.detail-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0.5rem 0; letter-spacing: -0.02em; }
.detail-head .lead { font-size: 1.15rem; color: var(--text-2); margin-bottom: 1.5rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.description { font-size: 1.1rem; color: var(--text-2); margin-bottom: 1.5rem; }
.detail-section { margin: 2.5rem 0; }
.detail-section h2 { display: flex; align-items: center; gap: 0.5rem; }
.detail-section h2 i { color: var(--primary-2); }
.game-embed-panel { margin-top: 1.5rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.game-embed-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; color: var(--text-2); }
.game-embed-head strong { color: var(--text); }
.game-embed-head i { color: var(--primary-2); }
.game-embed-head a { color: var(--primary-2); font-size: .85rem; }
.game-embed-frame { display: block; width: 100%; height: min(72vh, 720px); min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.game-embed-note { margin: .65rem 0 0; color: var(--text-3); font-size: .8rem; }

/* ---------- prompt detail ---------- */
.prompt-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0;
}
.prompt-block-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.1rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-weight: 600;
  color: var(--text-2);
}
.prompt-block-head i { color: var(--primary-2); margin-right: 0.4rem; }
.prompt-full { margin: 0; padding: 1.25rem; background: var(--bg-2); font-size: 0.95rem; overflow-x: auto; white-space: pre-wrap; color: var(--text); }
.prompt-output { background: var(--bg-2); padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); white-space: pre-wrap; font-size: 0.9rem; }

/* ---------- prose ---------- */
.prose { color: var(--text-2); font-size: 1.02rem; line-height: 1.75; max-width: 75ch; }
.prose h1,.prose h2,.prose h3 { color: var(--text); margin-top: 2em; }
.prose h2 { border-bottom: 1px solid var(--border); padding-bottom: 0.4em; }
.prose a { color: var(--primary-2); }
.prose a:hover { text-decoration: underline; }
.prose code { background: var(--surface-2); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.92em; color: var(--accent); }
.prose pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; }
.prose pre code { background: none; padding: 0; color: var(--text); }
.prose blockquote { border-left: 4px solid var(--primary); padding-left: 1rem; color: var(--text-2); margin: 1.5em 0; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; }
.prose th { background: var(--surface-2); text-align: left; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

.tutorial-prose { max-width: 80ch; }
.video-embed { aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; margin: 1rem 0 2rem; }
.video-embed iframe { width: 100%; height: 100%; border: 0; }
.video-fallback { margin: .65rem 0 0; color: var(--muted); font-size: .9rem; }
.video-fallback a { color: var(--accent); }
.tutorial-complete { margin-top: 3rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }

/* ---------- blog detail ---------- */
.blog-detail { padding: 2rem 0 4rem; }
.blog-hero { height: 360px; border-radius: var(--radius-lg); background-size: cover; background-position: center; margin: 1rem 0 1.5rem; border: 1px solid var(--border); }
.blog-head h1 { font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: -0.02em; }
.blog-meta { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--text-3); font-size: 0.9rem; margin: 0.5rem 0 1.5rem; }
.blog-meta i { color: var(--primary-2); margin-right: 0.3rem; }
.blog-body .prose { font-size: 1.08rem; }
.blog-gallery { margin: 2rem auto 2.5rem; max-width: 960px; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.blog-gallery-head, .blog-gallery-controls { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.blog-gallery-head { margin: .25rem .25rem .9rem; }
.blog-gallery-head h2 { margin: 0; font-size: 1.15rem; }
.blog-gallery-head h2 i, .blog-reference-panel i { color: var(--primary-2); }
.blog-gallery-count { color: var(--text-3); font-size: .8rem; }
.blog-gallery-stage { margin: 0; overflow: hidden; border-radius: var(--radius); background: var(--bg-2); }
.blog-gallery-image { display: block; width: 100%; height: min(54vw, 520px); min-height: 220px; object-fit: cover; transition: opacity .2s ease; }
.blog-gallery-caption { padding: .7rem .9rem; color: var(--text-2); font-size: .85rem; }
.blog-gallery-controls { justify-content: center; margin-top: .8rem; }
.blog-gallery-dots { display: flex; align-items: center; gap: .4rem; }
.blog-gallery-dot { width: .5rem; height: .5rem; padding: 0; border: 0; border-radius: 50%; background: var(--text-3); cursor: pointer; }
.blog-gallery-dot.active { width: .75rem; border-radius: 1rem; background: var(--primary-2); }
.blog-reference-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0; padding: 1rem 1.15rem; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border)); border-radius: var(--radius); }
.blog-reference-panel div { display: flex; align-items: center; gap: .6rem; }
.blog-reference-panel a { color: var(--primary-2); font-weight: 600; }
.book-cover { position: relative; min-height: 250px; background-size: cover; background-position: center; }
.book-year { position: absolute; top: .7rem; right: .7rem; padding: .25rem .5rem; border-radius: 999px; background: rgba(8,12,24,.78); color: #fff; font-size: .75rem; }
.book-author, .book-detail-author { color: var(--text-3); font-size: .9rem; }
.book-detail-grid { display: grid; grid-template-columns: minmax(190px, 280px) 1fr; gap: 3rem; max-width: 1000px; margin: 2rem auto; }
.book-detail-cover { display: block; width: 100%; border-radius: var(--radius); box-shadow: 0 18px 40px rgba(0,0,0,.28); }
.book-buy-links { display: flex; flex-direction: column; gap: .55rem; margin-top: 1rem; }
.book-buy-links .btn { justify-content: center; }
.book-author-panel { display: flex; align-items: flex-start; gap: 1rem; margin: 2rem 0; padding: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.book-author-panel img { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; }
.book-author-panel h2, .book-detail-section h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.book-author-panel p, .book-detail-section p { margin: 0; color: var(--text-2); line-height: 1.7; }
.book-detail-section { margin-top: 2rem; }
.book-detail-section h2 i { color: var(--primary-2); }
.book-resource-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.book-resource-links a { color: var(--primary-2); }
.share-bar {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 3rem 0 2rem; padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.share-bar span { color: var(--text-2); font-weight: 600; }
.share-bar a, .share-bar button {
  width: 40px; height: 40px; border-radius: 8px;
  display: grid; place-items: center; background: var(--surface-2);
  color: var(--text-2); border: 1px solid var(--border); cursor: pointer; transition: all var(--transition);
}
.share-bar a:hover, .share-bar button:hover { color: var(--primary-2); transform: translateY(-2px); }
.related { margin-top: 3rem; }
.related h3 { margin-bottom: 1.5rem; }

/* ---------- tutoring ---------- */
.tutoring-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 3rem; }
.tutoring-info h2 { margin-top: 1.5rem; }
.check-list { list-style: none; padding: 0; }
.check-list li { padding: 0.5rem 0; display: flex; gap: 0.6rem; align-items: center; }
.check-list i { color: var(--green); }
.subject-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tutoring-form-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.tutoring-form-wrap h2 { margin-top: 0; }

.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--text-2); font-weight: 500; }
.form input, .form select, .form textarea {
  padding: 0.7rem 0.85rem; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.95rem; font-family: inherit;
  transition: all var(--transition);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--shadow-glow);
}
.form textarea { resize: vertical; min-height: 90px; }
.form .check { flex-direction: row; align-items: center; gap: 0.5rem; }
.form-check-group { display: flex; gap: 1rem; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }

.alert { padding: 0.85rem 1rem; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.alert-success { background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.alert-error { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* ---------- contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 3rem; }
.contact-grid p i { width: 24px; color: var(--primary-2); margin-right: 0.4rem; }
.socials { display: flex; gap: 0.5rem; }
.socials a { width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-2); transition: all var(--transition); }
.socials a:hover { color: var(--primary-2); transform: translateY(-2px); }
.socials-lg a { width: 44px; height: 44px; }

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.4rem; flex-wrap: wrap; margin: 2rem 0; }
.page-link { padding: 0.5rem 0.85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-2); font-size: 0.9rem; }
.page-link:hover { color: var(--text); }
.page-link.active { background: var(--grad-1); color: #fff; border: none; }
.page-ellipsis { color: var(--text-3); padding: 0 0.5rem; }
.pagination-info { text-align: center; color: var(--text-3); font-size: 0.85rem; }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-3); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; color: var(--text-3); }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }
.empty-state-sm { text-align: center; padding: 2rem; color: var(--text-3); }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 5rem; padding: 4rem 0 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  position: relative; z-index: 1;
}
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 2.5rem; margin-bottom: 3rem; }
.footer-col h4 { color: var(--text); margin-bottom: 1rem; font-size: 1rem; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { padding: 0.3rem 0; }
.footer-col a { color: var(--text-2); }
.footer-col a:hover { color: var(--primary-2); }
.footer-col p { color: var(--text-3); font-size: 0.9rem; }
.newsletter { display: flex; gap: 0.4rem; margin-top: 1rem; }
.newsletter input { flex: 1; padding: 0.6rem 0.85rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem; font-family: inherit; }
.newsletter button { width: 42px; height: 42px; border: none; background: var(--grad-1); color: #fff; border-radius: var(--radius-sm); cursor: pointer; }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 2rem; border-top: 1px solid var(--border); color: var(--text-3); font-size: 0.85rem; }
.footer-meta { margin-top: 1rem; font-size: 0.85rem; }

/* ---------- floating actions & toast ---------- */
.floating-actions {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  display: flex; align-items: center; gap: 12px;
}
.floating-action,
.theme-toggle {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  display: grid; place-items: center; font-size: 1.1rem;
  box-shadow: var(--shadow-1); transition: all var(--transition);
}
.floating-action:hover,
.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle:hover { transform: translateY(-2px) rotate(15deg); }
.floating-action.active {
  background: var(--grad-1);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-2);
}
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 0.85rem 1.4rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; color: var(--text); font-weight: 500; opacity: 0;
  transition: all 300ms; z-index: 1000; box-shadow: var(--shadow-1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- cta section ---------- */
.cta-section { padding: 4rem 0; }
.cta-card {
  background: var(--grad-1);
  border-radius: var(--radius-lg);
  padding: 3rem;
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  color: #fff; flex-wrap: wrap;
  box-shadow: 0 20px 60px rgba(124,58,237,0.4);
}
.cta-card h2 { font-size: 1.8rem; margin: 0 0 0.5rem; }
.cta-card p { margin: 0; opacity: 0.9; }
.cta-card .btn { background: #fff; color: var(--primary); border: none; }
.cta-card .btn:hover { background: rgba(255,255,255,0.9); }

/* ---------- reading-progress bar ---------- */
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, #7c3aed, #ec4899, #f97316);
  z-index: 1000; transition: width 80ms linear;
  box-shadow: 0 0 12px rgba(124,58,237,0.5);
}

/* ---------- KaTeX / prose math enhancements ---------- */
.prose .katex { font-size: 1.05em; }
.prose .katex-display { margin: 1.2em 0; overflow-x: auto; overflow-y: hidden; }
.prose pre {
  position: relative;
  background: #0a0c14;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
}
.prose pre code { background: none; padding: 0; }
.prose :not(pre) > code {
  background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 4px;
  font-size: 0.92em; color: var(--accent);
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .site-nav a { padding-inline: 0.42rem; font-size: 0.76rem; }
  .site-nav a i { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .tutoring-grid, .contact-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1320px) {
  .nav-wrap { justify-content: flex-start; }
  .brand { order: 1; }
  .nav-toggle { order: 2; margin-inline-start: .25rem; }
  .search-trigger { order: 3; margin-inline-start: auto; }
  .header-language { order: 4; min-height: 44px; min-width: 44px; padding-inline: .45rem; justify-content: center; }
  .nav-toggle { display: grid; place-items: center; }
  .site-nav {
    position: fixed; top: 0; right: 0; bottom: 0; left: auto; z-index: 110;
    width: min(82vw, 292px); height: 100dvh;
    background: var(--bg-2); background: color-mix(in srgb, var(--bg-2) 94%, var(--primary) 6%);
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: 4.75rem .9rem 1rem; gap: .3rem;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateX(110%); transition: transform 260ms cubic-bezier(.22,1,.36,1), opacity 180ms ease, visibility 0s linear 260ms;
    border-left: 1px solid var(--border-2); border-top: 0;
    box-shadow: -24px 0 70px rgba(0,0,0,.35); overflow-y: auto;
  }
  .site-nav.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(0); transition: transform 260ms cubic-bezier(.22,1,.36,1), opacity 180ms ease; }
  .nav-close { display: grid; place-items: center; position: absolute; top: .8rem; inset-inline-end: .9rem; z-index: 2; width: 42px; height: 42px; padding: 0; border: 1px solid var(--border-2); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 1.05rem; line-height: 1; cursor: pointer; }
  .nav-close i { display: block; line-height: 1; pointer-events: none; }
  .site-nav a { padding: .7rem .8rem; font-size: .92rem; min-height: 42px; justify-content: flex-start; }
  .site-nav a i { display: inline-block; width: 1.35rem; text-align: center; color: var(--primary-2); }
  .site-nav a.nav-cta { margin: .7rem 0 0; justify-content: center; }
  .site-nav .language-switch { justify-content: center; margin-top: .35rem; border-top: 1px solid var(--border); border-radius: 0; padding-top: 1.25rem; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 105; background: rgba(4,6,16,.62); opacity: 0; pointer-events: none; transition: opacity 220ms ease; backdrop-filter: blur(2px); }
  .nav-scrim.open { opacity: 1; pointer-events: auto; }
  [dir="rtl"] .site-nav { right: auto; left: 0; transform: translateX(-110%); border-left: 0; border-right: 1px solid var(--border-2); box-shadow: 24px 0 70px rgba(0,0,0,.35); }
  [dir="rtl"] .site-nav.open { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  .container { padding-inline: 1rem; }
  .main { padding-top: 70px; }
  .page-head { padding: 2rem 0 1rem; margin-bottom: 1rem; }
  .page-head h1 { font-size: clamp(1.7rem, 8vw, 2.35rem); }
  .page-head p { font-size: 1rem; }
  .section { padding: 2.5rem 0; }
  .listing-section .filter-bar { top: 76px; }
  .filter-bar { display: grid; grid-template-columns: 1fr; padding: .75rem; gap: .55rem; }
  .filter-bar .search-input, .filter-bar select, .filter-bar .filter-input, .filter-bar .btn { width: 100%; min-width: 0; }
  .card-grid, .card-grid-3 { grid-template-columns: 1fr; gap: 1rem; }
  .home-rail { grid-auto-flow: column; grid-auto-columns: minmax(82vw, 1fr); grid-template-columns: none; }
  .quick-actions { padding-top: .5rem; }
  .quick-actions-head { align-items: flex-start; flex-direction: column; gap: .3rem; }
  .quick-actions-grid { display: flex; overflow-x: auto; padding-bottom: .35rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .quick-action { flex: 0 0 76vw; scroll-snap-align: start; }
  .meem-callout { align-items: flex-start; flex-wrap: wrap; }
  .meem-count { margin-inline-start: 4rem; }
  .meem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .meem-joke { min-height: 185px; padding-inline: .8rem; }
  .meem-setup { font-size: .78rem; }
  .meem-punchline { font-size: .92rem; }
  .meem-card-foot { align-items: flex-start; flex-direction: column; }
  .listing-toolbar { align-items: flex-start; flex-direction: column; gap: .2rem; margin-bottom: .75rem; }
  .card-repo { display: flex; }
  .card-repo .card-cover { height: 140px; min-height: 140px; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .card-cover, .prompt-card-cover, .repo-card-cover { height: 170px; }
  .card-body { padding: 1rem; }
  .detail-page { padding: 1.25rem 0 3rem; }
  .detail-head h1 { font-size: clamp(1.55rem, 7vw, 2.2rem); overflow-wrap: anywhere; }
  .detail-head .lead, .description { font-size: 1rem; }
  .detail-actions, .hero-actions, .form-actions { flex-direction: column; align-items: stretch; }
  .detail-actions .btn, .hero-actions .btn, .form-actions .btn { width: 100%; justify-content: center; min-height: 48px; }
  .prompt-full { font-size: .82rem; padding: 1rem; }
  .prompt-block-head { gap: .6rem; }
  .prompt-block-head .btn { flex-shrink: 0; }
  .form-row, .grid-2 { grid-template-columns: 1fr; }
  .form input, .form select, .form textarea { max-width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 680px; }
  .form-row { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .detail-hero, .blog-hero { height: 200px; }
  .tutoring-form-wrap { padding: 1rem; }
  .cta-card { padding: 2rem; }
  .hero-actions { gap: .7rem; }
  .hero-actions .surprise-btn { order: 3; }
}

/* ---------- affiliate disclosure ---------- */
.affiliate-disclosure {
  display: flex; gap: 0.75rem; align-items: flex-start;
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.3);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.92rem;
}
.affiliate-disclosure i { color: var(--amber); flex-shrink: 0; margin-top: 2px; }
.affiliate-disclosure p { margin: 0; }
.affiliate-disclosure a { color: var(--amber); text-decoration: underline; }
.affiliate-disclosure a:hover { color: #fcd34d; }
[data-theme="light"] .affiliate-disclosure {
  background: rgba(245,158,11,0.06);
  color: #92400e;
}
[data-theme="light"] .affiliate-disclosure a { color: #b45309; }

/* ---------- cross-content related widget ---------- */
.related-cross {
  margin: 3rem 0 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.related-cross h3 {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; font-size: 1.1rem;
}
.related-cross h3 i { color: var(--primary-2); }
.related-cross-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem;
}
.related-cross-item {
  padding: 0.85rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 0.3rem;
  color: var(--text);
  transition: all var(--transition);
}
.related-cross-item:hover { transform: translateY(-2px); border-color: var(--border-2); color: var(--text); }
.related-cross-item .kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary-2); font-weight: 600; }
.related-cross-item .title { font-weight: 600; font-size: 0.95rem; line-height: 1.35; }
.related-cross-item .sub { font-size: 0.82rem; color: var(--text-3); }

/* ---------- coming soon ---------- */
.coming-soon-hero {
  min-height: 80vh; display: flex; align-items: center;
  text-align: center;
}
.coming-soon-hero .container { max-width: 640px; margin: 0 auto; }
.coming-soon-hero .hero-sub { max-width: none; margin: 0 auto; }
.coming-soon-form {
  display: flex; gap: 0.6rem; margin-top: 2rem;
  max-width: 420px; margin-left: auto; margin-right: auto;
}
.coming-soon-form input {
  flex: 1; padding: 0.7rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.95rem; font-family: inherit;
}
.coming-soon-form button { white-space: nowrap; }

/* ---------- smart board ---------- */
.smart-board-head p { max-width: 760px; }
.smart-board-section { padding-top: .5rem; }
.smart-board-callout {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem;
  align-items: center; padding: 1rem 1.1rem; margin-bottom: 1.25rem;
  background: linear-gradient(135deg, rgba(124,58,237,.16), rgba(6,182,212,.12));
  border: 1px solid var(--border); border-radius: 18px;
}
.smart-board-callout p { margin: .25rem 0 0; color: var(--text-2); }
.smart-board-callout-symbol {
  width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: 16px; background: rgba(255,255,255,.08);
  font-size: 1.7rem; font-weight: 800;
}
.smart-board-grid {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .9fr);
  gap: 1.2rem; align-items: start;
}
.smart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-1);
  padding: 1.2rem;
}
.smart-panel-head {
  display: flex; align-items: start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.smart-board-beta {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .35rem .65rem; border-radius: 999px;
  background: rgba(6,182,212,.12); color: var(--accent);
  font-weight: 700; font-size: .76rem; letter-spacing: .04em;
}
.smart-board-surface {
  position: relative; border-radius: 18px; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(14, 18, 31, .92), rgba(18, 23, 39, .98)),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,.04) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,.03) 40px);
  min-height: 420px; border: 1px solid var(--border);
}
[data-theme="light"] .smart-board-surface {
  background:
    linear-gradient(180deg, rgba(248,250,255,.96), rgba(240,244,252,.98)),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(15,20,40,.04) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(15,20,40,.03) 40px);
}
.smart-board-canvas {
  display: block; width: 100%; height: 420px; touch-action: none; cursor: crosshair;
}
.smart-board-toolbar, .smart-board-keypad, .smart-board-actions {
  display: flex; flex-wrap: wrap; gap: .6rem;
}
.smart-board-toolbar { margin-top: 1rem; }
.smart-board-hint, .smart-board-supported p {
  margin-top: .9rem; color: var(--text-2); font-size: .95rem;
}
.smart-board-label {
  display: block; margin-bottom: .45rem; font-weight: 700; color: var(--text-2);
}
.smart-board-input {
  width: 100%; min-height: 90px; resize: vertical;
  padding: .95rem 1rem; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); font: inherit;
}
.smart-board-keypad { margin-top: .9rem; }
.smart-board-preview {
  margin-top: 1rem; padding: 1rem; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg-2);
}
.smart-board-preview-label {
  display: block; margin-bottom: .45rem; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700;
}
.smart-board-preview-value {
  min-height: 2.2rem; font-family: var(--font-mono); font-size: 1.05rem;
  color: var(--text); overflow-wrap: anywhere;
}
.smart-board-actions { margin-top: 1rem; }
.smart-board-status {
  margin-top: .9rem; padding: .8rem .9rem; border-radius: 14px;
  background: rgba(124,58,237,.10); border: 1px solid rgba(124,58,237,.18); color: var(--text-2);
}
.smart-board-result {
  margin-top: 1rem; padding: 1rem; border-radius: 18px;
  border: 1px solid rgba(16,185,129,.22); background: rgba(16,185,129,.08);
}
.smart-board-result-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.smart-board-result-head strong { font-size: 1.15rem; }
.smart-board-steps { margin: .8rem 0 0 1.2rem; color: var(--text-2); }
.smart-board-supported { margin-top: 1rem; }

@media (max-width: 640px) {
  .floating-actions { right: 16px; bottom: 16px; gap: 10px; }
  .coming-soon-form { flex-direction: column; }
  .brand { font-size: 1.05rem; min-width: 0; }
  .brand-icon { width: 34px; height: 34px; }
  .nav-wrap { min-height: 76px; gap: .45rem; }
  .site-nav { padding-top: 5rem; }
  .search-trigger, .nav-toggle { width: 44px; height: 44px; flex: 0 0 44px; }
  .brand-name { overflow: hidden; text-overflow: ellipsis; }
  .brand-byline { font-size: .46rem; }
  .hero { padding: 2.25rem 0 2rem; }
  .hero-title { font-size: clamp(2.15rem, 12vw, 3.2rem); }
  .hero-sub { font-size: 1rem; }
  .hero-stats { gap: .65rem; }
  .hero-stats strong { font-size: 1.45rem; }
  .hero-stats span { font-size: .68rem; }
  .detail-hero, .blog-hero, .prompt-detail-hero { height: 170px; }
  .newsletter { flex-direction: column; }
  .blog-reference-panel { align-items: flex-start; flex-direction: column; }
  .blog-gallery { margin-inline: 0; padding: .7rem; }
  .book-detail-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .book-detail-cover { max-width: 240px; margin: 0 auto; }
  .prose { overflow-wrap: anywhere; }
  .listing-section { padding-top: .45rem; }
  .listing-section .filter-bar { border-radius: 12px; }
  .prose table { display: block; max-width: 100%; overflow-x: auto; }
  .smart-board-grid { grid-template-columns: 1fr; }
  .smart-panel { padding: 1rem; border-radius: 18px; }
  .smart-board-surface, .smart-board-canvas { min-height: 300px; height: 300px; }
  .smart-board-result-head { align-items: start; flex-direction: column; }
}

@media (max-width: 390px) {
  .container { padding-inline: .8rem; }
  .brand-mark { gap: .35rem; }
  .brand-icon { width: 32px; height: 32px; font-size: 1rem; }
  .brand-byline { font-size: .42rem; }
  .hero-title { font-size: 2rem; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-stats div { padding: .6rem .45rem; }
  .filter-bar { border-radius: 12px; }
  .meem-grid { grid-template-columns: 1fr; }
  .meem-count { margin-inline-start: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
