:root {
  --bg: #f6f1e9;
  --surface: #fffdf8;
  --ink: #1f1b16;
  --muted: #74695c;
  --line: #e4dccf;
  --accent: #b5532f;
  --accent-ink: #fff8f2;
  --ok: #2f6b4a;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px 48px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; text-decoration: none; }
.brand span { color: var(--accent); margin-left: 2px; }
nav { display: flex; align-items: center; gap: 18px; }
nav a { text-decoration: none; color: var(--muted); }
nav a.active { color: var(--ink); font-weight: 600; }
.cart-btn {
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  border-radius: 999px; padding: 6px 14px; display: inline-flex; align-items: center; gap: 8px;
}
.badge {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; min-width: 22px; padding: 0 6px; font-size: 0.8rem; text-align: center;
}

/* Hero + filters */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; }
.hero p { color: var(--muted); margin: 8px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 24px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; text-transform: capitalize;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card-art {
  aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 4rem;
  background: radial-gradient(circle at 30% 25%, hsl(var(--hue) 70% 92%), hsl(var(--hue) 45% 80%));
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-cat { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.card h3 { font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.price { font-weight: 700; }
.stock { font-size: 0.8rem; color: var(--muted); }
.stock.low { color: var(--accent); font-weight: 600; }

.primary {
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 10px; padding: 8px 14px; font-weight: 600;
}
.primary:hover:not(:disabled) { filter: brightness(0.94); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
.icon { background: transparent; border: 0; font-size: 1.1rem; padding: 4px 8px; }

/* Orders */
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 40px 0 20px; }
.order {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px;
}
.order-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.order-head strong { font-family: var(--serif); font-size: 1.1rem; }
.order ul { margin: 10px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.92rem; }
.pill { font-size: 0.75rem; border-radius: 999px; padding: 2px 10px; background: #e3efe7; color: var(--ok); font-weight: 600; text-transform: capitalize; }

/* Cart drawer */
.drawer { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.drawer::before {
  content: ""; position: absolute; inset: 0; background: rgb(31 27 22 / 0.35);
  opacity: 0; transition: opacity 0.2s;
}
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(420px, 100%);
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column; padding: 20px; overflow-y: auto;
}
.drawer.open { pointer-events: auto; }
.drawer.open::before { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.line { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-art { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 1.4rem; background: hsl(var(--hue) 60% 88%); }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.totals { display: flex; justify-content: space-between; font-weight: 700; padding: 14px 0; font-size: 1.05rem; }
form.checkout { display: grid; gap: 10px; margin-top: 4px; }
form.checkout label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
form.checkout input {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
form.checkout .primary { padding: 12px; margin-top: 6px; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }
.success { text-align: center; padding: 30px 0; }
.success .big { font-size: 3rem; }

/* Toast + footer */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  opacity: 0; transition: all 0.2s; z-index: 30; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--accent); }
.footer {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--line);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

@media (max-width: 560px) {
  nav { gap: 12px; }
  .hero { padding-top: 28px; }
}
