/* Material Design 3 dark baseline tokens, amber/yellow accent */
:root {
  --md-primary: #f4c430;
  --md-on-primary: #3f2e00;
  --md-primary-container: #5c4400;
  --md-on-primary-container: #ffdf9b;
  --md-secondary-container: #4d4636;
  --md-on-secondary-container: #f2e0bb;
  --md-surface: #15130f;
  --md-surface-container-low: #1e1c16;
  --md-surface-container: #221f19;
  --md-surface-container-high: #2c2921;
  --md-surface-container-highest: #37332a;
  --md-on-surface: #e9e3d8;
  --md-on-surface-variant: #cbc4b3;
  --md-outline: #948d7c;
  --md-outline-variant: #4a4638;
  --md-success: #7ee787;

  --md-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-elevation-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);

  --tabs-height: 48px;
  --topbar-height: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Top app bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 11;
  min-height: 72px;
  background: var(--md-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--md-outline-variant);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.brand-fog {
  font-size: 26px;
  font-weight: 700;
  color: var(--md-primary);
  letter-spacing: 0.02em;
}

.brand-shop {
  font-size: 16px;
  font-weight: 700;
  color: #000;
  background: var(--md-primary);
  padding: 3px 10px;
  border-radius: 6px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  min-width: 200px;
  padding: 0 16px;
  height: 44px;
  background: var(--md-surface-container-high);
  border-radius: 22px;
  color: var(--md-on-surface-variant);
}

.search-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--md-on-surface);
  font-size: 15px;
  font-family: inherit;
}

.search-field input::placeholder {
  color: var(--md-on-surface-variant);
}

.account-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 6px;
  border-radius: 20px;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  font-size: 13px;
  font-weight: 500;
}

.account-badge[hidden] {
  display: none;
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--md-surface-container-highest);
}

.cart-pill {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}

.cart-pill[hidden] {
  display: none;
}

#cartCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-size: 12px;
  font-weight: 700;
}

/* Category tabs */
.tabs {
  position: sticky;
  top: var(--topbar-height);
  z-index: 10;
  height: var(--tabs-height);
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
}

.tabs-scroll {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  white-space: nowrap;
  padding: 0 20px;
  height: 100%;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.tab:hover {
  color: var(--md-on-surface);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  color: var(--md-primary);
}

.tab-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--md-primary);
  border-radius: 3px 3px 0 0;
  transition: transform 0.25s ease, width 0.25s ease;
}

/* Filter chips */
.chips-row {
  position: sticky;
  top: calc(var(--topbar-height) + var(--tabs-height));
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px;
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
}

.chip {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  padding: 6px 14px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chip.selected {
  background: var(--md-secondary-container);
  border-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

.chip-clear {
  border-style: dashed;
  color: var(--md-primary);
}

.chip-clear[hidden] {
  display: none;
}

/* Legal documents (offer / privacy) */
.legal-doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  line-height: 1.6;
  color: var(--md-on-surface);
}

.legal-doc h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.legal-doc .legal-subtitle {
  color: var(--md-on-surface-variant);
  font-size: 14px;
  margin-bottom: 24px;
}

.legal-doc h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-primary);
  margin: 32px 0 8px;
}

.legal-doc p {
  margin: 0 0 12px;
  font-size: 14px;
}

.legal-doc ul {
  margin: 0 0 12px;
  padding-left: 20px;
  font-size: 14px;
}

.legal-doc li {
  margin-bottom: 6px;
}

.legal-doc a {
  color: var(--md-primary);
}

.legal-doc .back-link {
  display: inline-block;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--md-on-surface-variant);
}

/* Content */
.content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.site-footer {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--md-on-surface-variant);
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--md-on-surface);
}

.site-footer-sep {
  margin: 0 8px;
}

.status {
  color: var(--md-on-surface-variant);
  font-size: 13px;
  margin-bottom: 16px;
}

.category-section {
  margin-bottom: 32px;
  scroll-margin-top: calc(var(--topbar-height) + var(--tabs-height) + 64px);
}

.category-section.hidden {
  display: none;
}

.category-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 18px;
  font-weight: 500;
  text-transform: capitalize;
  margin: 0 0 16px;
  color: var(--md-on-surface);
}

.category-count {
  font-size: 13px;
  font-weight: 400;
  color: var(--md-on-surface-variant);
}

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

.card {
  background: var(--md-surface-container-low);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--md-elevation-1);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card {
  cursor: pointer;
}

.card:hover {
  box-shadow: var(--md-elevation-2);
  transform: translateY(-2px);
}

.card.hidden {
  display: none;
}

/* Scrim + bottom sheet */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 20;
}

.scrim.open {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--md-surface-container-high);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--md-elevation-2);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 21;
  padding-bottom: 16px;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 32px;
  height: 4px;
  background: var(--md-outline);
  border-radius: 2px;
  margin: 12px auto;
}

.sheet-content {
  padding: 0 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--md-surface-container-highest);
}

.sheet-icon[hidden] {
  display: none;
}

.sheet-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--md-on-surface);
}

.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sheet-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--md-primary);
  margin: 4px 0 12px;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--md-surface-container-highest);
  border-radius: 20px;
  padding: 4px;
}

.qty-stepper button {
  appearance: none;
  cursor: pointer;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: transparent;
  color: var(--md-on-surface);
  font-size: 18px;
  line-height: 1;
}

.qty-stepper button:hover {
  background: rgba(255, 255, 255, 0.08);
}

#qtyValue {
  min-width: 28px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
}

.btn-add {
  flex: 1;
  appearance: none;
  cursor: pointer;
  border: none;
  height: 44px;
  border-radius: 22px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: filter 0.15s ease;
}

.btn-add:hover {
  filter: brightness(1.08);
}

.btn-add:active {
  filter: brightness(0.95);
}

/* Cart sheet */
.cart-sheet {
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 12px;
}

.sheet-header .sheet-name {
  font-size: 20px;
}

.sheet-close {
  appearance: none;
  cursor: pointer;
  border: none;
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  width: 32px;
  height: 32px;
  border-radius: 16px;
  font-size: 14px;
}

.cart-body {
  overflow-y: auto;
  padding: 0 24px 24px;
}

.cart-empty {
  color: var(--md-on-surface-variant);
  padding: 24px 0;
  text-align: center;
}

.cart-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}

.cart-line-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--md-surface-container-highest);
  flex-shrink: 0;
}

.cart-line-info {
  flex: 1;
  min-width: 0;
}

.cart-line-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-line-unit {
  font-size: 12px;
  color: var(--md-on-surface-variant);
}

.cart-line-qty {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--md-surface-container-highest);
  border-radius: 16px;
  padding: 2px;
}

.cart-line-qty button {
  appearance: none;
  cursor: pointer;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: transparent;
  color: var(--md-on-surface);
  font-size: 15px;
}

.cart-line-qty button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cart-line-qty span {
  min-width: 20px;
  text-align: center;
  font-size: 13px;
}

.cart-line-total {
  min-width: 64px;
  text-align: right;
  font-weight: 700;
  color: var(--md-primary);
  font-size: 14px;
}

.cart-footer {
  position: sticky;
  bottom: 0;
  background: var(--md-surface-container-high);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.cart-total {
  flex: 1;
  font-size: 16px;
}

.cart-total strong {
  color: var(--md-primary);
  font-size: 20px;
}

.auth-step {
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--md-on-surface-variant);
  background: var(--md-surface-container-highest);
  border-radius: 12px;
  padding: 12px 16px;
}

.auth-google-slot {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.auth-status {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  text-align: center;
}

.auth-status.error {
  color: #f2b8b5;
}

.auth-back {
  appearance: none;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 13px;
  text-decoration: underline;
  align-self: center;
}

.confirm-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
  padding: 8px 0 16px;
}

.confirm-name {
  font-size: 18px;
  font-weight: 500;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.card-icon {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: var(--md-surface-container-high);
}

.card-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--md-on-surface);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
}

.badge-tradable {
  color: var(--md-success);
}

.card-price {
  margin-top: auto;
  font-size: 16px;
  font-weight: 700;
  color: var(--md-primary);
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 0 12px;
  }

  .topbar-title,
  .account-badge,
  .cart-pill {
    flex-shrink: 0;
  }

  .brand-fog {
    font-size: 20px;
  }

  .brand-shop {
    font-size: 13px;
    padding: 2px 8px;
  }

  .search-field {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    padding: 0 10px;
    gap: 6px;
  }

  .search-field input {
    min-width: 0;
  }

  .content {
    padding: 16px;
  }

  .card-icon {
    aspect-ratio: 2 / 1;
  }
}
