/* Warm dark "OTT" look: near-black ink, amber → orange accents, serif display headings.
   --primary / --accent can be overridden by the store's admin colours. */
:root {
  color-scheme: dark;
  --primary: #ffb020;
  --accent: #ff7a18;
  --gold: #fbbf24;
  --cta: linear-gradient(90deg, var(--primary), var(--accent));
  --cta-ink: #1a0d00;
  --background: #0b0807;
  --surface: #15100d;
  --surface-soft: #1c1511;
  --raise: rgba(255, 255, 255, .06);
  --raise-border: rgba(255, 255, 255, .14);
  --foreground: #f6efe9;
  --muted: #b8aaa0;
  --border: rgba(255, 214, 170, .16);
  --chip-bg: rgba(255, 179, 71, .16);
  --chip-ink: #ffb347;
  --money: #4ade80;
  --danger: #fb7185;
  --danger-bg: rgba(225, 29, 72, .16);
  --user-bubble: linear-gradient(135deg, #3a2413, #2a1a0e);
  --user-ink: #ffe7c7;
  --glow: radial-gradient(60% 40% at 50% 0%, rgba(255, 176, 32, .14), transparent 70%);
  --shadow: 0 18px 48px rgba(0, 0, 0, .45);
  --radius: 22px;
  --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Fluid type: ~15px on a 320px phone up to ~17px on wide screens; rem-based so the phone's own text-size setting still scales it. */
  font-size: clamp(0.94rem, 0.86rem + 0.4vw, 1.06rem);
  --fs-xs: clamp(.7rem, .66rem + .2vw, .78rem);
  --fs-sm: clamp(.8rem, .76rem + .2vw, .9rem);
  --fs-title: clamp(1.18rem, 1.02rem + .8vw, 1.45rem);
  --fs-display: clamp(1.4rem, 1.15rem + 1.3vw, 1.85rem);
  --fs-header: clamp(1.05rem, .96rem + .5vw, 1.25rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #fbf8f2;
  --surface: #ffffff;
  --surface-soft: #fff8ec;
  --raise: #fff;
  --raise-border: rgba(120, 72, 20, .18);
  --foreground: #1f140c;
  --muted: #6b5a4c;
  --border: rgba(120, 72, 20, .16);
  --chip-bg: rgba(255, 176, 32, .18);
  --chip-ink: #9a5200;
  --money: #15803d;
  --danger: #e11d48;
  --danger-bg: rgba(225, 29, 72, .1);
  --user-bubble: linear-gradient(135deg, #ffe2b0, #ffd08a);
  --user-ink: #2a1600;
  --glow: radial-gradient(60% 40% at 50% 0%, rgba(255, 176, 32, .16), transparent 70%);
  --shadow: 0 16px 40px rgba(90, 50, 10, .12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --background: #fbf8f2;
    --surface: #ffffff;
    --surface-soft: #fff8ec;
    --raise: #fff;
    --raise-border: rgba(120, 72, 20, .18);
    --foreground: #1f140c;
    --muted: #6b5a4c;
    --border: rgba(120, 72, 20, .16);
    --chip-bg: rgba(255, 176, 32, .18);
    --chip-ink: #9a5200;
    --money: #15803d;
    --danger: #e11d48;
    --danger-bg: rgba(225, 29, 72, .1);
    --user-bubble: linear-gradient(135deg, #ffe2b0, #ffd08a);
    --user-ink: #2a1600;
    --glow: radial-gradient(60% 40% at 50% 0%, rgba(255, 176, 32, .16), transparent 70%);
    --shadow: 0 16px 40px rgba(90, 50, 10, .12);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; min-height: 100dvh; color: var(--foreground); background: var(--background); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.skip-link { position: fixed; top: 8px; left: 8px; transform: translateY(-160%); z-index: 20; padding: 10px 14px; border-radius: 999px; color: var(--cta-ink); background: var(--cta); }
.skip-link:focus { transform: translateY(0); }

.app-shell {
  position: relative; display: flex; flex-direction: column; width: min(100%, 480px); min-height: 100dvh; margin: 0 auto; overflow: hidden;
  background-color: var(--background);
  background-image: var(--glow), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='112' height='112' viewBox='0 0 112 112'%3E%3Cg fill='none' stroke='%23ffb020' stroke-opacity='.07' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M14 30h18M23 21v18M70 84l12-12M66 20l5 5 10-11M30 90c4-9 12-12 21-8'/%3E%3Ccircle cx='88' cy='44' r='6'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed, scroll;
}

.chat-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: 70px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 82%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.brand-mark { display: grid; flex: 0 0 42px; place-items: center; width: 42px; height: 42px; overflow: hidden; border-radius: 50%; color: var(--cta-ink); background: var(--cta); font-family: var(--serif); font-size: 1.25rem; box-shadow: 0 0 0 2px var(--background), 0 0 0 3.5px color-mix(in srgb, var(--primary) 70%, transparent); }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-mark.has-logo { background-position: center; background-size: cover; font-size: 0; }
.header-copy { min-width: 0; flex: 1; }
.header-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-family: var(--serif); font-size: 1.18rem; font-weight: 400; letter-spacing: .01em; }
.header-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verified { display: inline-grid; flex: 0 0 auto; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: var(--cta-ink); background: var(--cta); font-family: system-ui, sans-serif; font-size: .68rem; font-weight: 800; }
.header-subtitle { overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-grid; flex: 0 0 42px; place-items: center; width: 42px; height: 42px; border: 1px solid transparent; border-radius: 50%; color: var(--foreground); background: transparent; font-size: 1.45rem; transition: background 160ms ease, border-color 160ms ease; }
.icon-button:hover { border-color: var(--raise-border); background: var(--raise); }

.chat-log { display: flex; flex: 1; flex-direction: column; gap: 14px; padding: 18px 12px 108px; }
.message { max-width: 92%; animation: message-in 240ms cubic-bezier(.2, .7, .2, 1) both; }
.message.user { align-self: flex-end; max-width: 80%; }
.message.bot { align-self: flex-start; }
.bubble { padding: 14px 15px; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) var(--radius) 8px; color: var(--foreground); background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); line-height: 1.5; overflow-wrap: anywhere; }
.user .bubble { padding: 10px 14px; border-color: transparent; border-radius: var(--radius) var(--radius) 8px var(--radius); color: var(--user-ink); background: var(--user-bubble); font-weight: 600; box-shadow: none; }
.bubble h1, .bubble h2, .bubble h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; line-height: 1.12; letter-spacing: .005em; }
.bubble h1 { font-size: 1.6rem; }
.bubble h2 { font-size: 1.3rem; }
.intro-logo { display: block; width: 68px; height: 68px; margin: 0 0 12px; border: 1px solid var(--border); border-radius: 20px; object-fit: cover; }
.bubble p { margin: 6px 0; }
.bubble small { color: var(--muted); }
.user .bubble small { color: inherit; opacity: .75; }
.quote { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--primary); border-radius: 0 12px 12px 0; color: var(--muted); background: var(--chip-bg); font-size: .9rem; }

.bubble-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.bubble-actions.one { grid-template-columns: 1fr; }
.action-button, .reply-keyboard button, .dialog-actions button, .form-button {
  min-height: 44px; padding: 10px 14px; border: 1px solid var(--raise-border); border-radius: 999px; color: var(--foreground); background: var(--raise);
  font-weight: 650; line-height: 1.18; transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.action-button:hover, .reply-keyboard button:hover, .dialog-actions button:hover, .form-button:hover { border-color: color-mix(in srgb, var(--primary) 55%, transparent); background: var(--chip-bg); }
.action-button:active, .reply-keyboard button:active, .dialog-actions button:active, .form-button:active { transform: scale(.97); }
.action-button.primary { color: var(--chip-ink); border-color: color-mix(in srgb, var(--primary) 40%, transparent); background: var(--chip-bg); }
.action-button.success { color: var(--cta-ink); border-color: transparent; background: var(--cta); font-weight: 750; box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 28%, transparent); }
.action-button.success:hover { filter: brightness(1.06); background: var(--cta); }
.action-button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.action-button:disabled { cursor: wait; opacity: .55; }

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.product-card { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 13px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-soft); transition: border-color 160ms ease, transform 160ms ease; }
.product-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, transparent); transform: translateY(-1px); }
.product-card strong { font-size: .92rem; line-height: 1.3; }
.product-card .action-button { margin-top: auto; min-height: 38px; padding: 8px 10px; font-size: .86rem; }
.price { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.02rem; }
:root[data-theme="light"] .price { color: #b45309; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .price { color: #b45309; } }
.muted { color: var(--muted); font-size: .86rem; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; color: var(--chip-ink); background: var(--chip-bg); font-size: .75rem; font-weight: 700; }

.typing { display: inline-flex; gap: 4px; padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) var(--radius) 8px; background: var(--surface); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: dot 900ms infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 120ms; } .typing i:nth-child(3) { animation-delay: 240ms; }
.empty-state { padding: 14px; border: 1px dashed var(--border); border-radius: 16px; color: var(--muted); background: var(--surface-soft); }
.cart-line { margin: 8px 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.quantity-input { width: 100%; min-height: 46px; margin: 8px 0; padding: 9px 14px; border: 1px solid var(--raise-border); border-radius: 999px; color: var(--foreground); background: var(--raise); }
.payment-qr { display: block; width: min(220px, 100%); height: auto; margin: 12px auto; padding: 10px; border-radius: 18px; background: #fff; }
.code-list { display: grid; gap: 7px; margin: 10px 0; }
.code-row { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.code-row code { flex: 1; min-width: 0; color: var(--gold); overflow-wrap: anywhere; }
.code-row button { min-height: 34px; padding: 6px 12px; border: 1px solid var(--raise-border); border-radius: 999px; color: var(--foreground); background: var(--raise); font-weight: 650; }

.reply-keyboard { position: fixed; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr) 46px; gap: 7px; width: min(100%, 480px); padding: 10px 10px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--background) 86%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.reply-keyboard button { padding: 9px 5px; font-size: .84rem; }
.reply-keyboard button[data-action="shop"] { color: var(--cta-ink); border-color: transparent; background: var(--cta); font-weight: 750; }
.reply-keyboard .keyboard-more { color: var(--foreground); font-size: 1.2rem; }

.menu-dialog { width: min(calc(100% - 24px), 420px); padding: 0; border: 1px solid var(--border); border-radius: 26px; color: var(--foreground); background: var(--surface); box-shadow: var(--shadow); }
.menu-dialog::backdrop { background: rgba(5, 3, 2, .62); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 8px 20px; }
.dialog-head h2 { margin: 0; font-family: var(--serif); font-size: 1.35rem; font-weight: 400; }
.dialog-actions { display: grid; gap: 9px; padding: 10px 16px 18px; }
.dialog-actions button { padding-left: 18px; text-align: left; }
.telegram-widget { min-height: 0; padding: 0 16px 16px; }
.form-row { display: flex; gap: 8px; margin-top: 10px; }
.form-row input, .form-row select { min-width: 0; flex: 1; min-height: 44px; padding: 9px 14px; border: 1px solid var(--raise-border); border-radius: 999px; color: var(--foreground); background: var(--raise); }
.toast { position: fixed; right: 12px; bottom: 86px; left: 12px; z-index: 10; max-width: 456px; margin: auto; padding: 11px 16px; border: 1px solid var(--border); border-radius: 999px; color: var(--foreground); background: var(--surface); box-shadow: var(--shadow); text-align: center; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@keyframes message-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (min-width: 768px) {
  body { padding: 24px 0; background: radial-gradient(70% 50% at 50% 0%, rgba(255, 176, 32, .08), transparent 70%), var(--background); }
  .app-shell { min-height: calc(100dvh - 48px); border: 1px solid var(--border); border-radius: 28px; box-shadow: var(--shadow); }
  .chat-header { border-radius: 28px 28px 0 0; }
  .reply-keyboard { bottom: 24px; border-radius: 0 0 28px 28px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* Grid buttons may wrap to two lines: soft corners there, full pills for single CTAs. */
.bubble-actions .action-button, .product-card .action-button { border-radius: 16px; }
.bubble-actions.one .action-button { border-radius: 999px; }

/* Responsive type scale (overrides the fixed sizes above). */
.header-name { font-size: var(--fs-header); }
.header-subtitle, .chip { font-size: var(--fs-xs); }
.bubble h1 { font-size: var(--fs-display); }
.bubble h2, .dialog-head h2 { font-size: var(--fs-title); }
.muted, .quote, .reply-keyboard button, .product-card .action-button { font-size: var(--fs-sm); }
.product-card strong { font-size: var(--fs-sm); }
.price { font-size: 1em; }
/* Inputs stay at 16px or more so iOS Safari doesn't zoom in on focus. */
input, select, textarea { font-size: max(16px, 1rem) !important; }
@media (max-width: 340px) { .reply-keyboard { grid-template-columns: repeat(3, 1fr) 40px; gap: 5px; } .reply-keyboard button { padding-inline: 3px; } }
