:root {
    --blue: #3875d7;
    --blue-d: #2a63b8;
    --focus: rgba(56, 117, 215, .4);
    --green: #34c759;
    --ink: #1d1d1f;
    --muted: #6e6e73;
    --line: #c4c4c4;
    --line-2: #e2e2e2;
    --panel: #f4f4f4;
    --them: #e9e9eb;
    --font: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--ink);
    background: repeating-linear-gradient(180deg, #ededed 0 2px, #e6e6e6 2px 4px);
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Pencere ---------- */
.win {
    background: #fff;
    border: 1px solid #a8a8a8;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    overflow: hidden;
}
.win-title {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 .8rem;
    background: linear-gradient(180deg, #f3f3f3 0%, #dcdcdc 100%);
    border-bottom: 1px solid #a8a8a8;
    color: #333;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
.logo { font-weight: bold; font-size: 13px; }
.logo b { color: var(--blue); }

/* ---------- Eylem satırı (buton yerine) ---------- */
.send-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .85rem 0;
    background: none;
    border: 0;
    border-top: 1px solid var(--line-2);
    border-radius: 0;
    color: var(--blue);
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.send-btn::after { content: "→"; transition: transform .2s ease; }
.send-btn:hover,
.send-btn:focus-visible { outline: none; background: var(--blue); color: #fff; }
.send-btn:hover::after,
.send-btn:focus-visible::after { transform: translateX(4px); }
.send-btn:active { background: var(--blue-d); }

/* ---------- Giriş / kayıt ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth { width: 100%; max-width: 380px; }
.auth-body { padding: 1.4rem 1.5rem 0; }
.auth-body h1 { font-size: 18px; font-weight: bold; margin-bottom: .25rem; }
.auth-body h1 b { color: var(--blue); }
.lead { color: var(--muted); font-size: 12px; margin-bottom: 1.1rem; }
.auth .send-btn,
.btn-block {
    margin: 1.2rem -1.5rem 0;
    width: calc(100% + 3rem);
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 4px; }
.field input {
    width: 100%;
    padding: .35rem .5rem;
    border: 1px solid #9c9c9c;
    border-radius: 3px;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
.handle {
    display: flex;
    align-items: center;
    border: 1px solid #9c9c9c;
    border-radius: 3px;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
}
.handle span { padding-left: .5rem; color: var(--muted); }
.handle input { border: 0; box-shadow: none; padding-left: .15rem; }
.handle input:focus { box-shadow: none; }
.handle:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
.help { font-size: 11px; color: var(--muted); margin-top: 3px; }
.err, .errors { color: #c4281b; font-size: 12px; margin-top: 3px; }
.errors { margin-bottom: .8rem; }

/* ================= UYGULAMA ================= */
.desk { height: 100vh; height: 100dvh; padding: 24px; display: flex; justify-content: center; }
.app-win { display: flex; width: 100%; max-width: 1100px; height: 100%; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-pane { width: 330px; flex-shrink: 0; border-right: 1px solid var(--line); }
.chat-pane { flex: 1; background: #fff; }

/* Üst çubuk */
.navbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 44px;
    padding: 0 .75rem;
    background: linear-gradient(180deg, #f3f3f3, #dcdcdc);
    border-bottom: 1px solid #a8a8a8;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
    flex-shrink: 0;
}
.nav-side { display: flex; align-items: center; min-width: 0; }
.nav-side.right { justify-content: flex-end; }
.nav-title { text-align: center; min-width: 0; }
.navbar .logo { font-size: 15px; }
.nav-link {
    background: none;
    border: 0;
    color: var(--blue);
    font-size: 14px;
    padding: .4rem .2rem;
    text-shadow: none;
}
.nav-link:hover { text-decoration: underline; }
.nav-link:disabled { color: #a9bcd9; cursor: default; text-decoration: none; }
.back { display: none; }
.chat-name { font-weight: bold; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.chat-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Arama */
.searchbar { padding: .5rem .6rem; background: var(--panel); border-bottom: 1px solid var(--line-2); }
.searchbar input {
    width: 100%;
    padding: .4rem .9rem;
    border: 1px solid #c9c9c9;
    border-radius: 999px;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.searchbar input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }

/* Liste */
.list-scroll { flex: 1; overflow-y: auto; background: #fff; }
.section-head {
    padding: .35rem .9rem;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--panel);
    border-bottom: 1px solid var(--line-2);
}
.me-row, .row {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    min-height: 62px;
    padding: .55rem .9rem;
    border: 0;
    border-bottom: 1px solid var(--line-2);
    background: #fff;
    text-align: left;
    color: inherit;
}
.row { transition: background .12s, color .12s; }
.row:hover, .row.active { background: var(--blue); color: #fff; }
.row:hover .row-sub, .row.active .row-sub,
.row:hover .row-time, .row.active .row-time,
.row:hover .chev, .row.active .chev,
.row:hover .handle-sm, .row.active .handle-sm { color: rgba(255, 255, 255, .85); }
.row:hover .badge, .row.active .badge { background: #fff; color: var(--blue); }

.avatar {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #8e9aaf;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
}
.dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #c7c7cc;
    border: 2px solid #fff;
}
.dot.on { background: var(--green); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: bold; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handle-sm { font-weight: normal; font-size: 12px; color: var(--muted); }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.is-typing { color: var(--blue); font-style: italic; }
.row:hover .row-sub.is-typing, .row.active .row-sub.is-typing { color: #fff; }
.row-side { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.row-time { font-size: 12px; color: var(--muted); }
.badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--blue);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chev { color: #c7c7cc; font-size: 20px; line-height: 1; }
.status-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    padding: 1px 3px;
    margin-left: -3px;
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}
.status-input:hover { border-color: var(--line-2); }
.status-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); font-style: normal; color: var(--ink); background: #fff; }
.empty-row { padding: 1.2rem .9rem; color: var(--muted); font-size: 13px; text-align: center; }

/* Sohbet */
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; color: var(--muted); }
.logo.big { font-size: 26px; color: var(--ink); }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.day-sep { align-self: center; margin: .7rem 0 .3rem; font-size: 11px; font-weight: bold; color: var(--muted); }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.bubble {
    max-width: 72%;
    padding: .5rem .8rem .4rem;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.msg.theirs .bubble { background: var(--them); border-bottom-left-radius: 6px; }
.msg.mine .bubble {
    color: #fff;
    background: linear-gradient(180deg, #5c9cf1 0%, #3875d7 100%);
    border-bottom-right-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.meta { display: inline-flex; gap: 3px; float: right; margin: 7px 0 0 10px; font-size: 10px; opacity: .65; }
.ticks.read { opacity: 1; font-weight: bold; }
.typing { padding: 0 1rem .5rem; font-size: 12px; color: var(--muted); font-style: italic; }

.composer {
    display: flex;
    align-items: flex-end;
    gap: .6rem;
    padding: .55rem .75rem;
    border-top: 1px solid var(--line);
    background: var(--panel);
    flex-shrink: 0;
}
.composer textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    padding: .45rem .9rem;
    border: 1px solid #c9c9c9;
    border-radius: 18px;
    background: #fff;
    font-size: 15px;
    line-height: 1.35;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.composer textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
.nav-link.send { font-weight: bold; font-size: 15px; padding: .45rem .2rem; }

.conn {
    position: fixed;
    top: 0; left: 0; right: 0;
    padding: 6px;
    text-align: center;
    background: #d64545;
    color: #fff;
    font-size: 12px;
    z-index: 10;
}

/* ---------- Telefon: tek ekran ---------- */
@media (max-width: 700px) {
    body { font-size: 14px; }
    .field input { font-size: 16px; }
    .desk { padding: 0; }
    .app-win { border: 0; border-radius: 0; box-shadow: none; max-width: none; }
    .list-pane { width: 100%; border-right: 0; }
    .chat-pane { display: none; }
    body.in-chat .list-pane { display: none; }
    body.in-chat .chat-pane { display: flex; animation: slideIn .22s ease; }
    .back { display: inline-block; }
    .bubble { max-width: 82%; }
    .navbar { padding-top: env(safe-area-inset-top); }
    .composer { padding-bottom: calc(.55rem + env(safe-area-inset-bottom)); }
    .composer textarea, .searchbar input, .status-input { font-size: 16px; }
}
@keyframes slideIn { from { transform: translateX(30%); opacity: 0; } to { transform: none; opacity: 1; } }