/* Quick Inbox — WhatsApp / LinkedIn one-tap drawers under the Day/Night toggle.
   Day palette on bare selectors, Night under html.theme-night (same pattern as theme-toggle.css). */

:root {
  --qi-ease: cubic-bezier(.2, .8, .2, 1);
  --qi-wa: #25D366;
  --qi-wa-deep: #128C4A;
  --qi-li: #0A66C2;
  --qi-ink: #0F172A;
  --qi-sub: #64748B;
  --qi-line: rgba(15, 23, 42, .08);
  --qi-glass: rgba(255, 255, 255, .78);
  --qi-glass-strong: rgba(255, 255, 255, .92);
  --qi-fill: rgba(15, 23, 42, .045);
  --qi-fill-hover: rgba(15, 23, 42, .07);
  --qi-in: #FFFFFF;
  --qi-out: #E7F8EE;
  --qi-accent: var(--qi-wa-deep);
}

/* ---------- rail ---------- */
.qi-rail {
  position: fixed; top: 58px; right: 14px; z-index: 3000;
  display: flex; flex-direction: column; gap: 10px;
  animation: qi-rail-in .5s var(--qi-ease) both;
}
@keyframes qi-rail-in { from { opacity: 0; transform: translateY(-6px) scale(.9); } }

.qi-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  border: 1px solid rgba(15, 23, 42, .14);
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(10px) saturate(160%); backdrop-filter: blur(10px) saturate(160%);
  box-shadow: 0 6px 18px -8px rgba(15, 23, 42, .35), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .35s var(--qi-ease), box-shadow .35s var(--qi-ease), border-color .25s ease, background .25s ease;
}
.qi-btn svg { width: 18px; height: 18px; transition: transform .35s var(--qi-ease); }
.qi-btn.qi-wa { color: var(--qi-wa-deep); }
.qi-btn.qi-li { color: var(--qi-li); }
.qi-btn.qi-li svg { width: 16px; height: 16px; }
.qi-btn.qi-ig { color: #8134AF; }
.qi-btn:hover { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 22px -10px rgba(15, 23, 42, .45), inset 0 1px 0 rgba(255, 255, 255, .8); }
.qi-btn:active { transform: scale(.94); transition-duration: .1s; }
.qi-btn:focus-visible { outline: 2px solid var(--qi-accent); outline-offset: 2px; }
.qi-btn.qi-wa.is-active { border-color: rgba(37, 211, 102, .6); box-shadow: 0 0 0 4px rgba(37, 211, 102, .14), 0 8px 20px -10px rgba(18, 140, 74, .55); }
.qi-btn.qi-li.is-active { border-color: rgba(10, 102, 194, .55); box-shadow: 0 0 0 4px rgba(10, 102, 194, .12), 0 8px 20px -10px rgba(10, 102, 194, .5); }
.qi-btn.qi-ig.is-active { border-color: rgba(129,52,175, .5); box-shadow: 0 0 0 4px rgba(129,52,175, .12), 0 8px 20px -10px rgba(129, 52, 175, .5); }

.qi-badge {
  position: absolute; top: -4px; right: -5px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: #EF4444; color: #fff;
  font: 700 10px/17px system-ui, -apple-system, sans-serif; letter-spacing: .01em; text-align: center;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(239, 68, 68, .45);
  animation: qi-pop .45s var(--qi-ease) both;
}
@keyframes qi-pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- drawer ---------- */
.qi-drawer {
  position: fixed; top: 10px; right: 62px; z-index: 2999;
  width: 400px; height: min(680px, calc(100vh - 20px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 22px;
  background: var(--qi-glass);
  -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 0 0 .5px rgba(15, 23, 42, .1), 0 30px 60px -20px rgba(15, 23, 42, .35), 0 12px 24px -12px rgba(15, 23, 42, .18), inset 0 1px 0 rgba(255, 255, 255, .9);
  color: var(--qi-ink);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  opacity: 0; transform: scale(.86); filter: blur(6px);
  transition: opacity .32s var(--qi-ease), transform .42s var(--qi-ease), filter .32s var(--qi-ease);
  will-change: transform, opacity;
}
.qi-drawer.is-open { opacity: 1; transform: none; filter: none; }
.qi-drawer[data-p="li"] { --qi-accent: var(--qi-li); --qi-out: #E8F1FB; }
.qi-drawer[data-p="ig"] { --qi-accent: #8134AF; --qi-out: #FCEAF2; }

.qi-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 16px;
  border-bottom: 1px solid var(--qi-line);
}
.qi-head-glyph {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(160deg, #3BE07F, var(--qi-wa-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 10px -4px rgba(18, 140, 74, .6);
}
.qi-drawer[data-p="li"] .qi-head-glyph { background: linear-gradient(160deg, #2A86E0, #0A58A8); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 10px -4px rgba(10, 102, 194, .6); }
.qi-drawer[data-p="ig"] .qi-head-glyph { background: radial-gradient(circle at 28% 108%, #FEDA75 0%, #FA7E1E 22%, #D62976 52%, #962FBF 76%, #4F5BD5 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 10px -4px rgba(129,52,175, .6); }
.qi-head-glyph svg { width: 18px; height: 18px; }
.qi-drawer[data-p="li"] .qi-head-glyph svg { width: 15px; height: 15px; }
.qi-head-text { flex: 1; min-width: 0; }
.qi-head-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.qi-head-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--qi-sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-live { width: 6px; height: 6px; border-radius: 50%; background: #22C55E; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); flex: none; }

.qi-icon-btn {
  width: 32px; height: 32px; border-radius: 10px; border: 0; background: transparent; color: var(--qi-sub);
  display: grid; place-items: center; cursor: pointer; flex: none; text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .2s var(--qi-ease);
}
.qi-icon-btn svg { width: 17px; height: 17px; }
.qi-icon-btn:hover { background: var(--qi-fill-hover); color: var(--qi-ink); }
.qi-icon-btn:active { transform: scale(.92); }
.qi-icon-btn:focus-visible { outline: 2px solid var(--qi-accent); outline-offset: 1px; }

/* two panes that slide like a navigation stack */
.qi-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.qi-pane { position: absolute; inset: 0; display: flex; flex-direction: column; transition: transform .45s var(--qi-ease), opacity .3s var(--qi-ease); }
.qi-pane-thread { transform: translateX(100%); opacity: 0; pointer-events: none; }
.qi-drawer.in-thread .qi-pane-list { transform: translateX(-28%); opacity: 0; pointer-events: none; }
.qi-drawer.in-thread .qi-pane-thread { transform: none; opacity: 1; pointer-events: auto; }

/* list */
.qi-tools { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.qi-search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 11px;
  background: var(--qi-fill); color: var(--qi-sub); transition: background .2s ease, box-shadow .2s ease;
}
.qi-search:focus-within { background: var(--qi-glass-strong); box-shadow: 0 0 0 1px var(--qi-line), 0 0 0 4px color-mix(in srgb, var(--qi-accent) 16%, transparent); }
.qi-search svg { width: 15px; height: 15px; flex: none; }
.qi-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: 14px system-ui, -apple-system, sans-serif; color: var(--qi-ink); }
.qi-search input::placeholder { color: var(--qi-sub); }
.qi-search input::-webkit-search-cancel-button { display: none; }

.qi-seg { display: inline-flex; align-self: flex-start; padding: 3px; gap: 2px; border-radius: 10px; background: var(--qi-fill); }
.qi-seg button {
  border: 0; background: transparent; cursor: pointer; padding: 5px 14px; border-radius: 8px;
  font: 600 12.5px system-ui, -apple-system, sans-serif; color: var(--qi-sub);
  transition: background .25s var(--qi-ease), color .2s ease, box-shadow .25s var(--qi-ease);
}
.qi-seg button b { display: inline-block; margin-left: 4px; min-width: 16px; padding: 0 5px; border-radius: 8px; background: var(--qi-accent); color: #fff; font-size: 10.5px; line-height: 16px; }
.qi-seg button.is-on { background: var(--qi-glass-strong); color: var(--qi-ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 0 0 .5px rgba(15, 23, 42, .06); }

.qi-rows { flex: 1; overflow-y: auto; padding: 2px 8px 8px; overscroll-behavior: contain; }
.qi-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 10px; border: 0; border-radius: 14px;
  background: transparent; cursor: pointer; text-align: left; color: inherit; font: inherit;
  transition: background .2s ease, transform .2s var(--qi-ease);
}
.qi-row:hover { background: var(--qi-fill); }
.qi-row:active { transform: scale(.985); background: var(--qi-fill-hover); }
.qi-row:focus-visible { outline: 2px solid var(--qi-accent); outline-offset: -2px; }
.qi-ava {
  position: relative; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  color: #fff; font-weight: 650; font-size: 13px; letter-spacing: .02em;
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.qi-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.qi-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qi-row-top, .qi-row-bottom { display: flex; align-items: center; gap: 8px; }
.qi-row-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 550; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-row-time { flex: none; font-size: 11.5px; color: var(--qi-sub); font-variant-numeric: tabular-nums; }
.qi-row-prev { flex: 1; min-width: 0; font-size: 13px; color: var(--qi-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-row.is-unread .qi-row-name { font-weight: 700; }
.qi-row.is-unread .qi-row-prev { color: var(--qi-ink); }
.qi-row.is-unread .qi-row-time { color: var(--qi-accent); font-weight: 600; }
.qi-row-count { flex: none; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--qi-accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; }
.qi-row-count:empty { min-width: 9px; width: 9px; height: 9px; padding: 0; }

.qi-foot {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; flex: none;
  border-top: 1px solid var(--qi-line); color: var(--qi-accent); font-size: 13px; font-weight: 600; text-decoration: none;
  transition: background .2s ease;
}
.qi-foot svg { width: 13px; height: 13px; }
.qi-foot:hover { background: var(--qi-fill); }

.qi-skel { height: 58px; margin: 4px 2px; border-radius: 14px; background: linear-gradient(90deg, var(--qi-fill) 25%, var(--qi-fill-hover) 50%, var(--qi-fill) 75%); background-size: 200% 100%; animation: qi-shimmer 1.3s linear infinite; }
@keyframes qi-shimmer { to { background-position: -200% 0; } }

.qi-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 24px; gap: 6px; }
.qi-empty-glyph { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--qi-fill); color: var(--qi-accent); margin-bottom: 6px; }
.qi-empty-glyph svg { width: 22px; height: 22px; }
.qi-empty-title { font-size: 14.5px; font-weight: 650; }
.qi-empty-sub { font-size: 13px; color: var(--qi-sub); }

/* thread */
.qi-thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 8px; border-bottom: 1px solid var(--qi-line); flex: none; }
.qi-thread-who { flex: 1; min-width: 0; }
.qi-thread-name { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-thread-sub { font-size: 12px; color: var(--qi-sub); }

.qi-msgs {
  flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, .025));
}
.qi-msgs-loading { margin: auto; display: flex; gap: 5px; }
.qi-msgs-loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--qi-sub); opacity: .4; animation: qi-dot 1s var(--qi-ease) infinite; }
.qi-msgs-loading span:nth-child(2) { animation-delay: .15s; }
.qi-msgs-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes qi-dot { 50% { opacity: 1; transform: translateY(-3px); } }

.qi-day { align-self: center; margin: 10px 0 6px; }
.qi-day span { font-size: 11px; font-weight: 600; color: var(--qi-sub); padding: 3px 10px; border-radius: 10px; background: var(--qi-glass-strong); box-shadow: 0 0 0 .5px var(--qi-line); letter-spacing: .02em; }
.qi-msg { display: flex; animation: qi-msg-in .35s var(--qi-ease) both; }
@keyframes qi-msg-in { from { opacity: 0; transform: translateY(6px); } }
.qi-msg.out { justify-content: flex-end; }
.qi-bubble {
  max-width: 80%; padding: 8px 11px 6px; border-radius: 16px; font-size: 13.5px; line-height: 1.42;
  white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1.5px rgba(15, 23, 42, .08);
}
.qi-msg.in .qi-bubble { background: var(--qi-in); border-bottom-left-radius: 6px; }
.qi-msg.out .qi-bubble { background: var(--qi-out); border-bottom-right-radius: 6px; }
.qi-msg.is-sending .qi-bubble { opacity: .6; }
.qi-msg.is-failed .qi-bubble { cursor: pointer; box-shadow: 0 0 0 1px rgba(239, 68, 68, .45); }
.qi-msg.is-failed .qi-meta { color: #DC2626; }
.qi-meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; margin-top: 2px; font-size: 10.5px; color: var(--qi-sub); font-variant-numeric: tabular-nums; }
.qi-ticks svg { width: 15px; height: 12px; }
.qi-ticks.seen { color: #3B82F6; }
.qi-att { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--qi-accent); }

/* composer */
.qi-composer { position: relative; flex: none; padding: 8px 10px 12px; border-top: 1px solid var(--qi-line); background: var(--qi-glass-strong); }
.qi-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.qi-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--qi-line); background: var(--qi-glass-strong); color: var(--qi-ink);
  font: 600 12px system-ui, -apple-system, sans-serif;
  transition: background .2s ease, transform .2s var(--qi-ease), border-color .2s ease;
}
.qi-chip svg { width: 14px; height: 14px; color: var(--qi-accent); }
.qi-chip:hover { background: var(--qi-fill); }
.qi-chip:active { transform: scale(.95); }
.qi-chip-icon { width: 28px; padding: 0; justify-content: center; }
.qi-chip-icon svg { color: var(--qi-sub); }
#qi-ai svg { color: #8B5CF6; }
.qi-chip.is-busy { pointer-events: none; }
.qi-chip.is-busy svg { animation: qi-spin 1.1s linear infinite; }
@keyframes qi-spin { to { transform: rotate(360deg); } }

.qi-input-row { display: flex; align-items: flex-end; gap: 8px; }
.qi-input-row textarea {
  flex: 1; min-width: 0; resize: none; max-height: 132px; padding: 9px 14px; border-radius: 19px;
  border: 1px solid var(--qi-line); background: var(--qi-in); color: var(--qi-ink);
  font: 14px/1.4 system-ui, -apple-system, sans-serif; outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.qi-input-row textarea:focus { border-color: color-mix(in srgb, var(--qi-accent) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--qi-accent) 14%, transparent); }
.qi-send {
  width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff;
  background: var(--qi-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 14px -6px color-mix(in srgb, var(--qi-accent) 70%, transparent);
  transition: transform .25s var(--qi-ease), opacity .2s ease, filter .2s ease;
}
.qi-send svg { width: 17px; height: 17px; margin-left: -2px; }
.qi-send:hover { filter: brightness(1.08); }
.qi-send:active { transform: scale(.9); }
.qi-send:disabled { opacity: .35; cursor: default; box-shadow: none; transform: none; }

/* popovers (templates / emoji), anchored above the composer */
.qi-pop {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); max-height: 280px; display: flex; flex-direction: column;
  border-radius: 16px; background: var(--qi-glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 0 0 .5px rgba(15, 23, 42, .12), 0 18px 40px -14px rgba(15, 23, 42, .35);
  transform-origin: 20% 100%; animation: qi-pop-in .3s var(--qi-ease) both; overflow: hidden;
}
@keyframes qi-pop-in { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.qi-pop-head { padding: 10px 14px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--qi-sub); }
.qi-pop-list { overflow-y: auto; padding: 0 6px 6px; }
.qi-pop-empty { padding: 14px; font-size: 13px; color: var(--qi-sub); }
.qi-tmpl { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: inherit; font: inherit; }
.qi-tmpl:hover { background: var(--qi-fill); }
.qi-tmpl b { font-size: 13px; font-weight: 600; }
.qi-tmpl span { font-size: 12.5px; color: var(--qi-sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qi-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); padding: 8px; gap: 2px; }
.qi-emoji-grid button { border: 0; background: transparent; font-size: 20px; height: 38px; border-radius: 10px; cursor: pointer; transition: background .15s ease, transform .2s var(--qi-ease); }
.qi-emoji-grid button:hover { background: var(--qi-fill); transform: scale(1.12); }

/* new message */
.qi-new { padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.qi-field { display: flex; flex-direction: column; gap: 6px; }
.qi-field span { font-size: 12px; font-weight: 600; color: var(--qi-sub); letter-spacing: .02em; }
.qi-field input {
  height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--qi-line); background: var(--qi-in); color: var(--qi-ink);
  font: 14px system-ui, -apple-system, sans-serif; outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
.qi-field input:focus { border-color: color-mix(in srgb, var(--qi-accent) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--qi-accent) 14%, transparent); }
.qi-primary {
  height: 42px; border: 0; border-radius: 12px; cursor: pointer; color: #fff; background: var(--qi-accent);
  font: 650 14px system-ui, -apple-system, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 18px -10px color-mix(in srgb, var(--qi-accent) 80%, transparent);
  transition: transform .2s var(--qi-ease), filter .2s ease;
}
.qi-primary:hover { filter: brightness(1.06); }
.qi-primary:active { transform: scale(.97); }
.qi-new-err { margin: 0; font-size: 12.5px; color: #DC2626; }

/* ---------- voice notes ---------- */
/* send button morphs mic <-> paper plane as the composer empties/fills */
.qi-send { position: relative; overflow: hidden; }
.qi-send-mic, .qi-send-go { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .38s var(--qi-ease), opacity .22s ease; }
.qi-send-mic svg { width: 18px; height: 18px; margin: 0; }
.qi-send-go { transform: scale(1); opacity: 1; }
.qi-send-mic { transform: scale(.4) rotate(-30deg); opacity: 0; }
.qi-send.is-mic .qi-send-go { transform: scale(.4) rotate(30deg); opacity: 0; }
.qi-send.is-mic .qi-send-mic { transform: none; opacity: 1; }

/* recording bar replaces the input row in place */
.qi-composer.is-recording .qi-actions { opacity: .35; pointer-events: none; transition: opacity .25s ease; }
.qi-composer.is-recording .qi-input-row { visibility: hidden; }
.qi-rec {
  position: absolute; left: 10px; right: 10px; bottom: 12px; height: 38px;
  display: flex; align-items: center; gap: 10px;
  animation: qi-rec-in .38s var(--qi-ease) both;
}
.qi-rec.is-leaving { animation: qi-rec-out .18s ease both; }
@keyframes qi-rec-in { from { opacity: 0; transform: translateX(14px) scale(.98); } }
@keyframes qi-rec-out { to { opacity: 0; transform: translateX(14px); } }
.qi-rec-x {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--qi-sub); background: transparent;
  transition: background .2s ease, color .2s ease, transform .2s var(--qi-ease);
}
.qi-rec-x svg { width: 18px; height: 18px; }
.qi-rec-x:hover { background: rgba(239, 68, 68, .1); color: #DC2626; }
.qi-rec-x:active { transform: scale(.9); }
.qi-rec-dot {
  width: 9px; height: 9px; flex: none; border-radius: 50%; background: #EF4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); animation: qi-rec-pulse 1.4s ease-in-out infinite;
}
@keyframes qi-rec-pulse { 50% { opacity: .45; box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); } }
.qi-rec-time { flex: none; min-width: 34px; font: 600 13.5px system-ui, -apple-system, sans-serif; color: var(--qi-ink); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.qi-rec-wave {
  flex: 1; min-width: 0; height: 30px; padding: 0 12px; border-radius: 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
  background: var(--qi-fill); box-shadow: inset 0 0 0 .5px var(--qi-line);
}
.qi-rec-wave i {
  display: block; width: 2.5px; border-radius: 2px; background: var(--qi-accent);
  height: calc(4px + var(--h, .08) * 18px); opacity: calc(.45 + var(--h, .08) * .55);
  transition: height .1s linear;
}
.qi-rec-send svg { margin-left: -2px; }
.qi-rec-hint {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); padding: 8px 12px; border-radius: 12px;
  font: 500 12.5px/1.35 system-ui, -apple-system, sans-serif; color: var(--qi-ink);
  background: var(--qi-glass-strong); box-shadow: 0 0 0 .5px var(--qi-line), 0 10px 24px -12px rgba(15, 23, 42, .35);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: qi-rec-in .3s var(--qi-ease) both;
}
.qi-rec-hint.is-leaving { animation: qi-rec-out .2s ease both; }

/* voice bubble */
.qi-msg.is-voice .qi-bubble { min-width: 232px; padding: 7px 10px 5px 7px; }
.qi-voice { display: flex; align-items: center; gap: 9px; }
.qi-play {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; padding: 0; cursor: pointer; color: #fff;
  display: grid; place-items: center; background: var(--qi-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 10px -5px color-mix(in srgb, var(--qi-accent) 80%, transparent);
  transition: transform .25s var(--qi-ease), filter .2s ease;
}
.qi-play svg { width: 14px; height: 14px; }
.qi-play:hover { filter: brightness(1.08); }
.qi-play:active { transform: scale(.9); }
.qi-voice.is-loading .qi-play svg { animation: qi-spin 1.1s linear infinite; opacity: .6; }
.qi-wave { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 1.5px; cursor: pointer; outline: none; border-radius: 6px; }
.qi-wave:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--qi-accent) 25%, transparent); }
.qi-wave i {
  display: block; width: 2.5px; border-radius: 2px; height: calc(3px + var(--h, .3) * 22px);
  background: color-mix(in srgb, var(--qi-sub) 45%, transparent);
  transition: background .15s ease, height .45s var(--qi-ease);
}
.qi-wave i.on { background: var(--qi-accent); }
.qi-vtime { flex: none; min-width: 30px; text-align: right; font-size: 11.5px; font-weight: 600; color: var(--qi-sub); font-variant-numeric: tabular-nums; }
.qi-voice.is-missing .qi-play { background: var(--qi-fill-hover); color: var(--qi-sub); box-shadow: none; }
.qi-voice.is-missing .qi-wave i { opacity: .4; }

/* ---------- Night ---------- */
html.theme-night {
  --qi-ink: #E6F1F4;
  --qi-sub: #8FA3AD;
  --qi-line: rgba(148, 163, 184, .14);
  --qi-glass: rgba(12, 22, 30, .76);
  --qi-glass-strong: rgba(20, 34, 44, .9);
  --qi-fill: rgba(148, 163, 184, .08);
  --qi-fill-hover: rgba(148, 163, 184, .14);
  --qi-in: rgba(30, 46, 58, .95);
  --qi-out: rgba(18, 140, 74, .32);
}
html.theme-night .qi-drawer[data-p="li"] { --qi-out: rgba(10, 102, 194, .34); --qi-accent: #4A9EEB; }
html.theme-night .qi-drawer[data-p="ig"] { --qi-out: rgba(129,52,175, .3); --qi-accent: #B57EDC; }
html.theme-night .qi-drawer[data-p="wa"] { --qi-accent: #2FD27A; }
html.theme-night .qi-btn {
  background: rgba(15, 28, 38, .72); border: 1px solid rgba(94, 234, 212, .3);
  box-shadow: 0 0 18px -8px rgba(45, 212, 191, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
}
html.theme-night .qi-btn.qi-wa { color: #3BE07F; }
html.theme-night .qi-btn.qi-li { color: #5AA9F0; }
html.theme-night .qi-btn.qi-ig { color: #B57EDC; }
html.theme-night .qi-btn.qi-wa.is-active { border-color: rgba(59, 224, 127, .6); box-shadow: 0 0 0 4px rgba(59, 224, 127, .12), 0 0 22px -6px rgba(59, 224, 127, .55); }
html.theme-night .qi-btn.qi-li.is-active { border-color: rgba(90, 169, 240, .6); box-shadow: 0 0 0 4px rgba(90, 169, 240, .12), 0 0 22px -6px rgba(90, 169, 240, .55); }
html.theme-night .qi-btn.qi-ig.is-active { border-color: rgba(240, 96, 158, .6); box-shadow: 0 0 0 4px rgba(240, 96, 158, .12), 0 0 22px -6px rgba(240, 96, 158, .55); }
html.theme-night .qi-badge { box-shadow: 0 0 0 2px #0B1620, 0 2px 8px rgba(239, 68, 68, .5); }
html.theme-night .qi-drawer {
  border: 1px solid rgba(94, 234, 212, .18);
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .5), 0 30px 70px -20px rgba(0, 0, 0, .7), 0 0 40px -18px rgba(45, 212, 191, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
}
html.theme-night .qi-msgs { background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .18)); }
html.theme-night .qi-bubble { box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
html.theme-night .qi-seg button.is-on { box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(148, 163, 184, .18); }
html.theme-night .qi-pop { box-shadow: 0 0 0 .5px rgba(148, 163, 184, .2), 0 18px 40px -14px rgba(0, 0, 0, .7); }
html.theme-night .qi-ticks.seen { color: #5EEAD4; }
html.theme-night .qi-wave i { background: rgba(148, 163, 184, .38); }
html.theme-night .qi-wave i.on, html.theme-night .qi-rec-wave i { background: var(--qi-accent); }
html.theme-night .qi-rec-hint { box-shadow: 0 0 0 .5px rgba(148, 163, 184, .2), 0 14px 30px -12px rgba(0, 0, 0, .7); }
html.theme-night .qi-rec-dot { background: #F87171; }
html.theme-night .qi-play { color: #04130B; }
html.theme-night .qi-drawer[data-p="li"] .qi-play { color: #fff; }
html.theme-night .qi-drawer[data-p="ig"] .qi-play { color: #fff; }

/* ---------- responsive + accessibility ---------- */
@media (max-width: 640px) {
  .qi-rail { top: 50px; right: 10px; gap: 8px; }
  .qi-btn { width: 34px; height: 34px; }
  .qi-drawer { top: 8px; right: 8px; left: 8px; width: auto; height: calc(100dvh - 16px); border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .qi-drawer { transform: none !important; filter: none !important; transition: opacity .2s ease; }
  .qi-pane { transition: opacity .2s ease; transform: none !important; }
  .qi-rail, .qi-badge, .qi-msg, .qi-pop { animation: none; }
  .qi-rec, .qi-rec-hint, .qi-rec-dot { animation: none; }
  .qi-send-mic, .qi-send-go { transition: opacity .15s ease; transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .qi-drawer, .qi-btn, .qi-pop { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .qi-drawer, .qi-pop { background: #fff; }
  html.theme-night .qi-drawer, html.theme-night .qi-pop { background: #0E1A23; }
}
