/* Tienda Madeline · mobile first */
:root {
  --berry: #b8385a;
  --berry-d: #962a47;
  --blush: #f0d0d9;
  --blush-l: #fbeaee;
  --cream: #fff8f9;
  --ink: #3b1f29;
  --muted: #7a5c66;
  --line: #ecd5dc;
  --ok: #168f47;
  --warn: #b4540a;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(184, 56, 90, .14);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 400 16px/1.45 var(--font-body);
  padding-bottom: 96px;
}
img { max-width: 100%; display: block; }
a { color: var(--berry-d); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(100% - 32px, 1040px); margin-inline: auto; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 248, 249, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 44px; height: 44px; border-radius: 50%; }
.brand b { font: 600 20px/1 var(--font-display); letter-spacing: -.01em; }
.brand small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--berry);
  background: var(--berry); color: #fff; font-weight: 700; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--berry-d); border-color: var(--berry-d); }
.btn:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--berry-d); }
.btn-ghost:hover { background: var(--blush-l); color: var(--berry-d); }
.btn-wa { background: var(--ok); border-color: var(--ok); }
.btn-wa:hover { background: #11753a; border-color: #11753a; }
.btn-block { width: 100%; min-height: 52px; font-size: 17px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--berry-d); text-decoration: underline; }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--blush); color: var(--berry-d); font: 700 17px var(--font-body); text-decoration: none;
}

/* Mensajes */
.msgs { list-style: none; margin: 12px 0 0; padding: 0; }
.msgs li { background: var(--blush-l); border: 1px solid var(--blush); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.msgs .error { border-color: #e7a3b3; }

/* Intro */
.intro { padding: 22px 0 8px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--berry); margin: 0 0 6px; }
.intro h1 { font: 600 clamp(26px, 7vw, 40px)/1.1 var(--font-display); margin: 0 0 14px; letter-spacing: -.02em; max-width: 18ch; }
.steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 6px; }
.steps span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--berry); color: #fff; font-size: 13px; font-weight: 700; }
.aviso { margin: 14px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--blush); color: var(--berry-d); font-weight: 600; }
.cerrada { margin: 20px 0; padding: 20px; border-radius: var(--radius); background: #fff; border: 1px dashed var(--berry); text-align: center; }

/* Productos */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 18px 0 8px; list-style: none; margin: 0; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 20px; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; }
.card .ph { position: relative; aspect-ratio: 4 / 5; background: var(--blush); display: grid; place-items: center; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card .ph .vacio { width: 46%; opacity: .55; }
.chip { position: absolute; top: 10px; left: 10px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.chip.low { background: var(--warn); }
.card .body { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h2 { font: 600 17px/1.2 var(--font-display); margin: 0; }
.card p { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .precio { font-weight: 700; font-size: 18px; color: var(--berry-d); margin-top: auto; padding-top: 6px; }
.card .accion { margin-top: 8px; }
.card.agotado .ph img { filter: grayscale(.7); opacity: .6; }

/* Foto y titulo abren el detalle */
.ph-btn { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.tit-btn { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.tit-btn:hover { color: var(--berry-d); }
.card .mas { position: absolute; right: 10px; bottom: 10px; background: rgba(59, 31, 41, .72); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; pointer-events: none; }

/* Detalle del producto */
dialog.det { max-width: 640px; }
dialog.det[open] { display: flex; flex-direction: column; }
.det-body { overflow-y: auto; overscroll-behavior: contain; }
.gal { position: relative; background: var(--blush-l); }
.gal-strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; height: min(50dvh, 560px); }
.gal-strip::-webkit-scrollbar { display: none; }
.gal-strip img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; scroll-snap-stop: always; }
.gal-strip img.vacio { object-fit: none; opacity: .5; }
.gal-nav { position: absolute; top: calc(50% - 44px); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .88); color: var(--berry-d); font-size: 28px; line-height: 1; box-shadow: var(--shadow); }
.gal-nav.prev { left: 10px; }
.gal-nav.next { right: 10px; }
.gal-nav[hidden] { display: none; }
.gal-thumbs { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; background: #fff; }
.gal-thumbs:empty { display: none; }
.gal-thumbs button { flex: 0 0 auto; width: 56px; height: 70px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: none; opacity: .65; }
.gal-thumbs button[aria-current="true"] { border-color: var(--berry); opacity: 1; }
.gal-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.det-info { padding: 14px 20px 18px; }
.det-info .precio { font: 700 26px var(--font-display); color: var(--berry-d); }
.det-info p { margin: 8px 0 0; }
.det-detalle { color: var(--muted); white-space: pre-line; }

/* Stepper */
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--blush-l); border: 2px solid var(--berry); border-radius: 999px; min-height: 44px; }
.stepper button { width: 44px; height: 40px; border: 0; background: none; font-size: 22px; font-weight: 700; color: var(--berry-d); border-radius: 999px; }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; }

/* Barra de pedido */
.cartbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 60%, rgba(255, 248, 249, 0));
  transform: translateY(110%); transition: transform .25s ease;
}
.cartbar.on { transform: none; }
.cartbar button {
  width: min(100%, 560px); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--berry); color: #fff;
  font-weight: 700; font-size: 16px; box-shadow: var(--shadow);
}
.cartbar button:hover { background: var(--berry-d); }

/* Hoja del pedido */
dialog.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--cream); color: var(--ink); overflow: hidden;
}
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; max-height: 90dvh; } }
dialog.sheet::backdrop { background: rgba(59, 31, 41, .5); }
.sheet form { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font: 600 22px var(--font-display); margin: 0; }
.x { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--blush-l); font-size: 22px; line-height: 1; color: var(--berry-d); }
.sheet-body { overflow-y: auto; padding: 8px 20px 16px; overscroll-behavior: contain; }
.sheet-foot { padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.sec { padding: 14px 0 6px; }
.sec > h3 { display: flex; align-items: center; gap: 10px; font: 600 17px var(--font-display); margin: 0 0 12px; }
.sec > h3 span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--berry); color: #fff; font: 700 13px var(--font-body); }

.linea { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.linea:last-child { border: 0; }
.linea b { font-weight: 600; }
.linea .sub { grid-column: 2; grid-row: 1; text-align: right; font-weight: 700; }
.linea .stepper { grid-column: 1 / -1; width: 140px; }
.vacio-txt { color: var(--muted); padding: 10px 0; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.field label small { font-weight: 400; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--berry); outline: 0; box-shadow: 0 0 0 3px var(--blush); }
.field.bad input, .field.bad textarea { border-color: #c0344f; }
.err { color: #b0223d; font-size: 14px; margin: 4px 0 0; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.help { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.errbox { background: #fdecef; border: 1px solid #e7a3b3; color: #8f1d34; padding: 10px 14px; border-radius: 12px; margin: 12px 0 0; font-weight: 600; }

.opt { position: relative; display: block; margin-bottom: 8px; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt .in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; min-height: 56px; }
.opt .in strong { display: block; font-weight: 600; }
.opt .in small { color: var(--muted); display: block; font-size: 13px; line-height: 1.3; }
.opt input:checked + .in { border-color: var(--berry); background: var(--blush-l); box-shadow: 0 0 0 2px var(--berry) inset; }
.opt input:focus-visible + .in { outline: 3px solid var(--berry); outline-offset: 2px; }
.opt input:disabled + .in { opacity: .5; }
.tag { white-space: nowrap; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--blush); color: var(--berry-d); }

.resumen { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 8px 0 4px; }
.resumen div { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.resumen div span:last-child { white-space: nowrap; }
.resumen .tot { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; font-size: 20px; font-weight: 700; font-family: var(--font-display); }
.legal { font-size: 13px; color: var(--muted); text-align: center; margin: 10px 0 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 8px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--berry); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Paginas simples (login, cuenta, gracias) */
.page { padding: 28px 0 40px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; max-width: 520px; margin: 0 auto 18px; box-shadow: var(--shadow); }
.panel h1 { font: 600 28px/1.1 var(--font-display); margin: 0 0 6px; letter-spacing: -.02em; }
.panel h2 { font: 600 20px var(--font-display); margin: 0 0 12px; }
.panel .sub { color: var(--muted); margin: 0 0 18px; }
.panel .alt { text-align: center; margin: 18px 0 0; }
.gracias .ok { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #e3f5ea; color: var(--ok); margin-bottom: 14px; }
.lista { list-style: none; margin: 0 0 12px; padding: 0; }
.lista li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pasos { padding-left: 20px; margin: 0 0 18px; }
.pasos li { margin-bottom: 6px; }
.warnbox { background: #fff3e6; border: 1px solid #f0c18f; color: #7a3d05; padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; }
.estado { display: inline-block; color: #fff; font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; }
.pedidos li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.pedidos small { color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 12px 0 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
