:root {
  --bg: #f7f3ec;
  --bg-card: #fffdf8;
  --ink: #1f1b16;
  --ink-soft: #5c5347;
  --ink-faint: #8a8071;
  --line: #e7dfd0;
  --accent: #b8442b;     /* terracotta */
  --accent-soft: #f3e2d6;
  --accent-ink: #7e2c18;
  --leaf: #4a5d3a;
  --gold: #c08a2e;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(31,27,22,.06), 0 2px 8px rgba(31,27,22,.04);
  --shadow-md: 0 6px 18px rgba(31,27,22,.10), 0 2px 6px rgba(31,27,22,.06);
  --shadow-lg: 0 24px 60px rgba(31,27,22,.22), 0 8px 20px rgba(31,27,22,.12);
  --maxw: 1180px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --bg-card: #221d18;
    --ink: #f3ece0;
    --ink-soft: #c8bdac;
    --ink-faint: #97897a;
    --line: #382e25;
    --accent: #e0724f;
    --accent-soft: #3a261d;
    --accent-ink: #f1a98c;
    --leaf: #8fa873;
    --gold: #e0b264;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 6px 18px rgba(0,0,0,.4);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, summary {
  touch-action: manipulation;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 40px);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -44px;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.1) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .01em;
}
.brand__mark { color: var(--accent); display: inline-flex; }
.brand__name { line-height: 1; }

.site-nav { display: flex; align-items: center; gap: 8px; }

.saved-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .08s ease;
}
.saved-pill:hover { border-color: var(--accent); }
.saved-pill:active { transform: translateY(1px); }
.saved-pill[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.saved-pill .heart { flex: none; }
.saved-pill[aria-pressed="true"] .heart { fill: var(--accent); }
.saved-pill__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  padding: 0 6px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}
.saved-pill[aria-pressed="true"] .saved-pill__count {
  background: var(--accent);
  color: #fff;
}

/* ---------- Intro ---------- */
.intro {
  padding: clamp(36px, 7vw, 72px) 0 clamp(24px, 4vw, 40px);
  max-width: 720px;
}
.intro__eyebrow {
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  margin: 0 0 14px;
}
.intro__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  text-wrap: balance;
}
.intro__lede {
  font-size: clamp(16px, 2vw, 19px);
  color: var(--ink-soft);
  margin: 0;
  max-width: 56ch;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field--search { flex: 2 1 320px; min-width: 240px; }
.field--filter { flex: 1 1 200px; min-width: 180px; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field__control {
  position: relative;
  display: flex;
  align-items: center;
}
.field__icon {
  position: absolute;
  left: 13px;
  color: var(--ink-faint);
  pointer-events: none;
}
#search, #filter {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
#search { padding-left: 40px; }
#search::placeholder { color: var(--ink-faint); }
#search:focus-visible, #filter:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#filter {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a8071' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

.results-meta {
  font-size: 14px;
  color: var(--ink-faint);
  margin: 0 0 16px;
  min-height: 1em;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: clamp(16px, 2.4vw, 26px);
  padding-bottom: 64px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--line) 50%, var(--accent)); }

.card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--accent-soft);
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}
.card:hover .card__img { transform: scale(1.04); }
@media (prefers-reduced-motion: reduce) {
  .card:hover .card__img { transform: none; }
  * { transition: none !important; animation: none !important; }
}
.card__savedflag {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px 6px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-sm);
}
.card__savedflag .heart { fill: var(--accent); }

.card__content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 20px;
  flex: 1;
}
.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.card__date {
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.card__title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.card__desc {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.card__price {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.card__price small {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
}
.open-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.open-item:hover { background: var(--ink); color: var(--bg); }
.open-item svg { transition: transform .15s ease; }
.open-item:hover svg { transform: translateX(2px); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: clamp(40px, 6vw, 72px) 20px;
  margin-bottom: 64px;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty-state__title {
  font-family: var(--serif);
  font-size: 26px;
  margin: 0 0 8px;
  text-wrap: balance;
}
.empty-state__text {
  color: var(--ink-soft);
  margin: 0 0 20px;
  max-width: 46ch;
  margin-inline: auto;
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  padding: 11px 18px;
  border: 1.5px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-card);
  margin-top: 20px;
}
.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-block: 28px;
}
.site-footer__brand {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.site-footer__note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- Detail dialog ---------- */
.detail {
  width: min(680px, 100vw);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  margin: 0;
  inset: 0;
  display: none;
  overflow: hidden;
}
.detail[open] { display: block; }
.detail::backdrop { background: rgba(20,16,12,.55); backdrop-filter: blur(3px); }

.detail__scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-card);
  margin-inline: auto;
  max-width: 680px;
  box-shadow: var(--shadow-lg);
  animation: rise .28s cubic-bezier(.2,.7,.2,1);
}
@media (prefers-reduced-motion: reduce) { .detail__scroll { animation: none; } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-width: 720px) {
  .detail {
    width: min(680px, 92vw);
    height: min(88vh, 880px);
    border-radius: var(--radius-lg);
    max-height: min(88vh, 880px);
  }
  .detail__scroll { border-radius: var(--radius-lg); }
}

.detail__media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--accent-soft); }
.detail__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail__close {
  position: absolute;
  top: 12px; right: 12px;
  width: 42px; height: 42px;
  border-radius: 999px;
  border: 0;
  background: color-mix(in srgb, var(--bg-card) 90%, transparent);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .1s ease;
}
.detail__close:hover { background: var(--bg-card); }

.icon-btn { cursor: pointer; }

.detail__body { padding: clamp(22px, 4vw, 34px); }
.detail__topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.detail__date { color: var(--ink-faint); font-size: 14px; font-weight: 600; }
.detail__title {
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.08;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.detail__desc {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0 0 22px;
}

.facts {
  margin: 0 0 22px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.facts__row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.facts__row:nth-child(2n) { border-right: 0; }
.facts__row:nth-last-child(-n+2) { border-bottom: 0; }
.facts dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-faint);
  font-weight: 700;
}
.facts dd { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts__row--price dd {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--accent-ink);
}

.detail__body-text {
  margin: 0 0 26px;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.7;
  padding: 16px 18px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.btn--save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn--save .heart { transition: fill .15s ease; }
.btn--save:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent)); }
.btn--save[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--save[aria-pressed="true"] .heart { fill: #fff; }
.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn--secondary:hover { border-color: var(--ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 24px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast[data-toast] { /* placeholder */ }
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 540px) {
  .controls { padding: 14px; }
  .field--search, .field--filter { flex-basis: 100%; }
  .grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts__row { border-right: 0 !important; }
  .facts__row:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .intro__lede { max-width: none; }
  .saved-pill__label { display: none; }
}
