:root {
  --primary: #007aff;
  --self-bg: #95ec69;
  --self-text: #111;
  --bg: #f2f4f7;
  --card: #fff;
  --muted: #8a8f98;
  --border: #e6e8eb;
  --danger: #e5484d;
  --max-width: 680px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1b1e24;
    --muted: #8c929c;
    --border: #2a2e36;
    --self-bg: #2f7d32;
    --self-text: #f2f2f2;
  }
  body { color: #e8e8e8; }
  .bubble.admin, .bubble.other { background: #242832 !important; color: #e8e8e8 !important; }
  textarea { background: #242832 !important; color: #e8e8e8; }
  .notice { background: #16202c !important; border-color: #22303f !important; color: #c9d1d9 !important; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  display: flex; justify-content: center;
  height: 100vh; height: 100dvh;
}
.app {
  width: 100%; max-width: var(--max-width); height: 100%;
  background: var(--card); display: flex; flex-direction: column; position: relative;
}
@media (min-width: 768px) {
  body { padding: 20px; }
  .app { max-height: 860px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: 0 12px 24px rgba(0,0,0,.08); }
}
.hidden { display: none !important; }

.topbar { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { font-weight: 600; font-size: 17px; }
.status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c7c7cc; }
.status.online .dot { background: #34c759; }
.status.offline .dot { background: var(--danger); }

.notice { background: #f0f9ff; border-bottom: 1px solid #e0f2fe; padding: 8px 16px; font-size: 13px; color: #444; line-height: 1.6; }
.notice ul { list-style: none; margin: 4px 0 0; padding: 0; }
.notice li { display: flex; gap: 6px; align-items: flex-start; margin: 2px 0; word-break: break-all; }
.notice a { color: var(--primary); text-decoration: none; font-weight: 500; }
.notice a:hover { text-decoration: underline; }
.notice.collapsed ul { display: none; }
.notice-toggle { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; display: flex; gap: 6px; width: 100%; justify-content: space-between; }
.copy { border: 1px solid var(--border); background: transparent; color: var(--primary); border-radius: 6px; font-size: 11px; padding: 0 6px; cursor: pointer; margin-left: 4px; }

main { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); overscroll-behavior: contain; }
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; max-width: 80%; line-height: 1.7; }
.day { align-self: center; font-size: 11px; color: var(--muted); margin: 6px 0; }
.msg { display: flex; flex-direction: column; max-width: 82%; animation: in .18s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.admin { align-self: flex-start; align-items: flex-start; }
.meta { font-size: 11px; color: var(--muted); margin: 0 4px 3px; display: flex; gap: 6px; align-items: center; }
.meta .who { color: var(--primary); font-weight: 600; }
.bubble { padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.bubble a { color: inherit; text-decoration: underline; }
.msg.me .bubble { background: var(--self-bg); color: var(--self-text); border-top-right-radius: 4px; }
.msg.admin .bubble { background: #fff; color: #111; border: 1px solid var(--border); border-top-left-radius: 4px; }
.tick { font-size: 11px; color: var(--muted); margin: 3px 4px 0; }
.tick.failed { color: var(--danger); cursor: pointer; }
.tick.failed:hover { text-decoration: underline; }
.system { align-self: center; background: rgba(127,127,127,.12); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 10px; }

.banner { padding: 8px 16px; font-size: 13px; background: #fff4e5; color: #8a5300; border-top: 1px solid #ffe2b8; }
.banner.danger { background: #ffecec; color: #a3272b; border-color: #ffc9c9; }

.composer { border-top: 1px solid var(--border); padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--card); }
.identity { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; margin: 0 4px 6px; }
.identity b { color: inherit; letter-spacing: 1px; user-select: all; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-size: 11px; cursor: pointer; }
.row { display: flex; gap: 10px; align-items: flex-end; }
textarea {
  flex: 1; resize: none; border: 0; outline: none; background: #f2f2f7; color: inherit;
  border-radius: 20px; padding: 10px 15px; font: inherit; font-size: 16px; line-height: 1.4;
  max-height: 140px; min-height: 42px;
}
.send { background: var(--primary); border: 0; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: opacity .15s; }
.send:disabled { opacity: .4; cursor: default; }
.send svg { fill: #fff; width: 18px; height: 18px; margin-left: 2px; }
.counter { text-align: right; font-size: 11px; color: var(--muted); height: 14px; margin: 2px 6px 0; }
.counter.over { color: var(--danger); }
