:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --panel: #ffffff;
  --ink: #181713;
  --muted: #756d60;
  --line: #ded5c6;
  --green: #176344;
  --green-soft: #e7f0ea;
  --gold: #b89458;
  --cream: #fbf8f1;
  --red: #9d3f32;
  --shadow: 0 18px 42px rgba(38, 31, 20, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fffdf8 0, var(--bg) 310px),
    var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

img {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 46px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 18px;
}

.brand-block {
  min-width: 0;
  max-width: 720px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0 0 8px;
  border: 1px solid rgba(184, 148, 88, 0.42);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 4.4vw, 58px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.brand-subtitle {
  max-width: 620px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.topbar__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.topbar__meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.58);
}

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(38, 31, 20, 0.08);
  backdrop-filter: blur(14px);
}

.mobile-filter-bar {
  display: none;
}

.filter-toggle {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--green);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.mobile-active-count {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-panel {
  display: grid;
  gap: 12px;
}

.search,
.select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search input,
.select-label select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--cream);
  color: var(--ink);
  outline: none;
}

.search input:focus,
.select-label select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--cream);
  color: var(--ink);
  white-space: nowrap;
}

.switch input {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.category-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.category-button,
.ghost-button,
.load-more,
.order-button {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 0 12px;
  white-space: nowrap;
}

.category-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.category-button strong {
  font-size: 12px;
  color: var(--muted);
}

.category-button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.category-button.is-active strong {
  color: rgba(255, 255, 255, 0.78);
}

.catalog-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 0 16px;
}

.catalog-head h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  line-height: 1.12;
}

.catalog-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  background: transparent;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.product-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(38, 31, 20, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(38, 31, 20, 0.11);
}

.product-card__image {
  position: relative;
  aspect-ratio: 4 / 5;
  background:
    linear-gradient(135deg, #fbf8f1 0, #eee5d6 100%);
}

.product-card__image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 10px;
}

.product-card__placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-weight: 700;
}

.badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carousel-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-grid;
  grid-template-columns: 28px auto 28px;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.carousel-controls button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.carousel-controls span {
  min-width: 32px;
  text-align: center;
}

.product-card__body {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.product-title {
  min-height: 40px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.product-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(251, 248, 241, 0.7);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.copy-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.load-more {
  display: block;
  min-width: 220px;
  margin: 22px auto 0;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.load-more[hidden] {
  display: none;
}

.empty {
  grid-column: 1 / -1;
  padding: 44px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.product-dialog {
  width: min(880px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.product-dialog::backdrop {
  background: rgba(16, 14, 10, 0.55);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
  gap: 0;
}

.dialog-media {
  min-height: 420px;
  background: linear-gradient(135deg, #fbf8f1 0, #eee5d6 100%);
}

.dialog-media img {
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: contain;
  padding: 14px;
  display: block;
}

.dialog-info {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 28px;
}

.dialog-info h3 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.dialog-info pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfaf7;
  color: #312d25;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.dialog-info details {
  display: grid;
  gap: 8px;
}

.dialog-info summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 800;
}

.dialog-carousel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.dialog-carousel button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfaf7;
  color: var(--ink);
}

.dialog-carousel span {
  min-width: 54px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.order-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.manager-buttons {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 11px 14px;
  background: #181713;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 960px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: 100%;
    padding: 0 0 32px;
  }

  .topbar,
  .catalog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar__meta {
    justify-content: flex-start;
  }

  .topbar {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 31px;
  }

  .brand-subtitle {
    margin-top: 7px;
    font-size: 13px;
  }

  .topbar__meta {
    display: none;
  }

  .controls {
    top: 0;
    gap: 8px;
    padding: 8px 10px 10px;
    border-right: 0;
    border-left: 0;
    border-radius: 0 0 8px 8px;
  }

  .mobile-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-active-count {
    display: none;
  }

  .filter-toggle::after {
    content: "▾";
    margin-left: 7px;
    font-size: 12px;
  }

  .filter-toggle[aria-expanded="true"]::after {
    content: "▴";
  }

  .filter-panel {
    display: none;
    gap: 8px;
  }

  .filter-panel.is-open {
    display: grid;
  }

  .search,
  .select-label {
    gap: 5px;
  }

  .search input,
  .select-label select,
  .switch {
    min-height: 38px;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .category-nav {
    gap: 6px;
    padding-bottom: 0;
  }

  .category-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 14px;
  }

  .category-button strong {
    font-size: 11px;
  }

  .catalog-head {
    padding: 18px 12px 12px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 10px;
  }

  .load-more {
    margin-right: 10px;
    margin-left: 10px;
  }

  .product-card__body {
    padding: 9px;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }

  .dialog-media,
  .dialog-media img {
    min-height: 280px;
  }

  .dialog-info {
    padding: 20px;
  }
}

@media (max-width: 390px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}
