:root {
  --blue: #2f6fe4;
  --blue-dark: #1d519e;
  --blue-soft: #eaf2ff;
  --bg: #f6f9fd;
  --panel: #ffffff;
  --line: #dbe7f3;
  --line-soft: #edf3f9;
  --text: #102033;
  --muted: #617083;
  --danger: #dc2626;
  --shadow: 0 14px 36px rgba(13, 45, 79, 0.08);
  --shadow-soft: 0 8px 22px rgba(13, 45, 79, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

body.chat-page {
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #f7fbff;
}

.chat-shell {
  height: 100%;
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "left main right";
  gap: 12px;
}

.shell-topbar,
.sidebar,
.chat-main,
.login-container {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.shell-topbar {
  grid-area: top;
  min-height: 68px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.brand-lockup,
.top-actions,
.profile-row,
.online-users-trigger,
.message-header,
.private-chat-banner,
.summary-row,
.channel-item,
.emoji-picker-header {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 10px; min-width: 0; align-items: center; }
.brand-logo,
.brand-panel-logo,
.hero-logo,
.login-logo {
  object-fit: contain;
  background: #fff;
}
.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.channel-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.channel-tabs::-webkit-scrollbar { display: none; }
.channel-tab {
  position: relative;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.channel-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.channel-tab.pm-tab {
  background: #f0f7ff;
  border-color: var(--blue);
  color: var(--blue-dark);
  gap: 5px;
}
@keyframes pmTabBlink {
  0%, 100% { background: var(--blue); color: #fff; border-color: var(--blue); }
  50%       { background: #1d519e;    color: #fff; border-color: #1d519e; }
}
.channel-tab.pm-tab.pm-tab-unread {
  animation: pmTabBlink .7s ease-in-out infinite;
}
.pm-tab-badge {
  font-size: 14px;
  line-height: 1;
  color: inherit;
}
.channel-badge {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  color: var(--blue-dark);
  font-size: 11px;
}

/* ============================================================
   FLOATING PM PANEL
   ============================================================ */
.pm-float {
  position: fixed;
  bottom: 20px;
  right: 24px;
  width: 320px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 36px rgba(13, 45, 79, 0.2);
  z-index: 300;
  overflow: hidden;
}
@keyframes pmBlink {
  0%, 100% { background: var(--blue); }
  50%       { background: var(--blue-dark); }
}
.pm-float-header {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  background: var(--blue);
  cursor: pointer;
  user-select: none;
  flex: 0 0 44px;
  transition: background .2s;
}
.pm-float-header.has-unread { animation: pmBlink .8s ease-in-out infinite; }
.pm-float-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 28px;
}
.pm-float-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.pm-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}
.pm-float-actions { display: flex; gap: 4px; }
.pm-float-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 28px;
}
.pm-float-btn:hover { background: rgba(255,255,255,0.34); }
.pm-float-body {
  display: flex;
  flex-direction: column;
  height: 360px;
  transition: height .2s;
}
.pm-float.collapsed .pm-float-body { display: none; }
.pm-float-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  -webkit-overflow-scrolling: touch;
}
.pm-float-loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}
.pm-float-bubble {
  max-width: 86%;
  padding: 7px 10px 5px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.pm-float-bubble.them {
  align-self: flex-start;
  background: var(--blue-soft);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.pm-float-bubble.me {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.pm-bubble-name {
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 3px;
  opacity: .7;
}
.pm-bubble-time {
  font-size: 10px;
  opacity: .55;
  margin-top: 4px;
  text-align: right;
}
.pm-float-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  padding: 8px;
  border-top: 1px solid var(--line-soft);
  background: #fff;
}
.pm-float-input input {
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 6px 0 0 6px;
  outline: none;
  font-size: 13px;
  background: #fff;
}
.pm-float-input input:focus { border-color: var(--blue); }
.pm-float-send {
  width: 38px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--blue);
  border-radius: 0 6px 6px 0;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}
.pm-float-send:disabled { opacity: .55; cursor: not-allowed; }

/* Gelen PM bildirim toast */
.pm-notify {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(13, 45, 79, 0.18);
  max-width: 320px;
  animation: pmNotifyIn .25s ease;
}
@keyframes pmNotifyIn {
  from { transform: translateX(calc(100% + 20px)); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.pm-notify-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 34px;
}
.pm-notify-text {
  flex: 1;
  min-width: 0;
}
.pm-notify-text strong {
  display: block;
  font-size: 13px;
  color: var(--blue-dark);
}
.pm-notify-text span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.pm-notify-open {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pm-notify-close {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 26px;
}

/* Mobile */
@media (max-width: 820px) {
  .pm-float {
    right: 8px;
    bottom: 72px;
    width: calc(100vw - 16px);
    max-width: 360px;
  }
  .pm-notify {
    top: auto;
    bottom: 78px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.icon-pill,
.logout-btn,
.sidebar-ghost-btn,
.sidebar-link,
.online-users-trigger,
.close-modal,
.close-online-users,
.emoji-btn,
.send-btn,
.quick-action-btn,
.add-btn,
.delete-channel {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.icon-pill,
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
/* Bildirim zil butonu */
.notif-pill .bell-icon { transition: color .15s; }
.notif-pill .notif-label { font-size: 12px; font-weight: 600; }
.notif-pill.notif-on  { border-color: #22c55e; }
.notif-pill.notif-off { border-color: var(--line); opacity: .65; }
.notif-pill.notif-off .bell-icon { stroke: var(--muted); }

/* Mobil kullanıcı sayacı */
#mobileUsersCount {
  min-width: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-dark);
}
.logout-btn {
  background: #fff5f5;
  border-color: #ffd6d6;
  color: #b91c1c;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.sidebar-left {
  grid-area: left;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-right {
  grid-area: right;
  padding: 12px;
}
.sidebar-card {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
}
.brand-panel { gap: 10px; }
.brand-panel-logo {
  width: 42px;
  height: 42px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.brand-panel-copy h2,
.sidebar-heading {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  color: var(--text);
}
.brand-panel-copy p,
.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.sidebar-summary { display: grid; gap: 8px; }
.summary-row { justify-content: space-between; gap: 8px; }
.summary-label { color: var(--muted); font-size: 12px; }
.summary-value { font-size: 13px; font-weight: 700; word-break: break-word; }
.sidebar-nav { display: grid; gap: 7px; margin-top: 10px; }
.sidebar-link {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  background: #fff;
}
.sidebar-link.active,
.sidebar-link:hover {
  background: var(--blue-soft);
  border-color: #cfe0fb;
}
.sidebar-link .ico {
  width: 18px;
  color: var(--blue-dark);
  text-align: center;
  font-size: 13px;
}
.sidebar-link .label { font-size: 13px; font-weight: 650; }
.sidebar-link .sub { margin-left: auto; color: var(--muted); font-size: 11px; }
.sidebar-tips .tips-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.sidebar-tips .tips-list li {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  padding-left: 4px;
}
.tip-key {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  color: var(--blue-dark);
  font-family: monospace;
}
.profile-card { margin-top: auto; }
.profile-row { gap: 10px; }
.profile-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 800;
}
.profile-meta { min-width: 0; }
.profile-meta strong { display: block; font-size: 13px; }
.profile-meta span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sidebar-ghost-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  text-decoration: none;
  font-weight: 650;
  font-size: 12px;
}
.sidebar-ghost-btn.danger { color: #b91c1c; background: #fff5f5; border-color: #ffd6d6; }

.chat-main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.main-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}
.hero-logo {
  width: 38px;
  height: 38px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.main-hero-copy { min-width: 0; }
.main-hero-copy h1 { margin: 0; font-size: 16px; line-height: 1.2; }
.main-hero-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.messages-section {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fbfdff;
}
.private-chat-banner {
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--blue-soft);
}
.private-chat-banner[hidden] { display: none; }
.private-chat-banner strong { display: block; font-size: 13px; color: var(--blue-dark); }
.private-chat-banner span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
#closePrivateChat {
  width: 32px;
  height: 32px;
  border: 1px solid #cfe0fb;
  border-radius: var(--radius);
  background: #fff;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.messages-list {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message-bubble {
  align-self: flex-start;
  max-width: min(72%, 560px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.message-bubble.own {
  align-self: flex-end;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.message-bubble.admin { border-left-color: #f59e0b; background: #fffdf5; }
.message-bubble.super-admin { border-left-color: #7c3aed; background: #faf7ff; }
.message-bubble.admin .message-nickname { color: #92400e; }
.message-bubble.super-admin .message-nickname { color: #5b21b6; }
.message-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}
.message-nickname { font-size: 13px; font-weight: 750; color: var(--blue-dark); }
.message-bubble.own .message-nickname { color: #fff; }
.message-time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.message-bubble.own .message-time { color: rgba(255,255,255,0.78); }
.time-tooltip { display: none; }
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
  font-size: 14px;
}
.typing-indicator {
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: typing 1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 50% { transform: translateY(-3px); opacity: .6; } }
.typing-text { font-size: 12px; }

.loading-spinner,
.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #dfeaf7;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue-dark);
}
.empty-state-title { margin: 0; font-size: 17px; color: var(--text); }
.empty-state-description { margin: 0; font-size: 13px; }

.input-section {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.98);
}
.emoji-btn,
.send-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.emoji-btn { color: var(--blue-dark); }
.send-btn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
#messageInput {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
#messageInput:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,111,228,0.11);
}
.quick-action-icons {
  position: absolute;
  right: 14px;
  bottom: 68px;
  z-index: 11;
}
.quick-action-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  box-shadow: var(--shadow);
}
.emoji-picker {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 8px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  animation: ctx-in 0.15s ease;
}
.emoji-picker-header {
  justify-content: space-between;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 700;
}
.emoji-picker-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}
.emoji-picker-content {
  max-height: 250px;
  overflow: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}
.emoji-item {
  height: 36px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
}

.online-users-dropdown,
.online-users-dropdown-content {
  height: 100%;
  min-height: 0;
}
.online-users-dropdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.online-users-trigger {
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}
.online-count { color: var(--blue-dark); }
.online-users-dropdown-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
}
.online-users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.online-users-header h4 { margin: 0; font-size: 14px; }
.close-online-users {
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--muted);
}
.online-users-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}
.loading-users { padding: 12px; color: var(--muted); font-size: 13px; }
.user-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-bottom: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}
.user-item:hover,
.user-item:focus { border-color: #cfe0fb; background: #fbfdff; outline: none; }
.user-item.me { background: var(--blue-soft); cursor: default; }
.user-item.admin {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}
.user-item.admin:hover { background: #fef3c7; }
.user-item.super-admin {
  border-left: 3px solid #7c3aed;
  background: #f5f3ff;
}
.user-item.super-admin:hover { background: #ede9fe; }
.user-item.super-admin .user-name { color: #5b21b6; font-weight: 750; }
.user-item.admin .user-name { color: #92400e; font-weight: 750; }
.user-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}
.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}
.user-private-hint { color: var(--muted); font-size: 12px; }
.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.user-role-badge.super {
  background: #7c3aed;
  color: #fff;
}
.user-role-badge.admin {
  background: #f59e0b;
  color: #fff;
}

.sidebar-overlay { display: none; }
.muted-label { color: var(--muted); font-size: 12px; }

/* SweetAlert toast küçük boyut */
.swal-toast-sm { font-size: 13px !important; }

body.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #eef4fb 100%);
}
.login-shell { width: min(100%, 440px); }
.login-card { width: 100%; }
.login-container {
  width: 100%;
  padding: 28px 24px 22px;
  text-align: center;
}
.login-logo {
  width: 92px;
  height: auto;
  margin: 0 auto 14px;
}
.login-title {
  margin: 0;
  color: var(--blue-dark);
  font-size: 24px;
  line-height: 1.2;
}
.login-subtitle {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 13px;
}
.login-container form { display: grid; gap: 14px; }
.form-group {
  display: grid;
  gap: 7px;
  text-align: left;
}
.form-group label {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.form-group input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
  font-size: 16px;
}
.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,111,228,0.11);
}
.form-group button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.kvkk-notice {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}
.error-message,
.success-message {
  min-height: 18px;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}
.error-message { color: var(--danger); }
.success-message { color: #15803d; }
.login-alt-link {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}
.login-alt-link a {
  color: var(--blue-dark);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .chat-shell {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "left main";
  }
  .sidebar-right {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 24px));
    z-index: 50;
    transform: translateX(calc(100% + 20px));
    transition: transform .18s ease;
  }
  body.sidebar-right-open .sidebar-right { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    background: rgba(16, 32, 51, 0.28);
    opacity: 0;
    pointer-events: none;
  }
  body.sidebar-right-open .sidebar-overlay,
  body.sidebar-left-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .close-online-users { display: inline-grid; place-items: center; }
}

@media (max-width: 820px) {
  .chat-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "main";
    padding: 8px;
    gap: 8px;
  }
  .shell-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px;
  }
  .brand-logo { width: 34px; height: 34px; flex: 0 0 34px; }
  .brand-subtitle { font-size: 11px; }
  .channel-tabs {
    grid-column: 1 / -1;
    order: 3;
  }
  .top-actions {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .top-actions::-webkit-scrollbar { display: none; }
  .icon-pill,
  .logout-btn {
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }
  .pill-text,
  #notificationStatus { display: none; }
  .channel-tab { height: 36px; padding: 0 11px; font-size: 12px; }
  .sidebar-left,
  .sidebar-right {
    position: fixed;
    top: calc(8px + env(safe-area-inset-top));
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 16px));
    z-index: 50;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-left {
    left: 8px;
    transform: translateX(calc(-100% - 18px));
    transition: transform .18s ease;
  }
  .sidebar-right { right: 8px; }
  body.sidebar-left-open .sidebar-left { transform: translateX(0); }
  .main-hero { display: none; }
  .chat-main { border-radius: var(--radius); }
  .messages-container { padding: 12px; }
  .message-bubble { max-width: 90%; }
  .input-section {
    grid-template-columns: 42px minmax(0, 1fr) 44px;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  }
  .emoji-btn,
  .send-btn {
    width: 42px;
    height: 42px;
  }
  #messageInput { height: 44px; }
  .quick-action-icons { bottom: 62px; }
  .emoji-picker-content { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .chat-shell { padding: 6px; gap: 6px; }
  .shell-topbar { min-height: auto; }
  .brand-lockup { gap: 8px; }
  .brand-logo { width: 30px; height: 30px; flex: 0 0 30px; }
  .brand-subtitle { font-size: 10px; }
  .message-bubble { max-width: 94%; }
  .message-header { gap: 8px; flex-wrap: wrap; }
  .profile-actions { grid-template-columns: 1fr; }
  .login-container { padding: 24px 18px 20px; }
}

/* ============================================================
   KULLANICI CONTEXT MENÜSÜ
   ============================================================ */
.user-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 170px;
  padding: 4px 0;
  animation: ctx-in 0.12s ease;
}
@keyframes ctx-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.ctx-menu-header {
  padding: 8px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 2px;
}
.ctx-menu-divider { height: 1px; background: var(--line-soft); margin: 4px 0; }
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
}
.ctx-menu-item:hover { background: var(--blue-soft); color: var(--blue); }
.ctx-menu-item.danger-item:hover { background: #fef2f2; color: var(--danger); }

/* ============================================================
   SUSTURULDU BANNER
   ============================================================ */
.mute-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8000;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 20px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
  pointer-events: none;
}

/* ============================================================
   @ MENTION DROPDOWN
   ============================================================ */
.mention-dropdown {
  position: fixed;
  z-index: 9000;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 180px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.mention-item:hover,
.mention-item.selected { background: var(--blue-soft); color: var(--blue); }
.mention-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mention-nick { font-weight: 600; }
.mention-role { font-size: 10px; color: var(--muted); margin-left: auto; }

/* @ mention highlight in messages */
.mention-tag {
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 4px;
  padding: 1px 4px;
  font-weight: 600;
  font-size: 0.9em;
}
.mention-tag.mention-me {
  background: #fef3c7;
  color: #92400e;
}
.message-bubble.mention-highlight {
  box-shadow: 0 0 0 2px #f59e0b44;
}

/* ============================================================
   AYARLAR PANELİ
   ============================================================ */
.settings-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 8500;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 300px;
  animation: ctx-in 0.15s ease;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.settings-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; padding: 2px;
  border-radius: 4px; transition: background 0.1s;
}
.settings-close:hover { background: var(--line-soft); }
.settings-body { padding: 8px 0; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
}
.settings-row:hover { background: var(--bg); }
.settings-label strong { display: block; font-size: 13px; margin-bottom: 2px; }
.settings-label span { font-size: 11px; color: var(--muted); }
.settings-toggle {
  flex-shrink: 0;
  min-width: 52px;
  height: 26px;
  border-radius: 13px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: background 0.2s, color 0.2s;
  background: var(--blue);
  color: #fff;
}
.settings-toggle[data-enabled="false"] {
  background: var(--line);
  color: var(--muted);
}

/* Kullanıcı listesinde PM kapalı gösterge */
.user-pm-off { opacity: 0.55; }
.user-pm-off .user-private-hint::after { content: ' (PM kapalı)'; font-size: 9px; color: var(--muted); }
