:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f4f7fa);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #242424);
  --muted: var(--tg-theme-hint-color, #6f7680);
  --accent: var(--tg-theme-button-color, #0061b2);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-strong: #004b89;
  --success: #016b2b;
  --line: #dfe5eb;
  --warm: #e99124;
  --danger: #bd2c2c;
  --shadow: 0 18px 50px rgba(0, 65, 119, 0.14);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, white); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.app-shell { min-height: 100vh; max-width: 1180px; margin: 0 auto; padding: 18px clamp(16px, 4vw, 44px) 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0 18px; }
.topbar h1, .section-heading h2, .sheet-header h2 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -0.03em; }
.topbar h1 { font-size: clamp(28px, 6vw, 42px); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; font-weight: 800; color: var(--muted); }
.cart-button { border: 0; background: var(--accent); color: var(--accent-text); min-width: 58px; height: 48px; border-radius: 18px; display: flex; gap: 9px; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow); }
.cart-button span:first-child { font-size: 22px; }
.cart-button span:last-child { min-width: 20px; font-weight: 800; }
.demo-banner { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 16px; border: 1px solid #b9daf3; background: #edf7ff; color: #004b89; border-radius: 14px; padding: 9px 14px; font-size: 13px; }
.demo-banner strong { border-radius: 99px; padding: 3px 8px; background: var(--accent); color: white; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }

.hero { position: relative; overflow: hidden; min-height: 260px; border-radius: 30px; background: linear-gradient(135deg, #003f73, #0061b2); color: #ffffff; display: grid; grid-template-columns: 1.25fr 0.75fr; box-shadow: var(--shadow); }
.hero-copy { position: relative; z-index: 2; padding: clamp(28px, 6vw, 64px); max-width: 680px; }
.hero-kicker { color: #b9dcff; font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.hero h2 { margin: 14px 0 12px; font: 600 clamp(34px, 7vw, 68px)/0.98 Georgia, serif; letter-spacing: -0.045em; }
.hero p { max-width: 560px; margin: 0; color: rgba(255, 255, 255, 0.78); font-size: clamp(15px, 2.4vw, 18px); line-height: 1.55; }
.hero-art { position: relative; min-height: 260px; }
.hero-mark { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 128px; height: 128px; border: 1px solid rgba(255, 255, 255, 0.48); border-radius: 50% 45% 55% 42%; font: italic 72px Georgia, serif; color: #ffffff; }
.orb { position: absolute; display: block; border-radius: 50%; filter: blur(1px); opacity: 0.85; }
.orb-one { width: 190px; height: 190px; right: -45px; top: -34px; background: #1189d6; }
.orb-two { width: 140px; height: 140px; left: -20px; bottom: -55px; background: #016b2b; }

.controls { display: grid; grid-template-columns: auto minmax(230px, 1fr) minmax(180px, 0.45fr); gap: 12px; margin: 24px 0 32px; }
.segment-control { display: inline-flex; padding: 4px; background: rgba(255, 255, 255, 0.66); border: 1px solid var(--line); border-radius: 15px; }
.segment-button { border: 0; background: transparent; padding: 11px 15px; border-radius: 11px; cursor: pointer; color: var(--muted); font-weight: 700; white-space: nowrap; }
.segment-button.is-active { background: var(--accent); color: var(--accent-text); }
.search-field, .category-field { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.search-field input, .category-field select { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.category-field { display: grid; gap: 1px; padding-block: 8px; }
.category-field > span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { font-size: clamp(28px, 5vw, 42px); }
.results-count { color: var(--muted); font-size: 13px; }
.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 8px 24px rgba(0, 65, 119, 0.07); }
.product-visual { position: relative; aspect-ratio: 1.15; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, #dcefff, #86bce4); }
.product-card:nth-child(3n + 2) .product-visual { background: linear-gradient(145deg, #e6f4ec, #9bc8aa); }
.product-card:nth-child(3n + 3) .product-visual { background: linear-gradient(145deg, #edf1f5, #b5c4d3); }
.product-visual::before, .product-visual::after { content: ""; position: absolute; border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 50%; }
.product-visual::before { width: 62%; height: 62%; transform: rotate(18deg); }
.product-visual::after { width: 36%; height: 36%; transform: rotate(-26deg); }
.product-glyph { position: relative; z-index: 1; font: italic 54px Georgia, serif; color: rgba(0, 61, 112, 0.68); }
.demo-chip { position: absolute; top: 12px; left: 12px; z-index: 2; border-radius: 99px; background: rgba(255, 255, 255, 0.9); color: var(--accent-strong); padding: 5px 9px; font-size: 9px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.product-body { display: flex; flex-direction: column; flex: 1; padding: 15px; }
.product-category { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-body h3 { margin: 7px 0 6px; font-size: 16px; line-height: 1.25; }
.product-meta { margin-bottom: 14px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.stock-row { display: flex; align-items: center; gap: 7px; margin-top: auto; font-size: 11px; color: var(--muted); }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.stock-row[data-code="zero"] .stock-dot, .stock-row[data-code="stale"] .stock-dot { background: var(--warm); }
.price-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
.price { font-size: 18px; font-weight: 900; }
.add-button { width: 40px; height: 40px; border: 0; border-radius: 13px; background: var(--accent); color: var(--accent-text); font-size: 23px; cursor: pointer; }

.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state > span { font-size: 38px; }
.empty-state h3 { margin: 10px 0 4px; color: var(--text); }
.empty-state p { margin: 0; }
.empty-state.compact { padding: 48px 24px; }

.cart-panel { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; visibility: hidden; pointer-events: none; }
.cart-panel.is-open { visibility: visible; pointer-events: auto; }
.cart-backdrop { position: absolute; inset: 0; background: rgba(20, 23, 20, 0.46); opacity: 0; transition: opacity 180ms ease; }
.cart-panel.is-open .cart-backdrop { opacity: 1; }
.cart-sheet { position: relative; width: min(680px, 100%); max-height: min(92vh, 860px); margin: 0 auto; overflow: auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 12px clamp(18px, 5vw, 34px) 32px; transform: translateY(104%); transition: transform 220ms ease; box-shadow: 0 -20px 70px rgba(20, 23, 20, 0.22); }
.cart-panel.is-open .cart-sheet { transform: translateY(0); }
.sheet-handle { width: 48px; height: 5px; margin: 0 auto 16px; border-radius: 99px; background: var(--line); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { font-size: 34px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-size: 25px; }
.cart-lines { display: grid; gap: 12px; padding: 18px 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.cart-line h4 { margin: 0 0 4px; font-size: 14px; }
.cart-line p { margin: 0; color: var(--muted); font-size: 12px; }
.quantity-control { display: flex; align-items: center; gap: 7px; }
.quantity-control button { width: 30px; height: 30px; border: 1px solid var(--line); background: white; border-radius: 9px; cursor: pointer; }
.remove-button { border: 0; background: none; color: var(--danger); padding: 4px; cursor: pointer; font-size: 11px; }
.cart-total { display: flex; justify-content: space-between; align-items: center; border-block: 1px solid var(--line); padding: 18px 0; font-size: 16px; }
.cart-total strong { font-size: 24px; }
.checkout-form { display: grid; gap: 15px; padding-top: 22px; }
.form-heading h3 { margin: 0 0 4px; font-size: 20px; }
.form-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.checkout-form label:not(.consent-row) { display: grid; gap: 7px; font-size: 12px; font-weight: 700; }
.checkout-form label small { color: var(--muted); font-weight: 400; }
.checkout-form input[type="text"], .checkout-form input[type="tel"] { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: white; padding: 13px 14px; color: var(--text); }
.consent-row { display: flex; align-items: flex-start; gap: 10px; font-size: 12px; line-height: 1.4; }
.consent-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.field-error { min-height: 14px; color: var(--danger); font-size: 11px; }
.primary-button, .secondary-button { min-height: 50px; border-radius: 14px; padding: 0 18px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; background: var(--accent); color: var(--accent-text); }
.secondary-button { border: 1px solid var(--line); background: transparent; color: var(--text); }
.success-panel { text-align: center; padding: 34px 0 8px; }
.success-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; background: #e3f3e9; color: var(--success); font-size: 30px; }
.success-panel h3 { margin: 8px 0; font: 600 30px Georgia, serif; }
.success-panel > p:not(.eyebrow):not(.duplicate-note) { color: var(--muted); line-height: 1.5; }
.flow-summary { display: grid; gap: 8px; margin: 24px 0; text-align: left; }
.flow-summary div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }
.flow-summary dt { color: var(--muted); }
.flow-summary dd { margin: 0; max-width: 58%; overflow-wrap: anywhere; font-weight: 800; text-align: right; }
.duplicate-note { padding: 10px 12px; border-radius: 10px; background: #edf7ff; color: var(--accent-strong); font-size: 12px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 22px; transform: translate(-50%, 20px); min-width: min(340px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg); text-align: center; opacity: 0; pointer-events: none; transition: 180ms ease; box-shadow: var(--shadow); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr 1fr; }
  .segment-control { grid-column: 1 / -1; justify-content: center; }
  .segment-button { flex: 1; }
}

@media (max-width: 640px) {
  .app-shell { padding-inline: 12px; }
  .hero { grid-template-columns: 1fr; min-height: 310px; }
  .hero-copy { padding: 30px 24px; }
  .hero-art { position: absolute; inset: auto -35px -45px auto; width: 210px; min-height: 190px; opacity: 0.7; }
  .controls { grid-template-columns: 1fr; margin-top: 16px; }
  .segment-control { grid-column: auto; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card { border-radius: 18px; }
  .product-body { padding: 12px; }
  .product-body h3 { font-size: 14px; }
  .product-visual { aspect-ratio: 1; }
  .product-glyph { font-size: 40px; }
  .stock-row { align-items: flex-start; }
  .price { font-size: 16px; }
  .add-button { width: 36px; height: 36px; }
}

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