:root {
    color-scheme: dark;
    --bg: #0e0e13;
    --surface: #17171f;
    --surface-2: #20202b;
    --surface-3: #2a2a38;
    --line: #343442;
    --ink: #ececf3;
    --muted: #a6a6b8;
    --indigo: #6366f1;
    --violet: #8b5cf6;
    --green: #22c55e;
    --danger: #f87171;
    --tick: #7dd3fc;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  button, input, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  ::selection { background: rgba(99, 102, 241, .45); }

  .hidden { display: none !important; }

  /* ---------- Giriş ---------- */
  .login-wrap {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
      radial-gradient(900px 500px at 15% 0%, rgba(99, 102, 241, .18), transparent 60%),
      radial-gradient(700px 500px at 100% 100%, rgba(139, 92, 246, .14), transparent 60%),
      var(--bg);
  }
  .login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 32px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  }
  .logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
  .logo {
    width: 54px; height: 54px; border-radius: 17px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    font-size: 27px; font-weight: 800; color: #fff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, .35);
  }
  .brand { font-size: 26px; font-weight: 750; letter-spacing: -.5px; }
  .tagline { color: var(--muted); font-size: 12.5px; letter-spacing: .2px; }
  .login-title { margin: 26px 0 4px; font-size: 21px; font-weight: 700; }
  .login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
  .field { margin-bottom: 14px; }
  .field label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px 2px; }
  .field input {
    width: 100%; padding: 13px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
  }
  .field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
  .btn-primary {
    width: 100%; padding: 13px 16px; margin-top: 6px;
    border: 0; border-radius: 14px;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    color: #fff; font-weight: 700;
    transition: filter .15s, transform .05s;
  }
  .btn-primary:hover { filter: brightness(1.07); }
  .btn-primary:active { transform: translateY(1px); }
  .btn-primary:disabled { opacity: .55; cursor: default; }
  .login-error {
    margin-top: 14px; padding: 10px 12px;
    background: rgba(248, 113, 113, .12);
    border: 1px solid rgba(248, 113, 113, .35);
    border-radius: 12px;
    color: #fca5a5; font-size: 13px;
  }
  .demo-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
  .demo-hint code { color: #c7d2fe; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

  /* ---------- Uygulama ---------- */
  .app {
    height: 100dvh;
    display: grid;
    grid-template-columns: 350px 1fr;
    overflow: hidden;
  }
  .sidebar {
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    min-width: 0; min-height: 0; overflow: hidden;
  }
  .side-top {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 12px;
  }
  .side-top .logo { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }
  .side-brand { font-size: 19px; font-weight: 750; letter-spacing: -.3px; line-height: 1.1; }
  .side-brand small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: .3px; }
  .side-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
  .icon-btn {
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center;
    background: transparent; border: 0; color: var(--muted);
    transition: background .15s, color .15s;
  }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  .icon-btn svg { width: 20px; height: 20px; }

  .side-actions { display: flex; gap: 8px; padding: 0 14px 12px; }
  .new-chat-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 12px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 12px; color: var(--ink); font-size: 13.5px; font-weight: 600;
  }
  .new-chat-btn:hover { background: var(--surface-3); }
  .new-chat-btn svg { width: 17px; height: 17px; color: var(--indigo); }

  .chat-list { flex: 1; overflow-y: auto; padding: 2px 8px 14px; }
  .chat-row {
    display: flex; gap: 12px; align-items: center;
    padding: 11px 10px; border-radius: 15px;
    cursor: pointer; border: 1px solid transparent;
  }
  .chat-row:hover { background: var(--surface-2); }
  .chat-row.active { background: linear-gradient(135deg, rgba(99, 102, 241, .18), rgba(139, 92, 246, .12)); border-color: rgba(99, 102, 241, .35); }
  .chat-row .chat-more {
    flex: none; width: 26px; height: 26px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); cursor: pointer; font-size: 16px;
    line-height: 1; opacity: 0; transition: opacity .12s;
  }
  .chat-row:hover .chat-more, .chat-row .chat-more:focus { opacity: 1; }
  .chat-row .chat-more:hover { background: var(--surface); color: var(--ink); }
  .chat-pin { font-size: 11px; margin-right: 4px; }
  .archive-toggle {
    margin: 10px 14px 16px; padding: 11px 14px; border: 1px solid var(--line);
    border-radius: 12px; background: var(--surface-2); color: var(--muted);
    font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left;
  }
  .archive-toggle:hover { color: var(--ink); border-color: var(--indigo); }
  .info-summary { color: var(--muted); font-size: 12px; padding: 2px 6px 8px; }
  .info-state { flex: none; font-size: 11.5px; color: var(--muted); }
  .info-state.read { color: var(--indigo); font-weight: 600; }
  .context-menu {
    position: fixed; z-index: 80; min-width: 190px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
  }
  .context-menu button {
    display: block; width: 100%; text-align: left; padding: 9px 11px;
    border: 0; border-radius: 9px; background: transparent; color: var(--ink);
    font-size: 13px; cursor: pointer;
  }
  .context-menu button:hover { background: var(--surface-2); }
  .context-menu button.danger { color: #f87171; }
  .context-menu .sep { height: 1px; margin: 5px 7px; background: var(--line); }
  .reply-bar {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    border-top: 1px solid var(--line); background: var(--surface-2);
  }
  .mention-bar {
    display: flex; align-items: center; gap: 7px; padding: 8px 14px;
    border-top: 1px solid var(--line); background: var(--surface);
    overflow-x: auto;
  }
  .mention-chip {
    flex: none; border: 1px solid rgba(99, 102, 241, .35);
    background: rgba(99, 102, 241, .12); color: var(--ink);
    border-radius: 999px; padding: 6px 11px; font-size: 12px; cursor: pointer;
  }
  .mention-chip b { color: var(--indigo); }
  .reply-bar .reply-main { flex: 1; min-width: 0; }
  .reply-bar .reply-label { color: var(--indigo); font-size: 11px; font-weight: 700; }
  .reply-bar .reply-text { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reply-bar button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
  .reply-quote {
    border-left: 3px solid var(--indigo); padding: 4px 8px; margin-bottom: 5px;
    background: rgba(99, 102, 241, .1); border-radius: 0 8px 8px 0;
    font-size: 12px; color: var(--muted); max-width: 100%;
  }
  .reply-quote b { display: block; color: var(--indigo); font-size: 11px; }
  .reply-quote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .msg.mine .reply-quote {
    background: rgba(255, 255, 255, .14);
    border-left-color: rgba(255, 255, 255, .85);
  }
  .msg.mine .reply-quote b { color: #fff; }
  .msg.mine .reply-quote span { color: rgba(255, 255, 255, .82); }
  .msg.mine .poll-option { background: rgba(255, 255, 255, .14); }
  .msg.mine .poll-total { color: rgba(255, 255, 255, .72); }
  .msg.mine .pending-label { color: rgba(255, 255, 255, .8); }
  .msg { cursor: context-menu; }
  .msg.pending .bubble { opacity: .72; }
  .pending-label { font-size: 10px; color: var(--muted); margin-left: 4px; }
  .mention {
    color: var(--indigo); font-weight: 650; background: rgba(99, 102, 241, .12);
    border-radius: 4px; padding: 0 2px;
  }
  .msg-more {
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    font-size: 14px; line-height: 1; padding: 0 3px; opacity: 0;
  }
  .msg:hover .msg-more, .msg-more:focus { opacity: 1; }
  .msg.mine .meta { justify-content: flex-end; }
  .avatar {
    width: 48px; height: 48px; flex: 0 0 48px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 16px;
    background: var(--c, #4f46e5);
    position: relative;
    user-select: none;
  }
  .avatar.small { width: 36px; height: 36px; flex-basis: 36px; font-size: 13px; }
  .avatar .online-dot {
    position: absolute; right: 0; bottom: 0;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--green); border: 2.5px solid var(--surface);
  }
  .conv-sub.typing { color: var(--indigo) !important; font-weight: 600; }
  .chat-main { flex: 1; min-width: 0; }
  .chat-line1 { display: flex; align-items: baseline; gap: 8px; }
  .chat-name { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-time { margin-left: auto; font-size: 11px; color: var(--muted); flex: none; }
  .chat-line2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
  .chat-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
  .chat-preview.unread { color: var(--ink); }
  .chat-muted { flex: none; font-size: 11px; opacity: .75; }
  .badge {
    flex: none; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--indigo);
    color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center;
  }
  .side-foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
  .foot-btn {
    width: 28px; height: 28px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--ink); font-size: 13px;
    display: grid; place-items: center; cursor: pointer;
  }
  .foot-btn:hover { filter: brightness(1.15); }
  .foot-btn.on { border-color: rgba(34, 197, 94, .45); color: var(--green); }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
  .dot.off { background: var(--danger); }

  .conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); position: relative; }
  .conv-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; min-height: 72px;
    background: rgba(23, 23, 31, .86); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .conv-title { font-weight: 700; font-size: 15.5px; line-height: 1.2; }
  .conv-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .back-btn { display: none; }
  .conv-actions { margin-left: auto; display: flex; gap: 4px; }
  .conv-actions .icon-btn { color: var(--ink); }
  .conv-actions .hidden { display: none; }

  .call-overlay {
    position: fixed; inset: 0; z-index: 80;
    display: grid; place-items: center;
    background: rgba(5, 5, 10, .78); backdrop-filter: blur(9px);
  }
  .call-card {
    width: min(360px, calc(100vw - 36px));
    border: 1px solid var(--line); border-radius: 26px;
    background: var(--surface); padding: 26px 22px;
    text-align: center; box-shadow: 0 30px 100px rgba(0, 0, 0, .65);
  }
  .call-avatar {
    width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%;
    display: grid; place-items: center; font-size: 26px; font-weight: 700;
    background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff;
  }
  .call-name { font-size: 20px; font-weight: 700; }
  .call-status { color: var(--muted); font-size: 13px; margin-top: 6px; min-height: 18px; }
  .call-timer { font-variant-numeric: tabular-nums; color: var(--green); font-size: 13px; margin-top: 4px; }
  .call-remote-video {
    width: 100%; max-height: 210px; margin-top: 14px; border-radius: 14px;
    background: #000; object-fit: cover;
  }
  .call-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
  .call-actions.hidden { display: none; }
  .call-btn {
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
    border-radius: 999px; padding: 10px 18px; font-weight: 600; cursor: pointer;
  }
  .call-btn.accept { background: rgba(34, 197, 94, .2); border-color: rgba(34, 197, 94, .5); }
  .call-btn.reject { background: rgba(239, 68, 68, .2); border-color: rgba(239, 68, 68, .5); }

  .pinned-bar {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 14px; background: var(--surface-2);
    border-bottom: 1px solid var(--line); cursor: pointer;
  }
  .pinned-bar .pin-icon { color: var(--indigo); font-size: 15px; }
  .pinned-text {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12.5px; color: var(--muted);
  }
  .pinned-text b { color: var(--ink); font-weight: 600; }
  .pinned-bar button {
    border: 0; background: transparent; color: var(--muted);
    font-size: 18px; cursor: pointer; line-height: 1;
  }
  .messages {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 18px 20px 10px;
    display: flex; flex-direction: column; gap: 3px;
    background-image: radial-gradient(rgba(99, 102, 241, .055) 1px, transparent 1px);
    background-size: 22px 22px;
  }
  .messages > :first-child { margin-top: auto; }
  .day { align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; }
  .sys { align-self: center; margin: 5px 0; padding: 5px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
  .msg { display: flex; margin: 2px 0; }
  .msg.mine { justify-content: flex-end; }
  .bubble {
    max-width: min(68%, 560px);
    background: var(--surface-2);
    border-radius: 17px 17px 17px 5px;
    padding: 8px 11px 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
    overflow-wrap: anywhere;
  }
  .msg.mine .bubble {
    background: linear-gradient(135deg, #4f46e5, #6d4ae0);
    border-radius: 17px 17px 5px 17px;
  }
  .sender { font-size: 11.5px; font-weight: 700; margin-bottom: 2px; }
  .text { font-size: 14.5px; line-height: 1.42; white-space: pre-wrap; }
  .meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 2px; font-size: 10.5px; color: rgba(236, 236, 243, .62); }
  .msg.mine .meta { color: rgba(255, 255, 255, .72); }
  .ticks { font-size: 11px; letter-spacing: -2px; }
  .ticks.read { color: var(--tick); }
  .media-note { font-size: 13.5px; opacity: .9; }
  .msg-image {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    background: rgba(0, 0, 0, .18);
  }
  .msg-audio { width: 250px; max-width: 100%; height: 38px; }
  .msg-video {
    display: block; width: 100%; max-width: 320px; max-height: 360px;
    border-radius: 12px; background: #000;
  }
  .view-once { font-size: 10.5px; opacity: .78; margin-bottom: 4px; letter-spacing: .2px; }
  .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
  .reaction {
    display: inline-flex; align-items: center; gap: 3px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface-2); color: var(--ink);
    padding: 2px 7px; font-size: 11.5px; line-height: 1.4;
  }
  .reaction.mine { border-color: rgba(99, 102, 241, .65); background: rgba(99, 102, 241, .18); }
  .reaction.add {
    color: var(--muted); font-weight: 700; opacity: 0;
    width: 0; padding: 0; border: 0; margin: 0; overflow: hidden;
    transition: opacity .12s;
  }
  .msg:hover .reaction.add, .reactions:hover .reaction.add {
    opacity: 1; width: auto; padding: 2px 7px; border: 1px solid var(--line);
  }
  @media (hover: none) {
    .reaction.add { display: none; }
  }
  .poll { min-width: 220px; max-width: 290px; }
  .poll-question { font-weight: 650; margin-bottom: 7px; }
  .poll-option {
    position: relative; display: flex; align-items: center; gap: 6px;
    padding: 8px 9px; margin: 3px 0; border-radius: 10px;
    background: var(--surface-2); border: 1px solid transparent;
    cursor: pointer; overflow: hidden;
  }
  .poll-option.mine { border-color: rgba(99, 102, 241, .6); }
  .poll-option .bar {
    position: absolute; inset: 0 auto 0 0; height: 100%;
    background: rgba(99, 102, 241, .2);
  }
  .poll-option .txt { position: relative; flex: 1; font-size: 13px; }
  .poll-option .num { position: relative; font-size: 11px; color: var(--muted); }
  .poll-total { font-size: 11px; color: var(--muted); margin-top: 4px; }
  .edited { opacity: .6; font-size: 10px; margin-right: 4px; }
  .file-download { color: inherit; font-weight: 600; text-decoration: underline; }
  .location-card {
    display: flex; align-items: center; gap: 9px;
    color: inherit; text-decoration: none;
    background: rgba(255, 255, 255, .10);
    border-radius: 12px; padding: 9px 11px;
    min-width: 180px;
  }
  .location-card .loc-icon { font-size: 22px; }
  .location-card small { opacity: .75; }
  .composer {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .composer textarea {
    flex: 1; resize: none; min-height: 46px; max-height: 150px;
    padding: 12px 15px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 22px; outline: none; line-height: 1.35;
  }
  .composer textarea:focus { border-color: rgba(99, 102, 241, .65); }
  .composer #attach-btn { margin-bottom: 4px; flex: none; }
  .send-btn {
    width: 46px; height: 46px; flex: none;
    border: 0; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    color: #fff;
  }
  .send-btn:disabled { opacity: .5; cursor: default; }
  .send-btn svg { width: 21px; height: 21px; }

  .empty-conv {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: var(--muted); text-align: center; padding: 40px;
  }
  .empty-conv .big { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; background: rgba(99, 102, 241, .12); color: var(--indigo); }
  .empty-conv .big svg { width: 34px; height: 34px; }
  .empty-conv h3 { margin: 8px 0 0; color: var(--ink); font-size: 17px; }
  .empty-conv p { margin: 0; font-size: 13.5px; max-width: 320px; }
  .empty-chats { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

  .banner {
    position: absolute; top: 82px; left: 50%; transform: translateX(-50%);
    background: rgba(248, 113, 113, .16); border: 1px solid rgba(248, 113, 113, .4);
    color: #fca5a5; padding: 7px 14px; border-radius: 999px; font-size: 12px; z-index: 5;
    backdrop-filter: blur(10px);
  }

  /* ---------- Yeni sohbet ---------- */
  dialog {
    border: 1px solid var(--line); border-radius: 22px; padding: 0;
    background: var(--surface); color: var(--ink);
    width: min(440px, calc(100vw - 32px));
    box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  }
  dialog::backdrop { background: rgba(5, 5, 10, .65); backdrop-filter: blur(3px); }
  .dialog-head { display: flex; align-items: center; padding: 18px 20px 10px; }
  .dialog-head h3 { margin: 0; font-size: 17px; }
  .dialog-head .icon-btn { margin-left: auto; }
  .dialog-body { padding: 0 20px 20px; }
  .search-input {
    width: 100%; padding: 12px 14px; margin-bottom: 12px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 13px; outline: none;
  }
  .search-input:focus { border-color: var(--indigo); }
  .user-row {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 8px; border-radius: 12px; cursor: pointer;
  }
  .user-row:hover { background: var(--surface-2); }
  .user-row .name { font-weight: 600; font-size: 14px; }
  .user-row .uname { color: var(--muted); font-size: 12px; }
  .search-hit {
    padding: 10px 10px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent;
  }
  .search-hit:hover { background: var(--surface-2); }
  .search-hit .hit-top {
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 11px; color: var(--muted);
  }
  .search-hit .hit-body { margin-top: 3px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .msg.flash .bubble { outline: 2px solid var(--indigo); outline-offset: 2px; }
  .dialog-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }

  .toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--surface-3); border: 1px solid var(--line);
    padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 50;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  }

  @media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; }
    .app.chat-open .sidebar { display: none; }
    .app:not(.chat-open) .conversation { display: none; }
    .back-btn { display: grid; }
    .bubble { max-width: 82%; }
    .messages { padding: 14px 12px 8px; }
    .conv-head { padding: 10px 12px; min-height: 64px; }
    .stories-head .muted { display: none; }
    .stories-card { padding: 14px; }
  }

  /* ---------- Topluluklar ---------- */
  .community-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 6px;
    border-radius: 14px;
  }
  .community-row:hover { background: var(--surface-2); }
  .community-main { flex: 1; min-width: 0; }
  .community-title { font-weight: 600; font-size: 14px; }
  .community-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
  .community-meta { color: var(--indigo); font-size: 11px; margin-top: 3px; }
  .community-join {
    border: 0; border-radius: 12px; padding: 8px 14px; font-size: 12.5px;
    font-weight: 600; background: var(--indigo); color: #fff; flex: none;
  }
  .community-join.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
  .community-code-row { display: flex; gap: 8px; padding: 10px 4px 2px; }
  .community-code-row input {
    flex: 1; padding: 10px 12px; background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 12px; outline: none;
  }
  .community-code-row input:focus { border-color: var(--indigo); }
  .community-code-row button {
    border: 0; border-radius: 12px; padding: 0 14px; background: var(--indigo);
    color: #fff; font-weight: 600;
  }

  
/* ---------- Durumlar ---------- */
  .story-shortcut { flex: 0 0 44px; padding: 0; }
  .stories-sheet {
    position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
    justify-content: center; padding: 18px; background: rgba(5, 5, 10, .66);
    backdrop-filter: blur(6px);
  }
  .stories-card {
    width: min(460px, 100%); max-height: min(82dvh, 760px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
    padding: 16px; box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
  }
  .stories-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px 12px; }
  .stories-head h2 { margin: 0; font-size: 18px; }
  .stories-head .muted { color: var(--muted); font-size: 12px; }
  .stories-head .spacer { flex: 1; }
  .stories-head .icon-btn { margin-left: 0; }
  .story-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 6px;
    border-radius: 14px; cursor: pointer;
  }
  .story-row:hover { background: var(--surface-2); }
  .story-ring {
    width: 56px; height: 56px; flex: none; border-radius: 50%; padding: 3px;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
  }
  .story-ring.viewed { background: var(--line); }
  .story-ring .avatar { width: 100%; height: 100%; flex-basis: auto; font-size: 17px; }
  .story-name { font-weight: 600; font-size: 14px; }
  .story-meta { color: var(--muted); font-size: 12px; }
  .story-me {
    margin-left: auto; font-size: 11px; color: var(--muted);
    border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px;
  }
  .story-viewer { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; color: #fff; }
  .story-top {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .35), transparent);
  }
  .story-top .avatar { width: 38px; height: 38px; flex-basis: 38px; font-size: 13px; }
  .story-top strong { display: block; font-size: 14px; }
  .story-top .icon-btn { margin-left: auto; color: #fff; }
  .story-top .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
  .story-content {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 18px; padding: 20px 26px; text-align: center;
    overflow: hidden;
  }
  .story-content img {
    max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  }
  .story-text {
    margin: 0; font-size: clamp(20px, 5vw, 30px); line-height: 1.3;
    font-weight: 600; text-shadow: 0 2px 24px rgba(0, 0, 0, .25);
  }
  .story-progress { text-align: center; padding: 0 16px 24px; font-size: 12px; opacity: .8; }
  .story-colors { display: flex; gap: 9px; padding: 8px 0 14px; flex-wrap: wrap; }
  .story-color {
    width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  }
  .story-color.selected { border-color: #fff; outline: 2px solid var(--indigo); }
  #story-text { width: 100%; resize: vertical; min-height: 84px; }
  #story-file { width: 100%; padding: 9px; margin-bottom: 4px; }
  .story-hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }

  .link-preview {
    display: flex; flex-direction: column; gap: 0; margin-top: 7px;
    max-width: 320px; border-radius: 12px; overflow: hidden;
    background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
    color: inherit; text-decoration: none;
  }
  .link-preview-image { width: 100%; max-height: 170px; object-fit: cover; display: block; }
  .link-preview-main { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
  .link-preview-site { font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--indigo); }
  .link-preview-title { font-size: 13px; font-weight: 650; color: var(--ink); }
  .link-preview-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
  .msg.mine .link-preview { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); }
  .msg.mine .link-preview-site { color: #fff; opacity: .8; }
  .msg.mine .link-preview-title { color: #fff; }
  .msg.mine .link-preview-desc { color: rgba(255, 255, 255, .78); }

  .poll-meta { font-size: 10.5px; color: var(--muted); margin: -2px 0 6px; text-transform: uppercase; letter-spacing: .25px; }
  .poll-option.correct { border-color: rgba(34, 197, 94, .75); background: rgba(34, 197, 94, .18); }
  .poll-option.closed { cursor: default; }
  .poll.closed { opacity: .92; }
  .poll-explanation { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
  .msg.mine .poll-meta, .msg.mine .poll-explanation { color: rgba(255, 255, 255, .72); }
  .msg.mine .poll-option.correct { background: rgba(34, 197, 94, .28); border-color: rgba(167, 243, 208, .8); }

  .poll-form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
  .poll-form-row .search-input { margin-bottom: 0; }
  .poll-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
  #poll-options { min-height: 90px; }
  #poll-dialog .btn-primary { margin-top: 12px; }

  .option-active { color: var(--indigo) !important; background: rgba(99, 102, 241, .16) !important; }
  .msg-flag { font-size: 10px; }
  .msg-flag.urgent { filter: drop-shadow(0 0 3px rgba(251, 191, 36, .8)); }
  .effect-layer {
    position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden;
  }
  .effect-layer span {
    position: absolute; top: -40px; animation: belgi-fall 2.4s ease-in forwards;
  }
  @keyframes belgi-fall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(320deg); opacity: 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .effect-layer { display: none; }
  }

  .media-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
  .media-filter {
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
    border-radius: 999px; padding: 6px 11px; font-size: 12px; cursor: pointer;
  }
  .media-filter.active { background: rgba(99, 102, 241, .18); color: var(--ink); border-color: rgba(99, 102, 241, .55); }
  .media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .media-tile {
    aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
    background: var(--surface-2); color: var(--muted); cursor: pointer; padding: 4px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  }
  .media-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
  .media-tile-icon { font-size: 22px; }
  .media-tile-name { font-size: 9.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  @media (max-width: 520px) {
    .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }

  #media-dialog { max-height: 88vh; }
  #media-dialog .dialog-body { max-height: 72vh; overflow-y: auto; }

  .saved-list { display: flex; flex-direction: column; gap: 6px; max-height: 65vh; overflow-y: auto; }
  .saved-row {
    display: flex; align-items: flex-start; gap: 8px; padding: 10px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
    cursor: pointer;
  }
  .saved-row:hover { border-color: rgba(99, 102, 241, .5); }
  .saved-main { flex: 1; min-width: 0; }
  .saved-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
  .saved-top b { color: var(--ink); font-size: 12.5px; }
  .saved-body { margin-top: 4px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .saved-remove { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 2px; }
  .saved-remove:hover { color: #f87171; }

  .folder-bar { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; }
  .folder-chip {
    flex: none; display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
    border-radius: 999px; padding: 6px 11px; font-size: 12px; cursor: pointer;
  }
  .folder-chip.active { color: var(--ink); border-color: rgba(99, 102, 241, .55); background: rgba(99, 102, 241, .16); }
  .folder-chip.folder-add { color: var(--muted); font-weight: 700; }
  .folder-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--folder, #6366f1); flex: none; }
  .folder-assign-row { display: flex; align-items: center; gap: 9px; padding: 9px 4px; font-size: 13.5px; }

  .checklist { min-width: 210px; max-width: 300px; }
  .checklist-title { font-weight: 650; margin-bottom: 6px; }
  .checklist-item { display: flex; align-items: flex-start; gap: 7px; padding: 4px 0; font-size: 13px; }
  .checklist-item input { margin-top: 2px; accent-color: var(--indigo); }
  .checklist-item.done span { text-decoration: line-through; opacity: .6; }
  .checklist-meta { margin-top: 5px; font-size: 10.5px; color: var(--muted); }
  .msg.mine .checklist-meta { color: rgba(255, 255, 255, .72); }

  .schedule-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 40vh; overflow-y: auto; }
  .schedule-row {
    display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px;
    border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2);
  }
  .schedule-main { flex: 1; min-width: 0; }
  .schedule-time { font-size: 11px; color: var(--indigo); font-weight: 600; }
  .schedule-text { margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .members-list { display: flex; flex-direction: column; gap: 4px; max-height: 55vh; overflow-y: auto; }
  .member-row { display: flex; align-items: center; gap: 9px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
  .member-main { flex: 1; min-width: 0; }
  .member-name { font-size: 13.5px; font-weight: 600; }
  .member-you { color: var(--muted); font-weight: 400; }
  .member-sub { font-size: 11px; color: var(--muted); }
  .avatar.small { width: 32px; height: 32px; font-size: 12px; }
  .role-badge { font-size: 10px; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
  .role-badge.admin { background: rgba(99, 102, 241, .18); color: var(--indigo); }
  .role-toggle { border: 0; background: transparent; color: var(--indigo); font-size: 11px; cursor: pointer; padding: 4px; }
  .admin-log-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
  .admin-log-row { padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
  .admin-log-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
  .admin-log-top b { color: var(--ink); font-size: 12.5px; }
  .admin-log-detail { margin-top: 3px; font-size: 12.5px; }
  .admin-log-actor { margin-top: 2px; font-size: 10.5px; color: var(--muted); }

  .permissions-title { font-weight: 650; margin-bottom: 8px; }
  .permissions-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
  .permission-row { display: flex; align-items: center; gap: 9px; padding: 7px 2px; font-size: 13px; }
  .permission-row input { accent-color: var(--indigo); }
  .role-toggle + .role-toggle { margin-left: -4px; }

  .folder-chip { cursor: pointer; }
  .folder-menu { margin-left: 2px; padding: 0 2px; color: var(--muted); font-size: 16px; line-height: 1; }
  .folder-menu:hover { color: var(--ink); }
