:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #23211d;
  --muted: #6f6a61;
  --line: #ded8cc;
  --accent: #24746b;
  --accent-dark: #18534d;
  --gold: #b87616;
  --sold: #2d2d2d;
  --danger: #b33131;
  --shadow: 0 18px 45px rgba(39, 34, 26, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 15;
  border-bottom: 1px solid rgba(222, 216, 204, 0.84);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(39, 34, 26, 0.08);
  backdrop-filter: blur(16px);
}

.nav-inner,
.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  gap: 14px;
}

.nav-title {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

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

.nav-icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 1.12rem;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-icon-button:hover,
.nav-icon-button:focus-visible,
.nav-icon-button.active,
.nav-icon-button.is-open {
  border-color: rgba(36, 116, 107, 0.28);
  background: rgba(36, 116, 107, 0.11);
  color: var(--accent-dark);
}

.nav-icon-button.has-value {
  border-color: rgba(184, 118, 22, 0.36);
  background: rgba(184, 118, 22, 0.1);
  color: #8a570f;
}

.nav-icon-button.has-value.is-open {
  border-color: rgba(36, 116, 107, 0.45);
  background: rgba(36, 116, 107, 0.14);
  color: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(36, 116, 107, 0.1);
}

.nav-icon-button:focus-visible {
  outline: 3px solid rgba(36, 116, 107, 0.2);
  outline-offset: 2px;
}

.nav-icon-button:active {
  transform: translateY(1px);
}

.nav-indicator,
.nav-badge {
  position: absolute;
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(39, 34, 26, 0.18);
}

.nav-indicator {
  top: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--gold);
}

.nav-badge {
  top: 2px;
  right: 2px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 13px;
  text-align: center;
}

.page-shell {
  padding: 12px 0 56px;
}

.control-panels {
  position: sticky;
  top: 68px;
  z-index: 14;
}

.control-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(39, 34, 26, 0.06);
  padding: 18px;
  margin-bottom: 12px;
}

.control-panel[hidden] {
  display: none;
}

.panel-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.search-field {
  flex: 1 1 360px;
  max-width: 680px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 260px));
}

.control-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.control-field input,
.control-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.control-field input:focus,
.control-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 116, 107, 0.16);
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.clear-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 7px 13px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.clear-button:hover:not(:disabled),
.clear-button:focus-visible:not(:disabled) {
  border-color: rgba(36, 116, 107, 0.34);
  background: rgba(36, 116, 107, 0.09);
  color: var(--accent-dark);
}

.clear-button:focus-visible {
  outline: 3px solid rgba(36, 116, 107, 0.18);
  outline-offset: 2px;
}

.clear-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-weight: 700;
}

.status-bar p {
  margin: 0;
}

.message-area {
  margin-bottom: 16px;
}

.message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  color: var(--muted);
}

.message.error {
  border-color: rgba(179, 49, 49, 0.28);
  background: #fff7f5;
  color: var(--danger);
}

.masonry-grid {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.masonry-column {
  display: grid;
  flex: 1 1 0;
  gap: 16px;
  min-width: 0;
}

.item-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(39, 34, 26, 0.08);
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.item-card:hover,
.item-card:focus-visible {
  border-color: rgba(36, 116, 107, 0.45);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.item-card:focus-visible {
  outline: 3px solid rgba(36, 116, 107, 0.22);
  outline-offset: 2px;
}

.card-image-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #e7e1d6;
}

.card-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.image-placeholder {
  display: grid;
  min-height: 150px;
  place-items: center;
  background: #ebe5da;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.sold-badge,
.date-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.sold-badge {
  background: rgba(45, 45, 45, 0.86);
}

.date-badge {
  background: rgba(45, 45, 45, 0.72);
}

.price-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-dark);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  padding: 6px 11px;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.card-body {
  padding: 14px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.pill {
  border-radius: 999px;
  background: #eaf3ef;
  color: var(--accent-dark);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.tag-pill {
  background: #eaf3ef;
  color: var(--accent-dark);
}

.card-title-row {
  display: block;
}

.card-title {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.25;
}

.card-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  padding: 20px;
}

.modal.is-open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 22, 19, 0.66);
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  width: min(980px, 100%);
  max-height: min(86vh, 760px);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.32);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1;
}

.modal-media {
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
  min-height: 0;
  background: #191815;
}

.carousel-frame {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
}

.carousel-frame img {
  width: 100%;
  height: 100%;
  max-height: 640px;
  object-fit: contain;
}

.modal-sold-badge {
  display: none;
}

.modal-sold-badge.is-visible {
  display: block;
}

.carousel-button {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
  transform: translateY(-50%);
}

.carousel-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.carousel-prev {
  left: 12px;
}

.carousel-next {
  right: 12px;
}

.carousel-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 12px;
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: transparent;
  padding: 0;
}

.carousel-dot.is-active {
  background: #fff;
}

.modal-content {
  overflow: auto;
  padding: 32px 28px 28px;
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-tags {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-weight: 800;
}

.modal-heading h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.1;
}

.modal-price {
  margin: 0;
  color: var(--gold);
  font-size: 1.55rem;
  font-weight: 900;
  white-space: nowrap;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 20px;
}

.detail-list div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.modal-summary {
  color: var(--ink);
  font-weight: 700;
}

.modal-description {
  color: var(--muted);
  white-space: pre-line;
}

@media (max-width: 900px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-panel {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow: auto;
  }

  .modal-media {
    min-height: 320px;
  }

  .modal-content {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .nav-inner,
  .page-shell {
    width: min(100% - 20px, 1180px);
  }

  .nav-inner {
    min-height: 54px;
  }

  .nav-title {
    font-size: 1.05rem;
  }

  .nav-actions {
    gap: 4px;
  }

  .nav-icon-button {
    width: 36px;
    height: 36px;
  }

  .nav-indicator {
    top: 6px;
    right: 6px;
  }

  .nav-badge {
    top: 1px;
    right: 1px;
  }

  .page-shell {
    padding-top: 10px;
  }

  .control-panels {
    top: 62px;
  }

  .control-panel {
    padding: 12px;
  }

  .panel-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-field {
    flex-basis: 100%;
    max-width: none;
  }

  .clear-button {
    min-height: 36px;
    padding: 7px 12px;
  }

  .filter-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

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

  .masonry-grid,
  .masonry-column {
    gap: 10px;
  }

  .card-body {
    padding: 11px;
  }

  .price-badge {
    left: 7px;
    bottom: 7px;
    padding: 5px 9px;
    font-size: 20px;
  }

  .sold-badge,
  .date-badge {
    right: 7px;
    bottom: 7px;
    padding: 5px 8px;
    font-size: 0.68rem;
  }

  .modal {
    padding: 8px;
  }

  .modal-media {
    min-height: 260px;
  }

  .modal-content {
    padding: 24px 16px 20px;
  }

  .modal-heading {
    display: block;
  }

  .modal-price {
    margin-top: 8px;
  }
}
