:root {
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --surface-2: #F1F4F9;
  --surface-hover: #EAF0F8;
  --text: #0F172A;
  --text-secondary: #334155;
  --muted: #64748B;
  --border: #E5E9F0;
  --border-strong: #CBD5E1;

  --primary: #1B56FD;
  --primary-hover: #0E3ECF;
  --primary-soft: rgba(27, 86, 253, 0.09);
  --primary-soft-2: rgba(27, 86, 253, 0.16);

  --bubble-me: #1B56FD;
  --bubble-me-text: #FFFFFF;
  --bubble-me-muted: rgba(255, 255, 255, 0.8);
  --bubble-other: #FFFFFF;
  --bubble-other-border: #E5E9F0;

  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #D97706;
  --unread-amber: #F59E0B;
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.1);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 4px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.14);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --rail-w: 68px;
  --sidebar-w: 320px;
  --mobile-bar-h: 60px;

  --font-sans: 'Plus Jakarta Sans', 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans Arabic', sans-serif;
}

[data-theme="dark"] {
  --bg: #0B0F17;
  --panel: #121824;
  --surface-2: #1A2232;
  --surface-hover: #212B3F;
  --text: #F1F5F9;
  --text-secondary: #CBD5E1;
  --muted: #94A3B8;
  --border: #222C3E;
  --border-strong: #324158;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.15);
  --primary-soft-2: rgba(59, 130, 246, 0.24);

  --bubble-me: #2563EB;
  --bubble-me-text: #FFFFFF;
  --bubble-me-muted: rgba(255, 255, 255, 0.8);
  --bubble-other: #161E2E;
  --bubble-other-border: #253147;

  --success: #34D399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.6);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

button:active:not(:disabled) { transform: scale(0.985); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.svg-ico {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.32);
  background: transparent;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.48);
}

.btn-sm {
  padding: 6px 11px;
  min-height: 32px;
  font-size: 13px;
  border-radius: 9px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.icon-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
.icon-btn.btn-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  min-height: 42px;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.app-root {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== Auth Hero Split ==================== */
.auth-screen {
  min-height: 100%;
  padding: 28px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(27, 86, 253, 0.11), transparent 65%),
    radial-gradient(ellipse 55% 45% at 88% 85%, rgba(16, 185, 129, 0.08), transparent 60%),
    var(--bg);
}

.auth-split {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 32px;
  align-items: center;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 6px;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.auth-hero-title {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 36px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.025em;
  color: var(--text);
}

.auth-hero-sub {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 48ch;
}

.preview-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.preview-pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.preview-orig {
  font-size: 12.5px;
  color: var(--muted);
}

.preview-trans {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.auth-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.auth-head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.privacy-pill {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-2);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 18px;
}

.privacy-pill .svg-ico {
  color: var(--primary);
  margin-top: 2px;
}

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.dev-otp-box {
  background: var(--surface-2);
  border: 1px dashed var(--primary);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dev-otp-box code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--primary);
}

/* ==================== App Shell: Left Icon Rail + Main ==================== */
.shell {
  height: 100%;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  background: var(--bg);
}

.icon-rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px;
  z-index: 20;
}

.rail-top, .rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.rail-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  text-decoration: none;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.nav-tab {
  position: relative;
  width: 48px;
  height: 46px;
  padding: 0;
  border-radius: 13px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  flex-direction: column;
  gap: 2px;
}

.nav-tab:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: transparent;
}

.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
  font-weight: 700;
}

.nav-tab-label {
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-tab .badge {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-size: 10.5px;
}

.rail-avatar-btn {
  padding: 2px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: transparent;
  min-height: 0;
}
.rail-avatar-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: transparent;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
}
.badge[hidden] { display: none; }

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.avatar-img {
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.main-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==================== Mobile Thumb-Zone Bottom Bar ==================== */
.mobile-bottom-bar {
  display: none;
}

.mobile-only { display: none; }

/* ==================== Chats Workspace ==================== */
.chat-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  position: relative;
}

.room-sidebar {
  border-inline-end: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  padding: 16px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-tools {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-wrap .svg-ico {
  position: absolute;
  inset-inline-start: 11px;
  color: var(--muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  padding-inline-start: 33px;
  min-height: 36px;
  font-size: 13.5px;
  outline: none;
}
.sidebar-search-input:focus {
  background: var(--panel);
  border-color: var(--primary);
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  padding: 4px 10px;
  min-height: 28px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.filter-pill.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: transparent;
}

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-item {
  width: 100%;
  text-align: start;
  justify-content: flex-start;
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 11px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
}
.room-item:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
}
.room-item.active {
  background: var(--primary-soft);
  border-color: var(--primary-soft-2);
}

.room-meta { flex: 1; min-width: 0; }
.room-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.room-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.room-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.room-langs {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==================== Chat Canvas ==================== */
.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  position: relative;
}

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

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-header-info { min-width: 0; }
.chat-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
}
.live-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}
.live-dot.open {
  color: var(--success);
  background: var(--success-soft);
}
.live-dot.open::before { background: var(--success); }

.sponsor-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.room-search-bar {
  display: flex;
  gap: 8px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.pinned-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--primary-soft-2);
  font-size: 13px;
}
.pinned-banner-body {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}
.pinned-banner-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-divider {
  display: flex;
  justify-content: center;
  margin: 12px 0 8px;
}
.day-divider span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: 82%;
  margin-top: 8px;
}
.msg-row.grouped { margin-top: 2px; }
.msg-row.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row.other { align-self: flex-start; }
.msg-row.grouped .avatar-spacer,
.msg-row.grouped .avatar-slot {
  width: 38px;
  flex-shrink: 0;
  visibility: hidden;
  height: 1px;
}

.msg-body,
.msg-body-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}
.msg-row.me .msg-body,
.msg-row.me .msg-body-wrap { align-items: flex-end; }
.msg-row.other .msg-body,
.msg-row.other .msg-body-wrap { align-items: flex-start; }

.msg-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 4px 4px;
}

.msg-cluster {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 100%;
}
.msg-row.me .msg-cluster { flex-direction: row-reverse; }

.bubble,
.msg-bubble {
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--bubble-other-border);
  background: var(--bubble-other);
  color: var(--text);
  word-break: break-word;
  position: relative;
  min-width: 44px;
}
.msg-row.other .bubble,
.msg-row.other .msg-bubble { border-bottom-left-radius: 5px; }
[dir="rtl"] .msg-row.other .bubble,
[dir="rtl"] .msg-row.other .msg-bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 5px;
}

.msg-row.me .bubble,
.msg-row.me .msg-bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border-color: transparent;
  border-bottom-right-radius: 5px;
}
[dir="rtl"] .msg-row.me .bubble,
[dir="rtl"] .msg-row.me .msg-bubble {
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 5px;
}

.bubble-text,
.msg-translated {
  font-size: 15.5px;
  line-height: 1.48;
  font-weight: 400;
}

.bubble-text.deleted-msg {
  font-style: italic;
  opacity: 0.72;
  font-size: 13.5px;
}

.bubble-original,
.msg-original {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  margin-top: 7px;
  padding-top: 6px;
}
.msg-row.me .bubble-original,
.msg-row.me .msg-original {
  color: var(--bubble-me-muted);
  border-top-color: rgba(255, 255, 255, 0.24);
}
.msg-row.me .bubble-original .lang-pill {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.translating-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
}
.msg-row.me .translating-hint { color: var(--bubble-me-muted); }

.slang-notes {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-row.me .slang-notes {
  border-top-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.9);
}

.msg-meta-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex-shrink: 0;
  padding-bottom: 2px;
}
.msg-row.me .msg-meta-side { align-items: flex-end; }

.msg-time-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.unread-num {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--unread-amber);
  line-height: 1;
}

.msg-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.conf-badge,
.msg-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}
.conf-badge.qa-repaired,
.msg-tag.repaired,
.msg-tag.fast {
  color: var(--primary);
  background: var(--primary-soft);
}
.conf-badge.conf-low {
  color: var(--danger);
  background: var(--danger-soft);
}
.edited-tag {
  font-size: 11px;
  color: var(--muted);
}

.bubble-quote,
.msg-quote {
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--surface-2);
  border-inline-start: 3px solid var(--primary);
  margin-bottom: 7px;
  color: var(--text-secondary);
}
.msg-row.me .bubble-quote,
.msg-row.me .msg-quote {
  background: rgba(255, 255, 255, 0.14);
  border-inline-start-color: rgba(255, 255, 255, 0.85);
  color: rgba(255, 255, 255, 0.94);
}

.msg-image {
  display: block;
  max-width: min(290px, 68vw);
  max-height: 290px;
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: zoom-in;
  object-fit: cover;
}
.voice-box,
.msg-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.voice-box audio,
.msg-voice audio {
  max-width: 240px;
  height: 36px;
}
.voice-dur {
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0.82;
}

.mention-chip {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.msg-row.me .mention-chip {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

.msg-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.msg-row:hover .msg-foot,
.msg-row:focus-within .msg-foot {
  opacity: 1;
}

.msg-act-btn {
  padding: 3px 7px;
  min-height: 24px;
  font-size: 11px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
}
.msg-act-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.reaction-pill {
  padding: 2px 8px;
  min-height: 24px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.reaction-pill.mine {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.reaction-picker, .msg-action-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  margin-top: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.msg-deleted {
  font-style: italic;
  color: var(--muted);
  font-size: 13.5px;
}

/* ==================== Composer & Bars ==================== */
.scroll-bottom-btn {
  position: absolute;
  inset-inline-end: 20px;
  bottom: 92px;
  z-index: 6;
  border-radius: 999px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  padding: 8px 15px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
}
.scroll-bottom-btn[hidden] { display: none; }

.typing-bar {
  padding: 4px 20px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.typing-bar[hidden] { display: none; }

.reply-bar, .attach-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.reply-bar-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}
.attach-thumb {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.mention-popup {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
  margin: 0 18px 8px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
}
.mention-popup[hidden] { display: none; }
.mention-opt {
  justify-content: flex-start;
  border: none;
  background: transparent;
  padding: 7px 11px;
  min-height: 36px;
}
.mention-opt:hover { background: var(--surface-2); }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.composer-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}
.composer-input-wrap:focus-within {
  background: var(--panel);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.composer textarea {
  width: 100%;
  resize: none;
  min-height: 36px;
  max-height: 130px;
  line-height: 1.45;
  padding: 6px 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
}
.composer textarea:placeholder-shown {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-send-btn {
  height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 999px;
}

/* ==================== Slide-Over Room Drawer ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: min(360px, 92vw);
  height: 100%;
  background: var(--panel);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px;
  gap: 16px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

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

/* ==================== Pages: QR / Friends / Billing / Settings ==================== */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 48px;
}

.page-header {
  max-width: 1060px;
  margin: 0 auto 18px;
}
.page-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.page-header p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  max-width: 1060px;
  margin: 0 auto 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  margin: 0 0 6px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.card-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.qr-frame {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  justify-content: center;
  margin: 10px 0 14px;
}
.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scanner-box {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #0B0F17;
  color: #CBD5E1;
  min-height: 110px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  margin-bottom: 10px;
}
.scanner-box video {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}
.scanner-box[hidden] { display: none; }

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}
.person-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.person-name {
  font-weight: 700;
  font-size: 14px;
}
.person-sub {
  font-size: 12px;
  color: var(--muted);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 14px;
  max-width: 1060px;
  margin: 0 auto 20px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.plan-card.current {
  border: 2px solid var(--primary);
  box-shadow: 0 8px 24px rgba(27, 86, 253, 0.12);
}
.plan-price {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.plan-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}
.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
.plan-features li::before {
  content: '✓';
  color: var(--primary);
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 12px 0 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #38BDF8);
  border-radius: 999px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  color: var(--muted);
  gap: 10px;
}
.empty-state h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}
.empty-state p {
  margin: 0;
  max-width: 38ch;
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.lightbox-wrap img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.toast-root {
  position: fixed;
  inset-inline-end: 18px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 340px;
}
.toast.err { background: var(--danger); }

.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.lab-card {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px;
  background: var(--surface-2);
}

/* ==================== Mobile Responsive Rules (<= 768px) ==================== */
@media (max-width: 900px) {
  .auth-split {
    grid-template-columns: 1fr;
    gap: 20px;
    max-width: 480px;
  }
  .auth-hero-title { font-size: 24px; }
}

@media (max-width: 768px) {
  .mobile-only { display: inline-flex; }

  .shell {
    flex-direction: column;
  }

  .icon-rail {
    display: none;
  }

  .mobile-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    min-height: var(--mobile-bar-h);
    flex-shrink: 0;
    z-index: 25;
  }

  .mobile-bottom-bar .nav-tab {
    flex: 1;
    height: 48px;
    max-width: 88px;
    border-radius: 12px;
    gap: 3px;
  }

  .mobile-bottom-bar .nav-tab-label {
    font-size: 11px;
  }

  /* When inside an active chat room on mobile, hide bottom bar for full-screen room UX */
  .shell.in-room-mobile .mobile-bottom-bar {
    display: none;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-layout.has-active-room .room-sidebar {
    display: none;
  }

  .chat-layout:not(.has-active-room) .chat-pane {
    display: none;
  }

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

  .messages-scroll {
    padding: 12px;
  }

  .msg-row {
    max-width: 90%;
  }

  .msg-foot {
    opacity: 1;
  }

  .composer {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }

  .composer textarea {
    font-size: 16px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .page-scroll {
    padding: 16px 14px 28px;
  }

  .scroll-bottom-btn {
    inset-inline-end: 14px;
    bottom: 82px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
