:root {
  --bg: #f7f1e8;
  --panel: #fffdf8;
  --ink: #231a14;
  --muted: #756a61;
  --line: #e3d8ca;
  --accent: #7b3f1d;
  --accent-2: #536631;
  --gold: #b9791c;
  --green: #2f6d48;
  --shadow: 0 12px 28px rgba(45, 30, 18, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

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

.site-header {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 8px 0 20px;
}

body[data-page-mode="detail"] .site-header,
body[data-page-mode="section"] .site-header {
  grid-template-columns: auto minmax(280px, 620px);
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding-bottom: 16px;
}

.logo-link img {
  display: block;
  width: min(360px, 78vw);
  height: auto;
}

body[data-page-mode="detail"] .logo-link img,
body[data-page-mode="section"] .logo-link img {
  width: 150px;
}

.home-search-copy {
  display: none;
  max-width: 820px;
  text-align: center;
}

body[data-page-mode="home"] .home-search-copy {
  display: block;
}

.home-search-copy h1 {
  margin: 0;
  font-size: 31px;
}

body[data-page-mode="detail"] .action-tiles,
body[data-page-mode="section"] .action-tiles {
  display: none;
}

.hero-search {
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.hero-search input {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 16px;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow);
}

.hero-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 63, 29, 0.12), var(--shadow);
}

.hero-search button,
.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 15px;
  font-weight: 800;
  cursor: pointer;
}

.button.secondary {
  border: 1px solid rgba(123, 63, 29, 0.28);
  background: #f0e5d7;
  color: var(--accent);
}

.button.small {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 13px;
}

.action-tiles {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.action-tiles a {
  min-height: 86px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.action-tiles a:hover {
  border-color: rgba(123, 63, 29, 0.42);
  transform: translateY(-1px);
}

.action-tiles span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-weight: 900;
  font-size: 13px;
}

.action-tiles strong {
  font-size: 13px;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

body[data-page-mode="detail"] .page-grid,
body[data-page-mode="section"] .page-grid {
  grid-template-columns: minmax(0, 1fr);
}

body[data-page-mode="home"] .page-grid {
  grid-template-columns: minmax(0, 1fr);
}

body[data-page-mode="detail"] .right-rail,
body[data-page-mode="section"] .right-rail {
  display: none;
}

body[data-page-mode="home"] .right-rail {
  display: none;
}

.main-view,
.right-rail,
.panel {
  min-width: 0;
}

.panel,
.right-rail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.right-rail {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.rail-title,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.rail-title {
  display: block;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-lede {
  max-width: 760px;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.35;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin: 0 0 12px;
  font-size: 21px;
}

.rail-title h2 {
  margin-bottom: 0;
}

.muted,
td span {
  color: var(--muted);
}

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.section-copy {
  max-width: 820px;
  margin: -4px 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.home-dashboard {
  display: grid;
  gap: 14px;
}

.home-dashboard-copy {
  max-width: 840px;
  margin: 0 auto 2px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.4;
  text-align: center;
}

.home-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.home-card {
  min-height: 100%;
}

.stats-row,
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stats-row div,
.detail-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.stats-row span,
.detail-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-row strong,
.detail-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.home-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

.home-top-list {
  display: grid;
  gap: 8px;
}

.home-top-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.home-top-row span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.home-top-row strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-top-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.home-top-row b {
  color: var(--green);
  font-size: 13px;
  white-space: nowrap;
}

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

.browse-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.browse-filters {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.browse-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.browse-filter-head h2 {
  margin: 0;
  font-size: 18px;
}

.browse-filter-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.browse-filter-group legend {
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.browse-filter-group label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.browse-filter-group input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.browse-filter-group span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browse-filter-group em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.browse-results {
  min-width: 0;
}

.browse-results-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.browse-results-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

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

.browse-product-tile {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.browse-product-tile:hover {
  border-color: rgba(123, 63, 29, 0.42);
}

.browse-product-art {
  display: grid;
  place-items: center;
  min-height: 178px;
  background: #f4eadc;
  padding: 16px;
}

.browse-product-img {
  max-width: 100%;
  max-height: 145px;
  object-fit: contain;
  filter: drop-shadow(0 10px 11px rgba(35, 26, 20, 0.16));
}

.browse-product-copy {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.browse-product-copy > span {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.browse-product-copy h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.22;
}

.browse-product-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.browse-product-copy div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.browse-product-copy strong {
  color: var(--ink);
}

.browse-product-copy em {
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.product-card {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.product-card:hover {
  border-color: rgba(123, 63, 29, 0.42);
}

.product-art {
  display: grid;
  place-items: center;
  background: #f4eadc;
  padding: 10px;
}

.product-img,
.thumb {
  max-width: 100%;
  max-height: 118px;
  object-fit: contain;
  filter: drop-shadow(0 9px 10px rgba(35, 26, 20, 0.16));
}

.thumb-empty {
  display: grid;
  place-items: center;
  color: rgba(123, 63, 29, 0.48);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: 12px;
  text-align: center;
}

.product-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.rank-label {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.product-copy h3 {
  margin: 5px 0 6px;
  font-size: 16px;
  line-height: 1.2;
}

.product-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.product-footer strong {
  font-size: 16px;
}

.product-footer span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.top-rail-list {
  display: grid;
  gap: 8px;
}

.top-rail-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.top-rail-item span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.top-rail-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.top-rail-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.top-list {
  display: grid;
  gap: 10px;
}

.top-list-row {
  display: grid;
  grid-template-columns: 64px minmax(230px, 1.15fr) minmax(280px, 1.4fr) minmax(210px, 0.9fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rank-chip {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-weight: 900;
}

.top-list-bottle {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.top-list-art {
  display: grid;
  place-items: center;
  width: 94px;
  height: 123px;
  border-radius: 8px;
  background: #f4eadc;
  padding: 10px;
}

.top-list-img {
  max-width: 100%;
  max-height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 9px 10px rgba(35, 26, 20, 0.16));
}

.top-list-bottle h2 {
  margin: 0 0 5px;
  font-size: 18px;
  line-height: 1.2;
}

.top-list-bottle p,
.top-list-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.top-list-bottle p {
  font-size: 12px;
}

.top-list-note {
  font-size: 14px;
}

.top-list-prices > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.price-preview-card {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.price-preview-card:hover {
  border-color: rgba(123, 63, 29, 0.42);
}

.price-preview-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price-preview-line strong {
  color: var(--green);
}

.price-preview-line em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retailer-deal-list {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.retailer-deal-pill {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.retailer-deal-pill:hover {
  border-color: rgba(123, 63, 29, 0.42);
}

.retailer-deal-pill strong {
  font-size: 13px;
  line-height: 1.2;
}

.retailer-deal-pill span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.stars {
  color: var(--gold);
  font-weight: 900;
}

.stars small {
  color: var(--ink);
  font-weight: 800;
}

.deal-row {
  background: #fff9ed;
}

.deal-star {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f0e5d7;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.num .deal-star {
  margin-left: 8px;
}

.detail-panel h2 {
  margin-top: 20px;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.nav-button {
  justify-content: center;
}

.back-link {
  display: inline-flex;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.home-button {
  flex: 0 0 auto;
}

.history-section {
  margin-top: 24px;
}

.history-section .section-header {
  margin-bottom: 8px;
}

.chart-wrap {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #fff;
  overflow: hidden;
}

.price-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-bg {
  fill: #fbfcfb;
}

.chart-grid {
  stroke: #dfe4df;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: #fff;
  stroke: var(--accent-2);
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.compact-history {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
}

.compact-history table th,
.compact-history table td {
  padding: 7px 10px;
}

.detail-head {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.detail-head.no-art {
  grid-template-columns: minmax(0, 1fr) auto;
}

.large-art {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4eadc;
  padding: 18px;
}

.large-img {
  max-width: 150px;
  max-height: 180px;
  object-fit: contain;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.store-rating {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  text-align: center;
}

.store-rating strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .page-grid,
  .home-card-grid,
  .top-list-row,
  .two-col {
    grid-template-columns: 1fr;
  }

  .right-rail {
    position: static;
  }

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

  .browse-filters {
    position: static;
  }

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

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 12px;
  }

  .logo-link img {
    width: min(300px, 82vw);
  }

  .hero-search,
  .action-tiles,
  body[data-page-mode="detail"] .site-header,
  body[data-page-mode="section"] .site-header,
  .stats-row,
  .detail-stats,
  .detail-head,
  .detail-head.no-art {
    grid-template-columns: 1fr;
  }

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

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

  .browse-product-grid {
    grid-template-columns: 1fr;
  }

  .browse-product-art {
    min-height: 150px;
  }

  .product-card {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .home-top-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .home-top-row em {
    display: none;
  }

  .top-list-row {
    align-items: start;
  }

  .top-list-bottle {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .top-list-art {
    width: 82px;
    height: 108px;
  }

  .top-list-img {
    max-height: 94px;
  }
}
