* { box-sizing: border-box; }
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #f0f3f8;
  color: #212529;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
html.keyboard-open #composer {
  padding-bottom: 8px;
}
#bar {
  flex: 0 0 auto;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 6px 12px;
  background: #0665d0;
  color: #fff;
  overflow: visible;
}
.bar-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.bar-title { font-weight: 600; font-size: 14px; letter-spacing: 0.02em; }
html.embedded .bar-heading { display: none; }
html.embedded #bar { justify-content: flex-start; }
html.embedded #bar-meta { max-width: 100%; }
#online-count {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.95;
  white-space: nowrap;
}
#bar-meta {
  font-size: 12px;
  opacity: 0.95;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.bar-who {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}
.bar-who > .bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 8em;
}
.bar-who > .nameplate {
  max-width: none;
  overflow: visible;
  margin-left: 6px;
  flex-shrink: 0;
}
#bar-meta button {
  margin-left: 0;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 7px;
  cursor: pointer;
}
#bar-meta .bar-gap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 11px;
}
#bar-meta .bar-gap select {
  background: transparent;
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 4px;
  cursor: pointer;
}
#bar-meta .bar-gap select option {
  color: #0f172a;
  background: #fff;
}
#login-banner, #ban-banner {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}
#login-banner { background: #e8f1fb; color: #054d9e; }
#ban-banner { background: #fef2f2; color: #991b1b; }
#pin-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 12px;
  background: #e8f1fb;
  color: #054d9e;
  border-bottom: 1px solid #c5daf3;
  font-size: 13px;
  cursor: pointer;
}
#pin-bar:hover {
  background: #d9e9f8;
}
#pin-bar[hidden] { display: none; }
.pin-label {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  background: #0665d0;
  border-radius: 3px;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  letter-spacing: 0.04em;
}
.pin-body {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}
.pin-author {
  font-weight: 600;
  color: #0665d0;
  margin-right: 6px;
}
.pin-text {
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pin-img-hint { color: #054d9e; }
#pin-bar .pin-unpin {
  flex-shrink: 0;
  background: none;
  border: 0;
  color: #0665d0;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  white-space: nowrap;
}
.msg-pinned-mark {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #0665d0;
}
.msg-recalled-mark {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fff7ed;
  border-radius: 8px;
  padding: 0 6px;
  line-height: 18px;
}
.msg-recalled-placeholder {
  color: #6c757d;
  font-size: 13px;
}
.msg.msg-jump {
  background: #e8f1fb;
  box-shadow: 0 0 0 2px #0665d0;
}
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 14px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.day-sep {
  text-align: center;
  color: #6c757d;
  font-size: 11px;
  margin: 10px 0 8px;
}
.msg {
  position: relative;
  margin: 0 0 10px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.msg-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 3px;
}
.msg-head .nameplate { flex-shrink: 0; }
.msg-name { font-weight: 600; color: #0665d0; }
.msg-email {
  font-weight: 400;
  font-size: 11px;
  color: #6c757d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.nameplate {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 7px;
  height: 18px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.nameplate-admin,
.msg-admin {
  color: #7a4a00;
  background: linear-gradient(180deg, #ffe9a8 0%, #f5c84c 100%);
  border: 1px solid #d4a017;
}
.nameplate-mod,
.msg-mod {
  color: #3d4a59;
  background: linear-gradient(180deg, #f3f5f7 0%, #c5ccd3 100%);
  border: 1px solid #8b96a3;
}
.user-meta .nameplate { margin-left: 6px; }
.msg-time { margin-left: auto; color: #6c757d; font-size: 11px; }
.msg-text { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg-img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  margin-top: 6px;
  border-radius: 8px;
  cursor: zoom-in;
}
.msg-actions {
  display: none;
  margin-top: 6px;
  gap: 8px;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg-actions.has-recall { display: flex; }
.msg-actions button, #banned-list button, #user-list button {
  background: none;
  border: 0;
  color: #0665d0;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.msg-actions button.danger, #banned-list button, #user-list button.danger { color: #b91c1c; }
#user-list .user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 10px;
  flex-shrink: 0;
}
#user-list .user-role-hint {
  margin-left: 6px;
  font-size: 11px;
  color: #6c757d;
  white-space: nowrap;
}
#admin-banned, #admin-users {
  flex: 0 0 auto;
  max-height: 28%;
  overflow: auto;
  border-top: 1px solid #e2e8f2;
  background: #fff;
  padding: 8px 12px;
}
.admin-panel-head { font-size: 12px; color: #6c757d; margin-bottom: 4px; }
#banned-list, #user-list { list-style: none; margin: 0; padding: 0; }
#banned-list li, #user-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 3px 0; font-size: 13px; }
#user-list .user-meta { min-width: 0; }
#user-list .user-email, #banned-list .user-email { display: block; font-size: 11px; color: #6c757d; word-break: break-all; }
#composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e2e8f2;
}
#composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#composer.disabled { opacity: 0.55; pointer-events: none; }
#send-gap-hint {
  font-size: 11px;
  color: #6c757d;
  line-height: 1.3;
  padding: 0 2px;
}
#text {
  flex: 1;
  resize: none;
  border: 1px solid #d4dcec;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  max-height: 120px;
  min-height: 38px;
  outline: none;
}
#text:focus { border-color: #0665d0; }
#send, .icon-btn span {
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: #0665d0;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.icon-btn span { background: #054d9e; }
#send:hover, .icon-btn span:hover { background: #0553ab; }
#send:disabled { opacity: 0.6; cursor: default; }
#empty {
  text-align: center;
  color: #6c757d;
  padding: 32px 12px;
  font-size: 13px;
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  cursor: zoom-out;
}
.lightbox img { max-width: 96%; max-height: 96%; }
