:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #707070;
  --line: #e4e4e4;
  --soft: #f3f3f3;
  --alert: #d10000;
  --display: "Michroma", "Chakra Petch", system-ui, sans-serif;
  --body: "Chakra Petch", system-ui, sans-serif;
  --gutter: 16px;
}
@media (min-width: 768px) { :root { --gutter: 32px; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 400 14px/1.5 var(--body);
  background: var(--bg); color: var(--fg);
  min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; border-radius: 0; }
main { flex: 1; }
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding-inline: var(--gutter); }
.label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
/* Scales with screen width so the full name fits on one line, even on small phones. */
.wordmark { font: 400 clamp(10px, 3.2vw, 15px)/1 var(--display); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; padding-block: 14px; }
.header-link { background: none; border: 0; cursor: pointer; padding: 14px 0 14px 12px; white-space: nowrap; flex: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; width: 100%;
  font: 400 11px/1 var(--display); letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--fg); background: var(--bg); color: var(--fg); cursor: pointer;
  transition: background .15s, color .15s;
}
.btn.solid { background: var(--fg); color: var(--bg); }
/* Hover only on real pointers — on touch screens it sticks after a tap. */
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
  .btn.solid:hover:not(:disabled) { background: #333; border-color: #333; }
}
.btn:active:not(:disabled) { opacity: .75; }
.btn:disabled { border-color: var(--line); color: var(--muted); background: var(--soft); cursor: not-allowed; }
.btn.small { height: 32px; padding: 0 12px; width: auto; font-size: 10px; }

input[type=email], input[type=text], input[type=url], input[type=number], textarea {
  height: 48px; padding: 0 14px; width: 100%;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 16px; /* below 16px, iPhones zoom in when the field is tapped */
}
textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
input:focus, textarea:focus, .btn:focus-visible, .size:focus-visible { outline: 1px solid var(--fg); outline-offset: -1px; }

/* Product grid */
.shop-head { display: flex; justify-content: space-between; align-items: baseline; padding-block: 32px 20px; }
.shop-head h1 { font: 400 13px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 12px; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 48px 20px; } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tile { display: flex; flex-direction: column; min-width: 0; }
.tile-media { position: relative; aspect-ratio: 4 / 5; background: var(--soft); overflow: hidden; }
.tile-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s; }
.tile-media img.alt { opacity: 0; }
@media (hover: hover) { .tile:hover .tile-media img.alt { opacity: 1; } }
.badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  padding: 5px 8px; background: var(--bg); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}
.badge.alert { color: var(--alert); }
.tile-info { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.tile-info .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-info .price { flex: none; }
@media (max-width: 519px) { .tile-info { flex-direction: column; gap: 2px; } }
.empty { grid-column: 1 / -1; padding: 96px 0; text-align: center; color: var(--muted); }

/* Product page */
.pdp { display: grid; gap: 24px; padding-block: 0 48px; }
@media (min-width: 900px) { .pdp { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 48px; padding-top: 32px; } }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin-inline: calc(-1 * var(--gutter)); scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--soft); scroll-snap-align: start; }
.gallery .ph { flex: 0 0 100%; aspect-ratio: 4 / 5; background: var(--soft); }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.dots span { width: 6px; height: 6px; background: var(--line); }
.dots span.on { background: var(--fg); }
@media (min-width: 900px) {
  .gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; overflow: visible; }
  .gallery img:first-child, .gallery .ph { grid-column: 1 / -1; }
  .dots { display: none; }
}
.buybox { display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 900px) { .buybox { position: sticky; top: 88px; align-self: start; } }
.pdp h1 { font: 400 clamp(18px, 2.2vw, 24px)/1.3 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.pdp .price { font-size: 18px; margin-top: 8px; }
.sizes-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.size {
  height: 44px; border: 1px solid var(--line); background: var(--bg); cursor: pointer;
  font-size: 12px; letter-spacing: .08em;
}
@media (hover: hover) { .size:hover:not(:disabled) { border-color: var(--fg); } }
.size[aria-pressed=true] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.size:disabled { color: #b5b5b5; text-decoration: line-through; cursor: not-allowed; background: var(--soft); }
.stock { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; min-height: 18px; }
.stock::before { content: ""; width: 8px; height: 8px; background: currentColor; flex: none; }
.stock.ok { color: #1f7a33; }
.stock.low { color: var(--alert); }
.stock.out { color: var(--muted); }
.stock:empty::before { display: none; }
.actions { display: grid; gap: 8px; }
/* Phones: buy buttons stay pinned to the bottom of the screen while the product is in view. */
@media (max-width: 899px) {
  .actions {
    position: sticky; bottom: 0; z-index: 10;
    grid-template-columns: 1fr 1fr;
    margin-inline: calc(-1 * var(--gutter));
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .actions .btn { padding: 0 8px; }
  .actions:has(#buy[hidden]) { grid-template-columns: 1fr; }
}
.desc { color: #333; white-space: pre-line; line-height: 1.7; }
.crumbs { padding-block: 20px 0; }
@media (max-width: 899px) { .crumbs { display: none; } }

/* Newsletter */
.newsletter { border: 1px solid var(--fg); padding: 24px; display: grid; gap: 12px; }
.newsletter h2 { font: 400 13px/1.3 var(--display); letter-spacing: .1em; text-transform: uppercase; }
.newsletter p { color: var(--muted); font-size: 13px; }
.newsletter form { display: flex; margin-top: 4px; }
.newsletter input[type=email] { border-color: var(--fg); border-right: 0; min-width: 0; }
.newsletter .btn { width: auto; flex: none; }
.newsletter .msg { font-size: 12px; min-height: 18px; }
.newsletter .msg.err { color: var(--alert); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.band { border-top: 1px solid var(--line); margin-top: 80px; padding-block: 48px; }
.band .newsletter { max-width: 560px; margin: 0 auto; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; padding-block: 24px; color: var(--muted); }
.site-footer button, .site-footer a { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 12px 0 12px 12px; margin: -12px 0; }

/* Cart drawer */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(420px, 100%);
  background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s ease; border-left: 1px solid var(--line);
}
body.cart-open .scrim { opacity: 1; pointer-events: auto; }
body.cart-open .drawer { transform: none; }
body.cart-open { overflow: hidden; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; height: 56px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 400 12px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.drawer-close { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; width: 44px; height: 44px; margin-right: -12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 20px; }
.line { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.line img, .line .ph { width: 72px; aspect-ratio: 4 / 5; object-fit: cover; background: var(--soft); }
.line-name { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.line-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.qty { display: inline-flex; border: 1px solid var(--line); margin-top: 10px; }
.qty button { width: 40px; height: 40px; font-size: 16px; background: none; border: 0; cursor: pointer; }
.qty button:disabled { color: #c4c4c4; cursor: not-allowed; }
.qty span { min-width: 28px; display: grid; place-items: center; font-size: 12px; }
.line-right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; font-size: 12px; }
.line-remove { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 11px; padding: 10px 0 0 10px; }
.drawer-foot { padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: grid; gap: 12px; }
.subtotal { display: flex; justify-content: space-between; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.drawer-note { font-size: 12px; color: var(--muted); text-align: center; min-height: 18px; }
.drawer-empty { padding: 64px 0; text-align: center; color: var(--muted); }

/* Admin (only visible after login on the shop page) */
.admin-only { display: none !important; }
body.admin .admin-only { display: flex !important; }
.tile-admin { gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tile-admin .btn { flex: 1; min-width: 0; padding: 0 6px; }
.add-tile { aspect-ratio: 4 / 5; border: 1px dashed var(--muted); background: none; cursor: pointer; color: var(--muted); align-items: center; justify-content: center; }
.admin-bar { gap: 8px; align-items: center; flex-wrap: wrap; }
dialog.editor {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); margin: auto; padding: 24px;
  border: 1px solid var(--fg); background: var(--bg);
}
dialog.editor::backdrop { background: rgb(0 0 0 / .45); }
.editor h3 { font: 400 13px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 20px; }
.editor form { display: grid; gap: 14px; }
.editor label, .editor .field { display: grid; gap: 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.editor input, .editor textarea { height: 44px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--fg); }
.editor textarea { height: auto; min-height: 72px; }
.photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 420px) { .photos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.photo { position: relative; aspect-ratio: 4 / 5; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.busy img { opacity: .35; }
.photo.busy::after { content: "Uploading…"; position: absolute; inset: auto 0 8px; text-align: center; font-size: 10px; color: var(--fg); }
.photo.add { display: grid; place-items: center; border: 1px dashed var(--muted); background: none; cursor: pointer; color: var(--fg); font-size: 11px; letter-spacing: .1em; }
.photo-main { position: absolute; left: 4px; bottom: 4px; padding: 3px 6px; background: var(--fg); color: var(--bg); font-size: 9px; letter-spacing: .1em; }
.photo-btn {
  position: absolute; top: 4px; width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); color: var(--fg); cursor: pointer; font-size: 15px; line-height: 1;
}
.photo-btn.left { left: 4px; }
.photo-btn.right { right: 4px; }
.size-rows { display: grid; gap: 6px; }
.size-row { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 6px; }
.size-row button { border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.editor .row { display: flex; justify-content: flex-end; gap: 8px; }
.editor .row .btn { width: auto; }
.editor .error { color: var(--alert); font-size: 12px; min-height: 18px; }
