:root {
  --bg: #FFFFFF; --surface: #FFFFFF; --border: #E5E7F0; --text: #1B1F33; --muted: #5D6276;
  --input: #F4F5FA; --thumb: #F4F5FA; --thumb-icon: #9AA0B8; --chip: #EEF0FA; --chip-text: #2E3570;
  --accent: #3A44A0; --accent-text: #3A44A0; --accent-soft: #EEF0FA; --pill: #1B1F33; --pill-text: #FFFFFF;
  --banner: #F4F5FC; --fav: #B83A2E; --brand: #2F3880; --danger: #A63A2B; --ok-soft: #EAF5EE; --ok-text: #2E6B4A;
  --radius: 12px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #111320; --surface: #181B2A; --border: #2A2E42; --text: #E9EBF5; --muted: #A0A5BC;
  --input: #1E2133; --thumb: #21253A; --thumb-icon: #6D7392; --chip: #1F2340; --chip-text: #C9CEF2;
  --accent: #5662C8; --accent-text: #AEB6F4; --accent-soft: #20244A; --pill: #E9EBF5; --pill-text: #111320;
  --banner: #1A1D30; --fav: #F0907F; --brand: #E9EBF5; --danger: #F0907F; --ok-soft: #1A2A20; --ok-text: #8CC49C;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 110px; }
.screen.no-pill { padding-bottom: 24px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: clamp(44px, 13vw, 56px); height: 32px; object-fit: contain; flex-shrink: 0; }
.brand > div { min-width: 0; }
.brand-name { font-size: clamp(12.5px, 3.8vw, 15px); font-weight: 700; letter-spacing: .3px; white-space: nowrap; color: var(--brand); overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--muted); }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn { position: relative; width: 40px; height: 36px; border: 0; border-radius: 8px; background: var(--chip); color: var(--chip-text);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; padding: 0; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.subbar { display: flex; align-items: center; gap: 6px; padding: 12px 10px 8px; }
.back { width: 44px; height: 44px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--text); }
.subtitle { font-size: 19px; font-weight: 700; }

/* search */
.search { margin: 0 16px; display: flex; align-items: center; gap: 8px; background: var(--input); border-radius: 10px; padding: 0 12px; height: 42px; color: var(--muted); }
.search input { border: 0; outline: none; flex: 1; min-width: 0; background: transparent; color: var(--text); font-size: 15px; }
.search input::placeholder { color: var(--muted); }

/* banner */
.banner { margin: 10px 16px 0; border-radius: var(--radius); background: var(--banner); border: 1px solid var(--border); overflow: hidden; display: block; width: calc(100% - 32px); text-align: left; padding: 0; }
.banner img { width: 100%; max-height: 150px; object-fit: cover; }
.banner-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.banner-tag { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--muted); }
.banner-title { font-size: 14px; font-weight: 700; }
.banner-text { font-size: 12px; color: var(--muted); white-space: pre-line; }

/* chips */
.chips { display: flex; gap: 6px; padding: 12px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--chip); color: var(--chip-text); font-weight: 700; font-size: 12px; padding: 0 12px; height: 34px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; }
.chip.on { background: var(--accent); color: #fff; }

/* grid */
.grid { padding: 0 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--thumb); color: var(--thumb-icon); overflow: hidden; }
.thumb-open { position: absolute; inset: 0; border: 0; padding: 0; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; }
.thumb-open img { width: 100%; height: 100%; object-fit: cover; }
.heart { position: absolute; top: 0; right: 0; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; }
.heart::before { content: ''; position: absolute; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); opacity: .92; box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.heart svg { position: relative; }
.heart.on { color: var(--fav); }
.heart.on svg { fill: currentColor; }
.card.off .thumb, .card.off .card-name { opacity: .55; }
.hide { display: none !important; }
.card-name { font-size: 13px; font-weight: 600; line-height: 1.25; min-height: 32px; border: 0; background: none; padding: 0; text-align: left; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.unit { height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; font-weight: 600; font-size: 13px; background: var(--surface); color: var(--text); width: 100%; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.price { font-size: 13px; font-weight: 700; }
.price small { font-weight: 600; color: var(--muted); }
.add { width: 36px; height: 36px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.out { font-size: 12px; color: var(--muted); height: 36px; display: flex; align-items: center; }
.stepper { display: flex; align-items: center; border: 1px solid var(--accent); border-radius: 8px; height: 40px; background: var(--accent-soft); }
.stepper button { width: 40px; height: 38px; border: 0; background: transparent; color: var(--accent-text); display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.stepper input { flex: 1; min-width: 0; width: 44px; height: 38px; border: 0; outline: none; text-align: center; font-weight: 700; font-size: 14px; color: var(--accent-text); background: transparent; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; }
.credit { padding: 18px 16px 4px; text-align: center; font-size: 12px; color: var(--muted); }
.credit a { color: var(--muted); }

/* floating cart */
.pill-wrap { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; z-index: 5; }
.pill { pointer-events: auto; display: flex; align-items: center; gap: 12px; height: 50px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--pill); color: var(--pill-text); font-weight: 700; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }

/* product page */
.pp-photo { margin: 0 16px; aspect-ratio: 1 / 1; border-radius: 14px; background: var(--thumb); color: var(--thumb-icon); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.pp-photo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pp-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.pp-name { font-size: 20px; font-weight: 700; margin: 0; }
.pp-price { font-size: 17px; font-weight: 700; color: var(--accent-text); }
.pp-meta { font-size: 13px; color: var(--muted); }
.pp-desc { font-size: 14px; line-height: 1.5; white-space: pre-line; }
.pp-actions { display: flex; flex-direction: column; gap: 8px; }
.big-btn { height: 52px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; width: 100%; }
.big-btn:disabled { opacity: .55; }
.ghost-btn { height: 48px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; padding: 0 22px; }

/* cart */
.lines { padding: 0 16px; }
.line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.line-thumb { width: 52px; height: 52px; border-radius: 8px; background: var(--thumb); overflow: hidden; flex-shrink: 0; color: var(--thumb-icon); display: flex; align-items: center; justify-content: center; }
.line-thumb img { width: 100%; height: 100%; object-fit: cover; }
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line-name { font-size: 14px; font-weight: 600; }
.line-price { font-size: 13px; color: var(--muted); }
.line-hint { font-size: 11px; color: var(--muted); }
.line-ctrl { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.line-ctrl .unit { width: auto; height: 36px; }
.line-ctrl .stepper { height: 38px; }
.line-ctrl .stepper button { height: 36px; width: 36px; }
.line-ctrl .stepper input { height: 36px; width: 44px; flex: 0 0 44px; }
.field { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.field textarea, .field input { border: 1px solid var(--border); border-radius: 10px; background: var(--input); padding: 10px 12px; font-size: 15px; outline: none; color: var(--text); font-weight: 400; }
.field textarea { min-height: 64px; resize: vertical; }
.phone-box { display: flex; align-items: center; height: 48px; border: 1px solid var(--border); border-radius: 10px; background: var(--input); overflow: hidden; }
.phone-box span { padding: 0 12px; height: 100%; display: flex; align-items: center; border-right: 1px solid var(--border); font-size: 16px; font-weight: 700; color: var(--text); }
.phone-box input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; height: 100%; font-weight: 600 !important; }
.field-note { font-size: 12px; font-weight: 400; color: var(--muted); }
.summary { margin-top: auto; padding: 14px 16px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; background: var(--bg); position: sticky; bottom: 0; }
.summary-row { display: flex; justify-content: space-between; font-size: 14px; }
.summary-row b { font-size: 16px; }
.summary-note { font-size: 12px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }

/* code + done */
.pad { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; }
.h1 { font-size: 22px; font-weight: 700; margin: 0; }
.p { font-size: 15px; color: var(--muted); line-height: 1.5; margin: 0; }
.code-input { height: 60px; border: 1px solid var(--border); border-radius: 12px; background: var(--input); text-align: center; letter-spacing: 14px; font-size: 26px; font-weight: 700; outline: none; color: var(--text); width: 100%; }
.link-btn { align-self: flex-start; height: 44px; border: 0; background: transparent; padding: 0; color: var(--accent-text); font-weight: 600; }
.link-btn:disabled { color: var(--muted); }
.done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 40px 32px; text-align: center; }
.done-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.bottom { padding: 12px 16px 24px; margin-top: auto; }

/* misc */
.loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--pill); color: var(--pill-text); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.orders { padding: 0 16px; }
.order { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.order-st { font-size: 12px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }

.pp-old { color: var(--muted); font-weight: 400; font-size: .7em; margin-left: 6px; }
.save { color: var(--ok-text); font-weight: 600; }
