/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.site-main { min-height: 60vh; padding-bottom: 48px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-contrast); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip-link:focus { left: 8px; }

.layout-with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; margin-top: 28px; }
@media (max-width: 1024px) { .layout-with-sidebar { grid-template-columns: 1fr; } }

/* ---------- header ---------- */
.site-header { background: var(--header-bg); color: var(--header-text); position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 0 rgba(255,255,255,.04); }
.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.02em; flex-shrink: 0; }
.site-header .logo { color: #fff; }
.logo img { height: 36px; width: auto; }

.main-nav { flex: 1; min-width: 0; }
.main-nav > ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.main-nav li { position: relative; }
.main-nav > ul > li > a {
  display: flex; align-items: center; gap: 4px; height: 64px; padding: 0 12px;
  text-decoration: none; color: var(--header-text); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.main-nav > ul > li > a:hover { color: var(--accent); }
.main-nav .caret { font-size: 10px; opacity: .7; }
.sub-menu {
  position: absolute; top: 100%; left: 0; min-width: 220px; list-style: none; margin: 0; padding: 8px;
  background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); opacity: 0; visibility: hidden; transform: translateY(6px); transition: .15s;
}
.main-nav li:hover > .sub-menu, .main-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.sub-menu a { display: block; padding: 8px 12px; border-radius: 6px; text-decoration: none; font-size: 14px; }
.sub-menu a:hover { background: var(--surface-2); color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  background: transparent; border: 0; color: var(--header-text); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.bm-count {
  position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-contrast); font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.lang-switch { display: flex; margin-left: 6px; border: 1px solid rgba(255,255,255,.15); border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 6px 9px; font-size: 12px; font-weight: 700; text-decoration: none; color: var(--header-muted); }
.lang-switch a.active { background: var(--accent); color: var(--accent-contrast); }
.lang-switch a:not(.active):hover { color: #fff; }

.menu-toggle { display: none; }
.search-bar { background: var(--header-bg); border-top: 1px solid rgba(255,255,255,.06); padding: 12px 0; }
.search-bar form { display: flex; gap: 8px; }
.search-bar input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06); color: #fff;
}
.search-bar input::placeholder { color: var(--header-muted); }

.mobile-nav { position: fixed; inset: 64px 0 0 0; z-index: 49; background: rgba(0,0,0,.45); }
.mobile-nav-panel { background: var(--surface); height: 100%; width: min(320px, 85vw); overflow-y: auto; padding: 16px; }
.mobile-nav ul { list-style: none; margin: 0; padding: 0; }
.mobile-nav li a { display: block; padding: 10px 6px; text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--border); }
.mobile-nav li ul a { padding-left: 22px; font-weight: 400; }
.mobile-search input { width: 100%; height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 8px; }

@media (max-width: 1024px) {
  .main-nav { display: none; }
  .menu-toggle { display: inline-grid; }
  .header-inner { gap: 8px; }
}
@media (max-width: 480px) {
  .logo-text { font-size: 17px; }
  .lang-switch a { padding: 6px 7px; }
  .icon-btn { width: 36px; }
}

/* ---------- featured ---------- */
.featured { padding-top: 24px; }
.featured-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: repeat(2, 200px); gap: 12px; }
.featured-item { position: relative; border-radius: var(--radius); overflow: hidden; text-decoration: none; color: #fff; background: #222; }
.featured-item.is-main { grid-row: span 2; }
.featured-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.featured-item:hover img { transform: scale(1.04); }
.featured-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 16px;
  background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,.85));
}
.featured-title { font-weight: 700; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.featured-item.is-main .featured-title { font-size: 24px; }
.featured-time { font-size: 12px; opacity: .8; }
.featured-overlay .badge { align-self: flex-start; }
@media (max-width: 900px) {
  .featured-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 240px repeat(2, 160px); }
  .featured-item.is-main { grid-column: span 2; grid-row: auto; }
}
@media (max-width: 520px) {
  .featured-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: 180px; }
  .featured-item.is-main { grid-column: auto; }
  .featured-item:nth-child(n+4) { display: none; }
}

/* ---------- section titles ---------- */
.section-title { font-size: 20px; margin: 0 0 16px; padding-left: 12px; border-left: 4px solid var(--accent); line-height: 1.2; }
.page-head { padding: 8px 0 4px; }
.page-head h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -.01em; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--text-muted); padding-top: 20px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; text-decoration: none; font-weight: 500;
}
.chip:hover, .chip.active { border-color: var(--accent); color: var(--accent); }
.chip.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); text-decoration: none;
}
.badge-accent { background: var(--accent); color: var(--accent-contrast); }

/* ---------- cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .card-grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .card-grid, .card-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } }
@media (max-width: 520px) { .card-grid, .card-grid-4 { grid-template-columns: 1fr; } }

.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-thumb { display: block; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.card-title { margin: 0; font-size: 15px; line-height: 1.35; }
.card-title a { text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a:hover { color: var(--accent); }
.card-excerpt { margin: 0; color: var(--text-muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: auto; font-size: 12.5px; color: var(--text-muted); }
.dl-count { margin-left: auto; font-weight: 600; }
.card-mini .card-body { padding: 12px 14px; }
.card-mini .card-title { font-size: 14px; }

.bm-btn {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 8px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(4px);
}
.bm-btn svg { fill: none; }
.bm-btn:hover { background: rgba(0,0,0,.75); }
.bm-btn[aria-pressed="true"] { background: var(--accent); }
.bm-btn[aria-pressed="true"] svg { fill: currentColor; }
.bm-inline { position: static; width: auto; height: auto; padding: 5px 10px; gap: 6px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); backdrop-filter: none; }
.bm-inline:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.bm-inline[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.widget-title { font-size: 16px; margin: 0 0 12px; padding-left: 10px; border-left: 3px solid var(--accent); line-height: 1.2; }
.popular-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.popular-list li { display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; align-items: start; }
.popular-list .rank { grid-row: span 2; width: 28px; height: 28px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--accent); }
.popular-list a { text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.35; }
.popular-list a:hover { color: var(--accent); }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list a { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); text-decoration: none; font-size: 14px; }
.cat-list li:last-child a { border-bottom: 0; }
.cat-list a:hover { color: var(--accent); }
.cat-list .count { color: var(--text-muted); font-size: 12px; background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }

/* ---------- resource page ---------- */
.resource { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); min-width: 0; }
.resource-head h1 { font-size: 28px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -.01em; }
.resource-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 13.5px; }
.resource-cover { margin: 20px 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.resource-cover img { width: 100%; }
.lead { font-size: 17px; color: var(--text-muted); }
.prose { font-size: 15.5px; line-height: 1.75; overflow-wrap: anywhere; }
.prose h2 { font-size: 20px; margin: 28px 0 10px; }
.prose a { color: var(--accent); }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.prose ul { padding-left: 22px; }
.download-box { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 28px 0 8px; padding: 20px; background: var(--surface-2); border-radius: var(--radius); border: 1px dashed var(--border); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.info-box .btn-block { margin-bottom: 14px; }
.info-list { margin: 0; }
.info-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-list dt { color: var(--text-muted); }
.info-list dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.share a, .share button {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); text-decoration: none; font-size: 13px; font-weight: 700; cursor: pointer;
}
.share a:hover, .share button:hover { border-color: var(--accent); color: var(--accent); }
.related { margin-top: 36px; }
@media (max-width: 600px) {
  .resource { padding: 18px; }
  .resource-head h1, .page-head h1 { font-size: 22px; }
  .download-box .btn { width: 100%; }
}

/* ---------- search / 404 ---------- */
.search-inline { display: flex; gap: 8px; margin: 14px 0; max-width: 620px; }
.search-inline input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.not-found { text-align: center; padding: 60px 16px; }
.not-found .search-inline { margin: 20px auto; }
.nf-code { font-size: 96px; font-weight: 900; margin: 0; color: var(--accent); line-height: 1; }

/* ---------- footer ---------- */
.site-footer { background: var(--header-bg); color: var(--header-muted); padding: 40px 0 0; margin-top: 40px; }
.site-footer .logo { color: #fff; }
.site-footer .muted { color: var(--header-muted); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-bottom: 28px; }
.footer-title { color: #fff; font-size: 15px; margin: 0 0 12px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.08); padding: 16px; font-size: 13px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; gap: 20px; } }

.back-to-top {
  position: fixed; right: 18px; bottom: 18px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; z-index: 40;
  background: var(--accent); color: var(--accent-contrast); font-size: 20px; font-weight: 700; box-shadow: var(--shadow-lg);
}
