/* ============================================================================
   ggchat — uygulama arayüzü (Discord yapısına yakın)
   Tek stil dosyası: Chat, DM, Friends, Profile, Search
   Web fontu bilinçli olarak yok — sistem yazı tipi yığını hem hızlı hem yakın.
   ========================================================================== */

:root {
    /* ── Zeminler (Discord karanlık tema karşılıkları) ── */
    --bg-rail: #1e1f22;      /* sunucu şeridi */
    --bg-sidebar: #2b2d31;   /* kanal listesi / üye listesi */
    --bg-chat: #313338;      /* mesaj alanı */
    --bg-input: #383a40;     /* mesaj kutusu */
    --bg-float: #111214;     /* açılır menü / tooltip */
    --bg-modal: #313338;
    --bg-hover: rgba(78, 80, 88, 0.30);
    --bg-active: rgba(78, 80, 88, 0.48);
    --bg-selected: rgba(78, 80, 88, 0.60);
    --bg-message-hover: #32353b;
    --bg-mention: rgba(88, 101, 242, 0.10);
    --bg-mention-hover: rgba(88, 101, 242, 0.16);

    /* ── Metin ── */
    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --text-faint: #80848e;
    --text-link: #00a8fc;
    --header-primary: #f2f3f5;
    --header-secondary: #b5bac1;

    /* ── Etkileşim ── */
    --interactive-normal: #b5bac1;
    --interactive-hover: #dbdee1;
    --interactive-active: #ffffff;
    --interactive-muted: #4e5058;

    /* ── Marka / durum ── */
    --brand: #5865f2;
    --brand-hover: #4752c4;
    --brand-active: #3c45a5;
    --green: #23a55a;
    --yellow: #f0b132;
    --red: #f23f43;
    --red-hover: #da373c;

    --border: rgba(255, 255, 255, 0.06);
    --divider: #3f4147;

    /* ── Ölçüler ── */
    --rail-w: 72px;
    --sidebar-w: 240px;
    --members-w: 240px;
    --header-h: 48px;
    --panel-h: 52px;

    --radius-sm: 3px;
    --radius: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 50%;

    --elev-low: 0 1px 0 rgba(4,4,5,.2), 0 1.5px 0 rgba(6,6,7,.05), 0 2px 0 rgba(4,4,5,.05);
    --elev-high: 0 8px 16px rgba(0,0,0,.24);
    --elev-max: 0 12px 32px rgba(0,0,0,.4);

    --font: "gg sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: Consolas, "Andale Mono WT", "Lucida Console", Monaco, monospace;

    --safe-b: env(safe-area-inset-bottom, 0px);

    /* Eski tema adları — görünümlerde hâlâ kullanılıyor. Tanımsız oldukları için
       sunucu ayarları penceresinde ikon önizlemesi, başlık rengi ve "Tehlikeli
       Bölge" arka planı görünmüyordu. */
    --text-primary: var(--header-primary);
    --text-secondary: var(--header-secondary);
    --bg-primary: var(--bg-chat);
    --bg-secondary: var(--bg-sidebar);
    --bg-tertiary: var(--bg-rail);
    --accent: var(--brand);
    --gradient-accent: linear-gradient(135deg, #5865f2 0%, #8b5cf6 100%);
    --red-light: rgba(242, 63, 67, 0.10);
    --transition: .15s ease;
    --channel-default: var(--text-muted);
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    height: 100%;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.375;
    color: var(--text-normal);
    background: var(--bg-chat);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* Uygulama kabuğu sayfayı kaydırmaz; paneller kendi içinde kayar */
body.app-shell { overflow: hidden; }

img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Kaydırma çubuğu (Discord ile aynı ölçüler) ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #131416; }
.thin-scroll::-webkit-scrollbar { width: 3px; }
* { scrollbar-width: thin; scrollbar-color: #1a1b1e transparent; }

/* ============================ KABUK ==================================== */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-rail);
}

.app-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0,0,0,.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.app-scrim.is-open { opacity: 1; visibility: visible; }

/* Masaüstünde sarmalayıcı düzeni bozmaz */
.app-drawer { display: contents; }

/* ============================ SUNUCU ŞERİDİ ============================ */

.server-list {
    width: var(--rail-w);
    min-width: var(--rail-w);
    background: var(--bg-rail);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 3;
}
.server-list::-webkit-scrollbar { width: 0; }

.server-icon {
    position: relative;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 24px;
    background: var(--bg-sidebar);
    color: var(--text-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    user-select: none;
    /* Discord'un imzası: hover'da daireden squircle'a geçiş */
    transition: border-radius .15s ease, background-color .15s ease, color .15s ease;
}

.server-icon img { width: 100%; height: 100%; object-fit: cover; }

.server-icon:hover { border-radius: var(--radius-lg); background: var(--brand); color: #fff; }

.server-icon.active { border-radius: var(--radius-lg); background: var(--brand); color: #fff; }

/* Soldaki beyaz gösterge çubuğu */
.server-icon::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 50%;
    width: 4px;
    height: 0;
    border-radius: 0 4px 4px 0;
    background: #fff;
    transform: translateY(-50%);
    transition: height .15s ease;
}
.server-icon:hover::before { height: 20px; }
.server-icon.active::before { height: 40px; }

.server-icon.friends { background: var(--bg-sidebar); color: var(--text-normal); }
.server-icon.friends:hover, .server-icon.friends.active { background: var(--brand); color: #fff; }

.server-icon.add-server { background: var(--bg-sidebar); color: var(--green); font-size: 24px; font-weight: 400; }
.server-icon.add-server:hover { background: var(--green); color: #fff; }

/* Şeritteki ayırıcı */
.server-list hr {
    width: 32px;
    height: 2px;
    border: 0;
    border-radius: 1px;
    background: rgba(255,255,255,.08);
    margin: 0;
    flex-shrink: 0;
}

/* ============================ KANAL LİSTESİ ============================ */

.channel-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
}

.server-header {
    height: var(--header-h);
    min-height: var(--header-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
    box-shadow: var(--elev-low);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color .1s ease;
}
.server-header:hover { background: var(--bg-hover); }

.server-header > span:first-of-type,
#server-name-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-header .icon-btn { color: var(--interactive-normal); font-size: 15px; }
.server-header .icon-btn:hover { color: var(--interactive-hover); }

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 0;
}
.channel-list::-webkit-scrollbar { width: 8px; }
.channel-list:not(:hover)::-webkit-scrollbar-thumb { background: transparent; }

/* Kategori başlığı */
.category-header {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    margin-top: 16px;
    padding: 0 8px 0 16px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color .1s ease;
}
.category-header:hover { color: var(--interactive-hover); }
.category-header > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .1s ease; }
.category-header:hover .cat-actions { opacity: 1; }

/* Kanal: .channel-item (kapsayıcı) > .channel-row (satır) > .channel-link (tıklanır alan).
   chat.js bu yapıyı üretir; ses kanallarında satırın altında bağlı kullanıcılar listelenir. */
.channel-item {
    display: block;
    color: var(--channel-default, #949ba4);
}

.channel-row {
    display: flex;
    align-items: center;
    margin: 1px 8px;
    border-radius: var(--radius);
    transition: background-color .1s ease;
}
.channel-row:hover { background: var(--bg-hover); }

.channel-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    color: inherit;
    cursor: pointer;
    transition: color .1s ease;
}
.channel-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.channel-item:hover { color: var(--interactive-hover); }
.channel-item.active,
.channel-item.active-channel { color: var(--interactive-active); }
.channel-item.active > .channel-row,
.channel-item.active-channel > .channel-row { background: var(--bg-selected); }

.channel-link__icon { font-size: 18px; color: var(--text-faint); flex-shrink: 0; line-height: 1; width: 20px; text-align: center; }
.channel-link__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row__actions { display: flex; gap: 2px; align-items: center; flex-shrink: 0; padding-right: 4px; }

.channel-row .edit-ch-btn,
.channel-row .delete-ch-btn {
    opacity: 0;
    color: var(--interactive-normal);
    font-size: 13px;
    padding: 4px 6px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    transition: opacity .1s ease, color .1s ease;
}
.channel-row:hover .edit-ch-btn,
.channel-row:hover .delete-ch-btn { opacity: 1; }
.channel-row .edit-ch-btn:hover { color: var(--interactive-active); }
.channel-row .delete-ch-btn:hover { color: var(--red); }

/* ============================ KULLANICI PANELİ ========================= */

.user-panel {
    height: var(--panel-h);
    min-height: var(--panel-h);
    padding: 0 8px;
    padding-bottom: var(--safe-b);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #232428;
    flex-shrink: 0;
}

.user-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-full);
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; min-width: 0; }

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--header-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status { font-size: 12px; color: var(--text-muted); }

/* ============================ SES PANELİ =============================== */

.voice-panel {
    padding: 8px;
    background: #232428;
    border-top: 1px solid rgba(0,0,0,.2);
    flex-shrink: 0;
}

.voice-status-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--green);
}

.voice-status-dot {
    width: 8px; height: 8px;
    border-radius: var(--radius-full);
    background: var(--green);
}

.voice-controls { display: flex; gap: 4px; }

.voice-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    color: var(--interactive-normal);
    font-size: 15px;
    transition: background-color .1s ease, color .1s ease;
}
.voice-btn:hover { background: var(--bg-hover); color: var(--interactive-hover); }
.voice-btn.danger { color: var(--red); }
.voice-btn.danger:hover { background: var(--red); color: #fff; }

/* ============================ SOHBET ALANI ============================= */

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    overflow: hidden;
}

.chat-header {
    height: var(--header-h);
    min-height: var(--header-h);
    padding: 0 8px 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--elev-low);
    flex-shrink: 0;
    z-index: 2;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
}
.chat-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.channel-hash { font-size: 24px; font-weight: 400; color: var(--text-faint); line-height: 1; }

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

.chat-header-actions a,
.chat-header-actions button {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    color: var(--interactive-normal);
    font-size: 17px;
    transition: background-color .1s ease, color .1s ease;
}
.chat-header-actions a:hover,
.chat-header-actions button:hover { background: var(--bg-hover); color: var(--interactive-hover); text-decoration: none; }

/* Yalnızca dar ekranda görünen çekmece düğmeleri */
.chat-header .drawer-toggle,
.chat-header-actions .drawer-toggle { display: none; }

/* ============================ MESAJLAR ================================= */

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0 24px;
    overscroll-behavior-y: contain;
}

/* Discord ölçüsü: 72px sol boşluk, avatar 16px'te mutlak konumlu */
.message {
    position: relative;
    padding: 2px 48px 2px 72px;
    margin-top: 17px;
    min-height: 22px;
}
.message:hover { background: var(--bg-message-hover); }

/* Aynı kişinin arka arkaya mesajları: avatar ve ad tekrarlanmaz */
.message.grouped { margin-top: 0; }
.message.grouped .message-avatar,
.message.grouped .message-author { display: none; }
/* Başlıkta yalnızca (sol boşluğa taşınan) saat ve düzenle/sil düğmeleri kalır;
   düğmeler satırın sağ üstünde yüzer, böylece hover'da yerleşim kaymaz. */
.message.grouped .message-header { display: block; height: 0; }
.message.grouped .edit-msg-btn,
.message.grouped .delete-msg-btn { position: absolute; top: 0; z-index: 1; background: var(--bg-chat) !important; }
.message.grouped .edit-msg-btn { right: 44px; }
.message.grouped .delete-msg-btn { right: 12px; }

.message-avatar {
    position: absolute;
    left: 16px;
    top: 2px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    cursor: pointer;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }

.message-content-area { min-width: 0; }

.message-header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.message-author {
    font-size: 16px;
    font-weight: 500;
    color: var(--header-primary);
    cursor: pointer;
}
.message-author:hover { text-decoration: underline; }

.message-time { font-size: 12px; color: var(--text-faint); font-weight: 500; }

/* Gruplanmış mesajlarda saat, hover'da sol boşlukta belirir */
.message.grouped .message-time {
    position: absolute;
    left: 0;
    width: 72px;
    top: 2px;
    text-align: center;
    opacity: 0;
    transition: opacity .1s ease;
}
.message.grouped:hover .message-time { opacity: 1; }

.message-text {
    font-size: 16px;
    line-height: 1.375;
    color: var(--text-normal);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-edited { font-size: 10px; color: var(--text-faint); margin-left: 4px; }

.message-image {
    max-width: min(100%, 420px);
    max-height: 350px;
    width: auto;
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: zoom-in;
    object-fit: cover;
}

.message-highlight { background: var(--bg-mention) !important; box-shadow: inset 2px 0 0 var(--yellow); }

/* Mesaj eylem çubuğu — sağ üstte yüzer */
.message-actions {
    position: absolute;
    top: -16px;
    right: 16px;
    display: flex;
    background: var(--bg-chat);
    border: 1px solid rgba(0,0,0,.2);
    border-radius: var(--radius-md);
    box-shadow: var(--elev-low);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
.message:hover .message-actions { opacity: 1; pointer-events: auto; }

.message-action-btn,
.edit-msg-btn,
.delete-msg-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: var(--interactive-normal);
    font-size: 15px;
    transition: background-color .1s ease, color .1s ease;
}
.message-action-btn:hover, .edit-msg-btn:hover { background: var(--bg-hover); color: var(--interactive-hover); }
.delete-msg-btn:hover { background: var(--bg-hover); color: var(--red); }

.message-edit-input {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    background: var(--bg-input);
    border: 0;
    border-radius: var(--radius-md);
    color: var(--text-normal);
    font-size: 16px;
    outline: none;
    resize: none;
}

/* ── Markdown / zengin metin ── */
.message-text code {
    font-family: var(--font-mono);
    font-size: 14px;
    background: #2b2d31;
    border-radius: var(--radius-sm);
    padding: 1px 3px;
}
.message-text pre {
    font-family: var(--font-mono);
    font-size: 14px;
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: var(--radius);
    padding: 8px;
    margin: 4px 0;
    overflow-x: auto;
    white-space: pre;
}
.message-text blockquote {
    margin: 2px 0;
    padding-left: 12px;
    border-left: 4px solid var(--interactive-muted);
    color: var(--text-normal);
}
.message-text a { color: var(--text-link); }
.message-text strong { font-weight: 700; }
.message-text em { font-style: italic; }
.message-text del { text-decoration: line-through; }
.message-text u { text-decoration: underline; }

.mention {
    background: var(--bg-mention);
    color: #c9cdfb;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0 2px;
    cursor: pointer;
}
.mention:hover { background: var(--brand); color: #fff; }

/* Bana bahseden mesaj */
.message.is-mentioned { background: var(--bg-mention); box-shadow: inset 2px 0 0 var(--yellow); }
.message.is-mentioned:hover { background: var(--bg-mention-hover); }

/* ── Yazıyor göstergesi ── */
.typing-indicator {
    height: 24px;
    padding: 0 16px;
    font-size: 14px;
    color: var(--text-normal);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================ MESAJ KUTUSU ============================= */

.message-input-area {
    padding: 0 16px 24px;
    padding-bottom: calc(24px + var(--safe-b));
    flex-shrink: 0;
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 0 16px;
}

.message-input-wrapper input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: none;
    padding: 11px 0;
    font-size: 16px;
    color: var(--text-normal);
}
.message-input-wrapper input::placeholder { color: var(--text-faint); }

.send-btn {
    width: 40px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    color: var(--interactive-normal);
    font-size: 20px;
    flex-shrink: 0;
    transition: color .1s ease;
}
.send-btn:hover { color: var(--interactive-hover); }
.send-btn.send-primary { color: var(--brand); }
.send-btn.send-primary:hover { color: #7983f5; }

/* ============================ ÜYE LİSTESİ ============================== */

.members-sidebar {
    width: var(--members-w);
    min-width: var(--members-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
}

.members-header {
    height: var(--header-h);
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--text-muted);
    flex-shrink: 0;
}

.members-sidebar > div:last-child { flex: 1; overflow-y: auto; padding: 0 8px 8px; }

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 42px;
    padding: 0 8px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    color: var(--channel-default, #949ba4);
    cursor: pointer;
    transition: background-color .1s ease, color .1s ease;
}
.member-item:hover { background: var(--bg-hover); color: var(--interactive-hover); }
.member-item > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.member-avatar {
    position: relative;
    width: 32px; height: 32px;
    min-width: 32px;
    border-radius: var(--radius-full);
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Durum rozeti — avatarın sağ altında, zemine oyulmuş görünür */
.online-dot {
    position: absolute;
    right: -2px; bottom: -2px;
    width: 14px; height: 14px;
    border-radius: var(--radius-full);
    background: var(--green);
    border: 3px solid var(--bg-sidebar);
}
.online-dot.idle { background: var(--yellow); }
.online-dot.dnd { background: var(--red); }
.online-dot.offline { background: #80848e; }

/* ============================ ORTAK BİLEŞENLER ========================= */

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--header-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    background: #1e1f22;
    border: 1px solid #1e1f22;
    border-radius: var(--radius-sm);
    color: var(--text-normal);
    font-size: 16px;
    outline: none;
    transition: border-color .15s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #00a8fc; }

.btn-primary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 2px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); text-decoration: none; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--text-normal); }
.btn-ghost:hover { background: var(--bg-hover); text-decoration: none; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }

.icon-btn {
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--interactive-normal);
    font-size: 14px;
    transition: background-color .1s ease, color .1s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--interactive-hover); }

.auth-box {
    background: var(--bg-modal);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--elev-max);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}
.auth-box h2 { margin: 0 0 16px; font-size: 20px; font-weight: 600; color: var(--header-primary); }

/* ── Modallar: varsayılan GİZLİ (JS style.display = "flex" ile açar) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,.85);
}
.modal-overlay.is-open { display: flex; }

.modal-content {
    width: 100%;
    max-width: 440px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    background: var(--bg-modal);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--elev-max);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.modal-header h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--header-primary); }

.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--interactive-normal);
    font-size: 18px;
}
.modal-close:hover { color: var(--interactive-active); background: var(--bg-hover); }

/* ── Sayfa kabuğu: Friends / Profile / Search ── */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--header-h);
    padding: 0 12px;
    background: var(--bg-chat);
    box-shadow: var(--elev-low);
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-bar a {
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--interactive-normal);
    white-space: nowrap;
    transition: background-color .1s ease, color .1s ease;
}
.nav-bar a:hover { background: var(--bg-hover); color: var(--interactive-hover); text-decoration: none; }
.nav-bar a.active { background: var(--bg-selected); color: var(--interactive-active); }

.nav-back {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    color: var(--interactive-normal);
    font-size: 18px;
    flex-shrink: 0;
}
.nav-back:hover { background: var(--bg-hover); color: var(--interactive-hover); }

.page-wrapper { max-width: 940px; margin: 0 auto; padding: 24px 16px 48px; }

.card {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}

.section-label {
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--header-secondary);
}

.danger-zone { border: 1px solid var(--red); border-radius: var(--radius-md); padding: 20px; }
.danger-zone-title { color: var(--red); font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.danger-zone p { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; }

.invite-friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color .1s ease;
}
.invite-friend-item:hover { background: var(--bg-hover); }
.invite-friend-item.selected { background: var(--bg-selected); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 560px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }

.fade-in { animation: fadeIn .15s ease both; }
.slide-up { animation: slideUp .2s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 500;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    background: var(--bg-float);
    border-radius: var(--radius-md);
    box-shadow: var(--elev-high);
    font-size: 14px;
    color: var(--text-normal);
}

#emoji-picker,
#member-context-menu {
    background: var(--bg-float);
    border-radius: var(--radius-md);
    box-shadow: var(--elev-high);
    overflow: hidden;
}
#emoji-grid::-webkit-scrollbar { width: 8px; }
#emoji-grid::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
#emoji-category-tabs::-webkit-scrollbar { height: 0; }

/* ============================ SAĞ ÜST ARAÇ ÇUBUĞU ====================== */

.util-cluster {
    position: fixed;
    top: 8px;
    right: 12px;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--bg-float);
    border-radius: var(--radius-md);
    box-shadow: var(--elev-high);
}

.util-btn {
    position: relative;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    color: var(--interactive-normal);
    font-size: 16px;
    transition: background-color .1s ease, color .1s ease;
}
.util-btn:hover { background: var(--bg-hover); color: var(--interactive-hover); text-decoration: none; }

.util-badge {
    display: none;
    position: absolute;
    top: 0; right: 0;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--red);
    border: 2px solid var(--bg-float);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
}

.notif-panel {
    display: none;
    position: fixed;
    top: 48px; right: 12px;
    z-index: 119;
    width: min(340px, calc(100vw - 24px));
    max-height: min(440px, calc(100dvh - 80px));
    overflow-y: auto;
    background: var(--bg-float);
    border-radius: var(--radius-md);
    box-shadow: var(--elev-max);
}
.notif-panel.is-open { display: block; }

.notif-panel__head {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-float);
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: 14px;
    font-weight: 600;
    color: var(--header-primary);
}

.notif-panel__all { color: var(--text-link); font-size: 12px; padding: 2px 4px; border-radius: var(--radius-sm); }
.notif-panel__all:hover { text-decoration: underline; }

/* Sohbet ekranında zil başlığa taşınır, diğerleri alt çubukta zaten var */
body.app-shell .util-hide-app { display: none; }
body.app-shell .util-cluster {
    position: static;
    padding: 0;
    background: none;
    box-shadow: none;
}
body.app-shell .notif-panel { top: calc(var(--header-h) + 4px); }

/* ============================ MOBİL ALT ÇUBUK ========================== */

.mobile-bottom-bar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 95;
    background: var(--bg-rail);
    border-top: 1px solid rgba(0,0,0,.3);
    padding: 4px 0 calc(4px + var(--safe-b));
}

.mobile-bottom-bar button,
.mobile-bottom-bar a {
    flex: 1;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: color .1s ease, background-color .1s ease;
}
.mobile-bottom-bar .icon { font-size: 18px; line-height: 1; }
.mobile-bottom-bar .label { font-size: 10px; font-weight: 600; }
.mobile-bottom-bar button.active,
.mobile-bottom-bar a.active { color: var(--interactive-active); }
.mobile-bottom-bar a:hover { text-decoration: none; }

body.has-bottom-bar .message-input-area {
    padding-bottom: calc(16px + 56px + var(--safe-b));
}

.mobile-panel-back {
    display: none;
    width: 32px; height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--interactive-normal);
    font-size: 22px;
    flex-shrink: 0;
}
.mobile-panel-back:hover { background: var(--bg-hover); color: var(--interactive-hover); }

/* ============================ RESPONSIVE =============================== */

/* Üye listesi 1100px altında sağ çekmeceye taşınır */
@media (max-width: 1100px) {
    .members-sidebar {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        z-index: 100;
        transform: translateX(100%);
        transition: transform .2s ease;
        box-shadow: var(--elev-max);
    }
    .members-sidebar.is-open { transform: none; }
    .chat-header-actions .drawer-toggle { display: flex; }
}

/* Sunucu + kanal listesi sol çekmeceye taşınır */
@media (max-width: 900px) {
    .app-drawer {
        display: flex;
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--elev-max);
    }
    .app-drawer.is-open { transform: none; }

    .channel-sidebar { width: auto; min-width: 0; flex: 1; }

    .mobile-panel-back { display: inline-flex; }
    .chat-header .drawer-toggle { display: flex; }
    .mobile-bottom-bar { display: flex; }

    .messages-container { padding-top: 8px; }
    .message { padding-right: 16px; }
    .message-input-area { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 600px) {
    :root { --rail-w: 68px; }

    .server-icon { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 15px; }
    .chat-header { padding-left: 8px; }
    .message { padding-left: 60px; }
    .message-avatar { left: 12px; width: 36px; height: 36px; }
    .message.grouped .message-time { width: 60px; }
    .page-wrapper { padding: 16px 12px 40px; }
    .card { padding: 16px; }
    .toast { bottom: calc(16px + 56px + var(--safe-b)); }

    /* Dokunmatikte hover yok. Eylem çubuğu mutlak konumlu olduğu için her zaman
       görünür yapılırsa mesaj metninin üstüne biniyordu. Bunun yerine Discord
       mobil gibi: mesaja dokununca akış içinde, metnin altında açılır. */
    .message-actions {
        opacity: 0;
        pointer-events: none;
    }

    .message.is-active .message-actions {
        position: static;
        opacity: 1;
        pointer-events: auto;
        display: flex;
        justify-content: flex-end;
        margin-top: 6px;
        background: none;
        border: 0;
        box-shadow: none;
    }

    .message.is-active { background: var(--bg-message-hover); }
    .channel-row .edit-ch-btn,
    .channel-row .delete-ch-btn,
    .cat-actions { opacity: 1; }
}

@media (max-width: 480px) {
    #emoji-picker {
        width: calc(100vw - 16px) !important;
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
    }
}

/* Dokunmatik hedefleri */
@media (hover: none) and (pointer: coarse) {
    .channel-link { height: 40px; }
    /* Hover olmayan cihazlarda kanal/kategori yönetim düğmeleri hep görünür */
    .channel-row .edit-ch-btn,
    .channel-row .delete-ch-btn,
    .cat-actions { opacity: 1; }
    .member-item { height: 44px; }
    .message-input-wrapper input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ============================ EK BİLEŞENLER ============================ */

/* Boş durumlar: sunucu yok, kanal boş, kanal yok */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    min-height: 100%;
    padding: 32px 16px;
    color: var(--text-muted);
}
.chat-empty__icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--header-primary);
    margin-bottom: 4px;
}
.chat-empty__title { font-size: 20px; font-weight: 700; color: var(--header-primary); }
.chat-empty__text { font-size: 14px; max-width: 360px; margin: 0; }
.chat-empty__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* Sunucuya ulaşmamış (onay bekleyen) mesaj */
.message.is-pending { opacity: .55; }

/* Mesajdaki dosya eki */
.message-file {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 8px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.message-file a {
    color: var(--text-link);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sunucu adı ekran okuyucular için; görsel olarak ipucu (title) kullanılır */
.server-icon__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Kullanıcı paneli: profil bağlantısı + hızlı düğmeler */
.user-panel__me {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    margin-left: -4px;
    border-radius: var(--radius);
    color: inherit;
}
.user-panel__me:hover { background: var(--bg-hover); text-decoration: none; }
.user-panel__btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--interactive-normal);
    flex-shrink: 0;
}
.user-panel__btn:hover { background: var(--bg-hover); text-decoration: none; }

/* Kanal listesindeki reklam alanı */
.ad-slot { margin: 8px; flex-shrink: 0; max-height: 180px; overflow: hidden; }
.ad-slot img { max-width: 100%; height: auto; display: block; }
