/* 美杰轮胎 客服 — dark theme matched to Oracle (black + Mrrjestic amber) */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #141414;
  --panel: #1e1e1e;
  --panel-2: #252525;
  --panel-3: #2b2b2b;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --muted: #999999;
  --faint: #6f6f6f;
  --accent: #e5ad2e;
  --accent-dark: #efbf52;
  --on-accent: #141414;
  --good: #2faa57;
  --bad: #ff5a5a;
  --read-blue: #4fb6ff;
  --bubble-in: #232323;
  --bubble-out: #332a10;
  --bubble-out-2: #3b3114;
  --rc: 8px;
  --rp: 12px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 28px rgba(0,0,0,.55);
  --ease: cubic-bezier(.32,.72,.33,1);
}
/* iOS-style type: genuine San Francisco on Apple devices (-apple-system),
   and Inter — the SF screen-twin — everywhere else (Apple doesn't license SF
   off-platform). Chinese falls through to PingFang / Noto Sans SC.
   Self-hosted Inter variable woff2, 48KB, weights 100-900. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/Inter-latin.woff2') format('woff2');
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em; /* SF-like tracking at UI sizes */
}

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  transition: transform .28s var(--ease);
  z-index: 1;
}
.screen-right { transform: translateX(100%); z-index: 2; box-shadow: -14px 0 36px rgba(0,0,0,.5); }
.screen-right.open { transform: translateX(0); }
#screen-list.pushed { transform: translateX(-18%); }

/* ---------- top bar ---------- */
.topbar {
  background:
    radial-gradient(640px 140px at 18% 0%, rgba(229,173,46,.07), transparent 70%),
    linear-gradient(180deg, #1d1d1c, #151514);
  color: var(--text);
  padding: calc(env(safe-area-inset-top) + 14px) 14px 13px;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(229,173,46,.16);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 6px 18px rgba(0,0,0,.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.topbar-title {
  font-size: 17px; font-weight: 700; letter-spacing: .03em;
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title .accent { color: var(--accent); }
.brand-row { display: flex; align-items: center; gap: 4px; }
.brand-logo { height: 34px; width: auto; display: block; filter: drop-shadow(0 1px 8px rgba(229,173,46,.10)); }
.topbar-sub { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 8px; letter-spacing: .02em; }
.topbar-phone { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.iconbtn {
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.08);
  color: #d9d9d6;
  font-size: 16px; width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s var(--ease);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.iconbtn:active { background: rgba(229,173,46,.14); border-color: rgba(229,173,46,.35); transform: scale(.92); }
.iconbtn svg { width: 17px; height: 17px; }
.lang-btn {
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  width: auto; padding: 0 13px; border-radius: 19px;
  color: var(--accent); border-color: rgba(229,173,46,.28);
  background: rgba(229,173,46,.07);
}

.banner {
  background: #2b2412; color: var(--accent-dark);
  padding: 9px 16px; font-size: 13px; text-align: center;
  border-bottom: 1px solid #3a3118;
}
.hidden { display: none !important; }

/* ---------- search ---------- */
.search-bar {
  display: flex; gap: 8px; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.search-bar input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 19px; padding: 9px 15px;
  color: var(--text); font-size: 15px; font-family: inherit; outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
  background: none; border: none; color: var(--muted); font-size: 14px;
  cursor: pointer; font-family: inherit; padding: 0 4px;
}
.search-head {
  padding: 10px 16px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; color: var(--faint);
}
.search-snip { font-size: 12.5px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-snip b { color: var(--accent); font-weight: 600; }

/* ---------- filter chips (lists) ---------- */
.filter-chips {
  display: flex; gap: 7px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 14px 4px; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.fchip {
  flex-shrink: 0;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 12.5px; font-weight: 650; font-family: inherit;
  padding: 6px 13px; border-radius: 16px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.fchip.on {
  background: rgba(229,173,46,.14); border-color: rgba(229,173,46,.4);
  color: var(--accent);
}
.fchip .n { opacity: .65; font-weight: 600; margin-left: 3px; }

/* list-assign sheet */
.list-sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.list-sheet-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 520px;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 14px);
  animation: slideup .22s var(--ease);
}
@keyframes slideup { from { transform: translateY(40%); opacity: .6; } }
.list-sheet-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.list-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; font-size: 15px; cursor: pointer;
  border-bottom: 1px solid #242424;
}
.list-opt input { width: 19px; height: 19px; accent-color: var(--accent); }
.list-sheet-row { display: flex; gap: 8px; margin: 12px 0 4px; }
#new-list-name {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 13px; font-size: 15px; color: var(--text);
  font-family: inherit; outline: none;
}
#new-list-name:focus { border-color: var(--accent); }
#new-list-add {
  background: var(--panel-3); color: var(--accent);
  border: 1px solid rgba(229,173,46,.3); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
#list-sheet-close {
  width: 100%; margin-top: 10px;
  background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  color: var(--on-accent); border: none; border-radius: 12px;
  padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ---------- conversation list ---------- */
.conv-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 24px; }
.conv {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.conv:active { background: var(--panel); }
.conv + .conv::before {
  content: ""; position: absolute; top: 0; left: 77px; right: 0;
  height: 1px; background: #222222;
}
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  color: #fff; font-size: 17px; font-weight: 650;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 -3px 10px rgba(0,0,0,.35), 0 0 0 2px rgba(255,255,255,.05);
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.conv-mid { flex: 1; min-width: 0; }
.conv-name { font-size: 15.5px; font-weight: 600; letter-spacing: .005em; }
.conv-preview {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 3px; line-height: 1.35;
}
.dir-out { color: var(--faint); font-weight: 700; }
.dir-in { color: var(--good); font-size: 10px; vertical-align: 1px; }
.conv-right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.conv-time { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.conv.unread .conv-time { color: var(--accent); font-weight: 600; }
.conv-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 6px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 10px; font-size: 11.5px; font-weight: 700;
}
.empty-list { padding: 64px 32px; text-align: center; color: var(--faint); font-size: 14px; line-height: 1.7; }
.empty-list::before { content: "💬"; display: block; font-size: 34px; margin-bottom: 10px; opacity: .5; }

/* skeleton shimmer */
.skel { display: flex; align-items: center; gap: 13px; padding: 11px 16px; }
.skel .sk { background: linear-gradient(90deg, #202020 25%, #2a2a2a 50%, #202020 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
.skel .sk-av { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.skel .sk-ln { height: 12px; margin: 5px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- chat ---------- */
.messages {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(1100px 440px at 50% -8%, rgba(229,173,46,.05), transparent 60%),
    #101010;
  padding: 14px 12px 18px;
}
/* Sticky date pill: pins to the top of the chat while that day scrolls (à la WhatsApp/Telegram) */
.day-sep {
  display: flex; justify-content: center; margin: 14px 0 10px;
  position: sticky; top: 2px; z-index: 5;
  pointer-events: none;
}
.day-sep span {
  background: rgba(24,24,24,.88);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.msg { display: flex; margin-bottom: 3px; animation: pop .18s var(--ease); }
.msg.gap { margin-top: 10px; }
.msg.out { justify-content: flex-end; }
@keyframes pop { from { opacity: 0; transform: translateY(5px); } }
.bubble {
  max-width: 84%;
  background: var(--bubble-in);
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 8px 12px 6px;
  box-shadow: var(--shadow-1);
  font-size: 15.5px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.msg.in .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble {
  background: linear-gradient(180deg, var(--bubble-out-2), var(--bubble-out));
  border-color: #4a3d18;
  border-bottom-right-radius: 5px;
}
.bubble-zh { white-space: pre-wrap; }
.bubble-zh.pending { color: var(--faint); font-style: italic; }
.bubble-en {
  font-size: 12.5px; color: var(--muted);
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed #3a3a3a;
  white-space: pre-wrap;
  display: none;
}
.bubble.show-orig .bubble-en { display: block; animation: pop .15s var(--ease); }
.bubble-meta {
  font-size: 10.5px; color: var(--faint);
  margin-top: 3px;
  display: flex; gap: 5px; justify-content: flex-end; align-items: center;
  font-variant-numeric: tabular-nums;
}
.bubble-meta .from-phone {
  font-style: normal; font-size: 10px;
  background: rgba(229,173,46,.15); color: var(--accent);
  padding: 1px 6px; border-radius: 7px; font-weight: 600;
}
.retry-link { color: var(--bad); font-size: 12.5px; cursor: pointer; display: inline-block; margin-top: 3px; }
.tick-read { color: var(--read-blue); }
.send-fail { color: var(--bad); font-weight: 600; }
.bubble-img {
  display: block; max-width: 100%; min-width: 160px; max-height: 320px;
  object-fit: cover; border-radius: 10px; margin: -2px 0 5px;
  cursor: pointer; background: #1a1a1a;
}

/* ---------- compose ---------- */
.compose {
  position: relative;
  background: rgba(20,20,20,.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 9px 10px calc(env(safe-area-inset-bottom) + 9px);
  flex-shrink: 0;
}
.preview {
  background: var(--panel);
  border: 1px solid #3a3118;
  border-left: 3px solid var(--accent);
  border-radius: var(--rp);
  padding: 8px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow-1);
  animation: pop .18s var(--ease);
}
.preview-label {
  font-size: 10.5px; color: var(--accent); font-weight: 700;
  letter-spacing: .06em; margin-bottom: 3px; text-transform: uppercase;
}
.preview-text { font-size: 14px; white-space: pre-wrap; line-height: 1.45; color: var(--text); }
.preview-text.loading { color: var(--faint); font-style: italic; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
#input {
  flex: 1; resize: none;
  border: 1px solid var(--border);
  border-radius: 21px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 15px;
  font-size: 16px; font-family: inherit;
  line-height: 1.4;
  max-height: 112px;
  outline: none;
  transition: border-color .15s;
}
#input::placeholder { color: var(--faint); }
#input:focus { border-color: var(--accent); }
#btn-send {
  background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  color: var(--on-accent);
  border: none; border-radius: 50%;
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease), opacity .15s;
}
#btn-send:disabled { opacity: .3; }
#btn-send:not(:disabled):active { transform: scale(.9); }
#btn-send svg { width: 19px; height: 19px; margin-left: 2px; }
.compose-hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; min-height: 14px; padding: 0 4px; }
#btn-attach, #btn-canned {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 50%;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: transform .12s var(--ease);
}
#btn-attach { color: var(--accent); }
#btn-canned { color: var(--accent); }
#btn-attach:active, #btn-canned:active { transform: scale(.9); }
#btn-attach svg { width: 19px; height: 19px; }
#btn-canned svg { width: 18px; height: 18px; }
.attach-wrap { position: relative; flex-shrink: 0; }
.attach-menu {
  position: absolute; bottom: 50px; left: 0;
  background: var(--panel-2); border-radius: var(--rp);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--border);
  overflow: hidden; z-index: 10;
  animation: pop .15s var(--ease);
  min-width: 175px;
}
.attach-menu button {
  display: block; width: 100%;
  background: none; border: none;
  padding: 13px 18px; font-size: 15px; font-family: inherit;
  text-align: left; cursor: pointer; color: var(--text);
}
.attach-menu button + button { border-top: 1px solid var(--border); }
.attach-menu button:active { background: var(--panel-3); }
.attach-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--rp);
  padding: 8px 10px; margin-bottom: 8px;
  box-shadow: var(--shadow-1);
  animation: pop .18s var(--ease);
}
.attach-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.attach-note { flex: 1; font-size: 12.5px; color: var(--muted); }
#attach-remove {
  background: var(--panel-3); border: none; border-radius: 50%;
  width: 26px; height: 26px; font-size: 12px; color: var(--muted);
  cursor: pointer;
}

/* ---------- sheets (canned + stock) ---------- */
.canned-sheet {
  position: absolute; left: 8px; right: 8px; bottom: 100%;
  margin-bottom: 8px;
  background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow-2);
  border: 1px solid var(--border);
  max-height: 46vh; display: flex; flex-direction: column;
  overflow: hidden; z-index: 20;
  animation: pop .18s var(--ease);
}
.canned-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 15px 9px;
  font-size: 13px; font-weight: 700; color: var(--accent);
  border-bottom: 1px solid var(--border);
}
#canned-close, #stock-close {
  background: var(--panel-3); border: none; border-radius: 50%;
  width: 24px; height: 24px; font-size: 11px; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.canned-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.canned-item { padding: 11px 15px; cursor: pointer; }
.canned-item:active { background: var(--panel-2); }
.canned-item + .canned-item { border-top: 1px solid #262626; }
.canned-label { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.canned-tag {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  background: var(--panel-3); border-radius: 6px; padding: 1px 7px;
  font-family: ui-monospace, monospace;
}
.canned-prev {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- stock lookup ---------- */
.stock-chip {
  display: block; width: 100%;
  background: rgba(229,173,46,.1); color: var(--accent);
  border: 1px solid rgba(229,173,46,.3); border-radius: var(--rp);
  padding: 9px 12px; margin-bottom: 8px;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  text-align: left; cursor: pointer;
  animation: pop .18s var(--ease);
}
.stock-chip:active { background: rgba(229,173,46,.18); }
.stock-search { display: flex; gap: 6px; align-items: center; flex: 1; margin: 0 10px; }
#stock-q {
  flex: 1; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--rc);
  padding: 6px 10px; font-size: 14px; font-family: inherit; outline: none; color: var(--text);
}
#stock-q:focus { border-color: var(--accent); }
#stock-go {
  background: var(--accent); color: var(--on-accent); border: none; border-radius: var(--rc);
  padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.stock-section {
  padding: 8px 15px 3px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  color: var(--faint); background: #191919;
  border-top: 1px solid var(--border);
}
.stock-row { padding: 9px 15px; cursor: pointer; display: flex; align-items: baseline; gap: 8px; }
.stock-row:active { background: var(--panel-2); }
.stock-row + .stock-row { border-top: 1px solid #242424; }
.stock-row input[type=checkbox] {
  width: 19px; height: 19px; accent-color: var(--accent);
  margin-right: 3px; flex-shrink: 0; align-self: center; pointer-events: none;
}
.stock-name { flex: 1; font-size: 14px; font-weight: 600; min-width: 0; }
.stock-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; display: block; margin-top: 1px; }
.stock-price { font-size: 15px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.stock-qty { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.stock-note { padding: 16px 15px; font-size: 13px; color: var(--muted); text-align: center; }
.stock-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 15px;
  border-top: 1px solid var(--border); background: #191919;
}
.stock-foot-toggle { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stock-foot-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.stock-foot-btns { display: flex; gap: 8px; }
#stock-flash {
  background: var(--panel-3); color: var(--accent);
  border: 1px solid #4a3d18; border-radius: var(--rc);
  padding: 9px 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
#stock-flash:active { filter: brightness(1.2); }
#stock-generate {
  background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  color: var(--on-accent); border: none; border-radius: var(--rc);
  padding: 9px 16px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
#stock-generate:disabled { opacity: .35; }

/* ---------- login ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(900px 480px at 80% -10%, rgba(229,173,46,.12), transparent 55%),
    var(--bg);
}
.login-card {
  background: var(--panel); border-radius: 16px;
  border: 1px solid var(--border);
  padding: 36px 28px 28px; width: min(90vw, 350px);
  display: flex; flex-direction: column; gap: 13px;
  box-shadow: var(--shadow-2);
}
.login-logo { text-align: center; }
.login-logo img { height: 52px; width: auto; }
.login-logo .accent { color: var(--accent); }
.login-sub { font-size: 13.5px; color: var(--muted); text-align: center; margin-bottom: 10px; }
.login-error { background: #35191e; color: #ff8a9a; font-size: 13px; padding: 9px 12px; border-radius: var(--rc); text-align: center; }
.login-card input {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 15px; font-size: 16px; color: var(--text);
  outline: none; transition: border-color .15s;
}
.login-card input::placeholder { color: var(--faint); }
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  color: var(--on-accent); border: none;
  border-radius: 10px; padding: 14px; font-size: 16px; font-weight: 700;
  cursor: pointer; margin-top: 8px;
}
.login-card button:active { filter: brightness(.92); }

/* ---------- simulator (internal tool, stays light-agnostic) ---------- */
.sim-page { background: var(--bg); color: var(--text); min-height: 100vh; padding: 16px; font-size: 14px; }
.sim-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--rp); padding: 18px; max-width: 560px; margin: 0 auto 16px; }
.sim-card h2 { font-size: 16px; margin-bottom: 10px; }
.sim-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.sim-card input, .sim-card textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--rc);
  padding: 9px 12px; font-size: 15px; font-family: inherit; color: var(--text);
}
.sim-card button {
  background: var(--accent); color: var(--on-accent); border: none; border-radius: var(--rc);
  padding: 10px 18px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 12px;
}
.sim-messages { margin-top: 10px; }
.sim-msg { padding: 8px 11px; border-radius: 10px; margin-bottom: 6px; font-size: 14px; max-width: 85%; }
.sim-msg.from-shop { background: var(--bubble-out); margin-left: auto; }
.sim-msg.from-cust { background: var(--panel-2); border: 1px solid var(--border); }
.sim-msg .sim-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- Telegram-feel additions ---------- */

/* quoted reply inside a bubble */
.bubble-quote {
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,.06);
  border-radius: 7px; padding: 5px 9px; margin-bottom: 6px;
  cursor: pointer; max-width: 100%;
}
.bq-who { color: var(--accent); font-size: 11.5px; font-weight: 700; }
.bq-text { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.flash .bubble { animation: flashbub 1.1s ease; }
@keyframes flashbub { 0%,55% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: none; } }

/* reply bar above composer */
.reply-bar {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border-top: 1px solid rgba(255,255,255,.07);
  padding: 7px 12px;
}
.reply-accent { width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); }
.reply-info { flex: 1; min-width: 0; }
.reply-who { color: var(--accent); font-size: 12px; font-weight: 700; }
.reply-snippet { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar button { background: none; border: none; color: var(--muted); font-size: 16px; padding: 4px 6px; }

/* reaction chip on a bubble */
.bubble { position: relative; }
.msg.has-react { margin-bottom: 16px; }
.bubble-react {
  position: absolute; bottom: -12px; font-size: 13px; line-height: 1;
  background: var(--panel); border: 1px solid rgba(255,255,255,.12);
  border-radius: 11px; padding: 3px 7px;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.msg.in .bubble-react { right: -4px; }
.msg.out .bubble-react { left: -4px; }
.star-mark { color: var(--accent); font-size: 10.5px; }

/* long-press message menu — frosted glass, matches the premium topbar */
.msg-menu {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(8,8,8,.42);
  -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
}
.msg-menu.hidden { display: none; }
.msg-menu-card {
  background:
    radial-gradient(420px 120px at 22% 0%, rgba(229,173,46,.09), transparent 70%),
    linear-gradient(180deg, rgba(34,33,31,.92), rgba(20,20,19,.94));
  -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid rgba(229,173,46,.18);
  border-radius: 22px; min-width: 258px; max-width: 84vw;
  box-shadow:
    0 1px 0 rgba(255,255,255,.06) inset,
    0 0 0 1px rgba(0,0,0,.4),
    0 24px 60px rgba(0,0,0,.65);
  overflow: hidden;
  animation: menuIn .2s var(--ease);
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(.9) translateY(10px); }
}
.react-row {
  display: flex; justify-content: space-around; gap: 2px;
  padding: 13px 12px 11px;
  border-bottom: 1px solid rgba(229,173,46,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent);
}
.react-opt {
  background: rgba(255,255,255,.04); border: 1px solid transparent;
  font-size: 22px; line-height: 1; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: transform .14s var(--ease), background .14s var(--ease);
}
.react-opt:active { transform: scale(1.35); background: rgba(255,255,255,.1); }
.react-opt.on {
  background: rgba(229,173,46,.18);
  border-color: rgba(229,173,46,.45);
  box-shadow: 0 0 12px rgba(229,173,46,.25);
}
.menu-items { display: flex; flex-direction: column; padding: 6px 7px 7px; }
.menu-item {
  background: none; border: none; color: var(--fg);
  display: flex; align-items: center; gap: 13px;
  text-align: left; font-size: 15px; font-weight: 600;
  letter-spacing: .012em;
  padding: 12px 13px; border-radius: 13px;
  transition: background .12s var(--ease);
}
.menu-item:active { background: rgba(229,173,46,.12); }
.mi-icon {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; color: var(--accent); opacity: .85;
}
.mi-icon svg { width: 19px; height: 19px; }
.menu-item.starred .mi-icon { opacity: 1; filter: drop-shadow(0 0 5px rgba(229,173,46,.5)); }

/* voice recording bar */
.rec-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: var(--panel);
}
.rec-bar.hidden { display: none; }
.rec-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #e5484d; animation: recblink 1s infinite;
}
@keyframes recblink { 50% { opacity: .25; } }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 44px; }
.rec-hint { color: var(--muted); font-size: 13px; flex: 1; }
#rec-cancel {
  background: none; border: 1px solid rgba(255,255,255,.18);
  color: var(--muted); border-radius: 15px; padding: 5px 13px; font-size: 13.5px;
}
#rec-send {
  background: var(--accent); color: var(--on-accent); border: none;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
#rec-send svg { width: 18px; height: 18px; }
.compose-row.recording { display: none; }

/* mic button */
#btn-mic {
  background: var(--accent); color: var(--on-accent); border: none;
  min-width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
#btn-mic svg { width: 19px; height: 19px; }
#btn-mic.hidden, #btn-send.hidden { display: none; }

/* scroll-to-bottom */
.jump-btn {
  position: absolute; right: 12px; bottom: 86px; z-index: 20;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); border: 1px solid rgba(255,255,255,.12);
  color: var(--fg); box-shadow: 0 4px 14px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.jump-btn.hidden { display: none; }
.jump-btn svg { width: 19px; height: 19px; }
.jump-n {
  position: absolute; top: -6px; right: -4px;
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 800; border-radius: 10px;
  min-width: 18px; height: 18px; line-height: 18px; padding: 0 4px;
}
.jump-n.hidden { display: none; }

/* drafts + pins in the chat list */
.draft-tag { color: var(--accent); font-weight: 700; }
.pin-mark { font-size: 10.5px; }
.pin-row {
  display: block; width: 100%; text-align: left;
  background: rgba(229,173,46,.1); color: var(--accent);
  border: none; border-radius: 9px;
  font-size: 14.5px; font-weight: 600; padding: 11px 13px; margin-bottom: 9px;
}

/* in-bubble audio player */
.bubble-audio { width: 215px; max-width: 62vw; height: 38px; display: block; margin: 2px 0; }

/* forward sheet + gallery */
.fwd-body { max-height: 52vh; overflow-y: auto; margin: 4px 0 10px; }
.fwd-body .conv { padding: 9px 6px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  max-height: 56vh; overflow-y: auto; margin: 6px 0 12px;
}
.gallery-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px;
}

/* full-screen image viewer */
.img-viewer {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.96);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.img-viewer.hidden { display: none; }
#viewer-img {
  max-width: 100vw; max-height: 100vh; object-fit: contain;
  transition: transform .08s linear; will-change: transform;
}
#viewer-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 14px;
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 50%; font-size: 16px;
}
.viewer-count {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; background: rgba(0,0,0,.45);
  padding: 4px 12px; border-radius: 12px;
}
