:root {
  --blush: #fee1e5;
  --red: #dc1228;
  --red-press: #b30d1f;
  --wine: #5a0a16;
  --wine-soft: #8c4a55;
  --petal: #fff6f7;
  --rose: #f3b9c2;
  --rose-deep: #e88f9d;
  --green: #2e7d4f;
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--blush);
  color: var(--wine);
  font: 400 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
a { color: var(--red); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 140px; }
.brand { display: flex; justify-content: center; padding: 8px 0 18px; }
.brand img { width: 190px; height: auto; }

h1, h2 { font-family: var(--serif); font-style: italic; font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 7vw, 36px); }
h2 { font-size: 24px; }
p { margin: 0; }
.lead { margin-top: 8px; color: var(--wine-soft); font-size: 18px; }
.lead b { color: var(--wine); font-weight: 800; }
.small { font-size: 14px; color: var(--wine-soft); }
.center { text-align: center; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 999px;
  padding: 14px 22px; font-weight: 800; font-size: 17px; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:not([disabled]):hover { background: var(--red-press); }
.btn.ghost { background: transparent; color: var(--wine); box-shadow: inset 0 0 0 1.5px var(--rose-deep); }
.btn.ghost:not([disabled]):hover { background: var(--petal); }
.btn.block { width: 100%; }
.btn.small { padding: 9px 14px; font-size: 15px; }
.link-btn { appearance: none; background: none; border: 0; padding: 6px 2px; cursor: pointer; font-weight: 700; color: var(--wine-soft); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rose-deep); }
.link-btn:hover { color: var(--wine); }
.link-btn.danger { color: var(--red); }

/* ---------- customer: open-book picker ---------- */
.hello { text-align: center; }
.book {
  position: relative; display: block; margin: 26px auto 0; width: 100%;
  aspect-ratio: 16 / 10; cursor: pointer;
  background: var(--petal);
  border: 1.5px solid var(--rose);
  border-radius: 6px;
  box-shadow: 0 4px 0 -1px var(--petal), 0 5px 0 -1px var(--rose), 0 9px 0 -3px var(--petal), 0 10px 0 -3px var(--rose);
  -webkit-tap-highlight-color: transparent;
}
.book::before { /* spine */
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 46px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(90, 10, 22, .07) 40%, rgba(90, 10, 22, .15) 50%, rgba(90, 10, 22, .07) 60%, transparent);
  pointer-events: none;
}
.book::after { /* centre fold line */
  content: ''; position: absolute; top: 6%; bottom: 6%; left: 50%; border-left: 1px solid rgba(90, 10, 22, .12);
}
.book-cta {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; z-index: 1; padding: 12px; text-align: center;
}
.plus {
  width: 64px; height: 64px; border-radius: 50%; background: var(--red); color: #fff;
  display: grid; place-items: center; font-size: 38px; line-height: 1; font-weight: 400;
  box-shadow: 0 0 0 7px var(--petal);
  transition: transform .15s;
}
.book:hover .plus { transform: scale(1.05); }
.cta-text { font-weight: 800; font-size: 20px; background: var(--petal); padding: 0 10px; border-radius: 6px; }
.cta-sub { font-size: 14px; color: var(--wine-soft); background: var(--petal); padding: 0 8px; border-radius: 6px; }
.book.full { cursor: default; }
.book.full .plus { background: var(--rose-deep); }
.book:focus-within { outline: 3px solid var(--red); outline-offset: 3px; }

.tally { display: flex; align-items: baseline; justify-content: space-between; margin-top: 30px; gap: 12px; }
.tally-num { font-family: var(--serif); font-style: italic; font-size: 52px; line-height: 1; font-weight: 600; font-variant-numeric: lining-nums; }
.tally-num .of { font-size: 26px; color: var(--wine-soft); font-weight: 500; }
.tally-label { color: var(--wine-soft); font-size: 15px; text-align: right; }
.bar { position: relative; height: 8px; border-radius: 99px; background: #fff; margin-top: 12px; box-shadow: inset 0 0 0 1px var(--rose); }
.bar > .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: var(--red); transition: width .3s ease; }
.bar > .minmark { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--wine); border-radius: 2px; opacity: .55; }
.hint { margin-top: 12px; font-size: 15px; color: var(--wine-soft); min-height: 1.5em; }

.grid { list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--rose); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; font-size: 11px; color: var(--wine-soft); text-align: center; word-break: break-all; }
.tile .prog { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .85); overflow: hidden; }
.tile .prog i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s; }
.tile.waiting img, .tile.uploading img { opacity: .55; }
.tile .ok { position: absolute; right: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 900; }
.tile .rm { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(90, 10, 22, .72); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.tile.error { box-shadow: inset 0 0 0 2px var(--red); }
.tile .err { position: absolute; inset: 0; border: 0; width: 100%; background: rgba(254, 225, 229, .9); color: var(--red); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 6px; text-align: center; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(254, 225, 229, .96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--rose);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.dock-inner { max-width: 560px; margin: 0 auto; display: grid; gap: 8px; }
.dock p { font-size: 14px; color: var(--wine-soft); text-align: center; }

.state { text-align: center; padding: 30px 8px 0; display: grid; gap: 12px; justify-items: center; }
.state svg { width: 64px; height: 64px; }

/* ---------- dialog + toast ---------- */
dialog { border: 0; border-radius: 14px; padding: 22px; max-width: min(420px, calc(100vw - 32px)); color: var(--wine); background: #fff; box-shadow: 0 20px 60px rgba(90, 10, 22, .25); }
dialog::backdrop { background: rgba(90, 10, 22, .35); }
dialog h2 { font-size: 22px; }
dialog p { margin-top: 10px; color: var(--wine-soft); }
.dlg-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; top: 14px; transform: translate(-50%, -20px); opacity: 0; z-index: 50;
  background: var(--wine); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 600;
  width: max-content; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- admin ---------- */
.admin .wrap { max-width: 720px; padding-bottom: 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 18px; }
.topbar img { width: 120px; height: auto; }
.panel { background: var(--petal); border: 1px solid var(--rose); border-radius: 14px; padding: 20px; }
.panel + .panel, .section + .section { margin-top: 22px; }
.section h2 { margin-bottom: 14px; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { font-weight: 700; font-size: 15px; }
.input {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1.5px solid var(--rose-deep); background: #fff; font-size: 17px;
}
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(220, 18, 40, .15); }
.pkgs { border: 0; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.pkgs legend { font-weight: 700; font-size: 15px; margin-bottom: 6px; padding: 0; }
.pkg {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--rose); background: #fff; cursor: pointer;
}
.pkg input { position: absolute; opacity: 0; pointer-events: none; }
.pkg .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--rose-deep); display: grid; place-items: center; }
.pkg:has(input:checked) { border-color: var(--red); background: var(--petal); }
.pkg:has(input:checked) .dot { border-color: var(--red); }
.pkg:has(input:checked) .dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.pkg:has(input:focus-visible) { outline: 3px solid var(--red); outline-offset: 2px; }
.pkg-name { font-weight: 800; }
.pkg-photos { display: block; font-size: 14px; color: var(--wine-soft); font-weight: 600; }
.pkg-price { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 19px; }
.form-actions { margin-top: 18px; }
.error-text { color: var(--red); font-weight: 700; font-size: 15px; margin-top: 10px; }

.result { margin-top: 18px; padding: 16px; border-radius: 12px; background: #fff; border: 1.5px dashed var(--red); }
.result .url { margin-top: 6px; font-weight: 700; word-break: break-all; color: var(--red); user-select: all; }
.result .row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.orders { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.order { background: #fff; border: 1px solid var(--rose); border-radius: 12px; padding: 14px 16px; }
.order-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.order-name { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 21px; line-height: 1.2; }
.order-meta { font-size: 14px; color: var(--wine-soft); margin-top: 2px; }
.order-meta b { color: var(--wine); }
.order-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 12px; }
.chip { flex: none; font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--blush); color: var(--wine-soft); white-space: nowrap; }
.chip.live { background: #fff1d6; color: #8a5300; }
.chip.in { background: #dff3e6; color: var(--green); }
.chip.gone { background: #eee; color: #777; }
.saved-mark { font-size: 13px; font-weight: 700; color: var(--green); }
.empty { padding: 26px 16px; text-align: center; color: var(--wine-soft); border: 1.5px dashed var(--rose-deep); border-radius: 12px; }

.sheet { position: fixed; inset: 0; z-index: 30; background: var(--blush); overflow-y: auto; }
.sheet .wrap { padding-top: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.save-box { margin-top: 16px; }
.progress { margin-top: 12px; }
.progress .bar { margin-top: 8px; }
.batches { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.batch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--rose); }
.batch.done { opacity: .6; }
.tips { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #fff; font-size: 15px; }
.tips li + li { margin-top: 4px; }
.thumbs { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 560px) { .thumbs { grid-template-columns: repeat(5, 1fr); } }
.thumbs a { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--rose); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .n { position: absolute; left: 5px; bottom: 5px; font-size: 11px; font-weight: 800; background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 1px 5px; }
.thumbs .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--wine-soft); padding: 6px; text-align: center; word-break: break-all; }

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