:root {
  --theme-color-foundation: var(--bg, #090b0a);
  --theme-color-surface: var(--surface, #111512);
  --theme-color-surface-raised: color-mix(in srgb, var(--surface, #111512) 86%, var(--forest, #1f2e21));
  --theme-color-frame: color-mix(in srgb, var(--gold, #d5b77a) 44%, transparent);
  --theme-color-focus: #f6dca4;
  --theme-font-display: Georgia, serif;
  --theme-font-functional: Arial, sans-serif;
  --theme-space-1: 0.375rem;
  --theme-space-2: 0.625rem;
  --theme-space-3: 0.875rem;
  --theme-space-4: 1.125rem;
  --theme-space-5: 1.5rem;
  --theme-radius-control: 0.75rem;
  --theme-radius-card: 1.125rem;
  --theme-radius-panel: 1.5rem;
  --theme-border-subtle: 1px solid color-mix(in srgb, var(--cream, #f4e8cf) 14%, transparent);
  --theme-border-accent: 1px solid var(--theme-color-frame);
  --theme-shadow-card: 0 16px 36px rgb(0 0 0 / 0.28);
  --theme-shadow-raised: 0 24px 64px rgb(0 0 0 / 0.52);
}

[data-tenant-theme="after-hours-apothecary"] {
  --theme-font-display: Georgia, "Times New Roman", serif;
  --theme-font-functional: Arial, sans-serif;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--theme-color-focus);
  outline-offset: 3px;
}

.theme-button-secondary,
.theme-button-quiet,
.theme-button-destructive {
  background: transparent;
  color: var(--cream, #f4e8cf);
  border: var(--theme-border-subtle);
}

.theme-button-quiet { border-color: transparent; }
.theme-button-destructive { border-color: color-mix(in srgb, var(--semantic-error) 62%, transparent); color: var(--semantic-error); }

.product-browser {
  display: grid;
  gap: var(--theme-space-4);
}

.product-browser-header {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: var(--theme-space-4);
  padding: clamp(1.125rem, 4vw, 1.75rem);
  border: var(--theme-border-accent);
  border-radius: var(--theme-radius-panel);
  background:
    radial-gradient(circle at 88% 12%, color-mix(in srgb, var(--gold, #d5b77a) 12%, transparent), transparent 34%),
    linear-gradient(145deg, var(--theme-color-surface-raised), var(--theme-color-foundation));
  box-shadow: var(--theme-shadow-card);
}

.product-browser-header::after {
  content: "☾  ✦";
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  color: color-mix(in srgb, var(--gold, #d5b77a) 42%, transparent);
  font: 700 1rem/1 var(--theme-font-display);
  letter-spacing: 0.3em;
  pointer-events: none;
}

.product-browser-title { margin: 0; font: 700 clamp(1.8rem, 8vw, 2.6rem)/1 var(--theme-font-display); }
.product-browser-guidance { margin: var(--theme-space-1) 0 0; color: var(--muted, #cfc2a8); }
.product-browser-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--theme-space-2); align-items: end; }
.product-search-wrap { position: relative; }
.product-search-wrap label { margin-top: 0; }
.product-search-wrap input { padding-right: 3rem; border-color: var(--theme-color-frame); }
.product-search-clear { position: absolute; right: 0.35rem; bottom: 0.35rem; width: 2.35rem; min-height: 2.35rem; margin: 0; padding: 0; border-radius: 50%; background: transparent; color: var(--cream, #f4e8cf); }
.product-search-clear[hidden] { display: none; }
.product-jump-wrap { display: grid; gap: var(--theme-space-1); }
.product-jump-wrap label { margin: 0; }
.product-jump-help { margin: 0; color: var(--muted, #cfc2a8); font-size: 0.72rem; }
.product-result-count { min-height: 1.3em; color: var(--muted, #cfc2a8); font-size: 0.82rem; }
.product-context-help { color: var(--muted, #cfc2a8); font-size: 0.78rem; }
.product-context-help summary { cursor: pointer; color: var(--gold, #d5b77a); }

.admin-product-list { display: grid; gap: var(--theme-space-2); }
.admin-product-row-item { min-width: 0; }
.admin-product-row { width: 100%; min-height: 5rem; margin: 0; padding: var(--theme-space-2); overflow: hidden; display: grid; grid-template-columns: 3.75rem minmax(0, 1fr) auto; gap: var(--theme-space-3); align-items: center; text-align: left; color: var(--cream, #f4e8cf); border: var(--theme-border-subtle); border-radius: var(--theme-radius-control); background: var(--theme-color-surface); box-shadow: none; }
.admin-product-row:hover { border-color: var(--theme-color-frame); background: var(--theme-color-surface-raised); }
.admin-product-row:active { background: var(--theme-color-foundation); }
.admin-product-row-media { width: 3.75rem; height: 3.75rem; overflow: hidden; display: grid; place-items: center; border-radius: calc(var(--theme-radius-control) - 0.2rem); background: color-mix(in srgb, var(--forest, #1f2e21) 62%, var(--theme-color-foundation)); color: var(--muted, #cfc2a8); font-size: 0.62rem; text-align: center; }
.admin-product-row-media img { width: 100%; height: 100%; object-fit: cover; }
.admin-product-row-copy { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--theme-space-1) var(--theme-space-3); align-items: center; }
.admin-product-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 0.95rem/1.28 var(--theme-font-functional); }
.admin-product-row-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted, #cfc2a8); font-size: 0.76rem; }
.admin-product-row-price { grid-column: 2; grid-row: 1 / span 2; color: var(--gold, #d5b77a); font-size: 0.82rem; font-weight: 800; text-align: right; white-space: nowrap; }
.admin-product-row-disclosure { color: var(--gold, #d5b77a); font: 700 1.5rem/1 var(--theme-font-display); }

.product-browser-state { padding: 2rem 1rem; text-align: center; color: var(--muted, #cfc2a8); border: var(--theme-border-subtle); border-radius: var(--theme-radius-card); background: var(--theme-color-surface); }
.product-browser-state strong { display: block; color: var(--cream, #f4e8cf); margin-bottom: var(--theme-space-1); }
.product-loading-state { min-height: 4rem; display: grid; place-items: center; }

#catalogLoadMore { width: min(22rem, 100%); margin: 0 auto; }

.admin-product-dialog { width: min(44rem, calc(100% - 1.5rem)); max-height: min(88dvh, 56rem); padding: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; color: var(--cream, #f4e8cf); border: var(--theme-border-accent); border-radius: var(--theme-radius-panel); background: var(--theme-color-foundation); box-shadow: var(--theme-shadow-raised); }
.admin-product-dialog::backdrop { background: rgb(0 0 0 / 0.78); backdrop-filter: blur(4px); }
.admin-product-dialog-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; padding: var(--theme-space-2); background: color-mix(in srgb, var(--theme-color-foundation) 92%, transparent); }
.admin-product-dialog-close { width: auto; min-width: 2.75rem; margin: 0; }
.admin-product-detail { display: grid; gap: var(--theme-space-4); padding: 0 var(--theme-space-5) var(--theme-space-5); }
.admin-product-detail-media { overflow: hidden; display: grid; place-items: center; min-height: 15rem; border-radius: var(--theme-radius-card); background: var(--theme-color-surface); }
.admin-product-detail-media img { width: 100%; max-height: 24rem; object-fit: contain; }
.admin-product-detail h2 { margin: 0; font: 700 clamp(1.65rem, 7vw, 2.5rem)/1.08 var(--theme-font-display); overflow-wrap: anywhere; }
.admin-product-detail-description { margin: 0; color: var(--muted, #cfc2a8); white-space: pre-wrap; }
.admin-product-detail-price { color: var(--gold, #d5b77a); font-size: 1.25rem; font-weight: 800; }
.admin-product-variants { display: grid; gap: var(--theme-space-2); border: 0; padding: 0; margin: 0; }
.admin-product-variants legend { margin-bottom: var(--theme-space-2); font-weight: 800; }
.admin-product-variant { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--theme-space-2); align-items: center; padding: var(--theme-space-3); border: var(--theme-border-subtle); border-radius: var(--theme-radius-control); background: var(--theme-color-surface); }
.admin-product-variant small { color: var(--muted, #cfc2a8); }
.admin-product-dialog-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; gap: var(--theme-space-2); padding: var(--theme-space-3) var(--theme-space-5) max(var(--theme-space-4), env(safe-area-inset-bottom)); border-top: var(--theme-border-subtle); background: color-mix(in srgb, var(--theme-color-foundation) 94%, transparent); }
.admin-product-dialog-actions button { margin: 0; }

button:disabled,
input:disabled,
select:disabled,
textarea:disabled { cursor: not-allowed; opacity: 0.58; }

@media (max-width: 540px) {
  .product-browser-actions { grid-template-columns: 1fr; }
  .product-browser-actions > button { margin-top: 0; }
  .admin-product-row { grid-template-columns: 3.25rem minmax(0, 1fr) auto; gap: var(--theme-space-2); }
  .admin-product-row-media { width: 3.25rem; height: 3.25rem; }
  .admin-product-row-copy { grid-template-columns: minmax(0, 1fr); }
  .admin-product-row-price { grid-column: 1; grid-row: auto; text-align: left; }
  .admin-product-dialog-actions { grid-template-columns: 1fr; }
}
