:root {
  --cream: #faf6e9;
  --cream-deep: #f1ebd6;
  --ivory: #fffdf7;
  --ink: #231f1d;
  --ink-muted: #6a6156;
  --line: #e3dac2;
  --berry: #e63956;
  --berry-dark: #c82541;
  --berry-tint: #fcebed;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--cream);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--cream);
  color: var(--ink);
}

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

button,
input,
select {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 2px;
}

/* Header */
.site-header {
  width: 100%;
  border-bottom: 1px solid var(--line);
  background-color: rgba(250, 246, 233, 0.94);
}

.header-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.brand-wordmark {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--berry);
  border: 1px solid var(--berry);
  border-radius: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover {
  background-color: var(--berry-dark);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  background-color: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease;
}

.btn-secondary:hover {
  color: var(--ink);
}

/* Main Content */
.main-content {
  flex: 1;
}

.hero-section {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4.5rem;
}

@media (min-width: 640px) {
  .hero-section {
    padding: 3.5rem 1.5rem 5rem;
  }
}

.hero-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.bottle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

.bottle-svg {
  width: 11rem;
  height: 14rem;
  overflow: visible;
}

@media (min-width: 640px) {
  .bottle-svg {
    width: 13rem;
    height: 16rem;
  }
}

.bottle-caption {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}

.text-berry {
  color: var(--berry);
}

.hero-title {
  margin: 1.5rem 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
  max-width: 36rem;
}

.hero-subtitle {
  margin: 0.75rem 0 0;
  max-width: 34rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* Price Section */
.price-board {
  margin-top: 2.5rem;
  transition: opacity 150ms ease;
}

.price-board.htmx-request {
  opacity: 0.7;
}

.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .controls-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.controls-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 0.5rem;
  background-color: var(--cream-deep);
  border: 1px solid var(--line);
}

.seg-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  background-color: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.is-active {
  background-color: var(--ivory);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(35, 31, 29, 0.08);
}

.seg-btn.is-active-berry {
  background-color: var(--berry);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(35, 31, 29, 0.12);
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-start;
  padding: 0.5rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-muted);
  background-color: var(--ivory);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 150ms ease, border-color 150ms ease;
}

.sort-btn:hover {
  color: var(--ink);
}

/* Ledger Table Card */
.ledger-card {
  background-color: var(--ivory);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(35, 31, 29, 0.04);
}

.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background-color: rgba(241, 235, 214, 0.45);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.ledger-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ledger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  transition: background-color 150ms ease;
}

.ledger-row:first-child {
  border-top: none;
}

.ledger-row:hover {
  background-color: rgba(250, 246, 233, 0.6);
}

.ledger-row.is-cheapest {
  background-color: rgba(252, 235, 237, 0.48);
}

.store-info {
  min-width: 0;
}

.store-top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.store-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cheapest-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--berry);
}

.store-meta {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.price-col {
  text-align: right;
  flex-shrink: 0;
}

.price-value {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
}

.price-value.is-cheapest {
  color: var(--berry);
}

.price-delta {
  margin-top: 0.1rem;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.not-stocked {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.ledger-foot {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--line);
  background-color: rgba(241, 235, 214, 0.35);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

@media (min-width: 640px) {
  .ledger-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.spread-highlight {
  font-weight: 500;
  color: var(--ink);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background-color: var(--cream);
}

.footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Modal */
dialog.price-dialog {
  width: calc(100% - 2rem);
  max-width: 28rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background-color: var(--ivory);
  color: var(--ink);
  box-shadow: 0 20px 40px rgba(35, 31, 29, 0.18);
}

dialog.price-dialog::backdrop {
  background-color: rgba(35, 31, 29, 0.42);
  backdrop-filter: blur(2px);
}

.dialog-body {
  padding: 1.5rem;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dialog-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.dialog-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.close-btn {
  padding: 0.35rem;
  background: transparent;
  border: none;
  border-radius: 0.4rem;
  color: var(--ink-muted);
  cursor: pointer;
}

.close-btn:hover {
  color: var(--ink);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

.field-input,
.field-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  color: var(--ink);
  background-color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--berry);
}

.price-input-wrap {
  position: relative;
}

.price-prefix {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.field-input.has-prefix {
  padding-left: 1.85rem;
}

.form-error {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--berry);
}

.form-notice {
  padding: 0.75rem 0.9rem;
  border-radius: 0.5rem;
  background-color: var(--berry-tint);
  border: 1px solid rgba(230, 57, 86, 0.25);
  font-size: 0.8125rem;
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 0.4rem;
}

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