:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #eef1f2;
  --text: #17201d;
  --muted: #65716d;
  --line: #dce2df;
  --accent: #087f5b;
  --accent-soft: #dff4ec;
  --focus: #e8590c;
  --shadow: 0 8px 24px rgba(23, 32, 29, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.brand strong { color: var(--muted); font-weight: 500; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--text); color: #fff; border-radius: 6px; }
.section-nav { display: flex; height: 38px; padding: 3px; background: var(--surface-2); border-radius: 7px; }
.section-nav a { display: grid; place-items: center; min-width: 96px; padding: 0 16px; color: var(--muted); border-radius: 5px; font-weight: 600; }
.section-nav a.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(23, 32, 29, 0.12); }
.archive-total { justify-self: end; color: var(--muted); font-size: 13px; }

main { width: 100%; }
main:focus { outline: none; }
.catalog-view { max-width: 1540px; margin: 0 auto; padding: 34px 28px 60px; }
.catalog-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: 0; }
.muted { margin: 7px 0 0; color: var(--muted); }

.search-box {
  width: min(480px, 45vw);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box > span { color: var(--muted); font-size: 22px; line-height: 1; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: #939d99; }
.icon-button { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; font-size: 20px; color: var(--muted); }
.icon-button:hover { background: var(--surface-2); color: var(--text); }

.filters { min-height: 54px; display: flex; align-items: flex-end; gap: 12px; margin: 20px 0 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.filters label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.filters select { height: 34px; min-width: 126px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--text); background: var(--surface); }
.quiet-button, .back-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); cursor: pointer; }
.quiet-button:hover, .back-button:hover { border-color: #adb8b4; background: var(--surface-2); }

.catalog-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; min-height: 300px; }
.resource-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease; }
.resource-card:hover { transform: translateY(-2px); border-color: #bdc8c4; box-shadow: var(--shadow); }
.card-cover { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; background: #e5e9e7; }
.card-cover img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 240ms ease; }
.resource-card:hover .card-cover img { transform: scale(1.025); }
.cover-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: #82908a; font-size: 32px; font-weight: 700; }
.image-count { position: absolute; right: 8px; bottom: 8px; padding: 4px 7px; border-radius: 4px; color: #fff; background: rgba(12, 18, 16, 0.76); font-size: 11px; }
.card-body { padding: 13px 14px 14px; }
.card-title { display: block; min-height: 42px; overflow: hidden; font-size: 15px; line-height: 1.4; font-weight: 650; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.skeleton { min-height: 270px; border-radius: 7px; background: linear-gradient(90deg, #e7ebe9 20%, #f3f5f4 38%, #e7ebe9 58%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }
.empty-state { min-height: 360px; place-content: center; text-align: center; color: var(--muted); }
.empty-state:not([hidden]) { display: grid; gap: 8px; }
.empty-state strong { color: var(--text); font-size: 18px; }

.load-sentinel { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.load-spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.detail-view { max-width: 1760px; margin: 0 auto; padding: 24px 28px 70px; }
.detail-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.detail-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 30px; align-items: start; }
.detail-sidebar { position: sticky; top: 88px; min-width: 0; }
.detail-cover { width: 100%; aspect-ratio: 4 / 3; margin-bottom: 22px; display: block; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.detail-kicker { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 700; }
.detail-sidebar h1 { font-size: 25px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-meta { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 9px 12px; margin: 22px 0; padding: 18px 0; border-block: 1px solid var(--line); }
.detail-meta dt { color: var(--muted); }
.detail-meta dd { margin: 0; overflow-wrap: anywhere; }
.detail-content { max-height: 160px; overflow: auto; color: var(--muted); line-height: 1.75; white-space: pre-line; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.tag-list span { padding: 4px 7px; color: #48615a; background: var(--accent-soft); border-radius: 4px; font-size: 11px; }
.detail-main { min-width: 0; }
.detail-count { margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.asset-grid { columns: 4 260px; column-gap: 12px; }
.asset-item { position: relative; width: 100%; display: block; break-inside: avoid; margin: 0 0 12px; padding: 0; overflow: hidden; border: 0; border-radius: 5px; background: #e5e9e7; cursor: zoom-in; }
.asset-item img { width: 100%; height: auto; min-height: 120px; display: block; object-fit: cover; }
.asset-item:hover img { opacity: 0.92; }
.asset-index { position: absolute; right: 7px; bottom: 7px; padding: 3px 6px; border-radius: 3px; color: #fff; background: rgba(12, 18, 16, 0.7); font-size: 10px; }
.video-grid video { width: 100%; max-height: 70vh; margin-top: 16px; background: #111; border-radius: 5px; }

.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(8, 12, 11, 0.96); color: #fff; }
.lightbox[open] { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: center; }
.lightbox::backdrop { background: rgba(8, 12, 11, 0.8); }
.lightbox figure { grid-column: 2; min-width: 0; max-width: calc(100vw - 180px); max-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 66px); display: block; object-fit: contain; }
.lightbox figcaption { width: 100%; min-height: 50px; display: flex; justify-content: space-between; gap: 20px; align-items: center; color: #bdc5c2; font-size: 12px; }
.lightbox figcaption a { color: #fff; }
.lightbox-close, .lightbox-arrow { position: fixed; z-index: 2; border: 0; color: #fff; background: rgba(255, 255, 255, 0.08); cursor: pointer; }
.lightbox-close { top: 18px; right: 20px; width: 42px; height: 42px; border-radius: 50%; font-size: 28px; }
.lightbox-arrow { top: 50%; width: 48px; height: 64px; border-radius: 5px; transform: translateY(-50%); font-size: 38px; }
.lightbox-arrow.previous { left: 16px; }
.lightbox-arrow.next { right: 16px; }
.lightbox button:hover { background: rgba(255, 255, 255, 0.16); }

@media (max-width: 1200px) {
  .catalog-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 22px; }
}

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; min-height: 60px; padding: 10px 18px; }
  .section-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .section-nav a { flex: 1; }
  .archive-total { display: none; }
  .catalog-view, .detail-view { padding-inline: 18px; }
  .catalog-head { align-items: stretch; flex-direction: column; gap: 18px; }
  .search-box { width: 100%; }
  .filters { overflow-x: auto; align-items: flex-end; }
  .filters { scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters label { flex: 0 0 auto; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .detail-layout { display: block; }
  .detail-sidebar { position: static; margin-bottom: 28px; }
  .detail-cover { width: min(320px, 100%); }
  .asset-grid { columns: 2 220px; }
}

@media (max-width: 520px) {
  .brand strong { display: none; }
  .section-nav a { min-width: 0; }
  .catalog-view { padding-top: 24px; }
  h1 { font-size: 24px; }
  .filters { gap: 8px; }
  .filters select { min-width: 112px; max-width: 150px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .resource-card { display: grid; grid-template-columns: 136px minmax(0, 1fr); }
  .card-cover { height: 112px; aspect-ratio: auto; }
  .card-title { min-height: 0; }
  .card-meta { align-items: flex-start; flex-direction: column; }
  .detail-toolbar { gap: 10px; }
  .asset-grid { columns: 1; }
  .lightbox[open] { grid-template-columns: 1fr; }
  .lightbox figure { grid-column: 1; max-width: 100vw; }
  .lightbox-arrow { width: 40px; height: 54px; }
  .lightbox-arrow.previous { left: 6px; }
  .lightbox-arrow.next { right: 6px; }
  .lightbox figcaption { padding: 0 12px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101513;
    --surface: #171d1b;
    --surface-2: #222a27;
    --text: #edf2f0;
    --muted: #9aa7a2;
    --line: #303936;
    --accent: #55d6ad;
    --accent-soft: #173a30;
    --focus: #ffa94d;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  }
  .topbar { background: rgba(23, 29, 27, 0.94); }
  .brand-mark { color: #111; background: #edf2f0; }
  .skeleton { background: linear-gradient(90deg, #202725 20%, #2a322f 38%, #202725 58%); background-size: 300% 100%; }
}
