/* ==========================================================================
   Uncensored Room · UI styles (responsive: desktop / tablet / mobile)
   ========================================================================== */
:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --green-soft: #e7f8ee;
  --bubble-mine: #95ec69;
  --text: #1b221e;
  --text-2: #667069;
  --text-3: #98a29c;
  --line: #e9efeb;
  --line-strong: #dfe7e2;
  --bg: #f4f8f5;
  --card: #ffffff;
  --danger: #e64340;
  --warn-bg: #fff8e6;
  --warn-line: #f2e2bf;
  --warn-text: #8a6a2a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, system-ui, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

button, input, textarea { font-family: inherit; }

/* ============================ Sign in / Sign up ============================ */
.auth-body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 12% 18%, #d9f5e6 0%, rgba(217, 245, 230, 0) 60%),
    radial-gradient(700px 500px at 88% 82%, #cfeedb 0%, rgba(207, 238, 219, 0) 62%),
    linear-gradient(140deg, #f0fbf5 0%, #e5f5ec 55%, #dff3e9 100%);
}

.auth-wrap {
  display: flex;
  align-items: center;
  gap: 56px;
  width: 100%;
  max-width: 1180px;
  justify-content: center;
}

.auth-brand { max-width: 480px; }

.privacy-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(7, 193, 96, .12);
  color: #0a7a45;
  border: 1px solid rgba(7, 193, 96, .3);
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; letter-spacing: .2px;
  margin-bottom: 16px;
}

.auth-brand h1 { font-size: 28px; line-height: 1.38; margin: 0 0 12px; letter-spacing: .5px; color: #123324; }
.auth-brand p { font-size: 13.5px; line-height: 1.8; color: #5c7166; margin: 0; }

.privacy-list {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.privacy-list li { font-size: 12.5px; color: #5c7166; line-height: 1.6; }
.privacy-list li b { color: #17563a; font-weight: 600; margin-right: 6px; }

/* Homepage "No phone. No email." highlight tag */
.zero-bar {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 4px;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(7, 193, 96, .14), rgba(7, 193, 96, .05));
  border: 1px solid rgba(7, 193, 96, .32);
}
.zero-bar b {
  font-size: 18px; font-weight: 700; color: #ffffff;
  background: #07c160; padding: 4px 10px; border-radius: 8px;
  letter-spacing: .5px;
}
.zero-bar span { font-size: 16px; font-weight: 600; color: #14653f; letter-spacing: .2px; }

/* Admin incognito-view banner */
.peek-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px;
  background: linear-gradient(90deg, #fff6e5, #fffaf0);
  border-bottom: 1px solid #f4e3bf;
  font-size: 12.5px; color: #8a5a12;
}
.peek-tag { font-weight: 700; color: #b06a00; }
.peek-text { flex: 1; min-width: 180px; color: #8a5a12; }
.peek-back { color: #0a7a45; text-decoration: none; font-weight: 600; white-space: nowrap; }
.peek-back:hover { text-decoration: underline; }

/* Video messages */
.chat-video { display: block; max-width: 260px; max-height: 220px; border-radius: 8px; background: #000; }
.video-name { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.video-bubble { padding: 6px 8px 8px; }
.msg.own .video-name { color: rgba(255, 255, 255, .82); }

.auth-card {
  width: 372px;
  background: #fff;
  border-radius: 18px;
  padding: 28px 30px 24px;
  box-shadow: 0 24px 60px rgba(12, 55, 33, .13);
  border: 1px solid rgba(255, 255, 255, .8);
}

.auth-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.auth-tabs .tab {
  padding-bottom: 11px;
  font-size: 16px;
  color: var(--text-2);
  text-decoration: none;
  position: relative;
}
.auth-tabs .tab.active { color: var(--text); font-weight: 600; }
.auth-tabs .tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 3px; background: var(--green); border-radius: 3px;
}

.auth-error {
  background: #fdeeee; color: var(--danger);
  border: 1px solid #f7cdcd; padding: 9px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 13px; font-size: 14px;
  outline: none; background: #fbfcfb;
  transition: .18s;
}
.field input:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(7, 193, 96, .12); }
/* Keep the color picker from stretching into a 44px-tall block */
.field input[type="color"] {
  height: 40px; width: 140px; padding: 3px; cursor: pointer; border-radius: 8px; background: #fff;
}

.auth-btn {
  width: 100%; height: 46px; margin-top: 6px;
  border: 0; border-radius: 9px;
  background: linear-gradient(120deg, #09ce6a, #06ac55);
  color: #fff; font-size: 15px; letter-spacing: 2px;
  cursor: pointer; transition: .18s;
  box-shadow: 0 10px 22px rgba(7, 193, 96, .25);
}
.auth-btn:hover { filter: brightness(1.03); }

.auth-hint { margin-top: 16px; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }
.auth-hint a { color: var(--green); text-decoration: none; }
.auth-hint-link { margin-top: 8px; }

/* ============================ Main layout ============================ */
.chat-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(900px 520px at 15% 10%, #ddf6ea 0%, rgba(221, 246, 234, 0) 62%),
    radial-gradient(800px 520px at 85% 92%, #d5f0e2 0%, rgba(213, 240, 226, 0) 60%),
    linear-gradient(150deg, #eef9f3 0%, #e7f4ec 50%, #e2f2e9 100%);
}

.app-shell {
  width: 100%;
  max-width: 1440px;
  height: 100%;
  max-height: 940px;
}

.app {
  display: flex;
  height: 100%;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 26px 60px rgba(14, 52, 34, .16), 0 4px 12px rgba(14, 52, 34, .05);
}

/* ============================ Left member panel ============================ */
.sidebar {
  width: 304px;
  flex: 0 0 304px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fbfdfc 0%, #f5faf7 100%);
  border-right: 1px solid var(--line);
  min-width: 0;
}

.side-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }

.me-row { display: flex; align-items: center; gap: 10px; }
.avatar-lg { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
.me-meta { flex: 1; min-width: 0; }
.me-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); margin-top: 3px; }

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: #fff; color: var(--text-2);
  font-size: 12px; padding: 5px 10px;
  border-radius: 7px; text-decoration: none; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: #cdd7d1; }

.side-search { position: relative; margin-top: 14px; }
.side-search input {
  width: 100%; height: 34px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; padding: 0 12px 0 32px;
  font-size: 12.5px; outline: none;
}
.side-search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7,193,96,.1); }
.search-icon { position: absolute; left: 11px; top: 8px; font-size: 12px; opacity: .55; }

.side-scroll { flex: 1; overflow-y: auto; padding: 10px 8px 12px; }

.member-group { margin-bottom: 8px; }
.group-title {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .4px;
}
.group-title.online { color: var(--green-dark); }
.group-title.offline { color: #9aa49e; }
.group-title .dot { width: 7px; height: 7px; }
.group-count { color: var(--text-3); font-weight: 400; }

.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.member-item:hover { background: rgba(7, 193, 96, .07); }

.avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1.12; text-align: center;
  padding: 2px; overflow: hidden; word-break: break-all;
  user-select: none; flex: 0 0 auto;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; background: #cbd3ce; flex: 0 0 auto;
}
.dot.online { background: var(--green); box-shadow: 0 0 0 2px rgba(7,193,96,.15); }
.dot.offline { background: #b9c2bd; }
.avatar-wrap .dot {
  position: absolute; right: -2px; bottom: -2px;
  border: 2px solid #fff;
}

.member-text { flex: 1; min-width: 0; }
.member-name {
  font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px;
}
.member-item.offline .member-name { color: #8d968f; }
.member-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tag {
  font-size: 10px; padding: 1px 4px; border-radius: 4px; font-weight: 400; flex: 0 0 auto;
}
.tag.owner { background: var(--green-soft); color: var(--green-dark); }
.tag.me { background: #eef1ff; color: #5165c8; }
.tag.muted { background: #ffeeee; color: var(--danger); }

.member-owner-btn {
  width: 26px; height: 26px; border: 0; background: transparent;
  color: var(--text-3); font-size: 15px; cursor: pointer; border-radius: 6px;
  opacity: 0; transition: .15s;
}
.member-item:hover .member-owner-btn { opacity: 1; }
.member-owner-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }

.side-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.new-room-btn {
  width: 100%; height: 36px;
  border: 1px dashed #c8d4cc; border-radius: 9px;
  background: rgba(255,255,255,.6); color: var(--text-2);
  font-size: 13px; cursor: pointer; transition: .18s;
}
.new-room-btn:hover { border-color: var(--green); color: var(--green-dark); background: #fff; }

.mine-link {
  display: block; margin-top: 8px; padding: 6px 8px;
  text-align: center; font-size: 12.5px; color: var(--text-2);
  text-decoration: none; border-radius: 8px;
}
.mine-link:hover { background: #fff; color: var(--green-dark); }

/* ============================ Chat area ============================ */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #fff; position: relative; }

.chat-head {
  height: 70px; flex: 0 0 70px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.chat-head .menu-btn { display: none; }

.room-switch {
  flex: 1; min-width: 0;
  border: 0; background: transparent; padding: 6px 10px; margin-left: -10px;
  border-radius: 10px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 10px;
}
.room-switch:hover { background: #f4f8f5; }
.room-switch .texts { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.room-name { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caret { font-size: 12px; color: var(--text-3); flex: 0 0 auto; }

.head-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 9px;
  background: transparent; font-size: 16px; line-height: 1; cursor: pointer;
  color: #46524b; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f1f6f3; }

/* Announcement bar */
.announce {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 18px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
  font-size: 12.5px; color: var(--warn-text); line-height: 1.6;
}
.announce-tag {
  flex: 0 0 auto; font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: #ffe9b8; color: #7d5a12; font-weight: 600;
}
.announce-text { flex: 1; word-break: break-word; }

/* Room switcher menu */
.room-menu {
  position: absolute;
  top: 66px; left: 12px;
  width: 300px; max-height: 360px; overflow-y: auto;
  background: #fff; border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(16, 48, 32, .16);
  padding: 6px; z-index: 30;
}
.room-menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
}
.room-menu-item:hover { background: #f4f8f5; }
.room-menu-item.active { background: var(--green-soft); }
.rm-name { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm-code { font-size: 11px; color: var(--text-3); }
.rm-unread { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: #f43f3f; color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; }
.room-menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.room-menu-new { color: var(--green-dark); font-size: 13px; padding: 10px; border-radius: 9px; cursor: pointer; }
.room-menu-new:hover { background: var(--green-soft); }

/* Message area */
.messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 16px 0 6px;
  background: linear-gradient(180deg, #f8fbf9 0%, #f2f6f4 100%);
}
.msgs-inner { width: 100%; max-width: 1000px; margin: auto auto 0; padding: 0 26px; }

.time-divider { text-align: center; margin: 14px 0 10px; }
.time-divider span {
  font-size: 11.5px; color: #a4ada7;
  background: rgba(255, 255, 255, .8);
  padding: 2px 9px; border-radius: 10px;
}

.msg { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.msg.own { flex-direction: row-reverse; }
.msg .avatar { width: 34px; height: 34px; border-radius: 9px; font-size: 13px; }

.msg-main { max-width: min(68%, 560px); display: flex; flex-direction: column; gap: 4px; }
.msg.own .msg-main { align-items: flex-end; }
.msg-name { font-size: 11.5px; color: var(--text-3); padding-left: 3px; }
.msg.own .msg-name { display: none; }

.bubble {
  position: relative;
  background: #fff;
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 14px; line-height: 1.65;
  word-break: break-word; white-space: pre-wrap;
  color: #202722;
  box-shadow: 0 1px 2px rgba(18, 48, 32, .06);
}
.bubble::before {
  content: ""; position: absolute; top: 13px; left: -5px;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  border-right: 6px solid #fff;
}
.msg.own .bubble { background: var(--bubble-mine); }
.msg.own .bubble::before {
  left: auto; right: -5px; border-right: 0; border-left: 6px solid var(--bubble-mine);
}

.bubble.image-bubble, .bubble.sticker-bubble { background: transparent; padding: 0; box-shadow: none; }
.msg.own .bubble.image-bubble, .msg.own .bubble.sticker-bubble { background: transparent; box-shadow: none; }
.bubble.image-bubble::before, .bubble.sticker-bubble::before { display: none; }

.bubble img.chat-img {
  max-width: 250px; max-height: 250px; border-radius: 10px;
  display: block; cursor: zoom-in; background: #fff;
}
.sticker-emoji { font-size: 52px; line-height: 1.15; }

.file-card { display: flex; align-items: center; gap: 10px; min-width: 195px; text-decoration: none; color: inherit; }
.file-icon {
  width: 40px; height: 40px; border-radius: 9px;
  background: linear-gradient(140deg, #4fa9ff, #2f7fe6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; flex: 0 0 auto;
}
.file-meta { min-width: 0; }
.file-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.file-size { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }

.sys-msg { text-align: center; margin: 10px 0; }
.sys-msg span {
  font-size: 11.5px; color: #98a09b;
  background: rgba(255, 255, 255, .78);
  padding: 3px 10px; border-radius: 10px; display: inline-block; max-width: 82%;
}

.del-msg {
  opacity: 0; border: 0; background: rgba(0, 0, 0, .055); color: #78827c;
  font-size: 11px; border-radius: 5px; padding: 2px 8px; cursor: pointer; transition: .15s;
}
.msg:hover .del-msg { opacity: 1; }
.del-msg:hover { background: var(--danger); color: #fff; }

/* Composer */
.composer {
  flex: 0 0 auto;
  padding: 10px 16px 12px;
  background: #fbfdfc;
  border-top: 1px solid var(--line);
  position: relative;
}
.composer-box {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px 5px;
  transition: .18s;
}
.composer-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7, 193, 96, .1); }

.composer textarea {
  width: 100%;
  min-height: 40px; max-height: 132px;
  border: 0; background: transparent; resize: none; outline: none;
  font-size: 14px; line-height: 1.65; padding: 2px 2px 4px;
}
.composer-tools { display: flex; align-items: center; gap: 2px; }
.tool-btn {
  width: 32px; height: 32px; border: 0; background: transparent;
  border-radius: 8px; font-size: 16px; cursor: pointer; color: #4c5851;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.tool-btn svg { width: 21px; height: 21px; display: block; }
.tool-btn:hover { background: #eef6f1; color: var(--green-dark); }
.tool-btn:active { background: #e2f2e8; }
.muted-tip { margin-left: 8px; font-size: 11.5px; color: var(--danger); }

.composer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.upload-tip { font-size: 12px; color: var(--text-2); }
.hint-text { margin-left: auto; font-size: 11px; color: var(--text-3); }
.send-btn {
  min-width: 76px; height: 34px;
  border: 0; border-radius: 9px;
  background: linear-gradient(120deg, #09ce6a, #06ae57);
  color: #fff; font-size: 13.5px; cursor: pointer;
  box-shadow: 0 6px 14px rgba(7, 193, 96, .22);
}
.send-btn:disabled { background: #c4e8d3; box-shadow: none; cursor: not-allowed; }

/* Emoji panel */
.emoji-panel {
  position: absolute;
  left: 16px; right: 16px; bottom: calc(100% - 6px);
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(16, 48, 32, .16);
  padding: 12px 14px 14px;
  max-height: 260px; overflow-y: auto;
  z-index: 25;
}
.panel-title { font-size: 12px; color: var(--text-2); margin: 0 0 9px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.emoji-grid button { border: 0; background: transparent; font-size: 22px; height: 38px; border-radius: 7px; cursor: pointer; }
.emoji-grid button:hover { background: #f2f6f4; }
.emoji-grid.stickers button { font-size: 29px; height: 50px; }

/* ============================ Overlays ============================ */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 32, 24, .34);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: 440px; max-width: 100%;
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(12, 40, 26, .24);
  overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.modal.narrow { width: 360px; }
.modal.card-modal { width: 360px; }
.modal-head {
  height: 54px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 15px;
}
.modal-body { padding: 18px 16px 20px; }
.modal-tip { font-size: 12px; color: var(--text-2); line-height: 1.7; margin: 4px 0 14px; }
.inline-field { display: flex; gap: 8px; }
.inline-field input {
  flex: 1; height: 36px; border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 0 10px; font-size: 13px; outline: none;
}
.inline-field input:focus { border-color: var(--green); }
.inline-field + .share-row { margin-top: 0; }
.share-row { display: flex; gap: 8px; }
.share-row input {
  flex: 1; height: 36px; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 0 10px; font-size: 12.5px; color: var(--text-2); background: #fbfcfb; outline: none;
}
.danger-zone {
  display: flex; align-items: center; gap: 10px;
  padding-top: 14px; margin-top: 4px; border-top: 1px dashed var(--line-strong);
}
.danger-zone .hint { font-size: 11.5px; color: var(--text-3); }

.mini-btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text-2);
  font-size: 12.5px; padding: 6px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { border-color: var(--green); color: var(--green-dark); }
.mini-btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.mini-btn.primary:hover { background: var(--green-dark); }
.mini-btn.danger { color: var(--danger); border-color: #f3cfcd; }
.mini-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.mini-btn.block { width: 100%; height: 40px; margin-top: 6px; }

/* Member overlay */
.member-hero { display: flex; align-items: center; gap: 14px; padding: 18px 16px 14px; }
.avatar-xl { width: 56px; height: 56px; border-radius: 14px; font-size: 20px; }
.member-hero-text { flex: 1; min-width: 0; }
.sheet-name { font-size: 17px; font-weight: 600; }
.sheet-status { font-size: 12px; color: var(--text-2); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.member-tags { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 14px; }
.sheet-actions { display: flex; gap: 10px; padding: 14px 16px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-actions .mini-btn { flex: 1 1 auto; min-width: 82px; height: 38px; }

/* Share card */
.share-card {
  background: linear-gradient(140deg, #f1fbf6, #e8f7ef);
  border: 1px solid #d9efe2; border-radius: 14px;
  padding: 18px; text-align: center; margin-bottom: 12px;
}
.share-room { font-size: 14px; font-weight: 600; color: #22503a; }
.share-code { font-size: 30px; font-weight: 700; letter-spacing: 3px; color: var(--green-dark); margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.share-url { font-size: 11.5px; color: var(--text-2); word-break: break-all; }
.share-btns { display: flex; gap: 10px; }

/* Photo preview */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 14, 10, .86);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%);
  background: rgba(20, 32, 26, .86); color: #fff;
  font-size: 13px; padding: 9px 16px; border-radius: 9px; z-index: 70;
  max-width: 76vw; text-align: center; pointer-events: none;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 404 */
.notfound {
  text-align: center; background: #fff; padding: 44px 40px; border-radius: 20px;
  box-shadow: 0 24px 60px rgba(12, 40, 26, .16); max-width: 480px;
}
.nf-emoji { font-size: 42px; }
.notfound h1 { font-size: 20px; margin: 12px 0 8px; }
.notfound p { color: var(--text-2); font-size: 13px; line-height: 1.7; }
.nf-btn { display: inline-block; margin-top: 14px; background: var(--green); color: #fff; text-decoration: none; padding: 9px 22px; border-radius: 9px; font-size: 13.5px; }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #cdd6d0; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #b6c1ba; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ Tablet ============================ */
@media (max-width: 1180px) {
  .chat-body { padding: 18px; }
  .app-shell { max-width: 100%; max-height: none; }
  .sidebar { width: 248px; flex-basis: 248px; }
  .room-menu { left: 264px; }
  .room-name { font-size: 17px; }
  .msgs-inner { padding: 0 18px; }
}

/* ============================ Phone ============================ */
@media (max-width: 900px) {
  body.chat-body { padding: 0; align-items: stretch; }

  .app-shell { max-width: none; height: 100%; }

  .app {
    border-radius: 0; border: 0; box-shadow: none;
    height: 100vh;              /* fallback for browsers without dvh */
    height: 100dvh;
    padding-top: env(safe-area-inset-top);   /* notch / status bar */
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 86%; max-width: 340px;
    z-index: 40;
    transform: translateX(-103%);
    transition: transform .25s ease;
    box-shadow: 12px 0 40px rgba(10, 34, 22, .2);
    border-radius: 0 18px 18px 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translateX(0); }

  .side-mask {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(10, 24, 16, .38);
  }

  .menu-btn { display: inline-flex; }

  .chat-head { height: 60px; flex-basis: 60px; padding: 0 10px; gap: 6px; }
  .chat-head .menu-btn { display: inline-flex; }
  .room-name { font-size: 16px; }
  .room-sub { font-size: 11px; }
  .icon-btn { width: 34px; height: 34px; }
  /* At most 5 icons in the narrow header; tighten spacing so nothing overflows */
  .head-actions { gap: 2px; flex: 0 0 auto; }
  .head-actions .icon-btn { width: 30px; height: 30px; font-size: 15px; }

  .announce { padding: 9px 12px; font-size: 12px; }

  .room-menu { top: 62px; left: 8px; right: 8px; width: auto; }

  .messages { padding: 12px 0 4px; }
  .msgs-inner { padding: 0 12px; max-width: 100%; }
  .msg .avatar { width: 32px; height: 32px; }
  .msg-main { max-width: 76%; }
  .bubble { font-size: 15px; }
  .bubble img.chat-img { max-width: 210px; max-height: 210px; }
  .sticker-emoji { font-size: 46px; }

  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; min-height: 36px; }
  .hint-text { display: none; }
  .send-btn { min-width: 64px; height: 32px; }
  .upload-tip { flex: 1; }

  .emoji-panel { left: 8px; right: 8px; max-height: 220px; padding: 10px; }

  .modal { width: 100%; max-width: 460px; }
  .modal.narrow, .modal.card-modal { width: 100%; }
  .modal-mask { padding: 14px; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; }
  .modal-mask { padding-bottom: 0; }

  .auth-body { padding: 24px 16px; }
  .auth-wrap { flex-direction: column; gap: 22px; }
  .auth-brand { text-align: center; }
  .auth-brand h1 { font-size: 24px; }
  .auth-brand p { font-size: 13px; }
  .zero-bar { display: flex; width: 100%; max-width: 420px; justify-content: center; padding: 10px 12px; }
  .zero-bar b { font-size: 16px; }
  .zero-bar span { font-size: 14px; }
  .peek-bar { padding: 8px 12px; gap: 6px; font-size: 12px; }
  .peek-text { min-width: 100%; order: 3; }
  .auth-card { width: 100%; max-width: 420px; padding: 22px 20px 18px; }
}

/* Long usernames in avatars: expand horizontally and scale the font so the full name stays visible */
.avatar.wide {
  width: auto; min-width: 36px; max-width: 120px;
  padding: 0 7px; border-radius: 9px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0;
}
.msg .avatar.wide { min-width: 34px; max-width: 108px; }
.avatar-lg.wide { min-width: 42px; max-width: 140px; }
.avatar-xl.wide { min-width: 56px; max-width: 170px; }

/* Extra-small screens */
@media (max-width: 380px) {
  .room-name { font-size: 15px; }
  .bubble { font-size: 14.5px; }
  .composer-tools .tool-btn { width: 28px; }
}

/* ==========================================================================
   Newer feature styles: replies / unsend / unread divider / polls / roll calls / room files / search / voice and more
   ========================================================================== */

.side-links { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

.typing-bar {
  padding: 6px 22px 2px;
  font-size: 12px;
  color: var(--green-dark);
  background: #fff;
  flex: 0 0 auto;
}

.load-older { text-align: center; padding: 6px 0 10px; }

.unread-divider {
  text-align: center;
  margin: 12px 0 8px;
  font-size: 11.5px;
  color: #9aa49e;
}
.unread-divider span {
  display: inline-block;
  padding: 3px 10px;
  background: #f2f5f3;
  border-radius: 10px;
}

.recalled-msg span { color: #98a29c; font-size: 12px; }

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
  margin-top: 2px;
}
.msg:hover .msg-actions { opacity: 1; }
.msg.own .msg-actions { justify-content: flex-end; }
.msg-action {
  border: 0;
  background: #f4f7f5;
  color: var(--text-2);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.msg-action:hover { background: #e7efe9; color: var(--green-dark); }
.msg-action.danger:hover { background: #fdeceb; color: var(--danger); }

.quote {
  border-left: 3px solid #cfe3d7;
  background: rgba(0, 0, 0, .03);
  border-radius: 6px;
  padding: 5px 8px;
  margin: 0 0 7px;
  font-size: 12px;
  line-height: 1.45;
  cursor: pointer;
  max-width: 100%;
}
.msg.own .quote { border-left-color: #8fce78; background: rgba(255, 255, 255, .35); }
.quote-name { color: var(--text-2); margin-right: 4px; }
.quote-text { color: var(--text-3); word-break: break-word; }

.msg-text { white-space: pre-wrap; word-break: break-word; }
.mention { color: #1a6fbf; font-weight: 600; }
.msg.own .mention { color: #0b5d33; }

.sticker-img {
  width: 116px;
  height: 116px;
  object-fit: contain;
  display: block;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 6px;
}
.sticker-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #f7faf8;
  border-radius: 10px;
  cursor: pointer;
  padding: 4px;
}
.sticker-thumb:hover { background: #edf5f0; }

.voice-bubble { display: inline-flex; align-items: center; gap: 8px; }
.voice-bubble audio { height: 34px; max-width: 220px; }
.voice-dur { font-size: 11.5px; color: var(--text-2); }

/* Polls */
.poll-bubble, .chain-bubble { min-width: 260px; padding: 11px 12px; }
.poll-card, .chain-card { display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-flag {
  font-size: 10.5px;
  color: var(--text-2);
  background: rgba(0, 0, 0, .05);
  border-radius: 5px;
  padding: 1px 6px;
}
.poll-options { display: flex; flex-direction: column; gap: 6px; }
.poll-option {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  font-size: 13px;
  color: var(--text);
}
.poll-option:disabled { cursor: default; }
.poll-option:hover:not(:disabled) { border-color: var(--green); }
.poll-option.mine { border-color: var(--green); background: #f1fbf5; }
.poll-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(7, 193, 96, .13);
  transition: width .25s ease;
  z-index: 0;
}
.poll-label { position: relative; z-index: 1; flex: 1; }
.poll-count { position: relative; z-index: 1; font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-sub { font-size: 11.5px; color: var(--text-3); }
.chain-list { display: flex; flex-direction: column; gap: 3px; }
.chain-item { font-size: 12.5px; color: var(--text-2); padding: 3px 6px; border-radius: 6px; }
.chain-item.mine { background: #f1fbf5; color: var(--green-dark); font-weight: 600; }

/* Composer: reply bar / more panel / recording hint */
.reply-bar {
  display: flex; align-items: center; gap: 8px;
  background: #f3f8f5; border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 10px; margin-bottom: 8px;
  font-size: 12px;
}
.reply-info { flex: 1; min-width: 0; display: flex; gap: 5px; align-items: baseline; }
.reply-label { color: var(--text-3); }
.reply-name { color: var(--green-dark); font-weight: 600; }
.reply-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.more-panel {
  position: absolute; right: 16px; bottom: 78px; z-index: 20;
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 14px 34px rgba(12, 40, 26, .16);
  padding: 8px; display: flex; flex-direction: column; gap: 2px;
  min-width: 190px;
}
.more-item {
  border: 0; background: transparent; text-align: left;
  padding: 9px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--text);
}
.more-item:hover { background: #f2f7f4; }

.rec-tip { margin-left: 8px; font-size: 11.5px; color: var(--danger); }

.msg.flash { animation: flash-bg 1.4s ease-out; }
@keyframes flash-bg { 0% { background: #fff5cf; } 100% { background: transparent; } }

/* Manage overlay extensions */
.modal.wide-modal { width: 560px; }
.field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.field select { height: 36px; padding: 0 8px; }
.field textarea { resize: vertical; line-height: 1.6; }
.field select:focus, .field textarea:focus { border-color: var(--green); }
.inline-field input[type="text"] { min-width: 0; }
.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }
.pref-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
/* .field input is 100% width for text inputs; checkboxes must be reset or they stretch into big blocks */
.switch input, .field input[type="checkbox"], .field input[type="radio"] {
  width: auto; height: auto; margin: 0; flex: 0 0 auto;
}
.switch input { accent-color: var(--green); }

.req-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.req-item {
  display: flex; align-items: center; gap: 8px;
  background: #fbfcfb; border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px;
}
.req-name { flex: 1; font-size: 12.5px; }

.qr-box { display: flex; justify-content: center; margin: 10px 0; min-height: 180px; }
.qr-box canvas, .qr-box img { border-radius: 10px; background: #fff; padding: 6px; }

.search-results { max-height: 52vh; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.search-row {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
}
.search-row:hover { background: #f5faf7; border-color: #e2efe7; }
.search-room { font-size: 11.5px; color: var(--green-dark); }
.search-text { font-size: 13px; color: var(--text); word-break: break-all; }
.search-time { font-size: 11px; color: var(--text-3); }
.search-row .avatar { width: 28px; height: 28px; }

.files-list { display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.file-row .file-meta { flex: 1; min-width: 0; }
.file-row .mini-btn { text-decoration: none; }
.file-row a.mini-btn { display: inline-flex; align-items: center; }

/* Badge inside the room menu */
.rm-pin { font-size: 11px; }
.rm-pending { font-size: 10px; color: #b06a00; background: #fff6e2; border-radius: 6px; padding: 1px 5px; }
.rm-mute { font-size: 11px; opacity: .7; }
.tag.admin { background: #eef4ff; color: #3968c6; }
.icon-btn.on { background: var(--green-soft); color: var(--green-dark); }

@media (max-width: 900px) {
  .modal.wide-modal { width: 100%; }
  .more-panel { right: 8px; bottom: 70px; }
  .poll-bubble, .chain-bubble { min-width: 210px; }
  .msg-actions { opacity: 1; }
  .sticker-img { width: 96px; height: 96px; }
  .voice-bubble audio { max-width: 180px; }
}

