/* ==========================================================================
   Shared tokens + landing page
   ========================================================================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --ink: #141a2e;
  --ink-2: #48506a;
  --muted: #7a8199;
  --line: #e2e5ef;
  --line-strong: #cdd2e1;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --focus: #6366f1;
  --ok: #16a34a;
  --bad: #dc2626;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 26, 46, .06), 0 4px 16px rgba(20, 26, 46, .06);
  --shadow-lg: 0 2px 6px rgba(20, 26, 46, .08), 0 18px 40px rgba(20, 26, 46, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "PingFang SC", "Hiragino Sans", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Naskh Arabic", "Geeza Pro", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
img, svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

svg.icon, .icon-btn svg, .lang-picker svg, .sim-back svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- buttons & small controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--subject, var(--accent)); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--subject, var(--accent)); filter: brightness(1.08); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.lang-picker {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.lang-picker select {
  appearance: none; border: 0; background: transparent; padding: 0 2px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 18px;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge-mode { background: var(--ink); color: #fff; letter-spacing: .03em; }

/* ==========================================================================
   Landing
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 247, 251, .86);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header-inner, .wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; }

.hero { padding: 56px 0 28px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 10px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 50px); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 14px; }
.hero p.lead { font-size: 18px; color: var(--ink-2); margin: 0 0 24px; max-width: 56ch; }
.search {
  position: relative; display: flex; align-items: center;
  max-width: 560px; height: 52px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.search svg { position: absolute; inset-inline-start: 16px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; height: 100%; border: 0; background: transparent; padding-inline: 46px 16px; font-size: 16px; border-radius: 14px; }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
.stats { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.stats div { display: flex; align-items: baseline; gap: 6px; color: var(--ink-2); }
.stats strong { font-size: 24px; color: var(--ink); letter-spacing: -.02em; }

.hero-art { position: relative; aspect-ratio: 1 / .82; }
.hero-art svg { width: 100%; height: 100%; }

/* subject quick nav */
.subject-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin: 8px 0 0; }
.subject-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.subject-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--c); }
.subject-tile .subject-icon { background: var(--soft); color: var(--c); }
.subject-tile b { font-size: 14px; }
.subject-tile small { color: var(--muted); font-size: 12px; }
.subject-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex: none; }
.subject-icon svg.icon { width: 22px; height: 22px; }

/* filters */
.filters {
  margin: 32px 0 8px; padding: 12px 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.filters-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-inline-end: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #fff; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ink)); }
.chip[aria-pressed="true"] .dot { background: #fff; }
.result-count { margin-inline-start: auto; font-size: 13px; color: var(--muted); font-weight: 600; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; font-size: 13px; }

/* catalog sections */
.subject-section { padding: 28px 0 8px; scroll-margin-top: 140px; }
.subject-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.subject-head .subject-icon { background: var(--soft); color: var(--c); width: 44px; height: 44px; border-radius: 12px; }
.subject-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.subject-head .count { color: var(--muted); font-weight: 600; font-size: 14px; }
.topic-block { margin: 18px 0 8px; }
.topic-block h3 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--ink-2);
}
.topic-block h3::before { content: ""; width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--c); }
.card-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--soft); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.card:hover .card-thumb img { transform: scale(1.04); }
.card-thumb .fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--c); }
.card-thumb .fallback svg { width: 56px; height: 56px; }
.card-thumb .badge-mode { position: absolute; top: 10px; inset-inline-end: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.card-body h4 { margin: 0; font-size: 16.5px; line-height: 1.3; letter-spacing: -.01em; }
.card-body p {
  margin: 0; color: var(--ink-2); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.card-meta .badge-level { background: var(--soft); color: var(--c); }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 10px; font-size: 16px; }
[hidden] { display: none !important; }

.site-footer { margin-top: 56px; padding: 28px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .hero { padding-top: 32px; }
}
@media (max-width: 640px) {
  .site-header-inner, .wrap { padding: 0 16px; }
  .brand span { display: none; }
  .subject-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-inner { gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filter-group { flex-wrap: nowrap; }
  .result-count { display: none; }
  .cards { grid-template-columns: 1fr; }
}
