/* SmartBranch Chat — mobile UI (vivid, Instagram-style composer) */
:root {
  --grad: linear-gradient(135deg, #7b2ff7 0%, #c13584 55%, #f77737 100%);
  --grad-out: linear-gradient(135deg, #7b2ff7 0%, #5b5bf0 100%);
  --accent: #8a3ffc;
  --accent-2: #4f6af0;
  --pink: #e1306c;
  --bg: #f4f2fa;
  --panel: #ffffff;
  --text: #15131c;
  --muted: #7b7589;
  --line: #ece8f3;
  --chat-bg: #ffffff;
  --bubble-in: #efecf5;
  --bubble-in-text: #15131c;
  --bubble-auto: #f3ecff;
  --pill: #f0edf5;
  --danger: #e5394a;
  --ok: #22c55e;
  --shadow: 0 6px 24px rgba(60, 30, 120, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --panel: #0e0d13;
    --text: #f4f3f8;
    --muted: #9b97a8;
    --line: #1f1d27;
    --chat-bg: #000000;
    --bubble-in: #26252e;
    --bubble-in-text: #f4f3f8;
    --bubble-auto: #2b2340;
    --pill: #1d1c24;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --panel: #0e0d13;
  --text: #f4f3f8;
  --muted: #9b97a8;
  --line: #1f1d27;
  --chat-bg: #000000;
  --bubble-in: #26252e;
  --bubble-in-text: #f4f3f8;
  --bubble-auto: #2b2340;
  --pill: #1d1c24;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; }
.ic { width: 24px; height: 24px; display: block; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--panel); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  background: var(--panel);
  color: var(--text);
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 14px;
  display: flex; align-items: center; gap: 10px;
  min-height: 58px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1; font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar .title span:first-child {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-btn {
  background: none; border: 0; padding: 8px; border-radius: 50%; line-height: 0; color: var(--text);
  min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--pill); }
.live { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22); }
.live.off { background: #a8a3b5; box-shadow: none; }

/* ---------------------------------------------------------------- login */
#login { align-items: center; justify-content: center; padding: 16px; background: var(--grad); }
.login-card { background: var(--panel); border-radius: 24px; padding: 30px 22px; width: 100%; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-card .logo { font-size: 46px; }
.login-card h1 { margin: 6px 0 4px; font-size: 23px; }
.login-card input {
  width: 100%; padding: 14px 16px; margin: 16px 0 10px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--pill); color: var(--text); font-size: 16px;
}
.primary {
  width: 100%; background: var(--grad); color: #fff; border: 0; padding: 14px; border-radius: 14px;
  font-weight: 700; font-size: 16px; box-shadow: 0 6px 18px rgba(193, 53, 132, 0.35);
}
.primary:active { transform: scale(0.98); }

/* ---------------------------------------------------------------- search + chips */
.searchbar { padding: 8px 14px 4px; background: var(--panel); }
.searchbar input {
  width: 100%; padding: 10px 16px; border-radius: 14px; border: 0;
  background: var(--pill); color: var(--text); font-size: 16px; font-family: inherit; outline: none;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px 10px; background: var(--panel); flex-shrink: 0; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 0; background: var(--pill); border-radius: 18px; padding: 6px 14px;
  white-space: nowrap; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
}
.chip.on { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(123, 47, 247, 0.3); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #a8a3b5; }
.chip .dot.up { background: var(--ok); }
.chip .n { background: var(--pink); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.chip.on .n { background: rgba(255, 255, 255, 0.3); }

/* ---------------------------------------------------------------- chat list */
.chat-list { flex: 1; overflow-y: auto; background: var(--panel); -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
.row { display: flex; gap: 12px; padding: 10px 14px; align-items: center; }
.row:active { background: var(--pill); }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  position: relative; overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 38px; height: 38px; font-size: 15px; }
.avatar.xs { width: 34px; height: 34px; font-size: 13px; cursor: pointer; }
.avatar.xl { width: 104px; height: 104px; font-size: 36px; margin: 0 auto 12px; }
/* story-style gradient ring for customers waiting for an answer */
.ring { padding: 2.5px; border-radius: 50%; background: var(--grad); flex-shrink: 0; }
.ring .avatar { border: 2.5px solid var(--panel); width: 54px; height: 54px; }
.row .mid { flex: 1; min-width: 0; }
.row .l1, .row .l2 { display: flex; align-items: center; gap: 6px; }
.row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; }
.row.unread .name { font-weight: 800; }
.row .time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.row.unread .time { color: var(--pink); font-weight: 600; }
.row .branch { font-size: 12px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .preview { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .preview { color: var(--text); font-weight: 500; }
.row .badge {
  background: var(--grad); color: #fff; border-radius: 11px; min-width: 22px; height: 22px; padding: 0 7px;
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.row .wait { font-size: 11px; color: var(--danger); font-weight: 700; white-space: nowrap; }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- menu */
.menu {
  position: absolute; top: calc(56px + env(safe-area-inset-top)); right: 10px; background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 20; min-width: 250px; border: 1px solid var(--line);
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 14px 18px; font-size: 15px; }
.menu button:active { background: var(--pill); }
.menu .danger { color: var(--danger); }
.menu-user { padding: 12px 18px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }

/* ---------------------------------------------------------------- conversation */
.chat-top { padding-left: 2px; gap: 8px; }
.chat-title { flex: 1; min-width: 0; cursor: pointer; }
#chatAvatar { cursor: pointer; }
.chat-title .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; background: var(--chat-bg); padding: 10px 10px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.day { text-align: center; margin: 14px 0 8px; }
.day span { color: var(--muted); font-size: 12px; font-weight: 600; }
.msg { display: flex; margin: 2px 0; align-items: center; gap: 6px; position: relative; transition: transform 0.15s; }
.msg.out { flex-direction: row-reverse; }
.bubble {
  max-width: 78%; background: var(--bubble-in); color: var(--bubble-in-text); border-radius: 20px; padding: 8px 13px 5px;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.out .bubble { background: var(--grad-out); color: #fff; }
.msg.auto .bubble { background: var(--bubble-auto); color: var(--text); }
.msg.out.auto .bubble { background: var(--bubble-auto); color: var(--text); }
.bubble a { color: inherit; text-decoration: underline; }
.bubble .meta { font-size: 10.5px; opacity: 0.65; text-align: right; margin-top: 1px; white-space: nowrap; }
.bubble .tag { font-size: 11px; color: var(--accent); font-weight: 700; display: block; }
.bubble img.photo { display: block; max-width: 100%; max-height: 340px; border-radius: 14px; margin: 2px -6px 4px; min-width: 140px; background: rgba(0, 0, 0, 0.06); }
.bubble img.sticker { width: 150px; height: 150px; object-fit: contain; background: none; }
.bubble video { display: block; max-width: 100%; max-height: 360px; border-radius: 14px; margin: 2px -6px 4px; background: #000; }
.bubble .file { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; padding: 4px 0; }
.bubble .file .ic2 { width: 42px; height: 42px; border-radius: 12px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.bubble .file .fn { font-weight: 600; word-break: break-all; }
.bubble .file .fs { font-size: 12px; opacity: 0.7; }
.bubble .missing { opacity: 0.7; font-style: italic; }
.loadmore { text-align: center; padding: 6px; }
.loadmore button { background: var(--pill); border: 0; border-radius: 14px; padding: 6px 14px; font-size: 12px; color: var(--text); }

.rbtn {
  border: 0; background: var(--pill); color: var(--muted); width: 30px; height: 30px; border-radius: 50%;
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; padding: 6px; opacity: 0;
  transition: opacity 0.15s;
}
.rbtn .ic { width: 16px; height: 16px; }
.msg:hover .rbtn, .msg.sel .rbtn { opacity: 1; }
@media (hover: none) { .rbtn { opacity: 0.5; } }
.bubble .quote {
  border-left: 3px solid currentColor; background: rgba(127, 127, 127, 0.16); border-radius: 10px;
  padding: 4px 9px; margin: 2px 0 5px; font-size: 13px; cursor: pointer; white-space: normal;
}
.bubble .quote b { display: block; font-size: 12px; }
.bubble .quote span { opacity: 0.8; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.msg.flash .bubble { box-shadow: 0 0 0 3px var(--pink); }

/* voice player */
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 3px 0; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 14px; flex-shrink: 0; }
.msg.out .voice .play { background: rgba(255, 255, 255, 0.25); }
.voice .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(127, 127, 127, 0.3); position: relative; }
.voice .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: currentColor; border-radius: 2px; }
.voice .dur { font-size: 12px; opacity: 0.75; min-width: 34px; text-align: right; }

/* ---------------------------------------------------------------- composer (Instagram style) */
.composer {
  background: var(--chat-bg); padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  position: relative; flex-shrink: 0;
}
.pill {
  display: flex; align-items: flex-end; gap: 4px; background: var(--pill); border-radius: 26px;
  padding: 5px 6px; min-height: 52px; border: 1px solid var(--line);
}
.cam-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(193, 53, 132, 0.35);
}
.cam-btn.danger { background: var(--danger); box-shadow: none; }
.cam-btn:active, .tool-btn:active, .send-pill:active { transform: scale(0.92); }
#input {
  flex: 1; min-width: 0; resize: none; border: 0; background: transparent; color: var(--text);
  padding: 10px 6px; font: inherit; font-size: 16px; line-height: 1.35; max-height: 130px; outline: none;
  caret-color: var(--accent);
}
#input::placeholder { color: var(--muted); }
.tools { display: flex; align-items: center; gap: 0; flex-shrink: 0; height: 42px; }
.tool-btn {
  width: 40px; height: 42px; border: 0; background: none; color: var(--text); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.tool-btn .ic { width: 26px; height: 26px; }
.send-pill {
  border: 0; background: none; color: var(--accent); font-weight: 800; font-size: 16px;
  padding: 0 14px; height: 42px; flex-shrink: 0;
}
.rec { align-items: center; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; margin-left: 6px; }
#recTime { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-hint { flex: 1; font-size: 13px; color: var(--muted); }
@keyframes blink { 50% { opacity: 0.2; } }

.replybar { display: flex; align-items: center; gap: 8px; padding: 2px 6px 8px; }
.replybar .rb-ic { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.replybar .rb-body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; }
.replybar .rb-name { color: var(--accent); font-weight: 700; font-size: 13px; }
.replybar .rb-text { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.plus-menu, .emoji-panel {
  position: absolute; bottom: calc(100% - 2px); right: 10px; background: var(--panel); border-radius: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; z-index: 10;
}
.plus-menu button { display: block; width: 100%; background: none; border: 0; padding: 14px 22px; text-align: left; font-size: 15px; }
.plus-menu button:active { background: var(--pill); }
.emoji-panel { left: 10px; display: grid; grid-template-columns: repeat(8, 1fr); padding: 8px; gap: 2px; max-height: 240px; overflow-y: auto; }
.emoji-panel button { border: 0; background: none; font-size: 26px; padding: 6px 0; border-radius: 10px; line-height: 1.1; }
.emoji-panel button:active { background: var(--pill); }

.upload { height: 24px; background: var(--chat-bg); position: relative; font-size: 12px; text-align: center; }
#uploadFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--grad); opacity: 0.25; }
#uploadText { position: relative; line-height: 24px; font-weight: 600; }

/* ---------------------------------------------------------------- viewer, toast, sheet */
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95); z-index: 50; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20, 18, 28, 0.94); color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 60;
  font-size: 14px; max-width: 90%; text-align: center; box-shadow: var(--shadow);
}
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s; }
.sheet-card {
  background: var(--panel); color: var(--text); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); position: relative; max-height: 88vh; overflow-y: auto;
  animation: up 0.2s ease-out;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-x { position: absolute; right: 6px; top: 6px; color: var(--muted); }
.sheet .ring { width: max-content; margin: 0 auto 12px; }
.sheet .ring .avatar.xl { margin: 0; width: 104px; height: 104px; border-width: 3px; }
.prof-name { text-align: center; font-size: 21px; font-weight: 800; }
.prof-user { text-align: center; margin-bottom: 16px; }
.prof-user a { color: var(--accent); text-decoration: none; font-weight: 600; }
.prof-rows { background: var(--pill); border-radius: 16px; overflow: hidden; }
.prof-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.prof-row:last-child { border-bottom: 0; }
.prof-row span:first-child { color: var(--muted); }
.prof-row span:last-child { text-align: right; word-break: break-all; font-weight: 500; }
.sheet label { display: block; font-size: 13px; margin-top: 6px; }
.sheet input[type=text] { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--pill); color: var(--text); font: inherit; font-size: 16px; margin: 6px 0 12px; }
.sheet .primary { margin-top: 8px; }
.sheet .ghost { width: 100%; background: var(--pill); border: 0; padding: 12px; border-radius: 14px; margin-top: 8px; font-weight: 600; }
@keyframes up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------- media editor */
.editor { position: fixed; inset: 0; z-index: 45; background: #000; color: #fff; display: flex; flex-direction: column; }
.ed-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 10px 8px 16px; gap: 8px; }
.ed-link { background: none; border: 0; color: #fff; font-size: 17px; font-weight: 700; padding: 8px 4px; }
.ed-count { flex: 1; text-align: center; font-weight: 600; opacity: 0.8; }
.ed-icon { color: #fff; background: rgba(255, 255, 255, 0.12); }
.ed-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.ed-stage img, .ed-stage video { max-width: 100%; max-height: 100%; transition: transform 0.2s; }
.ed-stage .ed-play {
  position: absolute; width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.85);
  color: #111; display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.ed-stage .ed-play .ic { width: 34px; height: 34px; margin-left: 4px; }
.ed-trimwrap { padding: 10px 18px 4px; }
.trim { position: relative; height: 56px; border-radius: 10px; background: #222; touch-action: none; user-select: none; }
.strip { position: absolute; inset: 0; display: flex; border-radius: 10px; overflow: hidden; }
.strip canvas, .strip span { flex: 1; height: 100%; display: block; background: #333; }
.shade { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.62); }
#edShadeL { left: 0; border-radius: 10px 0 0 10px; }
#edShadeR { right: 0; border-radius: 0 10px 10px 0; }
.win { position: absolute; top: -3px; bottom: -3px; border: 3px solid #fff; border-left-width: 16px; border-right-width: 16px; border-radius: 10px; box-sizing: border-box; }
.win .h { position: absolute; top: 0; bottom: 0; width: 34px; }
.win .h[data-h="l"] { left: -26px; }
.win .h[data-h="r"] { right: -26px; }
.win::before, .win::after { content: ""; position: absolute; top: 50%; width: 3px; height: 16px; margin-top: -8px; background: #444; border-radius: 2px; }
.win::before { left: -10px; }
.win::after { right: -10px; }
.playhead { position: absolute; top: -4px; bottom: -4px; width: 3px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px rgba(0,0,0,.6); pointer-events: none; }
.trim-info { text-align: center; font-size: 13px; padding: 8px 0 2px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ed-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 2px; scrollbar-width: none; }
.ed-thumbs::-webkit-scrollbar { display: none; }
.ed-thumbs .t { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; flex-shrink: 0; border: 2px solid transparent; background: #222; }
.ed-thumbs .t.on { border-color: #fff; }
.ed-thumbs .t img, .ed-thumbs .t video { width: 100%; height: 100%; object-fit: cover; }
.ed-thumbs .t b { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.7); font-size: 11px; display: flex; align-items: center; justify-content: center; }
.ed-bottom { display: flex; gap: 10px; align-items: center; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.ed-bottom input { flex: 1; min-width: 0; background: #1d1c24; border: 1px solid #2c2a36; border-radius: 22px; color: #fff; padding: 12px 16px; font: inherit; font-size: 16px; outline: none; }
.ed-send {
  border: 0; border-radius: 24px; background: var(--grad-out); color: #fff; font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; flex-shrink: 0; box-shadow: 0 4px 16px rgba(91, 91, 240, 0.45);
}
.ed-send .ic { width: 20px; height: 20px; }
.ed-send:disabled { opacity: 0.6; }

/* ---------------------------------------------------------------- v5: video length, contact, phones */
.vwrap { position: relative; }
.vwrap .vdur {
  position: absolute; left: 6px; top: 8px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; pointer-events: none; font-variant-numeric: tabular-nums;
}
.voice.playing .play { box-shadow: 0 0 0 4px rgba(225, 48, 108, 0.25); }
.voice .dur { font-variant-numeric: tabular-nums; font-weight: 600; }
.contact-card { display: flex; gap: 10px; align-items: center; padding: 4px 0; }
.contact-card .cc-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.contact-card b { display: block; font-size: 15px; letter-spacing: 0.3px; }
.contact-card small { opacity: 0.7; }
.prof-bio { text-align: center; color: var(--muted); font-size: 13.5px; margin: -8px 0 14px; white-space: pre-wrap; }
.phones { background: var(--pill); border-radius: 16px; margin-bottom: 12px; overflow: hidden; }
.phone-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.phone-row:last-child { border-bottom: 0; }
.phone-row > div { flex: 1; min-width: 0; }
.phone-row small { display: block; color: var(--muted); font-size: 12px; }
.phone-row b { font-size: 16px; letter-spacing: 0.4px; }
.ph-btn { border: 0; background: var(--panel); color: var(--accent); font-weight: 700; font-size: 13px; padding: 8px 10px; border-radius: 12px; text-decoration: none; white-space: nowrap; }
.bubble .meta { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- v6: icon system (no emoji) + vivid menu */
.g1 { background: linear-gradient(135deg, #7b2ff7, #c13584); }
.g2 { background: linear-gradient(135deg, #2f80ed, #56ccf2); }
.g3 { background: linear-gradient(135deg, #f77737, #fcaf45); }
.g4 { background: linear-gradient(135deg, #11998e, #38ef7d); }
.g5 { background: linear-gradient(135deg, #00b4db, #0083b0); }
.g6 { background: linear-gradient(135deg, #8e2de2, #4a00e0); }
.g7 { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.mi {
  width: 34px; height: 34px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}
.mi .ic { width: 19px; height: 19px; }

.menu { min-width: 280px; padding: 6px; border-radius: 22px; }
.menu-user {
  display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 4px; border: 0;
  border-radius: 16px; background: var(--grad); color: #fff;
}
.menu-user .avatar { border: 2px solid rgba(255, 255, 255, 0.85); }
.menu-user b { display: block; font-size: 15px; }
.menu-user small { display: block; opacity: 0.85; font-size: 12px; }
.menu button {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; font-size: 15px; font-weight: 500;
}
.menu button .ml { flex: 1; min-width: 0; text-align: left; }
.menu button .mv { color: var(--muted); font-size: 13px; font-weight: 600; background: var(--pill); padding: 3px 10px; border-radius: 10px; }
.menu button .chev { width: 18px; height: 18px; color: var(--muted); }
.menu button.danger { color: var(--danger); }

.plus-menu { padding: 6px; border-radius: 20px; min-width: 190px; }
.plus-menu button { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; font-weight: 500; }

.login-card .logo {
  width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 22px; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 28px rgba(193, 53, 132, 0.45);
}
.login-card .logo .ic { width: 38px; height: 38px; }

.searchbar { position: relative; }
.searchbar .s-ic { position: absolute; left: 26px; top: 50%; margin-top: -8px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.searchbar input { padding-left: 40px; }

.pv-ic { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; margin-right: 4px; opacity: 0.85; }
.br-ic, .w-ic { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; margin-right: 3px; }
.row .wait { background: rgba(229, 57, 74, 0.12); padding: 1px 8px; border-radius: 9px; }
.sub-ic { width: 12px; height: 12px; display: inline-block; vertical-align: -1px; margin-right: 3px; }
.bubble .tag { display: flex; align-items: center; gap: 4px; }
.tag-ic { width: 14px; height: 14px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.tick { width: 14px; height: 14px; }

.voice .play { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.voice .play .ic { width: 18px; height: 18px; }
.vwrap .vdur { display: flex; align-items: center; gap: 3px; padding: 3px 9px 3px 6px; }
.vwrap .vdur .ic { width: 12px; height: 12px; }
.bubble .file .ic2 .ic { width: 22px; height: 22px; }
.contact-card .cc-ic .ic { width: 20px; height: 20px; }

.prof-row span:first-child { display: flex; align-items: center; gap: 10px; }
.pr-ic { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.st { padding: 3px 10px; border-radius: 10px; font-size: 12.5px; font-weight: 700; }
.st.ok { background: rgba(34, 197, 94, 0.14); color: #16a34a; }
.st.warn { background: rgba(229, 57, 74, 0.14); color: var(--danger); }
.phone-row { gap: 12px; }
.ph-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--accent);
}
.ph-btn .ic { width: 19px; height: 19px; }
.ph-btn.call { background: var(--grad); color: #fff; box-shadow: 0 3px 10px rgba(193, 53, 132, 0.35); }
.sheet .ghost { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ed-thumbs .t b .ic { width: 11px; height: 11px; }
.trim-info { display: flex; align-items: center; justify-content: center; gap: 4px; }

/* ---------------------------------------------------------------- v7: Appearance (Telegram-style) */
:root { --msg-fs: 15px; --bub-r: 20px; --wall: none; --wall-size: auto; }
.messages { background-image: var(--wall); background-size: var(--wall-size); background-attachment: local; }
.bubble { font-size: var(--msg-fs); border-radius: var(--bub-r); }
.bubble img.photo, .bubble video { border-radius: max(6px, calc(var(--bub-r) - 6px)); }
html.noanim *, html.noanim *::before, html.noanim *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }

.look { position: fixed; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; animation: lookIn 0.22s ease-out; }
@keyframes lookIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.look-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; flex-shrink: 0; }
.look-top h2 { margin: 0; font-size: 19px; font-weight: 700; }
.round-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; }
.ghost-sp { visibility: hidden; }
.look-body { flex: 1; overflow-y: auto; padding: 4px 14px calc(28px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.look-label { font-size: 12.5px; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; margin: 12px 6px 8px; }
.look-card { background: var(--panel); border-radius: 22px; overflow: hidden; margin-bottom: 18px; border: 1px solid var(--line); }
.look-preview { flex: none; overflow: hidden; padding: 16px 12px 14px; min-height: 150px; pointer-events: none; }
.look-preview .msg { margin: 6px 0; }
.look-themes { display: flex; gap: 10px; overflow-x: auto; padding: 14px; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.look-themes::-webkit-scrollbar { display: none; }
.lt {
  position: relative; flex-shrink: 0; width: 86px; height: 112px; border-radius: 16px; border: 2px solid var(--line);
  background-color: var(--chat-bg); padding: 0; overflow: hidden; transition: transform 0.15s, border-color 0.15s;
}
.lt:active { transform: scale(0.95); }
.lt.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.lt-out { position: absolute; right: 9px; top: 16px; width: 50px; height: 18px; border-radius: 10px; }
.lt-in { position: absolute; left: 9px; top: 42px; width: 46px; height: 18px; border-radius: 10px; background: var(--bubble-in); }
.lt-name { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text); }
.lt-ok { position: absolute; left: 50%; bottom: 28px; margin-left: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.lt-ok .ic { width: 14px; height: 14px; }
.look-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0;
  border-bottom: 1px solid var(--line); text-align: left; font-size: 15.5px; font-weight: 500; color: var(--text);
}
.look-card > .look-row:last-child, .look-card > .look-exp:last-child { border-bottom: 0; }
.look-row .ml { flex: 1; min-width: 0; }
.look-row .mv { color: var(--muted); font-size: 14px; font-weight: 500; }
.look-row .chev { width: 18px; height: 18px; color: var(--muted); transition: transform 0.2s; }
.look-row.open .chev { transform: rotate(90deg); }
.look-row.dim .ml { opacity: 0.55; }
.look-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.look-row .rowhead { display: flex; align-items: center; gap: 12px; }
.look-exp { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; border-bottom: 1px solid transparent; }
.look-exp.open { max-height: 260px; border-bottom-color: var(--line); }
.look-walls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px 14px 14px; }
.lw { background: none; border: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.lw-img { width: 100%; aspect-ratio: 3 / 4; border-radius: 14px; background-color: var(--chat-bg); border: 2px solid var(--line); }
.lw.on { color: var(--accent); }
.lw.on .lw-img { border-color: var(--accent); }
.look-colors { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px; }
.lc { width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; position: relative; display: flex; align-items: center; justify-content: center; color: #fff; }
.lc small { font-size: 9.5px; font-weight: 700; }
.lc.on { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--accent); }
.color-dots { display: inline-flex; }
.color-dots i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); }
.color-dots i + i { margin-left: -9px; }
.sw { width: 52px; height: 32px; border-radius: 16px; border: 0; padding: 0; background: var(--pill); position: relative; flex-shrink: 0; transition: background 0.2s; }
.sw i { position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.sw.on { background: var(--grad-out); }
.sw.on i { transform: translateX(20px); }
.look-seg { padding: 6px 8px 10px; }
.look-seg button { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 10px 8px 10px 52px; font-size: 15px; text-align: left; border-radius: 12px; }
.look-seg button .ic { width: 18px; height: 18px; color: var(--accent); visibility: hidden; }
.look-seg button.on { font-weight: 700; }
.look-seg button.on .ic { visibility: visible; }
.look-slider { display: flex; align-items: center; gap: 12px; padding: 0 2px 4px 46px; }
.look-slider small { font-size: 12px; color: var(--muted); font-weight: 700; }
.look-slider b { font-size: 20px; color: var(--muted); }
.look-slider .cn { width: 18px; height: 18px; border: 2.5px solid var(--muted); border-right: 0; border-bottom: 0; flex-shrink: 0; }
.look-slider .cn.rd { border-top-left-radius: 12px; }
.look-slider input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; outline: none; margin: 10px 0;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--pill) var(--p, 50%));
}
.look-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); border: 0; }
.look-slider input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); border: 0; }
.look-reset { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--danger); font-weight: 700; padding: 14px; border-radius: 18px; font-size: 15px; }

/* ---------------------------------------------------------------- v8: mini voice player + unread total */
.tbadge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--grad); color: #fff;
  font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.mini {
  position: relative; display: flex; align-items: center; gap: 4px; padding: 6px 6px 8px 10px; flex-shrink: 0;
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; animation: miniIn 0.2s ease-out;
}
@keyframes miniIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.mini button { border: 0; background: none; color: var(--accent); width: 34px; height: 34px; border-radius: 50%; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mini button .ic { width: 20px; height: 20px; }
.mini button:disabled { opacity: 0.3; }
.mini .mp-play { background: var(--grad-out); color: #fff; width: 36px; height: 36px; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 40%, transparent); }
.mini .mp-play .ic { width: 18px; height: 18px; }
.mini .mp-txt { flex: 1; min-width: 0; margin-left: 6px; line-height: 1.25; }
.mini .mp-who { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mp-sub { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mp-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini .mp-rate { width: auto; min-width: 38px; height: 26px; border-radius: 13px; background: var(--pill); font-size: 12.5px; font-weight: 800; padding: 0 8px; }
.mini .mp-x { color: var(--muted); }
.mini .mp-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.mini .mp-bar::before { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; top: -8px; }
.mini .mp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--grad-out); border-radius: 0 2px 2px 0; transition: width 0.25s linear; }
.voice.current .play { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
@media (max-width: 360px) { .mini .mp-time { display: none; } }

/* ---------------------------------------------------------------- v9: media that is still downloading */
.bubble .missing { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-style: normal; opacity: 1; padding: 4px 0; min-width: 190px; }
.bubble .missing > span { font-weight: 600; }
.bubble .missing small { flex-basis: 100%; font-size: 12px; opacity: 0.7; }
.bubble .missing .spin {
  width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite; opacity: 0.8; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.bubble .missing .retry {
  flex-basis: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; margin-top: 2px;
  padding: 8px 12px; border-radius: 14px; background: rgba(127, 127, 127, 0.18); color: inherit; font-weight: 700; font-size: 13px;
}
.bubble .missing .retry .ic { width: 16px; height: 16px; }
.bubble .missing .retry:disabled { opacity: 0.5; }

/* ---------------------------------------------------------------- v10: voice not listened to yet */
.voice.unheard .dur::after {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%;
  background: var(--accent); vertical-align: 1px;
}

/* ---------------------------------------------------------------- v11: in-app pop-up for every new message */
.banner {
  position: fixed; left: 10px; right: 10px; top: calc(8px + env(safe-area-inset-top)); z-index: 70; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 20px; cursor: pointer;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--text);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  transform: translateY(-140%); opacity: 0; transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.2s;
}
.banner.show { transform: none; opacity: 1; }
.banner.gone { transform: translateY(-140%); opacity: 0; }
.banner::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.banner.out::before { background: var(--grad-out); }
.banner .avatar { flex-shrink: 0; }
.banner .bn-txt { flex: 1; min-width: 0; }
.banner .bn-top { display: flex; align-items: center; gap: 4px; font-size: 13.5px; white-space: nowrap; overflow: hidden; }
.banner .bn-top b { overflow: hidden; text-overflow: ellipsis; max-width: 42%; }
.banner .bn-top span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.banner .bn-top em {
  margin-left: auto; padding-left: 6px; font-style: normal; font-size: 11px; font-weight: 700; color: var(--pink); flex-shrink: 0;
}
.banner.out .bn-top em { color: var(--accent); }
.banner .bn-arrow { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.banner .bn-body { font-size: 14px; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.banner .bn-ic { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; margin-right: 4px; color: var(--accent); }
.banner .bn-time { align-self: flex-start; font-size: 11px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.row.fresh { animation: rowFresh 1.4s ease-out; }
@keyframes rowFresh { 0% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }

/* ---------------------------------------------------------------- v13: Telegram history button */
#loadTg { display: inline-flex; align-items: center; gap: 6px; }
.spin-s { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }

/* ---------------------------------------------------------------- v14: reply status notes + animated stickers */
.rnote {
  display: flex; align-items: center; gap: 5px; margin: 1px 0 8px 6px; max-width: 86%;
  font-size: 11.5px; font-weight: 600; line-height: 1.35;
}
.rnote .ic { width: 13px; height: 13px; flex-shrink: 0; }
.rnote b { font-weight: 800; }
.rnote.ok { color: #16a34a; }
.rnote.wait { color: var(--danger); }
.rnote span { background: color-mix(in srgb, var(--panel) 80%, transparent); padding: 2px 8px; border-radius: 9px; }
.bubble .meta .by { font-weight: 700; margin-right: 5px; opacity: 0.95; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .okr { color: #16a34a; background: rgba(34, 197, 94, 0.12); padding: 1px 8px; border-radius: 9px; font-size: 12px; font-weight: 600; }
.tgs { width: 170px; height: 170px; }
.tgs svg { display: block; }
.vsticker { width: 170px; height: 170px; object-fit: contain; background: none !important; border-radius: 0 !important; margin: 0 !important; }
.msg:has(.tgs) .bubble, .msg:has(.vsticker) .bubble, .msg:has(img.sticker) .bubble { background: transparent; box-shadow: none; padding: 2px; }
.msg:has(.tgs) .bubble .meta, .msg:has(.vsticker) .bubble .meta, .msg:has(img.sticker) .bubble .meta {
  color: var(--text); background: color-mix(in srgb, var(--panel) 75%, transparent); display: inline-flex; padding: 1px 7px; border-radius: 9px; float: right;
}

/* ---------------------------------------------------------------- v15: Telegram Premium / verified badges */
.prem, .verif { width: 17px; height: 17px; display: inline-block; vertical-align: -3px; margin-left: 4px; flex-shrink: 0; }
.prof-name .prem, .prof-name .verif { width: 22px; height: 22px; vertical-align: -4px; }
.row .name { display: inline-flex; align-items: center; min-width: 0; }
.prem-chip {
  display: flex; align-items: center; gap: 6px; width: max-content; margin: -4px auto 12px; padding: 4px 12px 4px 8px; border-radius: 14px;
  font-size: 13px; font-weight: 800; color: #fff; background: linear-gradient(90deg, #6b93ff, #976fff 50%, #e46ace);
  box-shadow: 0 3px 12px rgba(151, 111, 255, 0.4);
}
.prem-chip .prem { width: 16px; height: 16px; margin: 0; filter: brightness(0) invert(1); }
.estatus { display: inline-block; width: 20px; height: 20px; margin-left: 4px; vertical-align: -4px; flex-shrink: 0; }
.estatus img, .estatus video, .estatus svg { width: 100% !important; height: 100% !important; object-fit: contain; display: block; }
.prof-name .estatus { width: 26px; height: 26px; vertical-align: -5px; }
#chatName .estatus { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- v16: branch statistics */
.stats-btn { color: var(--accent); }
.st-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--pill); border-radius: 16px; padding: 4px; margin: 6px 0 14px; }
.st-seg button { border: 0; background: none; padding: 9px 4px; border-radius: 12px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.st-seg button.on { background: var(--grad); color: #fff; box-shadow: 0 3px 10px rgba(193, 53, 132, 0.35); }
.st-sum { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .st-sum { grid-template-columns: repeat(4, 1fr); } .st-best { grid-template-columns: repeat(4, 1fr) !important; } }
.st-card { border-radius: 20px; padding: 14px; color: #fff; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15); }
.st-card i .ic { width: 22px; height: 22px; opacity: 0.9; }
.st-card b { font-size: 22px; line-height: 1.2; margin-top: 4px; }
.st-card span { font-size: 12.5px; opacity: 0.92; font-weight: 600; }
.st-best { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.st-b { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-b i { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: 4px; }
.st-b i .ic { width: 18px; height: 18px; }
.st-b.most i { background: linear-gradient(135deg, #7b2ff7, #c13584); }
.st-b.fast i { background: linear-gradient(135deg, #11998e, #38ef7d); }
.st-b.slow i { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.st-b.few i { background: linear-gradient(135deg, #f7971e, #ffd200); }
.st-b em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 700; }
.st-b b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-b small { font-size: 12.5px; color: var(--muted); }
.st-tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.st-tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 7px 14px; font-weight: 700; font-size: 13.5px; white-space: nowrap; color: var(--text); }
.st-tabs button.on { background: var(--text); color: var(--panel); border-color: var(--text); }
.st-list { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.st-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; color: var(--text); }
.st-row:last-child { border-bottom: 0; }
.st-rank { width: 30px; height: 30px; border-radius: 50%; background: var(--pill); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.st-rank.r1 { background: linear-gradient(135deg, #f7971e, #ffd200); color: #fff; }
.st-rank.r2 { background: linear-gradient(135deg, #bdc3c7, #8e9eab); color: #fff; }
.st-rank.r3 { background: linear-gradient(135deg, #c07a4a, #e0a070); color: #fff; }
.st-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.st-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; min-width: 0; }
.st-name .dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }
.st-name .dot.up { background: var(--ok); }
.st-name .lv { font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 9px; font-weight: 800; margin-left: auto; flex-shrink: 0; }
.lv.hi { background: rgba(123, 47, 247, 0.14); color: #7b2ff7; }
.lv.md { background: rgba(47, 128, 237, 0.14); color: #2f80ed; }
.lv.lo { background: rgba(247, 151, 30, 0.16); color: #d97706; }
.st-bar { height: 6px; border-radius: 3px; background: var(--pill); overflow: hidden; }
.st-bar i { display: block; height: 100%; background: var(--grad); border-radius: 3px; }
.st-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--muted); align-items: center; }
.st-meta span { display: inline-flex; align-items: center; gap: 3px; }
.st-meta b { color: var(--text); }
.sp { padding: 1px 8px; border-radius: 9px; font-weight: 700; }
.sp.fast { background: rgba(34, 197, 94, 0.14); color: #16a34a; }
.sp.mid { background: rgba(245, 158, 11, 0.16); color: #d97706; }
.sp.slow { background: rgba(229, 57, 74, 0.14); color: var(--danger); }
.sp.none { background: var(--pill); }
.st-meta .un { color: var(--danger); font-weight: 700; }
.st-note { font-size: 12px; color: var(--muted); margin: 12px 6px 0; line-height: 1.5; }
/* ---------------------------------------------------------------- v17: AI assistant */
.ai-btn { color: #8b5cf6; position: relative; }
.ai-btn.dot-new::after { content: ""; position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--panel); }
.ai-title { display: flex; align-items: center; gap: 7px; }
.ai-title .ic { width: 22px; height: 22px; color: #8b5cf6; }
.ai-tabs { margin: 0 14px 8px; grid-template-columns: repeat(3, 1fr); flex-shrink: 0; }
.ai-setup { background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(193, 53, 132, 0.1)); border: 1px solid rgba(139, 92, 246, 0.35); border-radius: 18px; padding: 14px; margin-bottom: 14px; font-size: 14px; }
.ai-setup p { margin: 6px 0; }
.ai-setup code { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 5px 0; font-size: 13px; overflow-x: auto; }
.ai-sec-t { font-weight: 800; font-size: 13.5px; color: var(--muted); margin: 6px 4px 8px; }
.ai-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ai-al { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 10px 12px; color: var(--text); font-size: 13.5px; line-height: 1.45; }
.ai-al i { width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: #f59e0b; }
.ai-al i .ic { width: 17px; height: 17px; }
.ai-al.high { border-color: rgba(229, 57, 74, 0.45); }
.ai-al.high i { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.ai-al.good i { background: linear-gradient(135deg, #11998e, #38ef7d); }
.ai-al span b { display: block; font-size: 14.5px; margin-bottom: 1px; }
.ai-gen { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 10px; margin-bottom: 14px; }
.ai-gen .ai-days { margin: 0 0 10px; grid-template-columns: repeat(3, 1fr); }
.ai-go { width: 100%; border: 0; border-radius: 16px; padding: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 15px; color: #fff; background: linear-gradient(135deg, #7b2ff7, #c13584); box-shadow: 0 6px 18px rgba(123, 47, 247, 0.3); }
.ai-go:disabled { opacity: 0.6; box-shadow: none; }
.ai-go .ic { width: 20px; height: 20px; }
.ai-report { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; font-size: 14.5px; line-height: 1.65; margin-bottom: 14px; overflow-wrap: anywhere; }
.ai-rep-h { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ai-rep-h span { display: inline-flex; align-items: center; gap: 4px; color: #8b5cf6; }
.ai-rep-h .ic { width: 15px; height: 15px; }
.ai-rep-h em { font-style: normal; }
.ai-rep-f { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 8px; }
.ai-report h2, .ai-report h3, .ai-msg h2, .ai-msg h3 { font-size: 16px; margin: 16px 0 6px; color: var(--text); }
.ai-report h2::before, .ai-report h3::before { content: ""; display: inline-block; width: 4px; height: 15px; border-radius: 2px; background: var(--grad); margin-right: 8px; vertical-align: -2px; }
.ai-report h4, .ai-msg h4 { font-size: 15px; margin: 12px 0 4px; }
.ai-report p, .ai-msg p { margin: 5px 0; }
.ai-report ul, .ai-report ol, .ai-msg ul, .ai-msg ol { margin: 4px 0; padding-left: 22px; }
.ai-report li, .ai-msg li { margin: 3px 0; }
.ai-report li.chk { list-style: "☐  "; }
.ai-report blockquote, .ai-msg blockquote { margin: 6px 0; padding: 6px 10px; border-left: 3px solid #8b5cf6; background: var(--pill); border-radius: 8px; }
.ai-report code, .ai-msg code { background: var(--pill); padding: 1px 5px; border-radius: 5px; }
.ai-report hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.ai-hist { display: flex; flex-direction: column; gap: 6px; }
.ai-hist button { display: flex; justify-content: space-between; gap: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; text-align: left; }
.ai-hist button.on { border-color: #8b5cf6; }
.ai-hist span { color: var(--muted); font-size: 12.5px; }
.ai-chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
.ai-msg { max-width: 88%; padding: 9px 13px; border-radius: 18px; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-msg.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.ai-msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.ai-msg.bot > :first-child { margin-top: 0; }
.ai-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.ai-msg.typing i { width: 8px; height: 8px; border-radius: 50%; background: #8b5cf6; animation: aiDot 1s infinite ease-in-out; }
.ai-msg.typing i:nth-child(2) { animation-delay: 0.15s; }
.ai-msg.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.ai-hello { text-align: center; padding: 18px 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ai-hello i { width: 56px; height: 56px; border-radius: 18px; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, #7b2ff7, #c13584); margin-bottom: 6px; }
.ai-hello i .ic { width: 30px; height: 30px; }
.ai-hello span { color: var(--muted); font-size: 13.5px; }
.ai-sugg { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ai-sugg button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 14px; padding: 10px 12px; text-align: left; font-size: 14px; }
.ai-ask { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); flex-shrink: 0; }
.ai-ask textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 20px; padding: 10px 14px; font: inherit; font-size: 15px; max-height: 120px; }
.ai-ask .ai-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-ask #aiClear { color: var(--muted); }
