:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --sidebar: #f8fafc;
  --chat: #f7f8fa;
  --room-active: #eef4ff;
  --mine-bubble: #95ec69;
  --other-bubble: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --border: #e2e8f0;
  --soft-border: #edf2f7;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #ff4d4f;
  --danger-soft: #fff1f2;
  --success: #18a058;
  --success-soft: #ecfdf3;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover {
  border-color: #cbd5e1;
  background: #e2e8f0;
}

button[type="submit"],
.tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button[type="submit"]:hover {
  background: var(--primary-dark);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #a5b4fc;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  min-height: 58px;
  max-height: 160px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.5;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.brand {
  padding: 18px 18px 10px;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-panel,
.session-card,
.room-section,
.admin-section {
  padding: 12px 16px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--soft-border);
  border-bottom: 1px solid var(--soft-border);
  background: rgba(255, 255, 255, 0.62);
}

.session-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.room-section {
  min-height: 0;
  overflow-y: auto;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-section h2,
.admin-section h2,
.admin-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 0;
}

.compact {
  margin-top: 10px;
}

.invite-result {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--soft-border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.invite-result code {
  display: inline-block;
  margin: 4px 0;
  font-size: 16px;
  font-weight: 700;
}

.room-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.room-empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 30px 18px;
  border: 1px solid #eef2f7;
  border-radius: 20px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.room-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.room-empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: #f1f5f9;
  font-size: 24px;
}

.room-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.room-empty-actions button {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
}

.room-empty-actions button.primary,
.welcome-empty-actions button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.room-empty-actions button.primary:hover,
.welcome-empty-actions button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.room-item {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 12px 42px 12px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(31, 35, 41, 0.04);
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.room-item:hover {
  border-color: #d4e6ff;
  background: #f9fbff;
}

.room-item.active {
  border-color: #c7ddff;
  background: var(--room-active);
  box-shadow: inset 3px 0 0 var(--primary), 0 1px 2px rgba(31, 35, 41, 0.04);
}

.room-item strong {
  display: block;
}

.room-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.room-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
}

.room-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 4px;
}

.room-actions button {
  min-height: 32px;
  font-size: 13px;
}

.current-room-badge {
  color: var(--success);
  font-size: 13px;
}

.chat-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  min-width: 0;
  height: 100vh;
  background: var(--chat);
  --chat-input-height: 160px;
}

.empty-chat {
  display: grid;
  align-content: center;
  justify-content: center;
  gap: 8px;
  height: 100vh;
  padding: 96px 24px 24px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.welcome-empty-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(520px, calc(100vw - 48px));
  padding: 38px 32px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

.welcome-empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 18px;
  background: var(--primary-soft);
  font-size: 28px;
}

.welcome-empty-card h2,
.welcome-empty-card p {
  margin: 0;
}

.welcome-empty-card h2 {
  color: var(--text);
  font-size: 24px;
}

.welcome-empty-card small {
  color: var(--subtle);
}

.welcome-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.welcome-empty-actions button {
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
}

.empty-chat h2,
.empty-chat p {
  margin: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--soft-border);
  background: #fff;
}

.chat-header strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
}

.chat-header span {
  display: block;
  margin-top: 4px;
  color: #666666;
  font-size: 13px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

.mobile-back {
  display: none;
}

.chat-drop-zone {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.chat-drop-zone.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -10px;
  background: #edf6ff;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  padding: 18px 22px;
}

.chat-empty-message {
  align-self: center;
  justify-self: center;
  margin: 0;
  color: #9aa5b5;
  font-size: 13px;
  line-height: 1.4;
}

.new-message-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  min-height: 32px;
  padding: 0 14px;
  border-color: #c9def8;
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  box-shadow: 0 10px 24px rgba(47, 128, 237, 0.14);
  transform: translateX(-50%);
}

.room-description {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message {
  display: grid;
  gap: 4px;
  max-width: 70%;
  word-break: break-word;
}

.chat-message.mine {
  justify-self: end;
  justify-items: end;
}

.chat-message.other {
  justify-self: start;
  justify-items: start;
}

.chat-message-meta {
  color: #999999;
  font-size: 12px;
}

.message-bubble {
  display: grid;
  gap: 8px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--other-bubble);
  color: #000000;
  box-shadow: 0 1px 2px rgba(31, 35, 41, 0.08);
}

.chat-message.mine .message-bubble {
  border-color: transparent;
  background: var(--mine-bubble);
  box-shadow: 0 1px 2px rgba(47, 112, 47, 0.12);
}

.chat-message.other .message-bubble {
  border-color: #e5e5e5;
  background: var(--other-bubble);
}

.message-located .message-bubble {
  outline: 2px solid rgba(39, 111, 191, 0.45);
  outline-offset: 2px;
}

.chat-system-message {
  justify-self: center;
  max-width: 90%;
  padding: 4px 10px;
  color: #999999;
  font-size: 12px;
  text-align: center;
}

.chat-system-message.recalled {
  border-radius: 0;
  background: transparent;
}

.reply-quote {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 0;
  padding: 6px;
  border: 0;
  border-left: 3px solid #4f8cff;
  border-radius: 6px;
  background: #f5f7fa;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.reply-quote strong {
  overflow: hidden;
  color: #334155;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chat-image {
  display: block;
  max-width: min(260px, 64vw);
  max-height: 220px;
  border-radius: 6px;
}

.chat-image-button {
  padding: 0;
  border: 0;
  background: transparent;
}

.local-upload-status {
  color: var(--muted);
}

.local-upload-status.failed {
  color: var(--danger);
}

.image-retry-button {
  width: max-content;
  min-height: 28px;
  padding: 0 10px;
  color: var(--danger);
  font-size: 12px;
}

.chat-audio {
  display: none;
}

.voice-message {
  min-width: 96px;
}

.voice-play-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: #111827;
  font-size: 13px;
  font-weight: 600;
}

.chat-message.other .voice-play-button {
  background: #f1f5f9;
}

.voice-play-button.playing {
  background: #e0f2fe;
  color: #0369a1;
}

.voice-play-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  font-size: 12px;
}

.voice-duration {
  white-space: nowrap;
}

.chat-file {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: min(360px, 72vw);
  padding: 10px;
  border: 1px solid #eaeaea;
  border-radius: 12px;
  background: #ffffff;
}

.chat-file-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 10px;
  background: #eef5ff;
  color: #2f80ed;
  font-size: 12px;
  font-weight: 700;
}

.file-icon-pdf {
  background: #fff1f0;
  color: #cf1322;
}

.file-icon-doc {
  background: #eaf3ff;
  color: #1d63d8;
}

.file-icon-xls {
  background: #eaf8ef;
  color: #16833a;
}

.file-icon-ppt,
.file-icon-zip {
  background: #fff7e6;
  color: #d46b08;
}

.file-icon-txt {
  background: #f2f3f5;
  color: #606873;
}

.chat-file-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.chat-file-main strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-file-main span {
  color: var(--muted);
  font-size: 12px;
}

.chat-file-download {
  display: inline-grid;
  min-height: 32px;
  padding: 0 12px;
  place-items: center;
  border: 1px solid #c9def8;
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  text-decoration: none;
}

.rename-row textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}

.pending-image-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--soft-border);
  background: #fff;
}

.pending-image-panel img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
}

.reply-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 18px;
  border-top: 1px solid var(--soft-border);
  background: #fff;
}

.reply-panel button {
  min-height: 30px;
}

#reply-jump {
  display: grid;
  justify-items: start;
  min-width: 0;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

#reply-jump strong {
  overflow: hidden;
  max-width: 100%;
  color: #334155;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reply-cancel {
  width: 32px;
  padding: 0;
  font-size: 18px;
}

.message-context-menu {
  position: fixed;
  z-index: 1300;
  display: grid;
  min-width: 120px;
  padding: 6px;
  border: 1px solid var(--soft-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.message-context-menu button {
  justify-content: start;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #1f2937;
  text-align: left;
}

.message-context-menu button:hover {
  background: #f0f7ff;
}

.chat-input-resizer {
  height: 10px;
  border-top: 1px solid #eaeaea;
  border-bottom: 1px solid #f0f2f5;
  background: #fff;
  cursor: ns-resize;
  touch-action: none;
}

.chat-input-resizer::before {
  content: "";
  display: block;
  width: 180px;
  height: 4px;
  margin: 3px auto 0;
  border-radius: 999px;
  background: #c6d1df;
}

.chat-input-resizer:hover::before,
.chat-input-resizer.dragging::before {
  background: var(--primary);
}

body.resizing-chat-input,
body.resizing-chat-input * {
  cursor: ns-resize !important;
  user-select: none;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 8px;
  height: var(--chat-input-height);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #eaeaea;
  background: #fff;
}

.chat-form textarea {
  height: 100%;
  min-height: 90px;
  max-height: none;
  border-color: #eaeaea;
  border-radius: 12px;
  background: #fff;
}

.chat-form button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  min-width: 72px;
  height: 100%;
}

.chat-form button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.chat-form button.recording {
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
}

.file-upload-hint {
  padding: 6px 18px 8px;
  border-top: 1px solid #f1f3f5;
  background: #fff;
  color: #8a8f99;
  font-size: 12px;
  line-height: 1.4;
}

.upload-status {
  display: grid;
  gap: 6px;
  padding: 10px 18px;
  border-top: 1px solid var(--soft-border);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.upload-status .error {
  color: var(--danger);
}

.upload-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.upload-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 120ms ease;
}

.admin-section {
  max-height: 36vh;
  overflow-y: auto;
  border-top: 1px solid var(--soft-border);
  background: var(--sidebar);
}

.admin-status,
.admin-item {
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(31, 35, 41, 0.04);
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-item strong,
.admin-item span {
  display: block;
}

.admin-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 35, 41, 0.42);
}

.modal-panel {
  width: min(520px, 100%);
  max-height: min(720px, 92vh);
  overflow-y: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(31, 35, 41, 0.2);
}

.modal-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft-border);
}

.modal-panel h2 {
  margin: 0;
  font-size: 18px;
}

.modal-content,
.member-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.modal-row,
.member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.modal-row strong,
.member-item strong {
  color: var(--text);
}

.rename-row {
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.member-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.member-status.online {
  color: var(--success);
}

.member-kick,
.member-remark {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.member-kick {
  color: var(--danger);
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.9);
}

.image-preview-content {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 48px 2.5vw 24px;
  overscroll-behavior: contain;
}

.image-preview-toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 1001;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}

.image-preview-toolbar button,
.image-preview-close {
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
}

.image-preview-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-image {
  display: block;
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  user-select: none;
  transform-origin: center center;
  cursor: zoom-in;
  transition: transform 120ms ease;
  will-change: transform;
}

.preview-image.zoomed {
  cursor: grab;
  transition: none;
}

.preview-image.dragging {
  cursor: grabbing;
}

.image-preview-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1002;
}

body.preview-open {
  overflow: hidden;
}

.message {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 1100;
  max-width: min(520px, calc(100vw - 32px));
  min-height: 20px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  transform: translateX(-50%);
}

.message:empty {
  display: none;
}

.message.error {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: 100dvh;
  }

  .sidebar {
    width: 100%;
    height: 100dvh;
    border-right: 0;
  }

  body.chat-active .sidebar,
  body.chat-active .empty-chat,
  body.chat-active .admin-section {
    display: none;
  }

  .chat-section {
    height: 100dvh;
  }

  .mobile-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
  }

  .chat-header {
    padding: 10px;
  }

  .chat-header strong {
    font-size: 16px;
  }

  .chat-header-actions button {
    min-width: 52px;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-message {
    max-width: 70%;
  }

  .chat-form {
    grid-template-columns: 1fr auto auto auto auto;
    height: auto;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .chat-input-resizer {
    display: none;
  }

  .chat-form textarea {
    grid-column: 1 / -1;
    height: auto;
    min-height: 44px;
    max-height: 132px;
    resize: none;
    overflow-y: hidden;
  }

  .chat-form button {
    min-width: 60px;
    height: auto;
    font-size: 14px;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    max-height: 86dvh;
    border-radius: 12px 12px 0 0;
  }

  .message {
    top: calc(76px + env(safe-area-inset-top));
    bottom: auto;
    max-width: calc(100vw - 40px);
  }
}

/* P7-3 advanced chat experience */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 58px;
  background: #ffffff;
  border-bottom: 1px solid #f0f0f0;
}

.chat-header span {
  color: #8a8f99;
  font-size: 12px;
}

.chat-messages {
  gap: 8px;
}

.message-time-divider {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  color: #999999;
  font-size: 12px;
  text-align: center;
}

.message-time-divider span {
  position: relative;
  padding: 0 10px;
}

.message-time-divider span::before,
.message-time-divider span::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 26px;
  height: 1px;
  background: #d8dce2;
}

.message-time-divider span::before {
  right: 100%;
}

.message-time-divider span::after {
  left: 100%;
}

.chat-message {
  max-width: 70%;
  gap: 4px;
}

.chat-message-sender {
  color: #999999;
  font-size: 11px;
  line-height: 1.2;
}

.message-bubble {
  min-width: 50px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 18px;
  color: #111111;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chat-message.mine .message-bubble {
  background: #95ec69;
  color: #111111;
}

.chat-message.other .message-bubble {
  border-color: #e5e5e5;
  background: #ffffff;
  color: #111111;
}

.chat-message-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #999999;
  font-size: 11px;
  line-height: 1.2;
}

.message-receipt {
  color: #999999;
}

.message-countdown {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f5f5f5;
  color: #777777;
  font-size: 11px;
  line-height: 1;
}

.message-countdown.warning {
  background: #fff7ed;
  color: #c2410c;
}

.message-countdown.danger {
  background: #fff1f2;
  color: #e11d48;
  animation: countdown-pulse 1.4s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
  }
}

.chat-system-message {
  justify-self: center;
  max-width: 86%;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.chat-system-message.recalled {
  background: #f3f4f6;
}

.input-shell {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input-shell:focus-within {
  border-color: #4f8cff;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
}

.input-toolbar {
  justify-content: flex-start;
}

.input-footer {
  display: flex;
  justify-content: flex-end;
}

.chat-form textarea {
  min-height: 56px;
  border: 0;
  background: transparent;
}

.chat-form textarea:focus {
  box-shadow: none;
}

.chat-file {
  border-color: #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
}

.chat-file-icon {
  border-radius: 12px;
}

@media (max-width: 720px) {
  .chat-message {
    max-width: 78%;
  }

  .message-bubble {
    padding: 10px 13px;
  }

  .message-time-divider {
    margin: 12px 0;
  }

  .input-shell {
    border-radius: 15px;
  }
}

/* Sidebar restructuring: conversation-first layout */
.app-shell {
  grid-template-columns: 328px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.brand {
  padding: 16px 16px 10px;
}

.room-section {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  padding: 8px 10px 10px;
  overflow: hidden;
}

.sidebar-section-header {
  padding: 4px 4px 10px;
}

.sidebar-section-header h2 {
  margin: 0;
  font-size: 17px;
}

.quick-action-button {
  display: inline-grid;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  border-color: #c7d2fe;
  background: #ffffff;
  color: var(--primary);
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.quick-action-button:hover {
  background: var(--primary-soft);
}

body.ordinary-user .quick-action-button {
  width: auto;
  min-width: 62px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

body.ordinary-user .quick-action-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

body.ordinary-user .quick-tabs {
  grid-template-columns: 1fr;
}

.invite-result {
  margin: 0 4px 8px;
  border-color: var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.room-list {
  min-height: 0;
  margin-top: 0;
  overflow-y: auto;
  gap: 0;
}

.room-item {
  display: grid;
  gap: 5px;
  padding: 11px 10px 11px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

.room-item + .room-item {
  margin-top: 2px;
}

.room-item:hover {
  border-color: transparent;
  background: #edf2f7;
  box-shadow: none;
}

.room-item.active {
  border-color: #4f8cff;
  background: #eaf3ff;
  box-shadow: none;
}

.room-title-row strong {
  font-size: 14px;
  font-weight: 700;
}

.room-description {
  display: none;
}

.room-tags {
  gap: 5px;
}

.room-tag {
  min-height: 20px;
  padding: 0 7px;
  font-size: 10.5px !important;
  line-height: 20px;
}

.room-compact-meta {
  gap: 4px 8px;
  font-size: 11.5px;
}

.room-actions {
  align-items: center;
  margin-top: 1px;
}

.room-actions button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.unread-badge {
  position: static;
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  line-height: 20px;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 64px;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
}

.session-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.session-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #f1f5f9;
}

.session-card strong {
  display: block;
  overflow: hidden;
  max-width: 110px;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card span {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.session-pill {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
}

.session-pill.danger {
  background: var(--danger-soft);
  color: #e11d48;
}

.quick-action-panel {
  width: min(460px, 92vw);
  border-radius: 16px;
}

.quick-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 14px 16px 0;
  padding: 4px;
  border-radius: 12px;
  background: #f1f5f9;
}

.quick-tab {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.quick-tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.quick-panel {
  padding: 16px;
}

.quick-form {
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.quick-form input,
.quick-form select {
  min-height: 42px;
  padding: 10px 12px;
}

.quick-form button[type="submit"] {
  min-height: 42px;
}

.join-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.join-inline:focus-within {
  border-color: #4f8cff;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.14);
}

.join-inline input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.join-inline input:focus {
  box-shadow: none;
}

.join-inline button {
  min-width: 72px;
  border: 0;
  border-radius: 0;
  background: var(--primary);
  color: #ffffff;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 920;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.28);
}

.drawer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(620px, 92vw);
  height: 100%;
  background: #f8fafc;
  box-shadow: -24px 0 60px rgba(15, 23, 42, 0.18);
}

.drawer-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.drawer-panel h2 {
  margin: 0;
  font-size: 18px;
}

.drawer .admin-section {
  display: block;
  max-height: none;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  border: 0;
  background: transparent;
}

.drawer .admin-section.hidden {
  display: none !important;
}

body.chat-active .drawer .admin-section {
  display: block;
}

body.chat-active .drawer .admin-section.hidden {
  display: none !important;
}

.drawer .admin-status,
.drawer .admin-item {
  border: 1px solid var(--border);
}

.drawer #admin-refresh {
  margin: 10px 0 16px;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .room-section {
    padding: 8px 8px 10px;
  }

  .session-card {
    min-height: 60px;
  }

  .session-actions {
    gap: 4px;
  }

  .session-pill {
    min-height: 26px;
    padding: 0 7px;
    font-size: 11px;
  }

  .quick-action-panel {
    width: 92vw;
  }

  .drawer-panel {
    width: 100vw;
  }
}

/* P7-3 final chat overrides */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 58px;
  background: #ffffff;
  border-bottom: 1px solid #f0f0f0;
}

.chat-message {
  max-width: 70%;
}

.message-bubble {
  min-width: 50px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 18px;
  color: #111111;
  overflow-wrap: anywhere;
}

.chat-message.mine .message-bubble {
  background: #95ec69;
  color: #111111;
}

.chat-message.other .message-bubble {
  border-color: #e5e5e5;
  background: #ffffff;
  color: #111111;
}

.chat-message-meta,
.chat-message-sender {
  color: #999999;
  font-size: 11px;
}

.chat-system-message,
.chat-system-message.recalled {
  justify-self: center;
  max-width: 86%;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.input-shell {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input-shell:focus-within {
  border-color: #4f8cff;
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
}

.input-toolbar {
  justify-content: flex-start;
}

.input-footer {
  display: flex;
  justify-content: flex-end;
}

.chat-form textarea {
  border: 0;
  background: transparent;
}

.chat-form textarea:focus {
  box-shadow: none;
}

@media (max-width: 720px) {
  .chat-message {
    max-width: 78%;
  }
}

/* TempChat V1.0 final visual polish */
.chat-header {
  min-height: 74px;
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
  background: #ffffff;
}

.chat-title-block {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.chat-header strong {
  font-size: 18px;
  line-height: 1.25;
}

.chat-header span {
  margin-top: 0;
  color: #8a8f99;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.chat-messages {
  padding-right: 30px;
  padding-left: 30px;
}

.chat-message {
  max-width: min(70%, 520px);
  min-width: 50px;
}

.chat-message.mine {
  padding-right: 16px;
}

.chat-message.other {
  padding-left: 16px;
}

.message-bubble {
  min-width: 50px;
  max-width: min(70vw, 520px);
  padding: 10px 14px;
  border-radius: 18px;
}

.message-countdown {
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f5f5f5;
  color: #6f6f6f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

.message-countdown.warning {
  background: #fff7ed;
  color: #c2410c;
}

.message-countdown.danger {
  background: #fff1f2;
  color: #e11d48;
}

.room-list {
  padding: 0 2px;
}

.room-item {
  padding: 12px 10px 12px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid #edf2f7;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.room-item + .room-item {
  margin-top: 0;
}

.room-item:hover {
  background: #edf2f7;
  box-shadow: none;
}

.room-item.active {
  border-left-color: #4f8cff;
  border-bottom-color: transparent;
  border-radius: 10px;
  background: #eaf3ff;
  box-shadow: none;
}

.room-title-row strong {
  font-size: 14px;
}

.room-tags {
  display: none;
}

.room-compact-meta {
  color: #7a7a7a;
  font-size: 11.5px;
}

.room-actions {
  display: flex;
  margin-top: 4px;
}

.room-actions button {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
}

.send-button,
.chat-form .send-button {
  width: 72px;
  min-width: 72px;
  height: 36px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .chat-header {
    min-height: 62px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .chat-header strong {
    font-size: 16px;
  }

  .chat-header span {
    line-height: 1.35;
  }

  .chat-messages {
    padding-right: 12px;
    padding-left: 12px;
  }

  .chat-message {
    max-width: min(78%, 520px);
  }

  .chat-message.mine {
    padding-right: 4px;
  }

  .chat-message.other {
    padding-left: 4px;
  }

  .message-bubble {
    max-width: 100%;
  }
}

/* UI 2.1 density and hierarchy tuning */
#create-room-form,
#join-room-form {
  gap: 16px;
  padding: 16px;
}

#create-room-form label,
#join-room-form label,
.auth-panel label {
  gap: 8px;
}

#create-room-form input,
#create-room-form select,
#join-room-form input,
.auth-panel input {
  min-height: 42px;
  padding: 10px 12px;
}

#create-room-form button[type="submit"],
#join-room-form button[type="submit"],
#submit-button {
  min-height: 42px;
}

.room-item {
  gap: 9px;
  padding: 13px 14px;
}

.room-title-row {
  align-items: flex-start;
}

.room-title-row strong {
  font-size: 15px;
  line-height: 1.35;
}

.room-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.room-tag {
  display: inline-flex !important;
  align-items: center;
  width: max-content;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px !important;
  font-weight: 600;
  line-height: 22px;
}

.room-tag.group {
  background: #eff6ff;
  color: #2563eb;
}

.room-tag.private {
  background: #f5f3ff;
  color: #7c3aed;
}

.room-tag.open {
  background: #ecfdf3;
  color: #15803d;
}

.room-tag.locked {
  background: #fff7ed;
  color: #c2410c;
}

.room-tag.closed {
  background: #fff1f2;
  color: #e11d48;
}

.room-compact-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: #7a7a7a;
  font-size: 12px;
  line-height: 1.35;
}

.room-compact-meta span {
  display: inline-flex;
  align-items: center;
  color: #7a7a7a;
}

.room-actions {
  margin-top: 2px;
}

.room-actions button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
}

.room-actions [data-action="select-room"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.room-actions [data-action="select-room"]:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.room-actions [data-action="copy-invite"],
.room-actions [data-action="new-invite"],
.room-actions [data-action="expired-invite"] {
  border-color: #c7d2fe;
  background: #ffffff;
  color: var(--primary);
  font-weight: 500;
}

.current-room-badge {
  align-self: center;
  color: var(--success);
  font-size: 12px;
}

.admin-item {
  padding: 11px 12px;
}

.admin-actions {
  gap: 6px;
  margin-top: 7px;
}

.admin-actions button {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.chat-header {
  min-height: 60px;
  padding: 10px 18px;
  border-bottom: 1px solid #f0f0f0;
}

.chat-header span {
  margin-top: 3px;
  color: #8a8f99;
  font-size: 12px;
}

.chat-message {
  gap: 3px;
}

.chat-message-meta {
  color: #a0a0a0;
  font-size: 11px;
  line-height: 1.25;
}

.message-bubble {
  padding: 12px 15px;
}

.modal-actions button {
  border-radius: 999px;
}

@media (max-width: 720px) {
  #create-room-form,
  #join-room-form {
    padding: 14px;
  }

  .room-item {
    padding: 12px;
  }

  .room-actions button,
  .admin-actions button {
    min-height: 28px;
    padding: 0 9px;
    font-size: 12px;
  }

  .chat-header {
    min-height: 54px;
    padding: 8px 10px;
  }

  .chat-header span {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Modern chat UI polish */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.brand {
  padding: 20px 18px 12px;
}

.brand h1 {
  font-size: 22px;
}

.brand p {
  color: var(--subtle);
}

.auth-panel,
.room-section,
.admin-section {
  padding: 12px 14px;
}

.auth-panel,
.session-card,
.create-room-form,
.join-room-form,
.admin-status,
.admin-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.auth-panel,
.session-card {
  margin: 0 14px 12px;
}

.session-card {
  padding: 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.tabs {
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: #f1f5f9;
}

.tab {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form.compact {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.form button[type="submit"],
.send-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.form button[type="submit"]:hover,
.send-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.room-list,
.admin-list {
  gap: 10px;
}

.room-item {
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.room-item:hover {
  border-color: #c7d2fe;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.room-item.active {
  border-color: #c7d2fe;
  background: var(--room-active);
  box-shadow: inset 3px 0 0 var(--primary), var(--shadow-sm);
}

.room-item span,
.admin-item span {
  color: var(--subtle);
  line-height: 1.45;
}

.room-description {
  color: var(--muted);
}

.room-actions,
.admin-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.room-actions button,
.admin-actions button,
.modal-actions button,
.chat-header-actions button,
.member-kick,
.member-remark,
#notification-button,
#logout-button,
#admin-refresh {
  width: auto;
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.room-actions .wide {
  flex: 0 0 auto;
}

[data-action="select-room"],
[data-action="copy-invite"],
[data-room-info-action="copy-invite"],
[data-room-info-action="new-invite"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

[data-action="select-room"]:hover,
[data-action="copy-invite"]:hover,
[data-room-info-action="copy-invite"]:hover,
[data-room-info-action="new-invite"]:hover {
  border-color: #c7d2fe;
  background: #e0e7ff;
}

[data-room-info-action="clear-room"],
[data-room-info-action="leave-room"],
[data-room-info-action="close-invite"],
[data-room-info-action="expire-invite-now"],
[data-admin-action="ban-user"],
[data-admin-action="dissolve-room"],
.member-kick {
  border-color: #fecdd3;
  background: var(--danger-soft);
  color: #e11d48;
}

[data-room-info-action="clear-room"]:hover,
[data-room-info-action="leave-room"]:hover,
[data-room-info-action="close-invite"]:hover,
[data-room-info-action="expire-invite-now"]:hover,
[data-admin-action="ban-user"]:hover,
[data-admin-action="dissolve-room"]:hover,
.member-kick:hover {
  background: #ffe4e6;
}

.chat-section {
  background: var(--chat);
  --chat-input-height: 132px;
}

.chat-header {
  min-height: 66px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.chat-title-block {
  min-width: 0;
}

.chat-header strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header span {
  color: var(--muted);
}

.chat-messages {
  gap: 12px;
  padding: 22px 26px;
}

.chat-message-meta {
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.35;
}

.message-bubble {
  padding: 11px 14px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  line-height: 1.5;
}

.chat-message.mine .message-bubble {
  background: var(--mine-bubble);
  box-shadow: 0 2px 8px rgba(45, 150, 64, 0.14);
}

.chat-message.other .message-bubble {
  border-color: var(--border);
  background: #ffffff;
}

.chat-system-message {
  color: var(--subtle);
  font-size: 12px;
}

.reply-quote {
  border-left-color: var(--primary);
  background: #f8fafc;
  color: var(--muted);
}

.chat-file {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.chat-file-download {
  border-color: #c7d2fe;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.pending-image-panel,
.reply-panel,
.file-upload-hint,
.upload-status {
  border-top: 1px solid var(--border);
}

.chat-input-resizer {
  height: 6px;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.chat-input-resizer::before {
  width: 120px;
  height: 3px;
  margin-top: 2px;
  background: #cbd5e1;
}

.chat-form {
  display: block;
  height: auto;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.input-shell {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.chat-form textarea {
  height: calc(var(--chat-input-height) - 74px);
  min-height: 48px;
  max-height: 150px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  resize: none;
  box-shadow: none;
}

.chat-form textarea:focus {
  box-shadow: none;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.input-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-form .icon-button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border-color: transparent;
  border-radius: 9px;
  background: #f8fafc;
  color: #475569;
  font-size: 17px;
}

.chat-form .icon-button:hover {
  border-color: var(--border);
  background: #f1f5f9;
}

.chat-form .icon-button.recording {
  border-color: #fecdd3;
  background: var(--danger-soft);
  color: #e11d48;
}

.chat-form .send-button {
  width: auto;
  min-width: 58px;
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
}

.file-upload-hint {
  padding: 7px 20px 9px;
  color: var(--subtle);
}

.message {
  top: 78px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--success);
  box-shadow: var(--shadow-md);
}

.message.error {
  color: #e11d48;
}

.modal-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.20);
}

.message-context-menu {
  border-color: var(--border);
  border-radius: 10px;
}

.message-bubble,
.message-content,
.message-text {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.action-sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 1280;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 220ms ease;
}

.action-sheet-mask.is-open {
  opacity: 1;
}

.message-context-menu.mobile-sheet,
.action-sheet-panel {
  left: 0 !important;
  right: 0;
  bottom: 0;
  top: auto !important;
  z-index: 1300;
  width: auto;
  min-width: 0;
  gap: 8px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 16px 16px 0 0;
  background: #ffffff;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform 240ms ease;
}

.message-context-menu.mobile-sheet::before,
.action-sheet-panel::before {
  content: "";
  justify-self: center;
  width: 42px;
  height: 4px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: #d1d5db;
}

.message-context-menu.mobile-sheet.is-open,
.action-sheet-panel.is-open {
  transform: translateY(0);
}

.message-context-menu.mobile-sheet button,
.action-sheet-panel button {
  justify-content: center;
  min-height: 44px;
  border-radius: 12px;
  background: #f8fafc;
  color: #111827;
  font-weight: 600;
  text-align: center;
}

@media (max-width: 720px) {
  .brand {
    padding: 18px 14px 10px;
  }

  .auth-panel,
  .session-card {
    margin-right: 12px;
    margin-left: 12px;
  }

  .chat-section {
    grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  }

  .chat-header {
    min-height: 58px;
    gap: 8px;
    padding: 8px 10px;
  }

  .chat-title-block {
    flex: 1;
  }

  .mobile-back,
  .chat-header-actions button {
    min-width: 44px;
    min-height: 32px;
    padding: 0 9px;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .chat-messages {
    padding: 14px 12px 18px;
  }

  .chat-message {
    max-width: 78%;
  }

  .chat-form {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .input-shell {
    gap: 6px;
    padding: 8px;
    border-radius: 13px;
  }

  .chat-form textarea {
    min-height: 42px;
    max-height: 112px;
  }

  .chat-form .icon-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    font-size: 16px;
  }

  .chat-form .send-button {
    min-width: 54px;
    height: 32px;
    min-height: 32px;
    padding: 0 12px;
  }

  .file-upload-hint {
    padding: 6px 12px 8px;
  }

  .message {
    top: calc(64px + env(safe-area-inset-top));
  }

  .room-actions,
  .admin-actions,
  .modal-actions {
    gap: 6px;
  }
}

/* Sidebar compact final tuning */
.app-shell {
  grid-template-columns: 360px minmax(0, 1fr);
}

.room-section {
  padding: 10px 10px 12px;
}

.room-list {
  padding: 0 2px;
  gap: 8px;
}

.room-item {
  min-height: 96px;
  padding: 12px 14px;
  gap: 7px;
  border-left-width: 3px;
  border: 1px solid #edf2f7;
  border-left: 3px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  overflow: visible;
}

.room-item + .room-item {
  margin-top: 8px;
}

.room-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-title-row strong {
  flex: 1;
  font-size: 15px;
  line-height: 1.35;
}

.room-tags {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.room-tag {
  min-height: 20px;
  padding: 0 7px;
  font-size: 11px !important;
  line-height: 20px;
}

.room-compact-meta {
  gap: 4px 10px;
  font-size: 12px;
  line-height: 1.35;
}

.room-actions {
  display: none;
  margin-top: 3px;
  gap: 8px;
}

.room-actions button {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
}

.current-room-badge {
  font-size: 11px;
}

.room-item:hover .room-actions,
.room-item.active .room-actions {
  display: flex;
}

.room-item:hover {
  border-color: #e2e8f0;
  border-left-color: transparent;
  border-radius: 12px;
  background: #ffffff;
}

.room-item.active {
  border-color: #dbeafe;
  border-left-color: #4f8cff;
  border-radius: 12px;
  background: #eaf3ff;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .room-item {
    min-height: 104px;
    padding: 12px;
  }

  .room-actions {
    display: flex;
  }
}

/* Room list stable rollback: readable cards with visible actions */
.app-shell {
  grid-template-columns: 360px minmax(0, 1fr);
}

.room-section {
  padding: 10px 12px 12px;
}

.room-list {
  display: grid;
  gap: 10px;
  padding: 0;
}

.room-item,
.room-item:hover,
.room-item.active {
  display: grid;
  min-height: 132px;
  gap: 8px;
  padding: 13px 14px;
  overflow: visible;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.room-item + .room-item {
  margin-top: 0;
}

.room-item:hover {
  border-color: #dbeafe;
  background: #f8fbff;
}

.room-item.active {
  border-color: #c7d2fe;
  border-left-color: #4f8cff;
  background: #eaf3ff;
}

.room-title-row {
  align-items: center;
}

.room-title-row strong {
  font-size: 15px;
  line-height: 1.35;
}

.room-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.room-tag {
  min-height: 21px;
  padding: 0 8px;
  font-size: 11px !important;
  line-height: 21px;
}

.room-compact-meta {
  gap: 4px 10px;
  color: #7a7a7a;
  font-size: 12px;
  line-height: 1.4;
}

.room-actions,
.room-item:hover .room-actions,
.room-item.active .room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.room-actions button {
  min-height: 32px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
}

.current-room-badge {
  align-self: center;
  font-size: 12px;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .room-section {
    padding: 8px 10px 10px;
  }

  .room-item,
  .room-item:hover,
  .room-item.active {
    min-height: 132px;
    padding: 12px;
  }
}

/* Emergency room card overlap fix */
.room-list {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
}

.room-item,
.room-item:hover,
.room-item.active {
  position: relative;
  display: grid;
  height: auto;
  min-height: 140px;
  max-height: none;
  overflow: visible;
  padding: 13px 14px 12px;
  margin: 0 0 12px;
  box-sizing: border-box;
}

.room-actions,
.room-item:hover .room-actions,
.room-item.active .room-actions {
  position: static;
  display: flex;
  flex-wrap: wrap;
  height: auto;
  min-height: 32px;
  max-height: none;
  overflow: visible;
  margin-top: 4px;
}

.room-actions button {
  position: static;
  flex: 0 0 auto;
}

/* WeChat-like send button state */
.send-button,
.chat-form .send-button,
.send-button:disabled,
.chat-form .send-button:disabled {
  border-color: #e5e7eb;
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.send-button.send-ready,
.chat-form .send-button.send-ready {
  border-color: #07c160;
  background: #07c160;
  color: #ffffff;
  cursor: pointer;
}

.send-button.send-ready:hover,
.chat-form .send-button.send-ready:hover {
  border-color: #06ad56;
  background: #06ad56;
}

/* P7-4 chat experience refinements */
.chat-message.mine .message-bubble {
  border-radius: 12px 4px 12px 12px;
}

.chat-message.other .message-bubble {
  border-radius: 4px 12px 12px 12px;
}

.chat-message-meta {
  margin-top: 4px;
  color: #b4bac4;
  font-size: 11px;
}

.message-receipt {
  color: #b4bac4;
}

.chat-empty-state {
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  gap: 8px;
  min-width: min(280px, 80vw);
  margin: auto;
  padding: 32px 20px;
  color: rgba(100, 116, 139, 0.72);
  text-align: center;
  pointer-events: none;
}

.chat-empty-state .chat-empty-icon {
  font-size: 34px;
  line-height: 1;
  opacity: 0.72;
}

.chat-empty-state strong {
  color: rgba(71, 85, 105, 0.78);
  font-size: 15px;
  font-weight: 700;
}

.chat-empty-state span {
  font-size: 13px;
  line-height: 1.45;
}

.session-card {
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.session-card:hover {
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.session-avatar {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #eef4ff, #f8fafc);
  color: #4f46e5;
  font-size: 17px;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.08);
}

.session-pill.danger {
  border-color: #f1f5f9;
  background: #f8fafc;
  color: #94a3b8;
}

.session-pill.danger:hover {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #e11d48;
}

.mobile-menu-button {
  display: none;
}

@media (max-width: 768px) {
  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: #475569;
    font-size: 18px;
    line-height: 1;
  }

  body.chat-active .sidebar {
    display: none;
  }

  body.chat-active.sidebar-open .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: grid;
    width: min(360px, 88vw);
    height: 100dvh;
    border-right: 1px solid var(--border);
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.18);
  }

  body.chat-active.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.22);
    pointer-events: none;
  }

  body.chat-active.sidebar-open .mobile-menu-button {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: min(calc(88vw + 8px), 368px);
    z-index: 45;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  }

  .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .chat-empty-state {
    padding: 28px 18px;
  }
}

/* Final UI detail polish */
.chat-messages.empty {
  align-content: center;
}

.chat-empty-state {
  opacity: 0.65;
}

.room-list,
.admin-list,
.member-list,
.drawer-panel {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.room-list::-webkit-scrollbar,
.admin-list::-webkit-scrollbar,
.member-list::-webkit-scrollbar,
.drawer-panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.room-list::-webkit-scrollbar-track,
.admin-list::-webkit-scrollbar-track,
.member-list::-webkit-scrollbar-track,
.drawer-panel::-webkit-scrollbar-track {
  background: transparent;
}

.room-list::-webkit-scrollbar-thumb,
.admin-list::-webkit-scrollbar-thumb,
.member-list::-webkit-scrollbar-thumb,
.drawer-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}

.room-list:hover::-webkit-scrollbar-thumb,
.admin-list:hover::-webkit-scrollbar-thumb,
.member-list:hover::-webkit-scrollbar-thumb,
.drawer-panel:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.25);
}

/* Room info modal final polish */
#room-info-modal .modal-panel {
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.12), 0 12px 40px rgba(15, 23, 42, 0.12);
}

#room-info-content {
  display: grid;
  gap: 12px;
}

.room-info-section-title,
.room-info-edit h3 {
  margin: 0;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.room-info-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid #e7ecf4;
  border-radius: 14px;
  background: linear-gradient(135deg, #f8fbff, #ffffff);
}

.room-info-icon {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: #eef4ff;
  color: #4f46e5;
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.08);
}

.room-info-title {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.room-info-title strong {
  overflow: hidden;
  color: #111827;
  font-size: 18px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info-title span {
  overflow: hidden;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid #e7ecf4;
  border-radius: 12px;
  background: #e7ecf4;
}

.room-info-stat {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 76px;
  padding: 12px;
  background: #f8fafc;
}

.room-info-stat span {
  color: #64748b;
  font-size: 12px;
}

.room-info-stat strong {
  color: #111827;
  font-size: 18px;
  line-height: 1.2;
}

.room-info-stat small {
  overflow: hidden;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info-stat.invite {
  gap: 5px;
}

.room-info-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.room-info-inline-actions button {
  width: auto;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border-color: #c7d2fe;
  background: #eef4ff;
  color: #4f46e5;
  font-size: 12px;
}

.room-info-inline-actions button:hover {
  background: #e0e7ff;
}

.room-info-inline-actions button.danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #e11d48;
}

.room-info-inline-actions button.danger:hover {
  background: #ffe4e6;
}

.room-info-stat.destroy {
  background: #fff7ed;
}

.room-info-stat.destroy strong {
  color: #c2410c;
  font-size: 16px;
}

.room-info-lines {
  display: grid;
  gap: 8px;
  padding: 2px 0;
}

#room-info-content .modal-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0;
  color: #64748b;
  font-size: 13px;
}

#room-info-content .modal-row strong {
  color: #1f2937;
  font-weight: 700;
}

#room-info-content .modal-row div {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

#room-info-content .modal-row div span {
  color: #94a3b8;
  font-size: 12px;
}

.room-info-edit {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e7ecf4;
  border-radius: 12px;
  background: #ffffff;
}

#room-info-content .rename-row {
  display: grid;
  gap: 6px;
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

#room-info-content .rename-row input,
#room-info-content .rename-row textarea {
  width: 100%;
  border-color: #dbe3ef;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 12px;
}

.room-info-save-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

#room-info-content [data-room-info-action="save-settings"] {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
  border-color: #4f46e5;
  border-radius: 999px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

#room-info-content [data-room-info-action="save-settings"]:hover {
  border-color: #4338ca;
  background: #4338ca;
}

.room-info-note {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 13px;
}

.room-info-danger-zone {
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.room-info-danger-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.room-info-danger-actions button {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

#room-info-content [data-room-info-action="clear-room"],
#room-info-content [data-room-info-action="leave-room"] {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #e11d48;
}

#room-info-content [data-room-info-action="clear-room"]:hover,
#room-info-content [data-room-info-action="leave-room"]:hover {
  background: #ffe4e6;
}

@media (max-width: 720px) {
  .room-info-hero {
    padding: 14px;
  }

  .room-info-stats {
    grid-template-columns: 1fr 1fr;
  }

  .room-info-stat {
    min-height: 70px;
    padding: 10px;
  }

  .room-info-stat strong {
    font-size: 16px;
  }

  #room-info-content .room-info-actions {
    align-items: stretch;
  }

  .room-info-danger-actions {
    align-items: stretch;
  }
}

/* Final admin drawer and room info density polish */
.room-info-lines {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#room-info-content .room-info-lines .modal-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e7ecf4;
  border-radius: 10px;
  background: #f8fafc;
}

#room-info-content .room-info-lines .modal-row > span {
  color: #94a3b8;
  font-size: 12px;
}

#room-info-content .room-info-lines .modal-row strong {
  color: #111827;
  font-size: 13px;
}

.drawer-panel {
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.12), -18px 0 55px rgba(15, 23, 42, 0.14);
}

.drawer .admin-section {
  display: grid;
  gap: 14px;
}

.drawer .admin-section h3 {
  margin: 4px 0 -4px;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}

.drawer #admin-refresh {
  justify-self: start;
  min-height: 32px;
  margin: 0;
  border-color: #dbe3ef;
  border-radius: 999px;
  background: #ffffff;
  color: #4f46e5;
  font-size: 12px;
}

.drawer #admin-refresh:hover {
  background: #eef4ff;
}

.drawer .admin-status {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-stat-card {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid #e7ecf4;
  border-radius: 12px;
  background: #f8fafc;
}

.admin-stat-card span {
  color: #64748b;
  font-size: 12px;
}

.admin-stat-card strong {
  color: #111827;
  font-size: 22px;
  line-height: 1;
}

.drawer .admin-list {
  display: grid;
  gap: 0;
  overflow: visible;
  border: 1px solid #edf2f7;
  border-radius: 12px;
  background: #ffffff;
}

.drawer .admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.drawer .admin-item:last-child {
  border-bottom: 0;
}

.drawer .admin-item:hover {
  background: #f8fafc;
}

.admin-row-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.admin-row-main strong {
  overflow: hidden;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-main strong span {
  display: inline;
  margin: 0;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.admin-row-main span {
  overflow: hidden;
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.admin-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-tag.role.user {
  background: #f1f5f9;
  color: #64748b;
}

.admin-tag.role.creator {
  background: #eef4ff;
  color: #4f46e5;
}

.admin-tag.role.root {
  background: #f5f3ff;
  color: #7c3aed;
}

.admin-tag.status.normal {
  background: #ecfdf5;
  color: #059669;
}

.admin-tag.status.banned {
  background: #fff1f2;
  color: #e11d48;
}

.drawer .admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
}

.drawer .admin-actions button {
  width: auto;
  min-height: 30px;
  padding: 0 10px;
  border-color: #dbe3ef;
  border-radius: 999px;
  background: #ffffff;
  color: #4f46e5;
  font-size: 12px;
}

.drawer .admin-actions button:hover {
  background: #eef4ff;
}

.drawer .admin-actions button.danger,
.drawer [data-admin-action="ban-user"],
.drawer [data-admin-action="dissolve-room"] {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #e11d48;
}

.drawer .admin-actions button.danger:hover,
.drawer [data-admin-action="ban-user"]:hover,
.drawer [data-admin-action="dissolve-room"]:hover {
  background: #ffe4e6;
}

.drawer .admin-actions button.success,
.drawer [data-admin-action="unban-user"] {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #059669;
}

.drawer .admin-actions button.success:hover,
.drawer [data-admin-action="unban-user"]:hover {
  background: #dcfce7;
}

.admin-room-row {
  grid-template-columns: minmax(0, 1fr) auto !important;
}

@media (max-width: 720px) {
  .room-info-lines {
    grid-template-columns: 1fr;
  }

  .drawer .admin-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-row-tags,
  .drawer .admin-actions {
    justify-content: flex-start;
  }
}

/* Final compact pass for room info modal and admin drawer */
#room-info-modal .modal-panel {
  max-height: min(680px, 92vh);
}

#room-info-content {
  gap: 10px;
}

#room-info-content,
.drawer .admin-section {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

#room-info-content::-webkit-scrollbar,
.drawer .admin-section::-webkit-scrollbar {
  width: 6px;
}

#room-info-content::-webkit-scrollbar-thumb,
.drawer .admin-section::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}

#room-info-content::-webkit-scrollbar-track,
.drawer .admin-section::-webkit-scrollbar-track {
  background: transparent;
}

.room-info-hero {
  padding: 13px 14px;
}

.room-info-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 22px;
}

.room-info-stats {
  gap: 1px;
}

.room-info-stat {
  min-height: 66px;
  gap: 4px;
  padding: 10px;
}

.room-info-stat strong {
  font-size: 16px;
}

.room-info-stat.destroy strong {
  font-size: 14px;
}

.room-info-stat.invite strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info-inline-actions {
  gap: 5px;
  margin-top: 0;
}

.room-info-inline-actions button {
  min-height: 28px;
  padding: 0 8px;
}

.room-info-lines {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

#room-info-content .room-info-lines .modal-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 8px 9px;
}

#room-info-content .room-info-lines .modal-row > span::after {
  content: "：";
}

#room-info-content .room-info-lines .modal-row strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info-edit {
  gap: 8px;
  padding: 10px;
}

.room-info-edit h3 {
  margin-bottom: 0;
}

#room-info-content .rename-row {
  gap: 4px;
  font-size: 12px;
}

#room-info-content .rename-row input,
#room-info-content .rename-row textarea {
  padding: 8px 10px;
}

#room-info-content .rename-row textarea {
  min-height: 58px;
  resize: vertical;
}

.room-info-save-row {
  margin-top: 0;
}

.room-info-danger-zone {
  padding-top: 10px;
}

.room-info-danger-actions button {
  min-height: 32px;
}

.admin-stat-grid {
  gap: 8px;
}

.admin-stat-card {
  min-height: 62px;
  padding: 10px;
}

.admin-stat-card strong {
  font-size: 20px;
}

.drawer .admin-item {
  padding: 10px 12px;
}

.admin-row-main {
  gap: 3px;
}

.admin-row-tags {
  min-width: 140px;
}

.drawer .admin-actions {
  min-width: 160px;
}

.drawer .admin-actions button {
  min-height: 28px;
  padding: 0 9px;
}

.admin-room-row .admin-row-main span {
  white-space: normal;
}

@media (max-width: 720px) {
  .room-info-lines {
    grid-template-columns: 1fr;
  }

  .admin-row-tags,
  .drawer .admin-actions {
    min-width: 0;
  }
}

/* Admin room list final readability polish */
.drawer .admin-room-row {
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center;
  padding: 16px 12px;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease;
}

.drawer .admin-room-row:hover {
  background: #f8fafc;
}

.admin-room-main {
  gap: 7px;
}

.admin-room-title {
  color: #111827;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.admin-room-title span {
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
}

.admin-room-summary {
  color: #64748b !important;
  font-size: 13px !important;
  line-height: 1.45;
}

.admin-room-timing {
  color: #94a3b8 !important;
  font-size: 12px !important;
  line-height: 1.45;
}

.admin-room-timing em {
  color: #ea580c;
  font-style: normal;
  font-weight: 700;
}

.drawer .admin-room-row .admin-actions {
  min-width: 94px;
}

.drawer .admin-room-row [data-admin-action="dissolve-room"] {
  min-height: 32px;
  padding: 0 13px;
  border-color: #fecdd3;
  border-radius: 999px;
  background: #fff1f2;
  color: #e11d48;
  font-size: 12px;
  font-weight: 700;
}

.drawer .admin-room-row [data-admin-action="dissolve-room"]:hover {
  border-color: #e11d48;
  background: #e11d48;
  color: #ffffff;
}

.admin-messages-panel {
  width: min(720px, 94vw);
  max-height: min(760px, 90vh);
}

.admin-messages-panel header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 12px;
}

.admin-messages-content {
  display: grid;
  gap: 12px;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}

.admin-messages-room-title,
.admin-messages-empty {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
}

.admin-messages-room-title strong,
.admin-messages-empty strong {
  color: #111827;
  font-size: 16px;
}

.admin-messages-room-title span,
.admin-messages-empty span {
  color: #64748b;
  font-size: 13px;
}

.admin-message-list {
  display: grid;
  gap: 10px;
}

.admin-message-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  background: #ffffff;
}

.admin-message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: #64748b;
  font-size: 12px;
}

.admin-message-meta strong {
  color: #111827;
  font-size: 13px;
}

.admin-message-meta em {
  color: #ea580c;
  font-style: normal;
  font-weight: 700;
}

.admin-message-body {
  color: #111827;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.admin-message-body p {
  margin: 0;
  white-space: pre-wrap;
}

.admin-message-thumb {
  display: block;
  max-width: min(240px, 70vw);
  max-height: 180px;
  border-radius: 10px;
  object-fit: cover;
}

.admin-message-image-button {
  display: inline-block;
  width: max-content;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

.admin-message-image-button:hover {
  background: transparent;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.admin-message-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-message-file span,
.admin-message-muted,
.admin-message-voice {
  color: #64748b;
}

.admin-message-voice {
  display: grid;
  gap: 8px;
}

.admin-message-voice span {
  font-weight: 700;
}

.admin-message-voice audio {
  width: min(320px, 100%);
  max-width: 100%;
}

.admin-message-file a {
  color: #4f46e5;
  font-weight: 700;
  text-decoration: none;
}

/* Mobile safe spacing polish */
.brand {
  padding-top: calc(20px + env(safe-area-inset-top));
}

.session-card {
  margin-bottom: 12px;
}

/* TempChat brand logo */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: block;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

@media (max-width: 720px) {
  .drawer .admin-room-row {
    grid-template-columns: 1fr !important;
    padding: 14px 12px;
  }

  .drawer .admin-room-row .admin-actions {
    min-width: 0;
    justify-content: flex-start;
  }
}

/* Admin final visual finishing touches */
.drawer-panel h2 {
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.drawer .admin-room-row {
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease;
}

.drawer .admin-room-row:hover {
  background: #f8fafc;
}

.admin-room-title {
  font-size: 19px;
}

.admin-room-title span {
  margin-left: 4px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.admin-room-summary {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 1px !important;
}

.admin-room-chip {
  display: inline-flex !important;
  align-items: center;
  min-height: 24px;
  margin: 0 !important;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px !important;
  font-weight: 700;
  line-height: 1;
}

.admin-room-chip.owner {
  background: #f5f3ff;
  color: #7c3aed;
}

.admin-room-chip.members {
  background: #eef4ff;
  color: #4f46e5;
}

.admin-room-chip.status {
  background: #ecfdf5;
  color: #059669;
}

.admin-room-chip.invite {
  background: #fffbeb;
  color: #b45309;
}

.admin-room-chip.active-messages {
  background: #f0f9ff;
  color: #0369a1;
}

.admin-room-timing em {
  color: #ea580c;
  font-weight: 700;
}

.drawer .admin-room-row [data-admin-action="view-active-messages"].muted {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #94a3b8;
}

.drawer .admin-room-row [data-admin-action="view-active-messages"].muted:hover {
  background: #f1f5f9;
  color: #64748b;
}

.drawer .admin-room-row [data-admin-action="dissolve-room"]:hover {
  border-color: #e11d48;
  background: #e11d48;
  color: #ffffff;
}
