:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --surface: #161a22;
  --surface-2: #1d222c;
  --border: #2a313e;
  --text: #e9edf3;
  --muted: #8b94a5;
  --accent: #3ee6c4;
  --accent-ink: #062a23;
  --warn: #ffb547;
  --danger: #ff5d6c;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + var(--safe-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 15, 20, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.top-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 8px;
}
#brand { font-size: 22px; letter-spacing: 0.5px; }
#brand::after { content: "_"; color: var(--accent); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.top-actions { display: flex; gap: 8px; align-items: center; }
.badge {
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--accent); color: var(--accent);
}
.pill {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}

.tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; background: transparent; border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; color: var(--muted); white-space: nowrap;
}
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.notice {
  margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--radius);
  background: rgba(255, 181, 71, 0.12); border: 1px solid rgba(255, 181, 71, 0.4); color: var(--warn);
  font-size: 14px;
}

/* Menu */
.menu { padding: 8px 16px 0; max-width: 720px; margin: 0 auto; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.cat { scroll-margin-top: 120px; padding-top: 16px; }
.cat h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 10px; }
.card {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; min-height: 72px;
}
.card:active { border-color: var(--accent); }
.card img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.card-text { flex: 1; min-width: 0; }
.card-text h3 { font-size: 17px; }
.card-text p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card-price { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-price small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; text-align: right; }
.card.off { opacity: 0.45; cursor: default; }
.card.off .card-price { color: var(--muted); font-weight: 400; font-size: 14px; }

.surprise {
  position: fixed; right: 16px; bottom: calc(16px + var(--safe-bottom)); z-index: 5;
  background: var(--surface-2); border: 1px dashed var(--accent); color: var(--accent);
  border-radius: 999px; padding: 12px 18px; font-weight: 600;
}
body.has-cart .surprise { bottom: calc(88px + var(--safe-bottom)); }

.cart-bar {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + var(--safe-bottom)); z-index: 6;
  max-width: 688px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius);
  padding: 16px 18px; font-weight: 700; min-height: 56px;
  box-shadow: 0 8px 24px rgba(62, 230, 196, 0.25);
}
#cart-count {
  background: var(--accent-ink); color: var(--accent); border-radius: 999px;
  min-width: 28px; height: 28px; display: inline-grid; place-items: center; font-size: 14px;
}

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-panel {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + var(--safe-bottom));
  animation: up 0.18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-panel h2 { font-size: 22px; padding-right: 40px; }
.sheet-close {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2);
}
#ps-desc { margin-top: 4px; }

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; }
.preset {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px;
  padding: 8px 14px; font-size: 14px;
}
.preset[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.preset.custom { border-style: dashed; color: var(--muted); cursor: default; }

.group { margin-top: 18px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.group-head h3 { font-size: 16px; }
.group-head span { font-size: 12px; color: var(--muted); }
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.option {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 48px; padding: 10px 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.option small { color: var(--muted); font-variant-numeric: tabular-nums; }
.option[aria-pressed="true"] { border-color: var(--accent); background: rgba(62, 230, 196, 0.1); }
.option[aria-pressed="true"] small { color: var(--accent); }
.option:disabled { opacity: 0.4; text-decoration: line-through; cursor: default; }

.sheet-foot {
  position: sticky; bottom: calc(-22px - var(--safe-bottom)); margin: 18px -18px calc(-22px - var(--safe-bottom)); z-index: 1;
  padding: 12px 18px calc(16px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--border);
}
.qty-row { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.stepper button { width: 48px; height: 48px; border: 0; background: transparent; font-size: 22px; }
.stepper span { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.primary {
  width: 100%; min-height: 56px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px;
}
.primary:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.secondary {
  width: 100%; min-height: 52px; margin-top: 12px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border);
}

/* Cart */
.cart-items { list-style: none; margin: 16px 0 0; padding: 0; }
.cart-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item-text { flex: 1; min-width: 0; }
.cart-item-text strong { display: block; }
.cart-item-text span { color: var(--muted); font-size: 13px; }
.cart-item-price { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.cart-item .stepper button { width: 40px; height: 40px; font-size: 20px; }
.note { display: block; margin-top: 16px; }
.note span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.note textarea {
  width: 100%; resize: none; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit;
}
.total-row { display: flex; justify-content: space-between; font-size: 20px; margin: 0 0 12px; }
.total-row strong { font-variant-numeric: tabular-nums; }
.center.small { margin-top: 10px; }

/* Orders */
.order { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; }
.order-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 22px; letter-spacing: 2px; color: var(--accent); }
.order-msg { margin: 10px 0 14px; font-size: 18px; font-weight: 600; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.step { height: 6px; border-radius: 3px; background: var(--border); }
.step.on { background: var(--accent); }
.step.now { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.step-labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.order.rejected .order-msg { color: var(--danger); }
.order-items { margin-top: 12px; font-size: 14px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100% - 32px);
  background: #f2f4f8; color: #111; border-radius: 12px; padding: 12px 16px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.error { background: var(--danger); color: #fff; }

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