/* ============================================================
   BEKOFRESH – CHAT PAGE STYLES
   ============================================================ */

/* ── Base ──────────────────────────────────────────────────── */
[hidden] { display: none !important; }

html, body { height: 100%; overflow: hidden; }

#chatScreen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Nickname Overlay ──────────────────────────────────────── */
.nick-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}

.nick-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  max-width: 400px; width: 92%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: nickSlideUp 0.3s ease;
}

@keyframes nickSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nick-logo { width: 68px; margin: 0 auto 22px; }
.nick-card h2 { margin-bottom: 8px; font-size: 1.45rem; color: var(--dark); }
.nick-hint { color: var(--muted); font-size: 0.875rem; margin-bottom: 22px; line-height: 1.5; }

.nick-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-size: 1rem; font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 16px;
}
.nick-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}
.nick-input.error { border-color: #e74c3c; }

.nick-btn {
  width: 100%; padding: 14px;
  background: var(--green); color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 1rem;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  border: none; cursor: pointer;
}
.nick-btn:hover { background: var(--green-dark); }
.nick-btn:active { transform: scale(0.98); }

/* ── Full Screen Message ────────────────────────────────────── */
.full-screen-msg {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

.fsm-card {
  text-align: center;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.fsm-logo { width: 72px; margin: 0 auto 24px; }
.fsm-card p { color: var(--muted); margin-bottom: 24px; line-height: 1.7; font-size: 0.95rem; }

.fsm-back {
  display: inline-block; padding: 11px 28px;
  background: var(--green); color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.9rem;
  transition: background 0.2s;
}
.fsm-back:hover { background: var(--green-dark); }

/* ── Chat Header ─────────────────────────────────────────────── */
.chat-header {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.chat-back-btn {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 0.85rem;
  transition: color 0.2s; text-decoration: none;
  flex-shrink: 0;
}
.chat-back-btn:hover { color: var(--green); }

.chat-header-brand {
  display: flex; align-items: center; gap: 8px;
  position: absolute; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}
.chat-header-logo { width: 28px; height: 28px; }
.chat-header-title {
  font-size: 1rem; font-weight: 700;
  color: var(--dark); letter-spacing: 0.3px;
}

.chat-header-right {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.chat-nick-display {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--muted);
}

.chat-lang-btn {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.78rem; font-family: inherit;
  color: var(--text); cursor: pointer;
  transition: all 0.2s; background: transparent;
}
.chat-lang-btn:hover { border-color: var(--green); color: var(--green); }

.mod-badge {
  background: #e74c3c; color: #fff;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase;
}
.mod-badge.hidden { display: none !important; }

/* ── Blocked Banner ─────────────────────────────────────────── */
.blocked-banner {
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 8px;
  font-size: 0.84rem; line-height: 1.5;
  flex-shrink: 0;
}

/* ── Moderator Panel ─────────────────────────────────────────── */
.mod-panel {
  background: #130a0a;
  border-bottom: 2px solid #3d1a1a;
  padding: 10px 20px 12px;
  flex-shrink: 0;
}

.mod-panel-inner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.mod-panel-title {
  color: #e74c3c; font-weight: 700;
  font-size: 0.72rem; letter-spacing: 1.5px;
  text-transform: uppercase; margin-inline-end: 6px;
}

.mod-action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px;
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.35);
  color: #e74c3c; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-family: inherit;
  cursor: pointer; transition: all 0.18s;
}
.mod-action-btn:hover { background: rgba(231, 76, 60, 0.28); }
.mod-action-btn.cancel {
  background: rgba(127, 140, 141, 0.12);
  border-color: rgba(127, 140, 141, 0.3);
  color: var(--muted);
}
.mod-action-btn.cancel:hover { background: rgba(127, 140, 141, 0.25); }

.create-room-panel {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; flex-wrap: wrap;
}
.create-room-input {
  max-width: 240px; margin-bottom: 0 !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(231, 76, 60, 0.35) !important;
  color: #f0e0e0 !important;
}
.create-room-input::placeholder { color: rgba(200,180,180,0.5); }
.create-room-input:focus {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15) !important;
}
.create-room-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: rgba(240, 224, 224, 0.85);
  cursor: pointer; user-select: none;
}
.create-room-check input { accent-color: #e74c3c; }

/* Auto-translation tag below message bubbles */
.msg-bubble .msg-tr-tag {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.55);
}
.msg-bubble .msg-tr-tag:empty { display: none; }
.msg-bubble .beko-tr-toggle {
  color: inherit;
  text-decoration: underline;
  font-style: normal;
  cursor: pointer;
}

.blocked-drawer {
  margin-top: 10px;
  max-height: 160px; overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 8px;
}

.blocked-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.blocked-id {
  font-size: 0.78rem; color: #9a7070;
  font-family: monospace; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px;
}
.btn-unblock {
  padding: 3px 10px;
  background: rgba(39, 174, 96, 0.15);
  border: 1px solid rgba(39, 174, 96, 0.35);
  color: var(--green); border-radius: var(--radius-sm);
  font-size: 0.73rem; font-family: inherit;
  cursor: pointer; transition: all 0.18s; white-space: nowrap;
}
.btn-unblock:hover { background: rgba(39, 174, 96, 0.3); }

.chat-hint { color: var(--muted); font-size: 0.82rem; }

/* ── Chat Layout ─────────────────────────────────────────────── */
.chat-layout {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}

/* ── Rooms Sidebar ───────────────────────────────────────────── */
.rooms-sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}

.rooms-header {
  padding: 13px 16px 11px;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rooms-list { overflow-y: auto; flex: 1; padding: 6px 0; list-style: none; margin: 0; }

.room-item {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 16px; cursor: pointer;
  color: var(--muted); font-size: 0.875rem;
  transition: all 0.15s; list-style: none;
  user-select: none;
}
.room-item:hover { background: var(--bg); color: var(--text); }
.room-item.active {
  background: rgba(39, 174, 96, 0.1);
  color: var(--green); font-weight: 600;
}
.room-hash { opacity: 0.45; font-size: 1.05rem; flex-shrink: 0; }
.room-item.active .room-hash { opacity: 0.9; color: var(--green); }

.no-rooms {
  padding: 14px 16px; color: var(--muted);
  font-size: 0.84rem; list-style: none;
}

/* ── Chat Main ────────────────────────────────────────────────── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  background: var(--bg);
}

.chat-main-header {
  padding: 11px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: var(--dark); font-size: 0.95rem;
  flex-shrink: 0; min-height: 46px;
}

.current-room-name::before { content: '# '; color: var(--muted); font-weight: 400; }

.mod-del-room-btn {
  padding: 5px 12px;
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.28);
  color: #e74c3c; border-radius: var(--radius-sm);
  font-size: 0.76rem; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.mod-del-room-btn:hover { background: rgba(231, 76, 60, 0.22); }
.mod-del-room-btn.hidden { display: none !important; }

/* ── Messages Area ─────────────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 0;
}

.no-messages {
  text-align: center; color: var(--muted);
  font-size: 0.9rem; margin: auto;
  padding: 48px 20px;
}

/* ── Message Rows ─────────────────────────────────────────── */
.msg-row {
  display: flex;
  justify-content: flex-start;
  animation: msgFadeIn 0.2s ease;
}
.msg-row.own { justify-content: flex-end; }

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bubble {
  max-width: 68%;
  background: var(--surface);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  padding: 8px 12px 5px;
  box-shadow: var(--shadow-sm);
  position: relative;
  word-break: break-word;
}
/* When mod dots button is present, reserve space in the top-right corner */
.msg-bubble.has-mod-dots { padding-inline-end: 30px; }

.msg-row.own .msg-bubble {
  background: var(--green);
  color: #fff;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
}

/* RTL flip for bubble corner */
[dir="rtl"] .msg-bubble        { border-radius: var(--radius-md); border-bottom-right-radius: 4px; }
[dir="rtl"] .msg-row.own .msg-bubble { border-radius: var(--radius-md); border-bottom-left-radius: 4px; }

.msg-nick {
  display: block;
  font-size: 0.72rem; font-weight: 700;
  color: var(--green); margin-bottom: 3px;
  /* per-user colour comes from inline style="color:hsl(...)"; this is the
     fallback if JS hasn't applied it yet. */
}
/* Inside the user's own bubble (green background) the per-user hue would
   be unreadable, so always show their nick in white there. */
.msg-row.own .msg-nick { color: rgba(255,255,255,0.92) !important; }
/* Thin coloured stripe on the side of each bubble matches the nickname,
   making it easy to scan who's who at a glance. */
.msg-bubble { border-left: 3px solid var(--user-color, transparent); }
.msg-row.own .msg-bubble { border-left: 0; border-right: 3px solid rgba(255,255,255,0.45); }
[dir="rtl"] .msg-bubble { border-left: 0; border-right: 3px solid var(--user-color, transparent); }
[dir="rtl"] .msg-row.own .msg-bubble { border-right: 0; border-left: 3px solid rgba(255,255,255,0.45); }

.msg-text {
  display: block;
  font-size: 0.9rem; line-height: 1.55;
  white-space: pre-wrap;
}
.msg-row.own .msg-text { color: #fff; }

.deleted-text {
  color: var(--muted) !important;
  font-style: italic;
  font-size: 0.83rem !important;
  opacity: 0.75;
}
.msg-row.own .deleted-text { color: rgba(255,255,255,0.6) !important; }

.msg-row.msg-deleted .msg-bubble {
  background: rgba(231, 76, 60, 0.05);
  border: 1px dashed rgba(231, 76, 60, 0.25);
}
.msg-row.msg-deleted.own .msg-bubble {
  background: rgba(231, 76, 60, 0.18);
  border-color: rgba(231, 76, 60, 0.3);
}

.msg-meta {
  display: flex; align-items: center;
  justify-content: flex-end; gap: 5px;
  margin-top: 4px;
}
.msg-time {
  font-size: 0.66rem; color: var(--muted);
  white-space: nowrap;
}
.msg-row.own .msg-time { color: rgba(255, 255, 255, 0.65); }

/* Mod 3-dots button — corner of each message bubble */
.msg-bubble { position: relative; }

.mod-dots-wrap {
  position: absolute;
  top: 5px;
  right: 6px;
  z-index: 10;
}
[dir="rtl"] .mod-dots-wrap { right: auto; left: 6px; }

.mod-dots-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
/* Show on hover over message row */
.msg-row:hover .mod-dots-btn { opacity: 1; }
/* Own messages: lighter color */
.msg-row.own .mod-dots-btn { color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.18); border-color: rgba(255,255,255,0.2); }
/* Touch devices: always visible */
@media (hover: none) { .mod-dots-btn { opacity: 0.75; } }

/* Dropdown menu */
.mod-dots-menu {
  position: absolute;
  top: 26px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 130px;
  z-index: 200;
  overflow: hidden;
}
[dir="rtl"] .mod-dots-menu { right: auto; left: 0; }

.mod-menu-item {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 9px 13px;
  background: none; border: none;
  font-size: 0.82rem; font-family: inherit;
  cursor: pointer; color: var(--text);
  transition: background 0.12s;
  text-align: start; white-space: nowrap;
}
.mod-menu-item:hover { background: var(--bg); }
.mod-menu-item.danger { color: #e74c3c; }
.mod-menu-item.danger:hover { background: rgba(231,76,60,0.07); }
.mod-menu-item.warn { color: #e67e22; }
.mod-menu-item.warn:hover { background: rgba(230,126,34,0.07); }

/* ── Message Input ─────────────────────────────────────────── */
.message-input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Toolbar buttons (emoji / GIF) */
.chat-tool-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border: none; background: transparent;
  color: var(--text-soft, #666);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chat-tool-btn:hover  { background: rgba(0,0,0,0.06); color: var(--green); }
.chat-tool-btn:active { transform: scale(0.92); }
.chat-gif-label {
  font-weight: 800; font-size: 0.7rem; letter-spacing: 0.04em;
  border: 1.5px solid currentColor; border-radius: 4px;
  padding: 1px 4px; line-height: 1;
}

#msgInput.error {
  border-color: #d9534f;
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.18);
  animation: bekoShake 0.35s ease;
}
@keyframes bekoShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* Emoji + GIF panels */
.chat-picker {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  max-height: 280px;
  display: flex; flex-direction: column;
}
.chat-picker[hidden] { display: none; }
.chat-picker-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 600;
  color: var(--text);
}
.chat-picker-header > span { flex: 1; }
.chat-picker-header input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg); color: var(--text);
  font-size: 0.85rem; font-family: inherit;
  outline: none;
}
.chat-picker-header input:focus { border-color: var(--green); }
.chat-picker-close {
  width: 26px; height: 26px;
  border: none; background: transparent;
  color: var(--text-soft, #888);
  font-size: 1.4rem; line-height: 1;
  border-radius: 50%; cursor: pointer;
}
.chat-picker-close:hover { background: rgba(0,0,0,0.06); color: var(--text); }

.emoji-grid {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
}
.emoji-btn {
  width: 100%; aspect-ratio: 1;
  border: none; background: transparent;
  font-size: 1.35rem; line-height: 1;
  border-radius: 6px; cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.emoji-btn:hover  { background: rgba(0,0,0,0.06); }
.emoji-btn:active { transform: scale(0.85); }

.gif-grid {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}
.gif-thumb {
  width: 100%; aspect-ratio: 1;
  border: none; padding: 0; margin: 0;
  border-radius: 6px; overflow: hidden;
  cursor: pointer; background: rgba(0,0,0,0.05);
  transition: transform 0.12s;
}
.gif-thumb:hover  { transform: scale(1.04); }
.gif-thumb img    { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px 16px;
  color: var(--text-soft, #888);
  font-size: 0.85rem;
}

/* GIF messages */
.msg-bubble-gif    { padding: 4px !important; background: transparent !important; }
.msg-bubble-gif .msg-nick { padding: 4px 6px 0; }
.msg-bubble-gif .msg-meta { padding: 2px 6px 4px; }
.msg-gif-link      { display: block; }
.msg-gif {
  max-width: 240px; max-height: 240px;
  width: 100%; height: auto;
  border-radius: 10px;
  display: block;
}

@media (max-width: 560px) {
  .chat-tool-btn { width: 34px; height: 34px; }
  .message-input-area { gap: 6px; padding: 10px 12px; }
  .chat-picker { max-height: 220px; }
  .gif-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .msg-gif { max-width: 200px; max-height: 200px; }
}

#msgInput {
  flex: 1;
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg); color: var(--text);
  font-size: 0.9rem; font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#msgInput:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.12);
}

.send-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  background: var(--green); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s;
  border: none; cursor: pointer;
}
.send-btn:hover  { background: var(--green-dark); }
.send-btn:active { transform: scale(0.92); }

/* ── Scrollbar ─────────────────────────────────────────────── */
.messages-area::-webkit-scrollbar,
.rooms-list::-webkit-scrollbar { width: 5px; }
.messages-area::-webkit-scrollbar-track,
.rooms-list::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb,
.rooms-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ── Premium Theme Overrides ────────────────────────────────── */
body.theme-premium .chat-header {
  background: rgba(15, 8, 8, 0.96);
  border-color: var(--border);
}
body.theme-premium .rooms-sidebar {
  background: #140c0c;
  border-color: var(--border);
}
body.theme-premium .room-item.active {
  background: rgba(184, 115, 51, 0.14);
  color: var(--green); /* bronze in premium */
}
body.theme-premium .room-item.active .room-hash { color: var(--green); }
body.theme-premium .msg-nick { color: var(--green); }
body.theme-premium .msg-row.own .msg-bubble {
  background: linear-gradient(135deg, var(--orange-dark), var(--green));
}
body.theme-premium .nick-btn,
body.theme-premium .send-btn,
body.theme-premium .fsm-back {
  background: linear-gradient(135deg, var(--orange), var(--green));
}
body.theme-premium .nick-btn:hover,
body.theme-premium .send-btn:hover {
  background: linear-gradient(135deg, var(--green), var(--orange));
}
body.theme-premium #msgInput:focus { border-color: var(--green); }
body.theme-premium .chat-lang-btn:hover { color: var(--green); border-color: var(--green); }
body.theme-premium .chat-main { background: #0f0808; }
body.theme-premium .chat-main-header { background: #150e0e; border-color: var(--border); }
body.theme-premium .message-input-area { background: #150e0e; border-color: var(--border); }
body.theme-premium #msgInput { background: #1a1010; border-color: var(--border); color: var(--text); }

/* ── Responsive ─────────────────────────────────────────────── */
/* Tablet */
@media (max-width: 768px) {
  .rooms-sidebar { width: 170px; }
  .msg-bubble { max-width: 78%; }
}

/* Mobile: sidebar becomes a horizontal tab strip above messages */
@media (max-width: 560px) {
  html, body { height: 100%; overflow: hidden; }

  #chatScreen {
    display: flex; flex-direction: column;
    height: 100dvh; /* dynamic viewport height — fixes iOS address bar */
    overflow: hidden;
  }

  /* Header: compact on mobile */
  .chat-header { height: 52px; padding: 0 12px; }
  .chat-header-brand { position: static; transform: none; }
  .chat-header-title { font-size: 0.9rem; }
  .chat-header-logo  { width: 22px; height: 22px; }
  .chat-back-btn span { display: none; }
  .chat-nick-display  { display: none; }
  .chat-lang-btn { padding: 4px 9px; font-size: 0.73rem; }
  .mod-badge { padding: 2px 7px; font-size: 0.62rem; }

  /* Rooms sidebar → horizontal scrollable tab strip */
  .chat-layout { flex-direction: column; }

  .rooms-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
  }

  .rooms-header {
    display: none; /* hidden — "Rooms" label not needed in tab strip */
  }

  .rooms-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    flex: 1;
  }
  .rooms-list::-webkit-scrollbar { display: none; }

  .room-item {
    flex-shrink: 0;
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .room-item span:not(.room-hash) { display: inline; } /* show names in tab strip */
  .room-item.active {
    background: transparent;
    border-bottom-color: var(--green);
    color: var(--green);
  }

  .no-rooms { padding: 10px 14px; }

  /* Chat main: fill remaining space */
  .chat-main { min-height: 0; }

  .chat-main-header { padding: 8px 14px; min-height: 40px; font-size: 0.88rem; }
  .current-room-name::before { content: '# '; }
  .mod-del-room-btn { font-size: 0.7rem; padding: 4px 9px; }

  /* Messages: better padding + bigger max bubble */
  .messages-area { padding: 12px 10px; gap: 5px; }
  .msg-bubble { max-width: 86%; padding: 7px 10px 5px; }

  /* Input area: compact */
  .message-input-area { padding: 8px 10px; gap: 8px; }
  #msgInput { padding: 9px 14px; font-size: 0.88rem; }
  .send-btn { width: 38px; height: 38px; }

  /* Mod panel: wrap tighter */
  .mod-panel { padding: 8px 12px 10px; }
  .mod-action-btn { padding: 5px 10px; font-size: 0.75rem; }
  .create-room-input { max-width: 100%; }

  /* 3-dots: always visible on touch */
  .mod-dots-btn { opacity: 0.75; }
  /* Dropdown: ensure it doesn't overflow the screen edge */
  .mod-dots-menu { min-width: 120px; font-size: 0.8rem; }
}
