:root {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #111318);
  --surface: var(--tg-theme-secondary-bg-color, #1b1e25);
  --surface-2: #242832;
  --text: var(--tg-theme-text-color, #f3f5f7);
  --muted: var(--tg-theme-hint-color, #9299a6);
  --accent: var(--tg-theme-button-color, #6c5ce7);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --border: rgba(255,255,255,.08);
  --success: #35c779;
  --danger: #ff5f68;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
button,textarea { font: inherit; }
button { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 18px 12px; background: color-mix(in srgb,var(--bg) 92%,transparent); backdrop-filter: blur(18px); border-bottom: 1px solid var(--border); }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 2px 0 0; font-size: 25px; line-height: 1.1; }
h2 { margin: 0 0 8px; font-size: 18px; }
p { margin: 8px 0 0; color: var(--muted); }
.icon-button,.back-button { border: 0; background: transparent; }
.icon-button { width: 42px; height: 42px; border-radius: 14px; background: var(--surface); font-size: 27px; }
main { padding: 14px 14px calc(90px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }
.summary-card { display: flex; justify-content: space-between; align-items: center; padding: 17px 18px; margin-bottom: 12px; border-radius: 20px; background: linear-gradient(135deg,var(--accent),#8d66f4); color: white; box-shadow: 0 12px 30px rgba(108,92,231,.25); }
.summary-card strong { font-size: 30px; }
.list { display: grid; gap: 10px; }
.card { padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 20px rgba(0,0,0,.12); }
.order-top,.chat-row,.status-row { display: flex; align-items: center; gap: 11px; }
.order-top { align-items: flex-start; justify-content: space-between; }
.item-title { font-size: 16px; font-weight: 750; overflow-wrap: anywhere; }
.price { flex: 0 0 auto; color: var(--success); font-weight: 800; }
.meta { display: grid; gap: 4px; margin: 13px 0; color: var(--muted); font-size: 13px; }
.primary-button,.secondary-button,.complete-button { min-height: 44px; padding: 10px 15px; border: 0; border-radius: 13px; font-weight: 750; }
.primary-button,.complete-button { background: var(--accent); color: var(--accent-text); }
.complete-button { width: 100%; }
.secondary-button { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 46px; border-radius: 15px; background: linear-gradient(145deg,var(--accent),#3c8ce7); color: white; font-size: 19px; font-weight: 800; }
.chat-body { min-width: 0; flex: 1; }
.chat-title-line { display: flex; justify-content: space-between; gap: 8px; }
.chat-preview,.muted { color: var(--muted); font-size: 13px; }
.chat-preview { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { min-width: 22px; height: 22px; padding: 2px 7px; border-radius: 99px; background: var(--accent); color: white; text-align: center; font-size: 12px; font-weight: 800; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(53,199,121,.12); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3,1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb,var(--surface) 95%,transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--border); }
.nav-item { display: grid; gap: 2px; place-items: center; padding: 5px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.nav-item span { font-size: 21px; }
.nav-item.active { color: var(--accent); }
.dialog-view { margin: -8px -4px 0; }
.back-button { padding: 8px 0; color: var(--accent); font-weight: 700; }
.dialog-heading { padding: 6px 0 12px; }
.messages { display: flex; flex-direction: column; gap: 8px; min-height: 200px; max-height: calc(100vh - 365px); overflow-y: auto; padding: 4px 1px 12px; }
.bubble { max-width: 86%; padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: var(--accent); color: var(--accent-text); }
.bubble .author { margin-bottom: 3px; color: var(--accent); font-size: 11px; font-weight: 750; }
.bubble.mine .author { color: rgba(255,255,255,.75); }
.bubble .time { margin-top: 4px; color: var(--muted); font-size: 10px; text-align: right; }
.bubble.mine .time { color: rgba(255,255,255,.65); }
.quick-replies { display: flex; gap: 7px; overflow-x: auto; padding: 8px 0; }
.quick-replies button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding-top: 6px; }
.composer textarea { flex: 1; min-height: 46px; max-height: 110px; resize: none; padding: 12px 14px; border: 1px solid var(--border); border-radius: 15px; outline: none; background: var(--surface); color: var(--text); }
.composer textarea:focus { border-color: var(--accent); }
.send-button { width: 46px; height: 46px; flex: 0 0 46px; border: 0; border-radius: 15px; background: var(--accent); color: white; font-size: 20px; }
.loader,.empty { padding: 35px 12px; color: var(--muted); text-align: center; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 92px; z-index: 20; padding: 12px 15px; border-radius: 13px; background: #303542; color: white; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #702d35; }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: end center; padding: 16px; background: rgba(0,0,0,.62); }
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 480px; padding: 20px; border-radius: 22px; background: var(--surface); }
.modal-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; margin-top: 20px; }
@media (min-width: 720px) { body { max-width: 720px; margin: 0 auto; } .bottom-nav { left: 50%; max-width: 720px; transform: translateX(-50%); } }
