:root {
    --qegpt-bg: #f8fafc;
    --qegpt-surface: #ffffff;
    --qegpt-sidebar: #0f172a;
    --qegpt-sidebar-hover: #1e293b;
    --qegpt-sidebar-border: #1e293b;
    --qegpt-emerald: #059669;
    --qegpt-emerald-dark: #047857;
    --qegpt-emerald-soft: #ecfdf5;
    --qegpt-text: #0f172a;
    --qegpt-muted: #64748b;
    --qegpt-border: #e2e8f0;
}

html, body {
    height: 100%;
    margin: 0;
    background-color: var(--qegpt-bg);
    color: var(--qegpt-text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    overscroll-behavior-y: contain;
}

.qegpt-workspace {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Sol Sohbet Menusu */
.qegpt-sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--qegpt-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--qegpt-sidebar-border);
    z-index: 30;
}

.qegpt-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--qegpt-sidebar-border);
}

.qegpt-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.qegpt-brand-title {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.03em;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qegpt-brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.qegpt-brand-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.qegpt-new-chat-btn {
    width: 100%;
    border: 1px solid rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.14);
    color: #ecfdf5;
    font-weight: 600;
    padding: 0.55rem 0.85rem;
    border-radius: 0.6rem;
    transition: background-color 0.15s ease;
}

.qegpt-new-chat-btn:hover {
    background: rgba(16, 185, 129, 0.25);
    color: #ffffff;
}

.qegpt-filters {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--qegpt-sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.qegpt-filter-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 0.2rem;
    display: block;
}

.qegpt-dark-select {
    width: 100%;
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.84rem;
}

.qegpt-dark-select:focus {
    outline: 2px solid #10b981;
    border-color: #10b981;
}

.qegpt-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
}

.qegpt-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.55rem;
    cursor: pointer;
    color: #cbd5e1;
    font-size: 0.86rem;
    margin-bottom: 0.25rem;
    transition: background-color 0.12s ease;
}

.qegpt-session-item:hover {
    background: var(--qegpt-sidebar-hover);
    color: #ffffff;
}

.qegpt-session-item.active {
    background: rgba(16, 185, 129, 0.18);
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.qegpt-session-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.qegpt-session-delete {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.78rem;
    padding: 0.1rem 0.35rem;
    border-radius: 0.3rem;
}

.qegpt-session-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.qegpt-sidebar-account {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--qegpt-sidebar-border);
    background: #0f172a;
}

.qegpt-sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--qegpt-sidebar-border);
    font-size: 0.76rem;
    color: #94a3b8;
    background: #0b1220;
}

.qegpt-progress-track {
    height: 6px;
    border-radius: 999px;
    background: #1e293b;
    overflow: hidden;
    margin: 0.35rem 0;
}

.qegpt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #059669, #34d399);
}

/* Orta Sohbet Alani */
.qegpt-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--qegpt-bg);
}

.qegpt-topbar {
    height: 58px;
    background: var(--qegpt-surface);
    border-bottom: 1px solid var(--qegpt-border);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.qegpt-topbar-pill {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qegpt-emerald-dark);
    background: var(--qegpt-emerald-soft);
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    padding: 0.22rem 0.7rem;
    white-space: nowrap;
}

.qegpt-messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.qegpt-chat-container {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Karsilama Ekrani */
.qegpt-welcome {
    max-width: 760px;
    margin: 2.5rem auto;
    text-align: center;
}

.qegpt-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #059669, #0f766e);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 24px rgba(5, 150, 105, 0.22);
}

.qegpt-prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    margin-top: 1.5rem;
    text-align: left;
}

.qegpt-prompt-card {
    background: var(--qegpt-surface);
    border: 1px solid var(--qegpt-border);
    border-radius: 0.85rem;
    padding: 0.95rem 1rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.qegpt-prompt-card:hover {
    border-color: var(--qegpt-emerald);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
}

/* Mesaj Balonlari */
.qegpt-msg-row {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.qegpt-msg-row.user {
    justify-content: flex-end;
}

.qegpt-user-bubble {
    background: #0f766e;
    color: #ffffff;
    padding: 0.85rem 1.15rem;
    border-radius: 1.1rem 1.1rem 0.25rem 1.1rem;
    max-width: 78%;
    line-height: 1.55;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.16);
}

.qegpt-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 0.65rem;
    background: #059669;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
}

.qegpt-assistant-card {
    background: var(--qegpt-surface);
    border: 1px solid var(--qegpt-border);
    border-radius: 1rem;
    padding: 1.1rem 1.25rem;
    flex: 1;
    min-width: 0;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.qegpt-msg-body {
    font-size: 0.96rem;
    line-height: 1.65;
    color: #1e293b;
}

.qegpt-msg-body p {
    margin-bottom: 0.75rem;
}

.qegpt-msg-body p:last-child {
    margin-bottom: 0;
}

.qegpt-msg-body ul {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.qegpt-callout {
    border-radius: 0.65rem;
    padding: 0.65rem 0.85rem;
    margin-top: 0.65rem;
    font-size: 0.86rem;
    line-height: 1.5;
}

.qegpt-callout.warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.qegpt-callout.preprint {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}

.qegpt-citation-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.05rem 0.42rem;
    margin: 0 0.12rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
    cursor: pointer;
    vertical-align: baseline;
}

.qegpt-citation-pill:hover {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
}

.qegpt-citation-pill.preprint {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

/* Kaynak Kartlari Seridi */
.qegpt-sources-strip {
    margin-top: 0.95rem;
    padding-top: 0.85rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.qegpt-source-chip {
    background: #f8fafc;
    border: 1px solid var(--qegpt-border);
    border-radius: 0.65rem;
    padding: 0.45rem 0.7rem;
    text-align: left;
    max-width: 260px;
    cursor: pointer;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.qegpt-source-chip:hover {
    border-color: var(--qegpt-emerald);
    background: #ecfdf5;
}

.qegpt-source-chip.active {
    border-color: var(--qegpt-emerald);
    background: #ecfdf5;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.16);
}

.qegpt-tier-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    display: inline-block;
}

.tier-official {
    background: #d1fae5;
    color: #065f46;
}

.tier-high-impact {
    background: #dbeafe;
    color: #1e40af;
}

.tier-peer {
    background: #e0e7ff;
    color: #3730a3;
}

.tier-taxonomy {
    background: #cffafe;
    color: #155e75;
}

.tier-preprint {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fdba74;
}

.tier-unknown {
    background: #f1f5f9;
    color: #475569;
}

/* Mesaj Giris Kutusu */
.qegpt-composer-wrap {
    padding: 0.75rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, var(--qegpt-bg) 24%);
}

.qegpt-quota-banner {
    max-width: 860px;
    margin: 0 auto 0.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.75rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.qegpt-touch-btn {
    min-height: 40px;
}

.qegpt-touch-input {
    min-height: 44px;
    font-size: 16px;
}

.qegpt-photo-preview-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--qegpt-border);
}

.qegpt-photo-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
}

.qegpt-user-photo {
    display: block;
    max-width: 240px;
    max-height: 200px;
    width: 100%;
    object-fit: cover;
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Kimlik Dogrulama Modali */
.qegpt-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 60;
}

.qegpt-modal-card {
    width: 100%;
    max-width: 470px;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 1.15rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    border: 1px solid var(--qegpt-border);
}

.qegpt-modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--qegpt-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.qegpt-modal-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.65rem 1.25rem 0;
    background: #f8fafc;
    border-bottom: 1px solid var(--qegpt-border);
}

.qegpt-modal-tab {
    border: none;
    background: transparent;
    padding: 0.6rem 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--qegpt-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.qegpt-modal-tab.active {
    color: var(--qegpt-emerald-dark);
    border-bottom-color: var(--qegpt-emerald);
}

.qegpt-modal-body {
    padding: 1.15rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
}

.qegpt-composer-box {
    max-width: 860px;
    margin: 0 auto;
    background: var(--qegpt-surface);
    border: 1px solid #cbd5e1;
    border-radius: 1rem;
    padding: 0.65rem 0.85rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.qegpt-composer-textarea {
    width: 100%;
    border: none;
    resize: none;
    background: transparent;
    color: var(--qegpt-text);
    font-size: 0.96rem;
    line-height: 1.5;
    max-height: 180px;
    outline: none;
}

/* Sag Kaynakca Cekmecesi */
.qegpt-drawer {
    width: 360px;
    min-width: 360px;
    background: var(--qegpt-surface);
    border-left: 1px solid var(--qegpt-border);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.qegpt-drawer-header {
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--qegpt-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.qegpt-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.1rem;
}

.qegpt-chunk-box {
    background: #f8fafc;
    border: 1px solid var(--qegpt-border);
    border-radius: 0.7rem;
    padding: 0.85rem;
    font-size: 0.86rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #1e293b;
}

.qegpt-mobile-backdrop {
    display: none;
}

@media (max-width: 1199px) {
    .qegpt-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .qegpt-sidebar.open {
        transform: translateX(0);
    }

    .qegpt-drawer {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: min(92vw, 380px);
        min-width: 0;
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }

    .qegpt-drawer.open {
        transform: translateX(0);
    }

    .qegpt-mobile-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 25;
    }
}

@media (max-width: 767px) {
    .qegpt-topbar {
        height: auto;
        min-height: 56px;
        padding: calc(0.4rem + env(safe-area-inset-top)) 0.85rem 0.4rem;
    }

    .qegpt-welcome {
        margin: 1.25rem auto;
    }

    .qegpt-prompt-grid {
        grid-template-columns: 1fr;
    }

    .qegpt-user-bubble {
        max-width: 90%;
    }

    .qegpt-composer-wrap {
        padding: 0.6rem 0.75rem calc(0.85rem + env(safe-area-inset-bottom));
    }

    .qegpt-composer-textarea {
        font-size: 16px;
    }

    .qegpt-drawer {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 78dvh;
        max-height: 78dvh;
        border-left: none;
        border-top: 1px solid var(--qegpt-border);
        border-radius: 1.1rem 1.1rem 0 0;
        transform: translateY(100%);
    }

    .qegpt-drawer.open {
        transform: translateY(0);
    }
}

/* Yerel Android / iOS Uygulama Ici OTA Guncelleme Karti */
.qegpt-upd-overlay {
    position: fixed;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 160;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.qegpt-upd-card {
    pointer-events: auto;
    width: 100%;
    max-width: 440px;
    border-radius: 18px;
    padding: 15px 16px;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96) 0%, rgba(6, 78, 59, 0.95) 100%);
    border: 1px solid rgba(52, 211, 153, 0.45);
    box-shadow: 0 20px 44px rgba(2, 12, 27, 0.52);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.qegpt-upd-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(52, 211, 153, 0.45);
    color: #6ee7b7;
}

.qegpt-upd-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.qegpt-upd-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #10b981 0%, #0ea5e9 100%);
    transition: width 0.2s ease;
}

.qegpt-upd-status {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(14, 165, 233, 0.16);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #e0f2fe;
    font-size: 0.76rem;
    font-weight: 600;
}

.qegpt-upd-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.qegpt-upd-btn-primary {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.qegpt-upd-btn-primary:disabled {
    opacity: 0.65;
}

.qegpt-upd-btn-later {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

