:root {
  --bg: #f6f1e7;
  --bg-soft: #efe7d6;
  --surface: #ffffff;
  --ink: #1f1a14;
  --ink-soft: #5a5144;
  --accent: #b8542b;
  --accent-dark: #923f1f;
  --border: #e3dac7;
  --focus: #1f1a14;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(31, 26, 20, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1611;
    --bg-soft: #231e17;
    --surface: #2a241c;
    --ink: #f2eadb;
    --ink-soft: #b9ad96;
    --accent: #e07a4a;
    --accent-dark: #f09060;
    --border: #3a3226;
    --focus: #f2eadb;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.site-header {
  padding: 2rem 1.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
}

.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 2.75rem; height: 2.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 700;
}
.brand-name {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.brand-tag {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.header-note {
  margin: 0;
  color: var(--ink-soft);
  max-width: 34ch;
  font-size: 0.95rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
  outline: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 220px; min-width: 0; }
.field-label { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }

input[type="search"], select {
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input[type="search"]:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle {
  padding: 0.6rem 1rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.toggle:hover { border-color: var(--accent); }
.toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.item-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; min-width: 0; }
.item-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-wrap: balance;
}
.item-meta { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.item-price { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.open-item {
  margin-top: auto;
  padding: 0.55rem 0.9rem;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, color 150ms ease;
}
.open-item:hover { background: var(--accent); color: #fff; }
.open-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
}
.empty-title { font-size: 1.2rem; color: var(--ink); margin: 0 0 0.25rem; font-weight: 700; }
.empty-body { margin: 0 0 1rem; }
.btn-secondary {
  padding: 0.6rem 1rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-secondary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.detail-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}
.detail-dialog::backdrop {
  background: rgba(31, 26, 20, 0.55);
}
.detail {
  background: var(--surface);
  color: var(--ink);
  max-width: 720px;
  margin: 2rem auto;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 4rem);
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
}
.detail img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.detail h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  font-weight: 700;
  text-wrap: balance;
}
.detail-category { margin: 0; color: var(--accent); font-weight: 600; }
.detail-body { margin: 0; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}
.detail dt { color: var(--ink-soft); font-weight: 600; }
.detail dd { margin: 0; font-variant-numeric: tabular-nums; }
.close-detail {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.close-detail:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.save-item {
  padding: 0.6rem 1.2rem;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  touch-action: manipulation;
  transition: background-color 150ms ease, transform 150ms ease;
}
.save-item[aria-pressed="true"] { background: var(--surface); color: var(--accent); }
.save-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (max-width: 600px) {
  .site-header { padding: 1.25rem 1rem 0.5rem; }
  .brand-name { font-size: 1.6rem; }
  main { padding: 0.75rem 1rem 3rem; }
  .detail { margin: 0; max-height: 100vh; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
