:root {
  color-scheme: light;
  --google-blue: #1a73e8;
  --google-blue-dark: #1765cc;
  --on-primary: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #f1f3f4;
  --border: #dadce0;
  --text: #202124;
  --text-muted: #5f6368;
  --green: #188038;
  --red: #d93025;
  --active-bg: #e8f0fe;
  --mark-bg: #fef7e0;
  --mark-fg: inherit;
  --toast-bg: #323232;
  --brand-blue: #4285f4;
  --brand-red: #ea4335;
  --brand-yellow: #fbbc05;
  --brand-green: #34a853;
  --auth-gradient: linear-gradient(135deg, #e8f0fe 0%, #f8f9fa 60%);
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --radius: 12px;
  --font: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --google-blue: #8ab4f8;
  --google-blue-dark: #aecbfa;
  --on-primary: #202124;
  --surface: #1f1f1f;
  --surface-2: #171717;
  --surface-3: #2d2d2d;
  --border: #3c4043;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --green: #81c995;
  --red: #f28b82;
  --active-bg: #28374a;
  --mark-bg: #fdd663;
  --mark-fg: #202124;
  --toast-bg: #3c4043;
  --brand-blue: #8ab4f8;
  --brand-red: #f28b82;
  --brand-yellow: #fdd663;
  --brand-green: #81c995;
  --auth-gradient: linear-gradient(135deg, #1b2735 0%, #121212 60%);
  --shadow-1: 0 1px 2px rgba(0,0,0,.6), 0 1px 3px 1px rgba(0,0,0,.4);
  --shadow-2: 0 1px 3px rgba(0,0,0,.6), 0 4px 8px 3px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; font-weight: 500; }
a { color: var(--google-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
button, a, .channel-item, .reaction, .rail-btn, .msg, .icon-btn { touch-action: manipulation; }
button, .channel-item, .reaction, .rail-btn, .msg { -webkit-tap-highlight-color: transparent; }
.muted { color: var(--text-muted); font-size: 14px; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ------------------------------------------------ Ikonlar (Material Symbols) */
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon.sm { width: 16px; height: 16px; }
.icon-btn .icon { width: 22px; height: 22px; }
.rail-icon.icon { width: 22px; height: 22px; }
.empty-emoji .icon { width: 46px; height: 46px; color: var(--text-muted); }
.file-link .icon { margin-right: 6px; }
.msg-actions .icon { width: 18px; height: 18px; }
.member-actions .icon { width: 18px; height: 18px; }

/* ----------------------------------------------------------- Butonlar */
.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--google-blue); color: var(--on-primary); }
.btn-primary:hover { background: var(--google-blue-dark); box-shadow: var(--shadow-1); }
.btn-ghost { background: transparent; color: var(--google-blue); }
.btn-ghost:hover { background: rgba(26,115,232,.08); }
.btn-danger { background: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(217,48,37,.08); }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; border-radius: 50%;
  width: 40px; height: 40px; font-size: 16px; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-3); }

/* ----------------------------------------------------------- Toasts */
.toast-stack { position: fixed; top: 12px; left: 12px; right: 12px; z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-2);
  background: var(--toast-bg); color: #fff; animation: drop .25s ease; max-width: 100%;
}
.toast-success { background: var(--green); color: var(--on-primary); }
.toast-error { background: var(--red); color: var(--on-primary); }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- Auth */
.auth-body { display: flex; align-items: center; justify-content: center; background: var(--auth-gradient); }
.auth-wrap { width: 100%; display: flex; justify-content: center; padding: 16px; }
.theme-fab {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  z-index: 600; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.theme-fab:hover { background: var(--surface-3); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 20px; box-shadow: var(--shadow-1);
}
.brand { font-weight: 700; letter-spacing: -.5px; }
.brand.big { font-size: 28px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 21px; margin-bottom: 8px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-form label { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  font-family: inherit; font-size: 16px; padding: 13px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); transition: border .15s, box-shadow .15s;
}
.auth-form input:focus { outline: none; border-color: var(--google-blue); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.code-input { text-align: center; letter-spacing: 10px; font-size: 24px !important; font-weight: 700; }
.auth-card .muted.center + .muted.center { margin-top: 6px; }

/* ----------------------------------------------------------- App layout */
.app-body { overflow: hidden; }
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* Sunucu rayi */
.server-rail {
  width: 60px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0;
  flex-shrink: 0;
}
.rail-sep { width: 28px; height: 1px; background: var(--border); margin: 2px 0; flex-shrink: 0; }
.rail-servers { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; width: 100%; align-items: center; }
.rail-servers::-webkit-scrollbar { width: 0; }
.rail-btn {
  width: 42px; height: 42px; border-radius: 14px; border: none; flex-shrink: 0;
  background: var(--surface-3); color: var(--text-muted); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; transition: border-radius .2s, background .15s, color .15s;
}
.rail-btn:hover { border-radius: 50%; background: var(--google-blue); color: var(--on-primary); }
.rail-btn.active { border-radius: 50%; background: var(--google-blue); color: var(--on-primary); }
.rail-home { font-weight: 700; }
.rail-add { color: var(--green); }
.rail-add:hover { background: var(--green); color: var(--on-primary); }
.rail-icon { line-height: 1; }

/* Sidebar — mobilde cekmece */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 60px;
  width: min(300px, calc(100vw - 60px));
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transform: translateX(-115%); transition: transform .22s ease;
  z-index: 320; box-shadow: var(--shadow-2);
}
.sidebar.open { transform: none; }
.sidebar-close { display: inline-flex; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-header-actions { display: flex; gap: 2px; flex-shrink: 0; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 8px; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--text-muted); padding: 12px 10px 6px; }
.channel-list { display: flex; flex-direction: column; gap: 2px; }
.channel-item {
  display: flex; align-items: center; gap: 6px; padding: 10px; border-radius: 8px;
  color: var(--text-muted); font-size: 15px; cursor: pointer; white-space: nowrap; overflow: hidden;
}
.channel-item:hover { background: var(--surface-3); color: var(--text); }
.channel-item.active { background: var(--active-bg); color: var(--google-blue); font-weight: 500; }
.channel-item .hash { opacity: .6; }
.channel-item .label { overflow: hidden; text-overflow: ellipsis; }
.channel-add { display: flex; align-items: center; gap: 8px; border: none; background: transparent; color: var(--text-muted); text-align: left; padding: 10px; border-radius: 8px; font-size: 14px; width: 100%; }
.channel-add:hover { background: var(--surface-3); color: var(--google-blue); }
.user-panel { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.user-panel .icon-btn { width: 34px; height: 34px; font-size: 15px; }
.user-panel-info { flex: 1; overflow: hidden; min-width: 0; }
.user-panel-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.user-panel-status { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.dot.online { background: var(--green); }

/* Chat area */
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--surface); min-width: 0; height: 100%; position: relative; }
.chat-header {
  position: relative; min-height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; flex-shrink: 0;
}
.menu-toggle { display: inline-flex; }
.search-toggle { display: inline-flex; }
.search-box { display: none; }
.chat-header.search-open .search-box {
  display: block; position: absolute; left: 8px; right: 8px; top: calc(100% + 6px); z-index: 250;
  background: var(--surface); border-radius: 20px;
}
.chat-title-wrap { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-hash { font-size: 20px; color: var(--text-muted); }
.chat-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topic { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-right { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
.search-box input {
  border: 1px solid var(--border); border-radius: 20px; padding: 11px 16px; font-size: 16px;
  width: 100%; font-family: inherit; background: var(--surface-2);
}
.search-box input:focus { outline: none; border-color: var(--google-blue); background: var(--surface); box-shadow: 0 0 0 3px rgba(26,115,232,.12); }

.messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 18px 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.empty-state { margin: auto; text-align: center; color: var(--text-muted); padding: 0 20px; }
.empty-emoji { font-size: 38px; margin-bottom: 10px; }

.msg { display: flex; gap: 10px; padding: 6px; border-radius: 8px; position: relative; }
.msg:hover { background: var(--surface-2); }
.msg.grouped { margin-top: 0; }
.msg .avatar { flex-shrink: 0; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-author { font-weight: 500; font-size: 15px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-edited { font-size: 11px; color: var(--text-muted); font-style: italic; }
.msg-text { font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg-text a { word-break: break-all; }
.msg-text code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg.deleted .msg-text { color: var(--text-muted); font-style: italic; }
.msg-attachment img { max-width: 100%; max-height: 320px; border-radius: 10px; border: 1px solid var(--border); margin-top: 6px; display: block; }
.msg-attachment a.file-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 14px; max-width: 100%; }

/* Satir ici medya (gorsel/ses/video) */
.media-image { display: block; padding: 0; border: none; background: transparent; cursor: zoom-in; max-width: 100%; }
.media-image img { max-width: 100%; max-height: 320px; border-radius: 10px; border: 1px solid var(--border); margin-top: 6px; display: block; }
.msg-attachment audio { display: block; margin-top: 6px; width: min(420px, 100%); height: 40px; }
.msg-attachment video { display: block; margin-top: 6px; max-width: 100%; max-height: 340px; border-radius: 10px; border: 1px solid var(--border); background: #000; }

.msg-actions { position: absolute; top: -10px; right: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-1); display: none; padding: 2px; gap: 2px; z-index: 5; }
.msg:hover .msg-actions, .msg.show-actions .msg-actions { display: flex; }
.msg-actions button { border: none; background: transparent; width: 36px; height: 36px; border-radius: 6px; font-size: 15px; }
.msg-actions button:hover { background: var(--surface-3); }

.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; cursor: pointer; }
.reaction.mine { border-color: var(--google-blue); background: var(--active-bg); color: var(--google-blue); }

.typing-indicator { height: 20px; padding: 0 14px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.composer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.composer[hidden] { display: none; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }

.composer-field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 4px 6px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.composer-field:focus-within {
  border-color: var(--google-blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

.composer-add { width: 38px; height: 38px; border-radius: 50%; color: var(--text-muted); flex-shrink: 0; }
.composer-add:hover { background: var(--surface-3); color: var(--text); }
.composer-add .icon { width: 22px; height: 22px; }

#messageInput {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  padding: 9px 4px;
  max-height: 180px;
  outline: none;
  color: var(--text);
}

.send-fab {
  flex-shrink: 0;
  width: 46px; height: 46px;
  border: none; border-radius: 50%;
  background: var(--google-blue); color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .12s ease, background .15s, opacity .15s;
}
.send-fab .icon { width: 22px; height: 22px; }
.send-fab:not(:disabled):hover { background: var(--google-blue-dark); }
.send-fab:not(:disabled):active { transform: scale(.92); }
.send-fab:disabled { background: var(--surface-3); color: var(--text-muted); box-shadow: none; cursor: default; }

/* Ek menusu */
.attach-menu {
  position: absolute; bottom: calc(100% - 4px); left: 10px; z-index: 60;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  min-width: min(250px, calc(100vw - 20px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-2);
}
.attach-menu[hidden] { display: none; }
.attach-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border: none; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; font-size: 14px;
  text-align: left; cursor: pointer; touch-action: manipulation;
}
.attach-menu button:hover, .attach-menu button:focus-visible { background: var(--active-bg); }
.attach-menu .icon { width: 20px; height: 20px; }
.attach-menu-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-3); color: var(--google-blue);
  display: inline-flex; align-items: center; justify-content: center;
}
.attach-menu .coarse-only { display: none; }
@media (pointer: coarse) { .attach-menu .coarse-only { display: flex; } }

/* Ek onizleme karti */
.attachment-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  font-size: 13px; color: var(--text);
}
.attachment-preview[hidden] { display: none; }
.attachment-preview img.attach-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.attachment-preview .attach-media-icon {
  width: 48px; height: 48px; border-radius: 10px; flex-shrink: 0;
  background: var(--surface-3); color: var(--google-blue);
  display: inline-flex; align-items: center; justify-content: center;
}
.attachment-preview .attach-media-icon .icon { width: 24px; height: 24px; }
.attachment-preview .attach-meta { display: flex; flex-direction: column; min-width: 0; }
.attachment-preview .attach-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview .attach-sub { font-size: 12px; color: var(--text-muted); }
.attachment-preview .attach-remove { margin-left: auto; flex-shrink: 0; width: 34px; height: 34px; }

.emoji-picker {
  position: absolute; bottom: calc(100% + 4px); right: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-2); padding: 8px; display: grid;
  grid-template-columns: repeat(6, 1fr); gap: 2px; z-index: 50; max-width: calc(100vw - 20px);
}
.emoji-picker[hidden] { display: none; }
.emoji-picker button { border: none; background: transparent; font-size: 20px; width: 40px; height: 40px; border-radius: 8px; }
.emoji-picker button:hover { background: var(--surface-3); }

/* Uye paneli — mobilde cekmece */
.members-panel {
  position: fixed; top: 0; bottom: 0; right: 0; width: min(300px, 85vw);
  background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto;
  flex-shrink: 0; z-index: 320; transform: translateX(105%); transition: transform .22s ease;
  box-shadow: var(--shadow-2);
}
.members-panel.open { transform: none; }
.members-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--text-muted); }
.members-close { display: inline-flex; }
.members-list { padding: 0 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; position: relative; }
.member-item:hover { background: var(--surface-2); }
.member-name { font-size: 14px; }
.member-role { font-size: 10px; text-transform: uppercase; color: var(--google-blue); font-weight: 700; }
.member-actions { margin-left: auto; display: none; gap: 2px; }
.member-item:hover .member-actions, .member-item.show-actions .member-actions { display: flex; }

/* Scrim (cekmeceler icin karartma) */
.scrim { position: fixed; inset: 0; background: rgba(32,33,36,.45); z-index: 310; }

/* Avatarlar */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 500; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; user-select: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }

/* Modal — mobilde alt sayfa */
.modal-overlay { position: fixed; inset: 0; background: rgba(32,33,36,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 500; padding: 0; }
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-2); width: 100%; max-width: 560px;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  animation: sheet .2s ease;
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal .field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.modal input, .modal select {
  font-family: inherit; font-size: 16px; padding: 12px 13px; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); width: 100%;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--google-blue); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.modal .hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.invite-code { font-family: monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 14px; word-break: break-all; font-size: 14px; }
.user-result { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: 8px; cursor: pointer; }
.user-result:hover { background: var(--surface-2); }

/* Arama sonuclari */
.search-results {
  position: fixed; left: 8px; right: 8px; top: 112px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2);
  z-index: 400; padding: 8px;
}
.search-result { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.search-result:hover { background: var(--surface-2); }
.search-result .where { font-size: 11px; color: var(--google-blue); font-weight: 500; }
.search-result .text { font-size: 14px; margin-top: 3px; }
.search-result mark { background: var(--mark-bg); color: var(--mark-fg); }

/* ===================================================== Tablet (>=768px) */
@media (min-width: 768px) {
  .toast-stack { left: 50%; right: auto; transform: translateX(-50%); align-items: center; }
  .auth-card { padding: 40px; }
  .brand.big { font-size: 30px; }

  .server-rail { width: 74px; gap: 10px; padding: 14px 0; }
  .rail-btn { width: 48px; height: 48px; border-radius: 16px; font-size: 18px; }
  .rail-sep { width: 34px; }

  .sidebar { position: static; transform: none; width: 244px; box-shadow: none; z-index: auto; }
  .sidebar-close { display: none; }
  .sidebar-header { padding: 16px; }

  .menu-toggle, .search-toggle { display: none; }
  .search-box { display: block; }
  .chat-header.search-open .search-box { position: static; }
  .chat-header { min-height: 64px; gap: 16px; padding: 0 20px; }
  .chat-hash { font-size: 22px; }
  .chat-title { font-size: 16px; }
  .chat-topic { max-width: 46vw; }
  .search-box input { width: 240px; font-size: 14px; }

  .messages { padding: 20px; }
  .msg { gap: 12px; padding: 6px 8px; }
  .msg .avatar { width: 40px; height: 40px; font-size: 16px; }
  .msg-actions { right: 12px; }
  .msg-actions button { width: 30px; height: 30px; font-size: 14px; }
  .typing-indicator { padding: 0 22px; }

  .composer { gap: 10px; padding: 12px 20px 20px; }
  .composer-field { padding: 5px 8px; }
  .composer-add { width: 40px; height: 40px; }
  .send-fab { width: 48px; height: 48px; }
  .emoji-picker { right: 20px; }

  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 16px; padding: 28px; max-width: 440px; }

  .search-results { left: auto; right: 24px; top: 72px; width: 420px; max-height: 70vh; }
}

/* ================================================== Geniş (>=1024px) */
@media (min-width: 1024px) {
  .sidebar { width: 260px; }
  .chat-topic { max-width: 40vw; }
  .members-panel { position: static; transform: none; width: 224px; box-shadow: none; z-index: auto; }
  .members-close { display: none; }
  .members-header { padding: 18px 16px 8px; }
  .scrim { display: none !important; }
}

/* ===================================================== Koyu tema ince ayar */
[data-theme="dark"] .msg-author { color: var(--text) !important; }
[data-theme="dark"] .btn-ghost:hover { background: rgba(138,180,248,.12); }
[data-theme="dark"] .btn-danger:hover { background: rgba(242,139,130,.12); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.64); }
[data-theme="dark"] .scrim { background: rgba(0,0,0,.6); }
[data-theme="dark"] .auth-form input:focus,
[data-theme="dark"] .search-box input:focus,
[data-theme="dark"] .composer-field:focus-within,
[data-theme="dark"] .modal input:focus,
[data-theme="dark"] .modal select:focus { box-shadow: 0 0 0 3px rgba(138,180,248,.28); }
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
}

/* ===================================================== Kucuk telefon (<=360px) */
@media (max-width: 360px) {
  .server-rail { width: 54px; }
  .sidebar { left: 54px; width: calc(100vw - 54px); }
  .msg-actions button { width: 32px; height: 32px; }
  .modal { padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); }
}

/* ===================================================== Erisilebilirlik & UX */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--google-blue); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .icon-btn:focus-visible, .rail-btn:focus-visible { outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Rozetler / okunmamis */
.rail-btn { position: relative; }
.rail-badge, .badge {
  position: absolute; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
  text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.rail-badge { top: -2px; right: -2px; }
.badge { position: static; margin-left: auto; box-shadow: none; }

/* ---- Satir menusu (kanal ayarlari) */
.channel-item { position: relative; }
.row-menu {
  border: none; background: transparent; color: var(--text-muted); border-radius: 6px;
  width: 28px; height: 28px; display: none; align-items: center; justify-content: center; flex-shrink: 0;
}
.channel-item:hover .row-menu, .channel-item.active .row-menu { display: inline-flex; }
.row-menu:hover { background: var(--surface-3); color: var(--text); }

/* ---- Mesaj alani sarmalayici + en alta in */
.messages-wrap { position: relative; flex: 1; display: flex; min-height: 0; }
.messages-wrap .messages { flex: 1; }
.scroll-bottom {
  position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-2); display: inline-flex; align-items: center; justify-content: center; z-index: 6;
}
.scroll-bottom:hover { background: var(--surface-3); }
.scroll-bottom-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 20px; text-align: center;
}

/* ---- Daha eski mesajlar */
.load-older {
  align-self: center; margin: 4px auto 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--google-blue); border-radius: 18px; padding: 7px 16px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.load-older:hover { background: var(--active-bg); }

/* ---- Mesaj duzenleme */
.edit-input {
  width: 100%; font-family: inherit; font-size: 16px; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; background: var(--surface-2); color: var(--text); resize: vertical;
}
.edit-actions { margin-top: 6px; display: flex; gap: 8px; }
.edit-actions .btn { padding: 7px 14px; font-size: 13px; }

/* ---- Tepki paneli (tekil, mesajdan bagimsiz sabit boyut) */
.react-bar {
  position: fixed; z-index: 700; display: grid; grid-template-columns: repeat(6, 40px);
  gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-2); width: max-content; max-width: calc(100vw - 16px);
}
.react-bar button {
  border: none; background: transparent; font-size: 20px; width: 40px; height: 40px;
  border-radius: 8px; cursor: pointer; line-height: 1;
}
.react-bar button:hover, .react-bar button:focus-visible { background: var(--active-bg); }

/* ---- Ek (attachment) ciplak gosterimi */
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; }
.attachment-chip button {
  border: none; background: transparent; color: inherit; padding: 0; width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.attachment-chip button:hover { background: var(--surface-3); }

/* ---- Profil renk secimi */
.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dot.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

/* ---- Tehlikeli birincil buton + toast cikis */
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); box-shadow: var(--shadow-1); }
.toast-out { opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s; }
.toast-info { background: #202124; color: #fff; }

/* ---- Uye satiri / baslik metni */
.member-info { min-width: 0; }
.chat-title-text { min-width: 0; }

/* ---- Kucuk ek dokunma hedefleri */
@media (hover: none) {
  .msg-actions button, .member-actions button, .icon-btn { min-width: 38px; min-height: 38px; }
}

/* ---- Profil butonu (kullanici paneli) */
.user-panel-profile {
  border: none; background: transparent; padding: 0; border-radius: 50%;
  display: inline-flex; flex-shrink: 0;
}
.user-panel-profile:hover { box-shadow: 0 0 0 3px var(--surface-3); }

/* ---- Kaydirilabilir uzun metin */
.msg-text, .member-name, .search-result .text { overflow-wrap: anywhere; }

/* ---- Ek menusu: kamera secenegi yalnizca dokunmatik cihazlarda */
.camera-only { display: none; }
@media (pointer: coarse) { .camera-only { display: inline-flex; } }

/* ---- Ek onizlemesi (besteci) icin eski medya kurallari kaldirildi */
.attachment-preview .icon.attach-spin { animation: spin 1s linear infinite; }

/* ---- Surukle-birak katmani */
.drop-overlay[hidden], .lightbox[hidden], .react-bar[hidden] { display: none; }
.drop-overlay {
  position: absolute; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
  background: rgba(26,115,232,.08);
  background: color-mix(in srgb, var(--google-blue) 12%, transparent);
  border: 2px dashed var(--google-blue); border-radius: 12px; margin: 8px; pointer-events: none;
}
.drop-card {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-2); font-size: 15px; font-weight: 500; color: var(--text);
}
.drop-card .icon { width: 26px; height: 26px; color: var(--google-blue); }

/* ---- Tam ekran gorsel goruntuleyici */
.lightbox {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.86); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.lightbox img { max-width: 94vw; max-height: 88vh; max-height: 88dvh; object-fit: contain; border-radius: 6px; }
.lightbox-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  background: rgba(255,255,255,.14); color: #fff; border: none;
}
.lightbox-close:hover { background: rgba(255,255,255,.28); }
.lightbox-download {
  position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
}
.lightbox-download:hover { background: rgba(255,255,255,.28); }




/* ===================================================== Etiketler, sticker, kirpma */

/* ---- Uye yetki / premium etiketleri */
.tag-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px;
  border-radius: 999px; font-size: 10.5px; font-weight: 700; line-height: 16px;
  letter-spacing: .02em; white-space: nowrap; vertical-align: middle;
  border: 1px solid transparent; text-transform: none;
}
.tag-chip .icon { width: 12px; height: 12px; }
.tag-chip.premium { background: #fef7e0; color: #8a5a00; border-color: #f2c14e; }
.tag-chip.vip { background: #fce8e6; color: #a5251c; border-color: #ee8b83; }
.tag-chip.verified { background: #e6f4ea; color: #12673a; border-color: #7cc79a; }
.tag-chip.owner { background: #e8f0fe; color: #174ea6; border-color: #9ab8f5; }
.tag-chip.admin { background: #f3e8fd; color: #651f9c; border-color: #c39ae8; }
.tag-chip.moderator { background: #e6f4ea; color: #1f6b3b; border-color: #8fceac; }
.tag-chip.role-min { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }
.tag-chip.restrict { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); font-weight: 500; text-transform: none; }
.tag-chip.restrict .icon { width: 13px; height: 13px; }
[data-theme="dark"] .tag-chip.premium { background: #4a3a12; color: #fdd663; border-color: #7a621f; }
[data-theme="dark"] .tag-chip.vip { background: #4d2220; color: #f6aea6; border-color: #7d3630; }
[data-theme="dark"] .tag-chip.verified { background: #1d3a29; color: #a8dcbb; border-color: #2f5c42; }
[data-theme="dark"] .tag-chip.owner { background: #26374d; color: #aecbfa; border-color: #3b5a86; }
[data-theme="dark"] .tag-chip.admin { background: #35284a; color: #d7bdf5; border-color: #584173; }
[data-theme="dark"] .tag-chip.moderator { background: #1d3a29; color: #a8dcbb; border-color: #2f5c42; }

/* ---- Avatar gorseli */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* ---- Mesaj basligindaki ad + etiketler */
.msg-author-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---- Mesaj ici sticker */
.msg-sticker { display: block; padding: 0; border: none; background: transparent; cursor: zoom-in; margin-top: 4px; }
.msg-sticker img { width: 148px; height: 148px; object-fit: contain; display: block; }
.msg-sticker-removed {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  color: var(--text-muted); font-style: italic; font-size: 13px;
}

/* ---- Sticker secici */
.sticker-picker {
  position: absolute; bottom: calc(100% - 6px); left: 56px; z-index: 80;
  width: min(360px, calc(100vw - 24px)); max-height: min(60vh, 420px);
  overflow-y: auto; overscroll-behavior: contain; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.sticker-picker[hidden] { display: none; }
.sticker-picker-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 2px 4px 8px; font-size: 12px; font-weight: 700; color: var(--text-muted);
}
.sticker-picker-head button { border: none; background: transparent; color: var(--google-blue); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.sticker-picker-head button:hover { background: var(--active-bg); }
.sticker-pack { margin-bottom: 10px; }
.sticker-pack-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text); padding: 2px 4px 6px; }
.sticker-pack-name .muted { font-weight: 400; color: var(--text-muted); }
.sticker-pack-name .pack-actions { margin-left: auto; display: flex; gap: 4px; }
.sticker-pack-name .pack-actions button {
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
}
.sticker-pack-name .pack-actions button:hover { background: var(--active-bg); color: var(--text); }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sticker-cell {
  position: relative; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); padding: 4px; cursor: pointer; overflow: hidden;
}
.sticker-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sticker-cell:hover { background: var(--active-bg); }
.sticker-cell .sticker-del {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.sticker-cell .sticker-del .icon { width: 14px; height: 14px; }
.sticker-cell:hover .sticker-del, .sticker-cell:focus-within .sticker-del { display: flex; }
.sticker-empty { padding: 14px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---- Kanal kisitlama uyarisi */
.restrict-notice {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 6px;
  padding: 7px 10px; border-radius: 10px; font-size: 12.5px;
  background: var(--mark-bg); color: var(--mark-fg);
}
.restrict-notice[hidden] { display: none; }
.restrict-notice .icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ---- Kare kirpma */
.crop-overlay {
  position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 12px env(safe-area-inset-right) 12px env(safe-area-inset-left);
}
.crop-overlay[hidden] { display: none; }
.crop-box {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-2);
  padding: 16px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px;
}
.crop-box h3 { margin: 0; font-size: 16px; }
.crop-stage { display: flex; justify-content: center; }
.crop-stage canvas { max-width: 100%; height: auto; border-radius: 12px; background: #000; cursor: grab; touch-action: none; }
.crop-zoom-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.crop-zoom-row input { flex: 1; }
.crop-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Uye listesi zenginlestirme */
.member-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.member-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.member-handle { font-size: 11.5px; color: var(--text-muted); }

/* ---- Bildirim düğmesi durumu */
#pushBtn[aria-pressed="true"] { color: var(--google-blue); }

/* ---- Attach menu ikon yardimcisi */
.attach-menu-icon { display: inline-flex; width: 20px; justify-content: center; }
.attach-menu-icon .icon { width: 19px; height: 19px; }

/* ---- Profil modali */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.profile-avatar-wrap { position: relative; }
.profile-avatar-wrap .avatar { width: 72px; height: 72px; font-size: 26px; }
.profile-avatar-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.profile-avatar-actions button { font-size: 12px; }
.form-row { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.form-row label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.form-hint { font-size: 11.5px; color: var(--text-muted); }
.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
}
.color-dot[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.settings-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13.5px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--google-blue); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }

/* ---- Icerik turu secim cipsleri */
.checkbox-row { flex-wrap: wrap; }
.check-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--border); border-radius: 18px; cursor: pointer;
  font-size: 13px; background: var(--surface-2); user-select: none;
}
.check-chip:has(input:checked) {
  border-color: var(--google-blue); background: var(--active-bg); color: var(--google-blue);
}
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }

/* ---- Kaldirilmis sticker yer tutucusu */
.msg-sticker-removed {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 3px;
  font-size: 12.5px; color: var(--text-muted); font-style: italic;
}
.msg-sticker-removed .icon { width: 16px; height: 16px; }
