/* Bubble skin v2 (also the page base: this file is linked as app.css). Own palette: fresh green accent, soft blue-grey wallpaper. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --line: #e6e8ec; --text: #1b1f27; --muted: #8b92a0;
  --accent: #2fb872; --accent-ink: #ffffff; --mine: #bfe9a8; --theirs: #ffffff; --chat-bg: #a8bbe2; --field: #f0f1f4; --meta: #4a5a7e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151922; --panel: #1d222d; --line: #2b3140; --text: #eceff5; --muted: #8b93a5;
    --accent: #4fcf8c; --accent-ink: #0d1a13; --mine: #3d7f55; --theirs: #2f3649; --chat-bg: #232c44; --field: #2a3040; --meta: #9aa7c9; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
#app { height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.bb-login { max-width: 320px; margin: 15vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.bb-login h1 { text-align: center; color: var(--accent); font-size: 28px; margin: 0 0 12px; }
.bb-login input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--text); font: inherit; }
.bb-login button { padding: 12px; border-radius: 22px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.bb-hint { color: var(--muted); font-size: 12px; text-align: center; }
.bb-error { color: #d23c2c; font-size: 13px; padding: 4px 12px; text-align: center; }

.bb-app { display: grid; grid-template-columns: 340px 1fr; height: 100%; }
.bb-bar { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; min-height: 52px; background: var(--panel); flex: none; }
.bb-bar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; }
.bb-bar-title small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); line-height: 1.2; }
.bb-list .bb-bar-title { font-size: 20px; }
.bb-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 18px; color: var(--muted); flex: none; }
.bb-icon:hover { background: var(--field); }
.bb-link { color: var(--muted); font-size: 13px; }
.bb-list { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.bb-search { display: flex; align-items: center; gap: 8px; margin: 0 14px 8px; padding: 0 12px; height: 36px; border-radius: 18px; background: var(--field); color: var(--muted); flex: none; }
.bb-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; }
.bb-offline { background: #ffe9a8; color: #6b5300; font-size: 12px; padding: 4px 16px; }
.bb-items { flex: 1; overflow-y: auto; }
.bb-item { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; min-width: 0; padding: 8px 16px; text-align: left; }
.bb-item:hover, .bb-item.is-active { background: var(--bg); }
.bb-item-main { flex: 1; min-width: 0; }
.bb-item-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-item-last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; align-self: stretch; justify-content: space-between; padding: 4px 0; flex: none; }
.bb-time { color: var(--muted); font-size: 12px; }
.bb-badge { background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 12px; font-weight: 600; padding: 0 6px; min-width: 20px; line-height: 20px; text-align: center; }
.bb-empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.bb-presence { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-size: 11px; font-weight: 400; color: var(--muted); vertical-align: middle; }
.bb-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.bb-presence.is-online .bb-dot { background: #3fae6a; }
.bb-presence.is-busy .bb-dot { background: #e0a030; }
.bb-presence.is-gaming .bb-dot { background: #7a6be0; }

.bb-avatar { border-radius: 50%; object-fit: cover; flex: none; }
.bb-avatar-letter { display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.bb-chat { display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--chat-bg); }
.bb-placeholder { background: var(--chat-bg); }
.bb-chat .bb-bar { border-bottom: 1px solid var(--line); }
.bb-back { visibility: hidden; }
.bb-msgs { flex: 1; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 4px;
  background-image: radial-gradient(ellipse 70% 60px at 20% 100%, rgba(255,255,255,.22), transparent), radial-gradient(ellipse 60% 50px at 85% 100%, rgba(255,255,255,.16), transparent); background-repeat: no-repeat; background-attachment: local; }
.bb-day { align-self: center; margin: 10px 0 6px; padding: 1px 12px; border-radius: 10px; background: rgba(0,0,0,.18); color: #fff; font-size: 11px; }
.bb-system { align-self: center; max-width: 85%; margin: 6px 0; padding: 4px 12px; border-radius: 12px; background: rgba(0,0,0,.2); color: #fff; font-size: 12px; text-align: center; white-space: pre-wrap; }
.bb-row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.bb-row.is-mine { justify-content: flex-end; }
.bb-row.first { margin-top: 8px; }
.bb-spacer { width: 32px; flex: none; }
.bb-bubble { position: relative; max-width: min(70%, 460px); padding: 8px 13px; border-radius: 18px; background: var(--theirs); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.bb-row.is-mine .bb-bubble { background: var(--mine); }
.bb-row.first .bb-bubble::before { content: ""; position: absolute; top: 0; width: 10px; height: 10px; background: inherit; }
.bb-row.first:not(.is-mine) .bb-bubble { border-top-left-radius: 4px; }
.bb-row.first:not(.is-mine) .bb-bubble::before { left: -7px; clip-path: polygon(100% 0, 100% 100%, 0 0); }
.bb-row.first.is-mine .bb-bubble { border-top-right-radius: 4px; }
.bb-row.first.is-mine .bb-bubble::before { right: -7px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.bb-meta { font-size: 10.5px; line-height: 1.25; color: var(--meta); text-align: right; flex: none; padding-bottom: 1px; }
.bb-row:not(.is-mine) .bb-meta { text-align: left; }
.bb-typing { color: #fff; font-size: 12px; padding: 2px 0 2px 38px; opacity: .9; }
.bb-input { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.bb-field { flex: 1; display: flex; align-items: flex-end; gap: 4px; padding: 0 8px 0 14px; border-radius: 19px; background: var(--field); color: var(--muted); }
.bb-field textarea { flex: 1; min-width: 0; resize: none; padding: 9px 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; max-height: 120px; line-height: 1.35; }
.bb-field .bb-icon { height: 38px; }
.bb-send { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent) !important; color: var(--accent-ink) !important; flex: none; }
.bb-toast { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 6; padding: 6px 14px; border-radius: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 13px; }
.bb-chat { position: relative; }

/* ---- desktop layout (window width >= 900px): dark icon rail | list | white chat pane ---- */
.bb-app.is-desktop { grid-template-columns: 60px 300px 1fr; --theirs: #f0f2f5; --chat-bg: #ffffff; --meta: #9aa1ad; --rail: #27324d; }
@media (prefers-color-scheme: dark) { .bb-app.is-desktop { --theirs: #2f3649; --chat-bg: var(--panel); --meta: #7c859b; --rail: #10141d; } }
.bb-rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; background: var(--rail); color: rgba(255,255,255,.6); }
.bb-rail-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; color: rgba(255,255,255,.6); }
.bb-rail-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.bb-rail-btn.is-on { color: #fff; background: rgba(255,255,255,.14); }
.bb-rail-btn .bb-badge { position: absolute; top: -2px; right: -2px; font-size: 10px; min-width: 16px; line-height: 16px; padding: 0 4px; }
.bb-grow { flex: 1; }
.bb-listcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.bb-dsearch { margin: 12px 12px 8px; height: 34px; border-radius: 8px; }
.bb-dsearch input { font-size: 14px; }
.bb-sect { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 16px; font-size: 12px; font-weight: 600; color: var(--muted); }
.bb-sect svg { transform: rotate(-90deg); transition: transform .15s; }
.bb-sect.is-open svg { transform: rotate(90deg); }
.bb-listcol .bb-item { padding: 8px 14px; gap: 10px; }
.bb-listcol .bb-item-name { font-size: 14px; }
.bb-listcol .bb-item-last { font-size: 12px; }
.bb-app.is-desktop .bb-chat { background: var(--chat-bg); }
.bb-app.is-desktop .bb-bar { min-height: 56px; border-bottom: 1px solid var(--line); }
.bb-app.is-desktop .bb-bar-title { font-size: 15px; }
.bb-app.is-desktop .bb-msgs { background-image: none; padding: 16px 24px 8px; }
.bb-app.is-desktop .bb-day, .bb-app.is-desktop .bb-system { background: var(--field); color: var(--muted); }
.bb-app.is-desktop .bb-typing { color: var(--muted); }
.bb-app.is-desktop .bb-bubble { max-width: min(62%, 520px); }
.bb-pick { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bb-dinput { flex: none; border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px 6px; }
.bb-dinput textarea { display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; line-height: 1.4; min-height: 52px; }
.bb-dtools { display: flex; align-items: center; gap: 2px; }
.bb-app.is-desktop .bb-toast { bottom: 100px; }

@media (max-width: 720px) {
  .bb-app { grid-template-columns: minmax(0, 1fr); }
  .bb-app.has-open .bb-list { display: none; }
  .bb-app:not(.has-open) .bb-chat { display: none; }
  .bb-back { visibility: visible; }
  .bb-bubble { max-width: 76%; }
}
