@import url('brand.css');

:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-accent: #383a40;
  --bg-hover: #35373c;
  --text-primary: #f2f3f5;
  --text-muted: #949ba4;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --neon: #7289ff;
  --neon-glow: rgba(88, 101, 242, 0.45);
  --green: #23a559;
  --red: #da373c;
  --input-bg: #383a40;
  --border: #3f4147;
  --panel-border: rgba(255,255,255,0.06);
  --server-bar: #1e1f22;
  --channel-bar: #2b2d31;
  --radius: 8px;
}

body.theme-amoled {
  --bg-primary: #000; --bg-secondary: #0a0a0a; --bg-tertiary: #000;
  --bg-accent: #111; --channel-bar: #0a0a0a; --server-bar: #000;
}

body.theme-neon {
  --brand: #7c3aed;
  --neon: #a78bfa;
  --neon-glow: rgba(167, 139, 250, 0.5);
  --bg-primary: #1a1b26;
  --bg-secondary: #16161e;
  --channel-bar: #16161e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'gg sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 72px 260px 1fr 260px;
  height: 100vh;
  gap: 0;
}

.hidden { display: none !important; }
.clickable { cursor: pointer; }
.empty-hint { color: var(--text-muted); font-size: 0.82rem; padding: 8px 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; display: block; }

.panel-border { border: 1px solid var(--panel-border); }
.panel-border-sm { border: 1px solid var(--panel-border); border-radius: var(--radius); }
.panel-border-top { border-top: 1px solid var(--panel-border); }
.panel-border-bottom { border-bottom: 1px solid var(--panel-border); }
.glow { box-shadow: 0 0 24px var(--neon-glow); }

/* Neon buttons */
.neon-btn {
  padding: 10px 18px;
  border: 1px solid var(--neon);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(88,101,242,0.15), rgba(88,101,242,0.05));
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 0 12px var(--neon-glow);
}
.neon-btn:hover { box-shadow: 0 0 20px var(--neon-glow); transform: translateY(-1px); }
.neon-btn.primary { background: linear-gradient(135deg, var(--brand), #7289da); border-color: transparent; color: #fff; }
.neon-btn.secondary { background: var(--bg-accent); border-color: var(--border); box-shadow: none; }
.neon-btn.success { background: linear-gradient(135deg, #23a559, #1a7d44); border-color: transparent; color: #fff; }
.neon-btn.danger { background: linear-gradient(135deg, #da373c, #a12828); border-color: transparent; color: #fff; }
.neon-btn.xs { padding: 4px 10px; font-size: 0.75rem; }
.neon-btn-sm { box-shadow: 0 0 8px var(--neon-glow); }
.neon-icon {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: 6px; font-size: 1rem;
  transition: color 0.2s, box-shadow 0.2s;
}
.neon-icon:hover { color: var(--neon); box-shadow: 0 0 10px var(--neon-glow); }
.send-btn { min-width: 80px; }

/* Server bar */
.server-bar {
  background: var(--server-bar);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 8px; overflow-y: auto;
  border-left: 1px solid var(--panel-border);
}
.server-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  font-weight: 700; font-size: 0.85rem;
  transition: border-radius 0.2s, background 0.2s, box-shadow 0.2s;
  border: 2px solid transparent; color: var(--text-primary);
}
.server-icon:hover, .server-icon.active {
  border-radius: 16px; background: var(--brand);
  box-shadow: 0 0 16px var(--neon-glow);
}
.server-icon.has-image {
  padding: 0;
  overflow: hidden;
  background: var(--bg-primary);
}
.server-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.home-icon { background: var(--brand); border-radius: 16px; position: relative; }
.unread-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ed4245;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-tertiary);
  z-index: 2;
}
.unread-badge.hidden { display: none !important; }
.dm-item { position: relative; }
.dm-item.has-unread {
  background: rgba(88, 101, 242, 0.12);
  border-right: 3px solid var(--neon);
}
.dm-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #ed4245;
  vertical-align: middle;
}
.dm-unread-count {
  position: static;
  margin-right: auto;
}
.toast-dm {
  border-color: #ed4245;
  box-shadow: 0 6px 28px rgba(237, 66, 69, 0.4);
  background: #2b2d31;
}
.toast-dm strong { display: block; margin-bottom: 4px; }
.toast-dm small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 0.75rem; }
.toast-clickable { cursor: pointer; }
.global-icon {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-radius: 16px;
  width: 52px;
  height: auto;
  min-height: 48px;
  padding: 6px 4px;
  border: 2px solid var(--neon);
  box-shadow: 0 0 14px var(--neon-glow), inset 0 0 8px rgba(88, 101, 242, 0.2);
}
.global-icon:hover, .global-icon.active {
  border-color: #eb459e;
  box-shadow: 0 0 20px rgba(235, 69, 158, 0.6), 0 0 10px var(--neon-glow);
}
.global-logo {
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  background: linear-gradient(90deg, var(--neon), #eb459e, #f0b232);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.neon-ring { animation: neon-pulse 2.5s ease-in-out infinite; }
@keyframes neon-pulse {
  0%, 100% { box-shadow: 0 0 12px var(--neon-glow); }
  50% { box-shadow: 0 0 22px rgba(235, 69, 158, 0.55), 0 0 12px var(--neon-glow); }
}
.home-logo {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.1;
}
.add-server, .join-server { background: var(--bg-primary); color: var(--green); font-size: 1.3rem; }
.server-divider { width: 32px; height: 2px; background: var(--border); margin: 4px 0; }

/* Sidebar */
.channel-bar {
  background: var(--channel-bar);
  display: flex; flex-direction: column; overflow: hidden;
}
.server-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.server-header h2 { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em; }
.sidebar-view { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }

.channel-category {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-muted); padding: 18px 8px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.channel-category button { background: none; border: none; color: var(--text-muted); cursor: pointer; }

.channel-item, .friend-item {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  color: var(--text-muted); display: flex; align-items: center; gap: 10px;
  font-size: 0.92rem; margin-bottom: 2px;
}
.channel-item:hover, .friend-item:hover { background: var(--bg-accent); color: var(--text-primary); }
.channel-item.active { background: var(--bg-hover); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--panel-border); }
.friend-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-name { font-weight: 600; color: var(--text-primary); font-size: 0.88rem; }
.friend-status { font-size: 0.72rem; color: var(--text-muted); }

/* Avatar */
.avatar, .avatar-wrap .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; flex-shrink: 0; overflow: hidden;
}
.avatar img, .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 0.65rem; }
.avatar.large { width: 80px; height: 80px; font-size: 1.4rem; margin-bottom: 12px; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.6rem; margin-top: -48px; border: 4px solid var(--bg-secondary); }

.avatar-wrap { position: relative; }
.presence-dot {
  position: absolute; bottom: 0; left: 0; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--bg-tertiary);
}
.presence-dot.online { background: var(--green); }
.presence-dot.idle { background: #faa61a; }
.presence-dot.dnd { background: var(--red); }
.presence-dot.offline { background: #747f8d; }

.user-panel {
  background: rgba(0,0,0,0.2); padding: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-name { display: block; font-size: 0.85rem; font-weight: 600; }
.user-status { font-size: 0.72rem; color: var(--text-muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.user-controls { display: flex; gap: 2px; }

/* Main */
.main-content { background: var(--bg-primary); display: flex; flex-direction: column; min-width: 0; }

.stories-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--panel-border); overflow: hidden;
}
.story-add {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  font-size: 1.5rem; padding: 0;
}
.stories-scroll { display: flex; gap: 12px; overflow-x: auto; flex: 1; padding: 4px 0; align-items: center; }

.story-ring-wrap {
  position: relative;
  flex-shrink: 0;
  width: 62px;
  height: 62px;
}
.story-add-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  box-shadow: 0 0 8px var(--neon-glow);
}
.story-ring {
  position: relative;
  flex-shrink: 0;
  width: 58px; height: 58px;
  border-radius: 50%; padding: 3px;
  border: none; cursor: pointer;
  background: var(--bg-tertiary, #36393f);
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-ring.unseen {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  box-shadow: 0 0 12px rgba(225, 48, 108, 0.45);
}
.story-ring.seen {
  background: #555;
  box-shadow: none;
}
.story-ring.empty {
  background: var(--border);
  box-shadow: none;
}
.story-ring.story-own { width: 58px; height: 58px; }
.story-count-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  border: 2px solid var(--bg-secondary);
}
.story-ring img, .story-ring span {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; color: #fff;
  background: var(--bg-primary);
  border: 2px solid var(--bg-secondary);
  box-sizing: border-box;
}
.story-overlay-text {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  text-align: center;
  max-width: 90%;
  pointer-events: none;
  z-index: 4;
}
#storyViewerMedia { position: relative; }
.story-viewer-tools {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.story-tool-btn {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1rem;
}
.story-tool-btn.danger:hover { background: rgba(237, 66, 69, 0.5); }
#storyMentions { width: 100%; min-height: 80px; margin-bottom: 8px; }

/* GLOBAL feed */
.global-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.global-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  flex-shrink: 0;
}
.global-sort-hint { font-size: 0.75rem; color: var(--text-muted); }
.global-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.global-empty { padding: 40px; }
.global-post {
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}
.global-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.global-post-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.global-post-meta span { font-size: 0.75rem; color: var(--text-muted); }
.global-score { font-size: 0.8rem; color: #f0b232; }
.global-post-media {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  display: block;
  background: #000;
}
.global-post-caption { padding: 10px 14px; font-size: 0.9rem; line-height: 1.5; }
.global-post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--panel-border);
  flex-wrap: wrap;
}
.global-action-btn {
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}
.global-action-btn:hover { background: var(--bg-primary); }
.global-action-btn.active {
  border-color: var(--neon);
  background: rgba(88, 101, 242, 0.15);
}
.global-action-btn.danger { border-color: var(--red); }
.global-views { margin-right: auto; font-size: 0.8rem; color: var(--text-muted); }
.global-comments-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.global-comment {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.global-comment p { margin: 4px 0 0; font-size: 0.85rem; }
.global-comment-compose {
  display: flex;
  gap: 8px;
}
.global-comment-compose input { flex: 1; }

.story-my {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.story-my-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--neon);
  box-shadow: 0 0 10px var(--neon-glow);
  background: #000;
  position: relative;
}
.story-my-thumb img,
.story-my-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-vid-icon,
.story-audio-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.1rem;
}
.story-my-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header {
  padding: 12px 20px; display: flex; align-items: center; gap: 12px;
  min-height: 52px;
}
.header-titles { flex: 1; min-width: 0; }
.chat-header h3 { font-size: 1rem; font-weight: 700; }
.header-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.channel-icon { color: var(--text-muted); font-weight: 700; font-size: 1.2rem; }
.header-actions { display: flex; gap: 6px; }
.header-btn { padding: 6px 12px; font-size: 0.9rem; }

.content-area { flex: 1; overflow-y: auto; padding: 16px 20px; }
.content-area.has-global {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.content-area.has-global .global-view {
  flex: 1;
  min-height: 0;
}
.content-area.server-text-view {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content-area.server-text-view .chat-messages:not(.hidden) {
  flex: 1;
  overflow-y: auto;
  min-height: 160px;
}

.welcome-card {
  max-width: 480px; margin: 40px auto; padding: 32px; text-align: center;
  border-radius: 12px; background: var(--bg-secondary);
}
.welcome-card h2 { margin-bottom: 10px; }
.welcome-card p { color: var(--text-muted); margin-bottom: 20px; }

.chat-messages { display: flex; flex-direction: column; gap: 2px; }

.message {
  display: flex; gap: 14px; padding: 4px 8px; border-radius: 6px;
}
.message:hover { background: rgba(0,0,0,0.08); }
.msg-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.msg-body { min-width: 0; flex: 1; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-author { font-weight: 600; font-size: 0.95rem; }
.msg-author:hover { text-decoration: underline; cursor: pointer; }
.msg-time { font-size: 0.68rem; color: var(--text-muted); }
.msg-content { word-break: break-word; line-height: 1.45; font-size: 0.95rem; }

.msg-attachment { margin-top: 6px; }
.msg-attachment img { max-width: 400px; max-height: 300px; border-radius: 8px; border: 1px solid var(--panel-border); }
.msg-attachment video { max-width: 400px; border-radius: 8px; }
.msg-attachment.file a { color: var(--neon); text-decoration: none; }

.chat-input-bar {
  padding: 14px 20px; display: flex; gap: 10px; align-items: center;
  background: var(--bg-secondary);
}
.attach-btn {
  font-size: 1.2rem;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.chat-input-bar input[type=text] {
  flex: 1; padding: 12px 16px; background: var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 0.95rem;
}
.chat-input-bar input:focus { outline: none; border-color: var(--neon); box-shadow: 0 0 8px var(--neon-glow); }

/* Voice */
.voice-panel { max-width: 900px; margin: 0 auto; }
.voice-screen-banner {
  margin: 12px 0 4px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(88, 101, 242, 0.18);
  border: 1px solid rgba(88, 101, 242, 0.45);
  color: var(--text-primary);
  font-weight: 600;
  text-align: center;
}
.voice-screen-banner.hidden { display: none; }
.voice-screen-banner p { margin: 0 0 8px; }
.voice-screen-banner-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.voice-bar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.voice-participants {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin: 20px 0;
}
.voice-user-card { padding: 16px; text-align: center; }
.voice-user-card.speaking .voice-avatar-wrap,
.voice-sidebar-user.speaking .voice-avatar-wrap {
  box-shadow: 0 0 0 3px var(--green), 0 0 14px rgba(35, 165, 89, 0.55);
  border-radius: 50%;
}
.voice-avatar-wrap {
  position: relative;
  display: inline-flex;
  border-radius: 50%;
  transition: box-shadow 0.15s ease;
}
.voice-mute-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2b2d31;
  border: 2px solid #ed4245;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  line-height: 1;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.voice-sidebar-user .voice-mute-badge {
  width: 17px;
  height: 17px;
  font-size: 0.52rem;
  right: -2px;
  bottom: -2px;
}
.voice-avatar-wrap.is-muted .avatar {
  opacity: 0.82;
}
.voice-avatar-wrap.speaking {
  box-shadow: 0 0 0 3px var(--green), 0 0 14px rgba(35, 165, 89, 0.55);
}
.voice-join-btn {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--green);
  background: rgba(35, 165, 89, 0.15);
  color: var(--green);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.voice-join-btn:hover { background: var(--green); color: #fff; }
.voice-join-btn.connected {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.voice-connected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  margin: 0 12px 8px;
  background: rgba(35, 165, 89, 0.12);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
  font-size: 0.9rem;
}
.voice-connected-bar.hidden { display: none; }
.neon-btn.xs { padding: 4px 10px; font-size: 0.75rem; }
.voice-user-card.is-me {
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(35, 165, 89, 0.25);
}
.voice-user-name { margin-top: 8px; font-weight: 600; font-size: 0.9rem; }
.you-badge { color: var(--green); font-size: 0.8rem; font-weight: 700; }
.voice-panel-count {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 0 8px;
  font-weight: 600;
}
.channel-item-wrap { margin-bottom: 2px; }
.channel-item.in-voice { color: var(--green); }
.channel-item .channel-name { flex: 1; }
.voice-count {
  font-size: 0.7rem;
  background: var(--green);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 700;
}
.voice-channel-users {
  padding: 4px 8px 8px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.voice-sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 2px 0;
}
.voice-sidebar-user.is-me { color: var(--green); font-weight: 600; }
.voice-sidebar-user .avatar.sm { width: 22px; height: 22px; font-size: 0.55rem; }
.channel-item { display: flex; align-items: center; gap: 6px; }
.voice-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.tunnel-section { padding: 16px; margin-top: 16px; border-radius: var(--radius); }
.tunnel-create { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tunnel-create input, .tunnel-create select {
  padding: 8px; background: var(--input-bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary);
}

/* Members panel */
.members-bar {
  background: var(--channel-bar);
  padding: 12px;
  overflow-y: auto;
}

.members-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: inset 0 0 0 1px var(--panel-border), 0 4px 20px rgba(0,0,0,0.15);
}

.members-count-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(88,101,242,0.12), rgba(124,58,237,0.08));
  border-radius: 10px;
  box-shadow: 0 0 16px var(--neon-glow);
}

.members-count-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.members-count-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--neon);
  line-height: 1;
  min-width: 36px;
  text-align: center;
}

.members-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}

.members-section-title.muted-title { opacity: 0.85; }

.section-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.section-dot.online { background: var(--green); color: var(--green); }
.section-dot.offline { background: #747f8d; color: #747f8d; }

.section-badge {
  margin-right: auto;
  background: var(--bg-accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  color: var(--green);
  border: 1px solid rgba(35,165,89,0.3);
}
.section-badge.offline-badge {
  color: var(--text-muted);
  border-color: var(--border);
}

.members-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.members-empty {
  padding: 12px 8px;
  text-align: center;
}

.member-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.member-card:hover {
  transform: translateX(-2px);
  box-shadow: 0 0 14px var(--neon-glow);
  border-color: rgba(88,101,242,0.35);
}

.member-status-lamp {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 10px currentColor;
}
.member-status-lamp.online {
  background: #23a559;
  color: #23a559;
  animation: lampPulse 2s ease-in-out infinite;
}
.member-status-lamp.idle {
  background: #faa61a;
  color: #faa61a;
}
.member-status-lamp.dnd {
  background: #da373c;
  color: #da373c;
}
.member-status-lamp.offline {
  background: #747f8d;
  color: #747f8d;
  box-shadow: none;
}

@keyframes lampPulse {
  0%, 100% { box-shadow: 0 0 6px #23a559; }
  50% { box-shadow: 0 0 14px #23a559; }
}

.member-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.member-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-card-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-mod-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.member-mod-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--bg-primary);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.member-mod-btn.danger {
  border-color: rgba(218, 55, 60, 0.45);
}
.profile-mod-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.manage-list { display: flex; flex-direction: column; gap: 8px; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border);
}
.manage-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.manage-row-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.manage-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.manage-role {
  color: var(--brand);
  font-weight: 700;
  margin-right: 6px;
}
.manage-invite-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.manage-invite-row input { margin: 0; flex: 1; min-width: 120px; }
.manage-inline-footer { margin-top: 18px; }
.manage-channel-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.manage-channel-row input { margin: 0; flex: 1; }
.manage-ch-icon { width: 18px; text-align: center; flex-shrink: 0; }
.manage-add-channel {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.manage-add-channel input,
.manage-add-channel select { margin: 0; flex: 1; min-width: 100px; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 5000;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
body.is-ios .modal {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.modal-open,
html.modal-open {
  overflow: hidden;
}
body.is-ios.modal-open {
  position: relative;
}
body.is-ios .modal {
  z-index: 10000;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.mobile-form-view {
  display: none;
}
@media (max-width: 768px) {
  .mobile-form-view:not(.hidden) {
    display: block;
  }
}
.watch-theater-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  padding: 20px;
  color: var(--text-muted);
  text-align: center;
}
.watch-theater-placeholder.hidden { display: none !important; }
.watch-theater-placeholder p { margin: 0; font-size: 0.9rem; }
.watch-theater-video.has-stream .watch-theater-placeholder { display: none; }
body.is-ios .modal-content input,
body.is-ios .modal-content textarea,
body.is-ios .modal-content select {
  font-size: 16px;
}
body.is-ios button,
body.is-ios .mobile-home-action,
body.is-ios .server-icon,
body.is-ios .mobile-nav-btn,
body.is-ios .voice-join-btn {
  touch-action: manipulation;
  cursor: pointer;
}
.modal:not(.hidden) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
.modal-content {
  background: var(--bg-secondary); border-radius: 12px;
  width: 90%; max-width: 600px; max-height: 85vh;
  overflow: hidden; display: flex; flex-direction: column;
}
.modal-content.small { max-width: 420px; }
.modal-content header {
  padding: 16px 20px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--panel-border);
}
.modal-content footer { padding: 16px 20px; border-top: 1px solid var(--panel-border); }
.modal-content input, .modal-content select {
  margin: 12px 20px; width: calc(100% - 40px); padding: 10px 12px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
}
.close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; }

.settings-modal { max-width: 760px; height: 540px; }
.settings-body { display: flex; flex: 1; overflow: hidden; }
.settings-nav {
  width: 180px; background: var(--bg-tertiary); padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.settings-nav button {
  background: none; border: none; color: var(--text-muted);
  padding: 10px 14px; text-align: right; border-radius: 6px; cursor: pointer; font-weight: 500;
}
.settings-nav button.active, .settings-nav button:hover {
  background: var(--bg-accent); color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--panel-border);
}
.settings-panels { flex: 1; padding: 20px; overflow-y: auto; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-panel label {
  display: block; margin: 14px 0 6px; font-size: 0.75rem;
  color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.settings-panel input, .settings-panel select { width: 100%; margin: 0; }
.profile-edit { text-align: center; margin-bottom: 20px; }
.profile-banner-edit { margin-bottom: 16px; }
.profile-banner-preview {
  width: 100%;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--brand), #eb459e);
  border: 1px solid var(--panel-border);
}
.profile-banner-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.profile-avatar-edit {
  position: relative;
  margin-top: -36px;
  padding-top: 8px;
}
.profile-avatar-edit .avatar.large {
  margin: 0 auto 12px;
  border: 4px solid var(--bg-secondary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* Profile modal */
.profile-modal { max-width: 440px; padding-bottom: 24px; position: relative; overflow: hidden; }
.profile-banner {
  height: 120px;
  background: linear-gradient(135deg, var(--brand), #eb459e);
  overflow: hidden;
}
.profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.profile-body { padding: 0 24px 16px; text-align: center; margin-top: -48px; }
.profile-close { position: absolute; top: 12px; left: 12px; z-index: 2; }
.profile-username { color: var(--text-muted); font-size: 0.85rem; margin: 4px 0; }
.profile-custom-status { color: var(--text-primary); font-size: 0.9rem; margin: 8px 0 16px; }
.profile-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.mutual-section { text-align: right; border-top: 1px solid var(--panel-border); padding-top: 16px; }
.mutual-section h4 { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; }
.mutual-list { display: flex; flex-direction: column; gap: 6px; }
.mutual-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; }
.mutual-item:hover { background: var(--bg-accent); }

/* Story viewer */
.story-viewer-content {
  width: 90%; max-width: 420px; background: #000; border-radius: 12px;
  overflow: hidden; position: relative; min-height: 70vh;
  display: flex; flex-direction: column;
}
.story-viewer-close {
  position: absolute;
  top: 36px;
  left: 12px;
  z-index: 12;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.story-viewer-close:hover { background: rgba(0, 0, 0, 0.75); color: #fff; }
.story-progress {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 11;
  display: flex;
  gap: 4px;
}
.story-progress-seg {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-fill {
  height: 100%;
  width: 0;
  background: #fff;
  border-radius: 2px;
  transition: width 0.2s;
}
.story-progress-fill.done { width: 100%; }
.story-progress-fill.active { width: 100%; opacity: 1; }
.story-viewer-header {
  padding: 28px 16px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
  position: absolute; top: 0; width: 100%; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  color: #fff;
  pointer-events: none;
}
.story-viewer-header > span:first-child { flex: 1; }
.story-counter { font-size: 0.8rem; opacity: 0.85; }
.story-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 44px;
  height: 72px;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.story-nav:hover { background: rgba(0, 0, 0, 0.55); }
.story-nav-prev { right: 8px; border-radius: 8px 0 0 8px; }
.story-nav-next { left: 8px; border-radius: 0 8px 8px 0; }
#storyViewerMedia {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  background: #000;
}
#storyViewerMedia img,
#storyViewerMedia video {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}
#storyViewerCaption {
  padding: 12px 16px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  margin: 0;
}

.screen-shares { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.screen-share-box { background: #000; border-radius: 8px; overflow: hidden; }
.screen-share-box video { width: 100%; }
.screen-share-label {
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
}

.watch-theater {
  margin: 0 0 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
}
.watch-theater.hidden { display: none !important; }
.watch-theater-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
  gap: 10px;
  flex-wrap: wrap;
}
.watch-theater-header h4 { margin: 0; font-size: 0.9rem; }
.watch-quality-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.watch-quality-btns button {
  border: 1px solid var(--panel-border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
}
.watch-quality-btns button.active {
  border-color: var(--neon);
  background: rgba(88, 101, 242, 0.2);
}
.watch-quality-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  align-self: center;
}
.watch-theater-video {
  min-height: 180px;
  max-height: min(420px, 50vh);
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.watch-screen-box { width: 100%; position: relative; }
.watch-screen-video {
  width: 100%;
  max-height: min(420px, 50vh);
  object-fit: contain;
  background: #000;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 72px 220px 1fr; }
  .members-bar {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 85vw);
    z-index: 200;
    box-shadow: -8px 0 24px rgba(0,0,0,0.45);
  }
  .members-bar.members-open { display: block; }
}

/* ── Mobile layout (phone) ── */
.mobile-nav,
.mobile-overlay,
.mobile-header-btn { display: none; }

@media (max-width: 768px) {
  body { overflow: hidden; }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 400;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--panel-border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    gap: 4px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
  }

  .mobile-nav-btn {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 0;
    transition: background 0.15s, color 0.15s;
  }
  .mobile-nav-btn.active {
    color: var(--text-primary);
    background: rgba(88, 101, 242, 0.18);
    box-shadow: inset 0 0 0 1px rgba(88, 101, 242, 0.35);
  }
  .mobile-nav-btn .unread-badge {
    top: 2px;
    left: 18%;
  }
  .mobile-nav-icon { font-size: 1.15rem; line-height: 1; }
  .mobile-nav-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em; }

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 280;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
  }
  .mobile-overlay.hidden { display: none !important; }

  .mobile-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--bg-accent);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.mobile-layout .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    grid-template-columns: unset;
  }

  body.mobile-layout .server-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    z-index: 320;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    height: auto;
    min-height: 76px;
    max-height: 40vh;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
    border-top: 1px solid var(--panel-border);
    border-left: none;
    background: var(--server-bar);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  }
  body.mobile-layout.mobile-servers-open .server-bar { display: flex; }

  body.mobile-layout .mobile-form-view:not(.hidden) {
    display: block;
    width: 100%;
    min-height: calc(100dvh - 140px);
    padding: 8px 4px 24px;
  }
  body.mobile-layout .mobile-form-page {
    max-width: 440px;
    margin: 0 auto;
  }
  body.mobile-layout .mobile-form-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
  }
  body.mobile-layout .mobile-form-tabs.hidden { display: none !important; }
  body.mobile-layout .mobile-form-tab.hidden { display: none !important; }
  body.mobile-layout .mobile-form-tab {
    min-height: 48px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    touch-action: manipulation;
  }
  body.mobile-layout .mobile-form-tab.active {
    color: #fff;
    background: var(--neon);
    border-color: var(--neon);
  }
  body.mobile-layout .mobile-form-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 22px 16px 18px;
    text-align: center;
  }
  body.mobile-layout .mobile-form-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: rgba(35, 165, 89, 0.16);
    color: var(--green);
    border: 1px solid rgba(35, 165, 89, 0.4);
  }
  body.mobile-layout .mobile-form-icon.create,
  body.mobile-layout .mobile-form-icon.story {
    background: rgba(88, 101, 242, 0.16);
    color: var(--neon);
    border-color: rgba(88, 101, 242, 0.4);
  }
  body.mobile-layout .mobile-form-panel h2 {
    margin: 0 0 8px;
    font-size: 1.2rem;
  }
  body.mobile-layout .mobile-form-panel p {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
  }
  body.mobile-layout .mobile-form-label {
    display: block;
    text-align: right;
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-muted);
  }
  body.mobile-layout .mobile-form-panel input,
  body.mobile-layout .mobile-form-panel textarea,
  body.mobile-layout .mobile-form-panel select {
    width: 100%;
    min-height: 52px;
    margin: 0 0 14px;
    padding: 14px 14px;
    font-size: 16px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    box-sizing: border-box;
  }
  body.mobile-layout .mobile-form-panel textarea {
    min-height: 110px;
    resize: vertical;
  }
  body.mobile-layout .mobile-form-panel input[type=file] {
    min-height: 44px;
    padding: 10px;
  }
  body.mobile-layout .mobile-form-panel select[multiple] {
    min-height: 120px;
  }
  body.mobile-layout .mobile-form-submit {
    width: 100%;
    min-height: 50px;
    font-size: 1rem;
  }
  body.mobile-layout .mobile-form-back {
    width: 100%;
    margin-top: 14px;
    min-height: 46px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    touch-action: manipulation;
  }

  body.mobile-layout.mobile-servers-open .mobile-join-server-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 118px;
    height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--green);
    background: rgba(35, 165, 89, 0.18);
    color: var(--green);
    font-weight: 700;
    font-size: 0.82rem;
    touch-action: manipulation;
    cursor: pointer;
  }
  body.mobile-layout .mobile-join-server-btn.hidden { display: none !important; }

  body.mobile-layout .channel-bar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    width: min(320px, 92vw);
    z-index: 300;
    transform: translate3d(100%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    visibility: hidden;
  }
  body.mobile-layout.mobile-menu-open .channel-bar {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    visibility: visible;
  }

  body.mobile-layout:not(.mobile-servers-open) .server-bar {
    pointer-events: none;
  }

  body.mobile-layout .mobile-home-actions {
    display: flex;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 350;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    pointer-events: auto;
  }
  body.mobile-layout .mobile-home-actions.hidden { display: none !important; }

  .mobile-home-action {
    flex: 1 1 calc(50% - 4px);
    min-width: 130px;
    padding: 12px 10px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(88, 101, 242, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  }
  .mobile-home-action:active {
    transform: scale(0.98);
    background: var(--bg-accent);
  }

  body.mobile-layout .main-content {
    flex: 1;
    min-height: 0;
    margin-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  body.mobile-layout .members-bar {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    z-index: 290;
    pointer-events: none;
    visibility: hidden;
  }
  body.mobile-layout .members-bar.members-open {
    pointer-events: auto;
    visibility: visible;
  }

  body.mobile-layout .chat-header {
    padding: 10px 12px;
    gap: 8px;
  }
  body.mobile-layout .chat-header h3 { font-size: 0.92rem; }
  body.mobile-layout .header-sub { font-size: 0.72rem; }
  body.mobile-layout .header-actions { flex-wrap: wrap; gap: 4px; }
  body.mobile-layout .header-btn { padding: 5px 8px; font-size: 0.82rem; }

  body.mobile-layout .content-area {
    padding: 10px 12px;
  }
  body.mobile-layout .chat-input-bar {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  body.mobile-layout .chat-input-bar input[type=text] {
    padding: 10px 12px;
    font-size: 16px;
  }

  body.mobile-layout .channel-category {
    font-size: 0.72rem;
    padding: 14px 8px 8px;
    color: var(--neon);
  }
  body.mobile-layout .channel-item,
  body.mobile-layout .friend-item {
    padding: 12px 10px;
    font-size: 0.95rem;
    min-height: 44px;
  }
  body.mobile-layout .friend-name { font-size: 0.92rem; }

  body.mobile-layout .global-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  body.mobile-layout .global-post { max-width: 100%; }
  body.mobile-layout .welcome-card {
    margin: 16px auto;
    padding: 24px 18px;
  }

  body.mobile-layout .voice-participants {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  body.mobile-layout .voice-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  body.mobile-layout .voice-controls .neon-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
  }

  body.mobile-layout .voice-connected-bar {
    position: fixed;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    z-index: 250;
    margin: 0;
  }

  body.mobile-layout .watch-theater-video {
    max-height: min(280px, 38vh);
  }
  body.mobile-layout .watch-screen-video {
    max-height: min(280px, 38vh);
  }

  body.mobile-layout .toast-container {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
  }
  body.mobile-layout .toast {
    min-width: 0;
    max-width: none;
    transform: translateY(120%);
  }
  body.mobile-layout .toast.show { transform: translateY(0); }

  body.mobile-layout .msg-attachment img.media-preview {
    max-width: 100%;
  }

  body.mobile-layout .modal-content {
    width: min(96vw, 480px);
    max-height: 90dvh;
    overflow-y: auto;
  }
}

/* Clickable avatars */
.avatar-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.avatar-clickable:hover {
  transform: scale(1.06);
  box-shadow: 0 0 12px var(--neon-glow);
}
.msg-author.avatar-clickable:hover {
  text-decoration: underline;
  color: var(--neon);
}

/* Media in chat */
.msg-attachment { margin-top: 8px; }
.msg-attachment img.media-preview {
  max-width: 360px; max-height: 280px;
  border-radius: 8px; cursor: pointer;
  border: 1px solid var(--panel-border);
  transition: transform 0.15s;
}
.msg-attachment img.media-preview:hover { transform: scale(1.02); }
.media-actions {
  display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap;
}
.media-btn {
  padding: 4px 12px; font-size: 0.78rem;
  background: var(--bg-accent); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary);
  cursor: pointer; text-decoration: none;
  transition: box-shadow 0.15s;
}
.media-btn:hover { box-shadow: 0 0 10px var(--neon-glow); color: var(--neon); }
.audio-attachment audio { width: 100%; max-width: 320px; margin-bottom: 4px; }

/* Media lightbox */
.media-viewer-content {
  width: 92%; max-width: 900px; max-height: 90vh;
  background: var(--bg-secondary); border-radius: 12px;
  display: flex; flex-direction: column; position: relative;
}
.media-close { position: absolute; top: 12px; left: 12px; z-index: 2; }
.media-viewer-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px 24px 16px; min-height: 300px; overflow: auto;
}
.media-viewer-img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.media-viewer-video { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.media-viewer-audio { text-align: center; padding: 24px; }
.media-viewer-audio .audio-icon { font-size: 3rem; margin-bottom: 12px; }
.media-viewer-audio audio { width: 100%; max-width: 400px; margin-top: 16px; }
.media-viewer-footer {
  padding: 14px 20px; border-top: 1px solid var(--panel-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* Toast notifications */
.toast-container {
  position: fixed; bottom: 24px; left: 24px; z-index: 10000;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px; max-width: 380px;
  padding: 14px 16px; border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--neon);
  box-shadow: 0 4px 24px var(--neon-glow);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transform: translateX(-120%); opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  font-size: 0.9rem;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { border-color: var(--green); box-shadow: 0 4px 20px rgba(35,165,89,0.35); }
.toast-message { border-color: var(--brand); }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; flex-shrink: 0;
}

/* Invite modal */
.invite-modal-body { padding: 8px 20px 20px; }
.invite-hint { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 10px; line-height: 1.5; }
.invite-hint.small { font-size: 0.82rem; margin-top: 16px; margin-bottom: 8px; }
.invite-hint strong { color: var(--text-primary); }
.invite-code-box, .invite-message-box {
  display: flex; gap: 8px; align-items: stretch; padding: 10px;
}
.invite-code-box input {
  flex: 1; margin: 0; padding: 12px 14px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--neon);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 1.15rem; font-weight: 700; letter-spacing: 0.08em;
  text-align: center;
}
.invite-message-box {
  flex-direction: column; align-items: stretch;
}
.invite-message-box textarea {
  width: 100%; margin: 0; padding: 10px 12px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 0.85rem; line-height: 1.5; resize: none;
  font-family: inherit;
}
.invite-code-box .neon-btn, .invite-message-box .neon-btn {
  white-space: nowrap; flex-shrink: 0;
}

body.mobile-layout .modal:not(.mobile-inline-page),
body.is-ios .modal:not(.mobile-inline-page) {
  display: none !important;
}
body.mobile-layout .mobile-page-host:not(.hidden),
body.is-ios .mobile-page-host:not(.hidden) {
  display: block;
  width: 100%;
  padding: 8px 4px 24px;
}
.mobile-page-host.hidden { display: none !important; }
.mobile-inline-page {
  display: block !important;
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  height: auto !important;
  background: transparent !important;
  padding: 0 !important;
  z-index: auto !important;
}
.mobile-inline-page > .modal-content,
.mobile-inline-page > .profile-modal,
.mobile-inline-page > .settings-modal,
.mobile-inline-page > .story-viewer-content,
.mobile-inline-page > .media-viewer-content {
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  height: auto;
  border-radius: 16px !important;
  margin: 0;
}
body.mobile-layout .modal:not(.hidden) > .modal-content,
body.mobile-layout .modal:not(.hidden) > .profile-modal,
body.mobile-layout .modal:not(.hidden) > .settings-modal,
body.mobile-layout .modal:not(.hidden) > .story-viewer-content,
body.mobile-layout .modal:not(.hidden) > .media-viewer-content,
body.is-ios .modal:not(.hidden) > .modal-content,
body.is-ios .modal:not(.hidden) > .profile-modal,
body.is-ios .modal:not(.hidden) > .settings-modal,
body.is-ios .modal:not(.hidden) > .story-viewer-content,
body.is-ios .modal:not(.hidden) > .media-viewer-content {
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  height: 100%;
  border-radius: 0 !important;
  box-shadow: none;
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-page-backbar {
  display: none;
}
body.mobile-layout .mobile-page-backbar,
body.is-ios .mobile-page-backbar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--panel-border);
  z-index: 2;
}
.mobile-page-back {
  min-height: 44px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}
body.mobile-page-open {
  overflow: hidden;
}

body.mobile-layout #serverManageModal .settings-body,
body.is-ios #serverManageModal .settings-body,
.mobile-inline-page .settings-body {
  flex-direction: column;
}
body.mobile-layout #serverManageModal .settings-nav,
body.is-ios #serverManageModal .settings-nav,
.mobile-inline-page .settings-nav {
  width: 100%;
  flex-direction: row;
  overflow-x: auto;
}
body.mobile-layout #btnManageServer {
  font-size: 0.78rem;
}
