:root {
  color-scheme: light;
  --bg: #faf6f0;
  --surface: #ffffff;
  --ink: #2b2226;
  --muted: #6e6166;
  --accent: #7a2e4f;
  --accent-ink: #ffffff;
  --accent-soft: #f3e7ec;
  --gold: #b08d57;
  --line: #e8dfd6;
  --danger: #b3261e;
  --whatsapp: #1f8f4e;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(43 34 38 / 6%), 0 4px 16px rgb(43 34 38 / 6%);
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-display: 'Frank Ruhl Libre', 'Heebo', Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.55;
}

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

button, input, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* Header & footer */

.site-header {
  text-align: center;
  padding: 40px 16px 8px;
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  line-height: 1.1;
  color: var(--accent);
}

.tagline {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 1.1rem;
}

.pearls {
  width: 200px;
  height: 22px;
  color: var(--gold);
}

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px 120px;
  border-top: 1px solid var(--line);
  margin-top: 32px;
}

.site-footer p { margin: 4px 0; }

.site-footer a, .confirm a:not(.btn) {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  direction: ltr;
  unicode-bidi: isolate;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.status {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

.load-error .btn { max-width: 280px; }

/* Product grid */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-img {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--accent-soft);
  cursor: zoom-in;
  aspect-ratio: 1;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card.sold .card-img img { filter: grayscale(0.7) opacity(0.75); }

.badge {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.card-price {
  margin: 4px 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: auto;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.whatsapp {
  background: var(--whatsapp);
  border-color: var(--whatsapp);
}

.btn:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn:focus-visible, .icon-btn:focus-visible, .card-img:focus-visible, .link-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

/* Floating cart button */

.cart-button {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 6px 24px rgb(122 46 79 / 35%);
  cursor: pointer;
  z-index: 10;
}

.cart-button svg { width: 26px; height: 26px; }

.cart-button .count {
  background: #fff;
  color: var(--accent);
  border-radius: 999px;
  min-width: 28px;
  padding: 0 8px;
  line-height: 28px;
  text-align: center;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  translate: -50% calc(-100% - 24px);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  visibility: hidden;
  background: var(--ink);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 500;
  transition: translate 0.25s ease, visibility 0.25s;
  z-index: 20;
  pointer-events: none;
}

.toast.show { translate: -50% 0; visibility: visible; }

/* Dialogs */

dialog {
  border: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgb(43 34 38 / 55%); }

.dialog-inner { padding: 20px; }

.viewer {
  border-radius: var(--radius);
  max-width: min(92vw, 720px);
}

.viewer img {
  max-height: 72vh;
  margin: 0 auto 16px;
  border-radius: 10px;
}

.sheet {
  width: min(100vw, 560px);
  max-width: 100vw;
  max-height: 100dvh;
  border-radius: var(--radius);
}

@media (max-width: 600px) {
  .sheet {
    margin: auto 0 0;
    width: 100vw;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92dvh;
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--accent);
}

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

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

.cart-line img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}

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

.cart-line-name { font-weight: 500; }
.cart-line-price { color: var(--muted); }

.qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-value {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
}

@media (max-width: 420px) {
  .cart-line {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 6px 12px;
  }
  .cart-line img { grid-row: span 2; }
}

.cart-total {
  font-size: 1.3rem;
  margin: 16px 0;
}

.cart-total strong { color: var(--accent); }

.order-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-form label, .admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}

input, textarea {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 1.1rem;
}

input[dir="ltr"] { text-align: right; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 500;
  min-height: 1em;
}

.form-error:empty { display: none; }

.notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  text-align: center;
}

.hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}

.confirm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  padding: 8px 0 4px;
}

.confirm p { margin: 0; }

.confirm .big {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--accent);
}

/* Admin */

.admin .site-header { padding-top: 28px; }
.admin .tagline a { color: var(--accent); font-weight: 500; }

.admin-main {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 64px;
}

.admin-main section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn.huge {
  min-height: 64px;
  font-size: 1.25rem;
}

.section-title {
  margin: 16px 0 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--accent);
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px 14px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-item img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
}

.admin-item.sold img { filter: grayscale(0.7); }

.admin-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-item-info strong { font-size: 1.15rem; }

.tag {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 12px;
  border-radius: 999px;
  background: #e5f3ea;
  color: var(--whatsapp);
  font-size: 0.95rem;
  font-weight: 700;
}

.tag.sold { background: var(--line); color: var(--ink); }

.admin-item-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

.admin-item-actions .btn {
  padding: 8px;
  font-size: 1rem;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-picker { cursor: pointer; }

.photo-picker img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.busy {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(250 246 240 / 80%);
  z-index: 30;
}

.busy span {
  padding: 16px 32px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
}
