:root {
  --bg: #fffaf3;
  --surface: #ffffff;
  --text: #2d2620;
  --muted: #6f6257;
  --accent: #d9682b;
  --accent-strong: #b44f17;
  --accent-soft: #fde9d2;
  --line: #eadfd2;
  --shadow: 0 6px 24px rgb(80 50 20 / 10%);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --surface: #26201b;
    --text: #f3ebe3;
    --muted: #b9aa9c;
    --accent: #f08a4b;
    --accent-strong: #ffa56b;
    --accent-soft: #3a2a1f;
    --line: #3b322a;
    --shadow: 0 6px 24px rgb(0 0 0 / 35%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

img { display: block; max-width: 100%; height: auto; }
.hero-art img, .photo-frame img, .card img, dialog img { width: 100%; }
a { color: var(--accent-strong); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

.skip {
  position: absolute; left: 16px; top: -48px;
  background: var(--surface); padding: 8px 14px; border-radius: 10px; z-index: 10;
}
.skip:focus { top: 12px; }

/* Header */
.header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header .wrap { display: flex; align-items: center; gap: 16px; min-height: 68px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.logo img { width: 34px; height: 34px; }
.nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 999px; }
.nav a:hover { background: var(--accent-soft); }
.nav a[aria-current="page"] { background: var(--accent); color: #fff; }
.fav-count { color: var(--muted); font-size: .95rem; white-space: nowrap; }

/* Hero */
.hero { padding: 56px 0 40px; }
.hero .wrap { display: grid; gap: 32px; grid-template-columns: 1.1fr 1fr; align-items: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.15; margin: 0 0 16px; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 0 24px; }
.hero-art { display: block; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.button {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; border: 0; cursor: pointer; font: inherit;
}
.button:hover { background: var(--accent-strong); }
.button.ghost { background: transparent; color: var(--accent-strong); box-shadow: inset 0 0 0 2px var(--accent); }

section { padding: 32px 0; }
h2 { font-size: 1.7rem; margin: 0 0 20px; }
.lead { color: var(--muted); margin-top: -8px; }

/* Facts */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.fact strong { display: block; font-size: 1.8rem; color: var(--accent-strong); }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.card[hidden] { display: none; }
.card .photo { all: unset; cursor: zoom-in; display: block; }
.card .photo:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.card-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h3 { margin: 0; font-size: 1.2rem; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent-strong); }
.meta { color: var(--muted); font-size: .95rem; margin: 0; }
.card-actions { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

.fav {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: .95rem;
  white-space: nowrap;
}
.fav[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.fav[hidden] { display: none; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filters[hidden] { display: none; }
.filters button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit;
}
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty { color: var(--muted); }

/* Detail page */
.detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: start; }
.detail .photo-frame { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.detail h1 { margin: 0 0 8px; font-size: clamp(2rem, 4vw, 2.6rem); }
.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 20px 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.crumbs { color: var(--muted); font-size: .95rem; margin-bottom: 16px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; flex-wrap: wrap; }

/* Dialog */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: min(720px, 100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(20 12 6 / 60%); }
.dialog-body { padding: 16px 20px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dialog-body h2 { margin: 0; font-size: 1.3rem; }

.prose { max-width: 720px; }
.steps { padding-left: 1.2em; }
.note { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; }

.footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0; color: var(--muted); font-size: .95rem; }

@media (max-width: 760px) {
  .hero .wrap, .detail { grid-template-columns: 1fr; }
  .hero { padding-top: 32px; }
  .facts { grid-template-columns: 1fr; }
  .nav { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .15s ease; }
  .card:hover { transform: translateY(-3px); }
}
