*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-main: #1a1d21;
  --bg-sidebar: #19171d;
  --bg-bar: #19171d;
  --ch-hover: rgba(255,255,255,0.08);
  --ch-active: rgba(255,255,255,0.13);
  --msg-hover: rgba(255,255,255,0.04);
  --text-p: #d1d2d3;
  --text-s: #8c8d90;
  --text-h: #ffffff;
  --text-ch: #c9cacc;
  --border: rgba(255,255,255,0.09);
  --badge: #cd2553;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ── WORKSPACE THEMES ── */
/* company: near-black */
body[data-workspace="company"] {
  --bg-bar:     #111111;
  --bg-sidebar: #1a1a1a;
  --bg-main:    #222222;
  --ch-active:  rgba(255,255,255,0.15);
}
/* friends: lilac / soft purple */
body[data-workspace="friends"] {
  --bg-bar:     #2e2250;
  --bg-sidebar: #38296a;
  --bg-main:    #1f1835;
  --ch-active:  rgba(255,255,255,0.18);
  --border:     rgba(255,255,255,0.10);
}
/* home: deep burgundy / dark red */
body[data-workspace="home"] {
  --bg-bar:     #3a0e0e;
  --bg-sidebar: #4d1212;
  --bg-main:    #2a0b0b;
  --ch-active:  rgba(255,255,255,0.15);
  --border:     rgba(255,255,255,0.09);
}

body {
  background: var(--bg-main); color: var(--text-p);
  font-family: var(--font); font-size: 15px; height: calc(var(--vh, 1vh) * 100); height: 100dvh; overflow: hidden;
  transition: background 0.35s ease;
}
#ws-bar, #sidebar { transition: background 0.35s ease; }

/* ── LAYOUT ── */
#app { display: flex; height: calc(var(--vh, 1vh) * 100); height: 100dvh; }

/* ── WORKSPACE BAR ── */
#ws-bar {
  width: 68px; background: var(--bg-bar);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 8px;
  border-right: 1px solid var(--border); z-index: 10; flex-shrink: 0;
}

.ws-icon {
  position: relative; width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; cursor: pointer; color: #fff;
  transition: border-radius 0.18s ease, transform 0.1s;
  user-select: none; flex-shrink: 0;
}
.ws-icon:hover { border-radius: 14px; transform: scale(1.05); }
.ws-icon[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: #1a1a1a; color: #fff; font-size: 13px; font-weight: 700;
  white-space: nowrap; padding: 6px 10px; border-radius: 6px;
  pointer-events: none; opacity: 0; transition: opacity 0.12s ease;
  z-index: 999;
}
.ws-icon[data-tooltip]:hover::after { opacity: 1; }
.ws-icon.active { border-radius: 14px; }
.ws-icon.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; background: #fff; border-radius: 0 3px 3px 0;
}
.ws-badge {
  position: absolute; top: -4px; right: -5px;
  background: var(--badge); color: #fff; font-size: 10px; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid var(--bg-bar);
}
.ws-badge.hidden { display: none; }
.ws-divider { width: 34px; height: 1px; background: var(--border); margin: 2px 0; }

/* ── SIDEBAR ── */
#sidebar {
  width: 224px; background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border); flex-shrink: 0;
}
#ws-header {
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
#ws-header h2 { font-size: 15px; font-weight: 900; color: var(--text-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
#ws-header .chevron { color: var(--text-s); font-size: 11px; flex-shrink: 0; }
#sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
#sidebar-scroll::-webkit-scrollbar { width: 4px; }
#sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sb-section-label {
  padding: 6px 8px 2px 8px; font-size: 13px; font-weight: 700;
  color: var(--text-s); display: flex; align-items: center; gap: 4px;
  cursor: pointer; user-select: none;
}
.sb-section-label:hover { color: var(--text-p); }

.ch-item {
  padding: 5px 8px; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  border-radius: 6px; margin: 1px 8px;
  color: var(--text-ch); font-size: 15px; font-weight: 400;
}
.ch-item:hover { background: var(--ch-hover); color: var(--text-h); }
.ch-item.active { background: var(--ch-active); color: var(--text-h); font-weight: 600; }
.ch-prefix { color: var(--text-s); font-size: 17px; line-height: 1; flex-shrink: 0; }
.ch-item.active .ch-prefix { color: var(--text-h); }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-unread {
  background: var(--badge); color: #fff; font-size: 10px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px; flex-shrink: 0;
}
.ch-unread.hidden { display: none; }

.dm-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--bg-sidebar); margin-left: -1px;
}

/* ── MAIN AREA ── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#ch-header {
  height: 49px; border-bottom: 1px solid var(--border);
  padding: 0 20px; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
#ch-header .hash { color: var(--text-s); font-size: 20px; font-weight: 400; }
#ch-header .ch-title { font-weight: 800; font-size: 15px; color: var(--text-h); }
.header-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
#ch-header .ch-topic { font-size: 13px; color: var(--text-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── MESSAGES ── */
#messages-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#messages-scroll::-webkit-scrollbar { width: 8px; }
#messages-scroll::-webkit-scrollbar-track { background: transparent; }
#messages-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

#messages-inner { padding: 12px 0 4px; }

.date-sep {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px 8px; font-size: 12px; font-weight: 700; color: var(--text-s);
}
.date-sep::before, .date-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.msg-group {
  display: flex; padding: 4px 20px; gap: 10px;
  transition: background 0.06s;
}
.msg-group:hover { background: var(--msg-hover); }

.msg-avatar {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; margin-top: 2px;
}
.msg-avatar.avatar-img, .profile-avatar.avatar-img {
  padding: 0; overflow: hidden; background: none;
}
.msg-avatar.avatar-img img, .profile-avatar.avatar-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.msg-body { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-sender { font-weight: 700; color: var(--text-h); font-size: 15px; }
.msg-sender.chia { color: #5ba4e6; }
.you-tag { font-weight: 400; font-size: 13px; color: var(--text-s); }
.msg-time { font-size: 11px; color: var(--text-s); }
.msg-text { color: var(--text-p); line-height: 1.46667; word-break: break-word; }
.msg-text em { font-style: italic; color: var(--text-s); }

.msg-cont {
  padding: 2px 20px 2px 66px; position: relative;
}
.msg-cont:hover { background: var(--msg-hover); }
.msg-cont .msg-text { color: var(--text-p); line-height: 1.46667; }
.msg-cont .msg-time-hover {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-s); opacity: 0; white-space: nowrap; pointer-events: none;
}
.msg-cont:hover .msg-time-hover { opacity: 1; }

/* ── TYPING INDICATOR ── */
#typing-row { min-height: 28px; padding: 0 20px 4px 66px; }
.typing-text { font-size: 13px; color: var(--text-s); font-style: italic; }
.typing-dots { display: inline-flex; gap: 3px; margin-left: 3px; }
.typing-dots b { width: 5px; height: 5px; background: var(--text-s); border-radius: 50%; display: block; animation: bounce 1.2s infinite; }
.typing-dots b:nth-child(2) { animation-delay: 0.2s; }
.typing-dots b:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── CHOICES ── */
#choices-area { padding: 8px 20px 10px; flex-shrink: 0; }
.choice-hint { font-size: 12px; color: var(--text-s); margin-bottom: 6px; font-style: italic; }
.choices-wrap { display: flex; flex-direction: column; gap: 5px; }
.choice-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-p); padding: 9px 14px; border-radius: 8px;
  cursor: pointer; text-align: left; font-size: 14px; font-family: var(--font);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.choice-btn:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.3); color: var(--text-h); }

/* wrong context hint */
.choice-redirect {
  background: rgba(205,37,83,0.12); border: 1px solid rgba(205,37,83,0.3);
  color: #e08099; padding: 9px 14px; border-radius: 8px;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}

/* ── INPUT BAR ── */
#input-bar { padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
#fake-input {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.11);
  border-radius: 8px; padding: 11px 14px; color: var(--text-s);
  font-size: 15px; cursor: default; user-select: none;
  min-height: 1.5em;
}
#fake-input.typing-active {
  color: var(--text-h);
  border-color: rgba(255,255,255,0.25);
}
#fake-input.typing-active::after {
  content: '|';
  display: inline;
  color: var(--text-h);
  animation: blink-cursor 0.7s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── TOAST ── */
#toast {
  position: fixed; top: 18px; right: 18px; z-index: 999;
  background: #2c2d30; border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 15px; max-width: 290px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; cursor: pointer; }
#toast.show:hover { background: #35373b; }
.toast-ws { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--text-s); margin-bottom: 1px; }
.toast-ch { font-size: 13px; font-weight: 700; color: var(--text-h); margin-bottom: 2px; }
.toast-preview { font-size: 13px; color: var(--text-p); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── EMPTY STATE ── */
.empty-msg { padding: 40px 20px; text-align: center; color: var(--text-s); font-size: 14px; margin-top: auto; }

/* ── MENTION HIGHLIGHT ── */
.mention {
  color: #f0c233; background: rgba(240,194,51,0.15);
  border-radius: 3px; padding: 0 2px; font-weight: 600;
}
/* @mention of another user — clickable, shows profile popover */
.mention-user {
  color: #5b9bd5; background: rgba(91,155,213,0.15);
  border-radius: 3px; padding: 0 2px; font-weight: 600;
  cursor: pointer;
}
.mention-user:hover { background: rgba(91,155,213,0.28); }

/* ── CHOICE NOTE (slackbot-style private echo) ── */
.choice-note {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 20px; margin: 2px 0;
}
.choice-note-avatar {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: #611f69;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-top: 2px;
}
.choice-note-body { flex: 1; min-width: 0; }
.choice-note-header {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
}
.choice-note-sender { font-weight: 700; color: var(--text-h); font-size: 15px; }
.choice-note-tag {
  font-size: 11px; color: var(--text-s);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 0 4px; line-height: 1.6;
}
.choice-note-time { font-size: 11px; color: var(--text-s); }
.choice-note-text { color: var(--text-p); font-size: 14px; line-height: 1.46667; }

/* ── NPC PROFILE POPOVER ── */
#profile-pop {
  position: fixed; z-index: 600;
  background: #1a1d21; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 16px 16px 14px;
  width: 230px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  opacity: 0; pointer-events: none;
  transition: opacity 0.13s, transform 0.13s;
  transform: translateY(4px);
}
#profile-pop.visible {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.pop-avatar-wrap { position: relative; width: 72px; height: 72px; margin-bottom: 10px; }
.pop-avatar {
  width: 72px; height: 72px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 24px; color: #fff;
}
.pop-active-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #2eb67d; border: 2px solid #1a1d21;
}
.pop-name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.3; margin-bottom: 2px; }
.pop-pronouns { font-size: 11px; color: var(--text-s); margin-bottom: 5px; }
.pop-role {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: var(--text-p); background: rgba(255,255,255,0.08);
  border-radius: 4px; padding: 2px 7px; margin-bottom: 0;
}
.pop-role:empty { display: none; }
.pop-divider { height: 1px; background: var(--border); margin: 10px 0 8px; }
.pop-note { font-size: 12px; color: var(--text-s); line-height: 1.5; }

/* ── USER PROFILE (sidebar footer) ── */
#user-profile {
  flex-shrink: 0; border-top: 1px solid var(--border);
  padding: 10px 10px 12px;
}
.profile-inner {
  display: flex; align-items: center; gap: 9px;
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
}
.profile-inner:hover { background: var(--ch-hover); }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: #1264a3; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 12px; color: #fff;
}
.profile-active-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 10px; height: 10px; background: #2bac76;
  border-radius: 50%; border: 2px solid var(--bg-sidebar);
}
.profile-text { flex: 1; min-width: 0; }
.profile-name { font-size: 14px; font-weight: 700; color: var(--text-h); line-height: 1.3; }
.profile-status { font-size: 12px; color: var(--text-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── UTILITY ── */
.hidden { display: none !important; }
.toast-click-hint { font-size: 11px; color: var(--text-s); margin-top: 3px; }

/* ── MODAL OVERLAY ── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 1000;
  opacity: 1; pointer-events: auto;  /* visible by default — covers game during intro */
  transition: opacity 0.4s ease;
}
#modal-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── INTRO MODAL ── */
#intro-modal {
  position: fixed; z-index: 1001;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #1e1f22; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 44px 48px; width: 500px; max-width: 92vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.45s ease;
}
#intro-modal.slide-out {
  transform: translate(-50%, calc(-50% - 130vh));
  opacity: 0;
}

/* ── ENDING MODAL ── */
#ending-modal {
  position: fixed; z-index: 1001;
  bottom: 0; left: 50%;
  transform: translateX(-50%) translateY(110%);
  background: #1e1f22; border: 1px solid rgba(255,255,255,0.1);
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  width: 580px; max-width: 92vw; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 -16px 48px rgba(0,0,0,0.6);
  transition: transform 0.52s cubic-bezier(0.32, 0.72, 0, 1);
}
#ending-modal.visible { transform: translateX(-50%) translateY(0); }
#ending-modal.minimized { transform: translateX(-50%) translateY(calc(100% - 44px)); }
#ending-toggle {
  flex-shrink: 0; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: #1e1f22; border: none; border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--text-s); font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 12px 16px;
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  transition: color 0.15s; z-index: 1;
}
#ending-toggle:hover { color: var(--text-p); }
#ending-modal.minimized #ending-toggle-icon { transform: rotate(180deg); }
#ending-toggle-icon { transition: transform 0.3s ease; }
#ending-scroll {
  flex: 1; overflow-y: auto; padding: 32px 48px 52px;
}
#ending-scroll::-webkit-scrollbar { width: 4px; }
#ending-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ── MODAL SHARED ── */
.modal-eyebrow {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-s); margin-bottom: 10px;
}
.modal-title {
  font-size: 30px; font-weight: 900; color: var(--text-h);
  line-height: 1.15; margin-bottom: 6px;
}
.modal-credit { font-size: 13px; color: var(--text-s); margin-bottom: 0; }
.modal-credit strong { color: var(--text-p); font-weight: 600; }
.modal-rule { height: 1px; background: var(--border); margin: 22px 0; }
.modal-instructions {
  font-size: 14px; color: var(--text-p); line-height: 1.65;
  margin-bottom: 30px;
}
.modal-btn {
  background: #1264a3; color: #fff; border: none;
  padding: 13px 32px; border-radius: 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: background 0.15s, transform 0.1s;
  display: inline-block;
}
.modal-btn:hover { background: #0f508a; transform: translateY(-1px); }
.modal-btn:active { transform: translateY(0); }

/* ── ENDING MODAL CONTENT ── */
.ending-inner { }
.ending-title {
  font-size: 26px; font-weight: 900; color: var(--text-h); margin-bottom: 6px;
}
.ending-sub { font-size: 14px; color: var(--text-s); margin-bottom: 28px; }
.ending-sections { display: flex; flex-direction: column; gap: 14px; margin-bottom: 36px; }
.ending-section {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px;
}
.ending-section-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-s); margin-bottom: 8px;
}
.ending-text { font-size: 14px; color: var(--text-p); line-height: 1.65; }

/* ══════════════════════════════════════════════════════════
   MOBILE UI  (≤ 599 px)
   On desktop all #mob-* elements are hidden.
   On mobile #ws-bar, #sidebar, #ch-header are hidden and
   #mobile-header takes their place.
   ══════════════════════════════════════════════════════════ */

/* Desktop: hide every mobile-only element */
#mobile-header,
#mob-overlay,
#mob-drawer,
#mob-ws-panel { display: none; }

@media (max-width: 599px) {

  /* ── Layout ── */
  #app { flex-direction: column; }
  #ws-bar, #sidebar, #ch-header { display: none !important; }

  /* ── Mobile header bar ── */
  #mobile-header {
    display: flex; align-items: center; gap: 6px;
    height: 52px; flex-shrink: 0;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    padding: 0 8px 0 4px;
    transition: background 0.35s ease;
    z-index: 10;
  }

  #mob-hamburger {
    background: none; border: none; color: var(--text-p);
    padding: 10px 12px; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; transition: background 0.12s;
    position: relative;
  }
  #mob-hamburger:hover { background: var(--ch-hover); }
  #mob-hamburger::after {
    content: ''; position: absolute; top: 6px; right: 6px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #cd2553; border: 2px solid var(--bg-main);
    opacity: 0; transition: opacity 0.2s;
  }
  #mob-hamburger.has-notif::after { opacity: 1; }

  #mob-ch-info {
    flex: 1; display: flex; align-items: center; gap: 6px;
    overflow: hidden; min-width: 0;
  }
  /* Small workspace avatar inline with the channel name */
  #mob-ws-icon-header {
    width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 9px; color: #fff;
  }
  #mob-ch-prefix {
    color: var(--text-s); font-size: 19px; font-weight: 400;
    flex-shrink: 0; line-height: 1;
  }
  #mob-ch-title {
    font-weight: 800; font-size: 16px; color: var(--text-h);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ── Shared overlay backdrop ── */
  #mob-overlay {
    display: block; /* always in flow; visibility controlled by opacity/pointer-events */
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
  }
  #mob-overlay.open { opacity: 1; pointer-events: auto; }

  /* ── Channel drawer (slides from left) ── */
  #mob-drawer {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; width: 82vw; max-width: 300px;
    z-index: 201; background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1),
                background 0.35s ease;
  }
  #mob-drawer.open { transform: translateX(0); }

  /* Drawer workspace button (tap to open ws switcher) */
  #mob-drawer-ws-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 18px 16px 14px;
    background: none; border: none; border-bottom: 1px solid var(--border);
    cursor: pointer; text-align: left; flex-shrink: 0;
    transition: background 0.12s;
  }
  #mob-drawer-ws-btn:hover { background: var(--ch-hover); }

  #mob-drawer-ws-icon {
    width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12px; color: #fff;
  }
  #mob-drawer-ws-name {
    flex: 1; font-size: 15px; font-weight: 900; color: var(--text-h);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mob-drawer-chevron {
    color: var(--text-s); font-size: 20px; flex-shrink: 0; line-height: 1;
  }
  /* badge inside the drawer ws button */
  #mob-drawer-ws-btn .ws-badge {
    position: static; border: none; flex-shrink: 0;
  }

  #mob-drawer-scroll { flex: 1; overflow-y: auto; padding: 8px 0 12px; }
  #mob-drawer-scroll::-webkit-scrollbar { width: 3px; }
  #mob-drawer-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

  /* Chia profile strip at bottom of drawer */
  #mob-drawer-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px 16px;
    border-top: 1px solid var(--border); flex-shrink: 0;
  }
  #mob-drawer-profile .profile-avatar {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    font-size: 12px; font-weight: 800; color: #fff;
    display: flex; align-items: center; justify-content: center;
  }
  .mob-drawer-profile-text .profile-name { font-size: 13px; font-weight: 700; color: var(--text-h); }
  .mob-drawer-profile-text .profile-status { font-size: 11px; color: var(--text-s); }

  /* ── Workspace switcher panel (slides from left, full-height) ── */
  #mob-ws-panel {
    display: flex; flex-direction: column;
    position: fixed; inset: 0; z-index: 202;
    background: var(--bg-sidebar);
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
  }
  #mob-ws-panel.open { transform: translateX(0); }

  #mob-ws-panel-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 16px 14px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  #mob-ws-panel-title { font-size: 18px; font-weight: 900; color: var(--text-h); }
  #mob-ws-panel-close {
    background: none; border: none; color: var(--text-s);
    font-size: 20px; cursor: pointer; padding: 4px 8px; line-height: 1;
    border-radius: 6px; transition: background 0.12s;
  }
  #mob-ws-panel-close:hover { background: var(--ch-hover); color: var(--text-h); }

  #mob-ws-list { flex: 1; overflow-y: auto; padding: 8px 0; }

  .mob-ws-item {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 16px; cursor: pointer;
    transition: background 0.1s; border-radius: 0;
  }
  .mob-ws-item:hover  { background: var(--ch-hover); }
  .mob-ws-item.active { background: var(--ch-active); }

  .mob-ws-item-icon {
    width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff;
  }
  .mob-ws-item-name {
    font-size: 15px; font-weight: 700; color: var(--text-h); flex: 1;
  }
  .mob-ws-item-badge {
    background: var(--badge); color: #fff; font-size: 11px; font-weight: 800;
    min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 5px;
  }

  /* ── Tweak main area for mobile ── */
  #main { flex: 1; min-height: 0; }
  #messages-scroll { -webkit-overflow-scrolling: touch; }
  #choices-area { padding: 8px 12px 10px; }
  .choice-btn { padding: 10px 12px; }
  #input-bar { padding: 10px 12px; }

  /* Bring toast down so it doesn't overlap the header */
  #toast { top: 60px; }

  /* Profile popover: keep within viewport on mobile */
  #profile-pop { max-width: calc(100vw - 24px); }

}
