body {
    font-family: 'Sofia Sans', 'Roboto', sans-serif;
    background-color: #faf9f5;
    color: #141413;
}

.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 0 !important;
    overflow: hidden;
    border-right-width: 0;
}

.panel-anim {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* AI Gözcü Kompakt Durum Butonu (header) */
.ai-guard-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.ai-guard-btn.clean {
    color: #16a34a;
}

.ai-guard-btn.clean:hover {
    background: rgba(22, 163, 74, 0.12);
}

.ai-guard-btn.alert {
    color: #dc2626;
    animation: aiGuardBlink 1s ease-in-out infinite;
}

.ai-guard-btn.alert:hover {
    background: rgba(220, 38, 38, 0.12);
    animation-play-state: paused;
}

.ai-guard-count {
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    font-family: 'Sofia Sans', sans-serif;
}

@keyframes aiGuardBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}

.dark .ai-guard-btn.clean {
    color: #4ade80;
}

.dark .ai-guard-btn.alert {
    color: #f87171;
}

/* AI Gözcü Highlighter Stili */
.ai-marker-highlight {
    background-color: rgba(204, 120, 92, 0.15) !important;
    border-bottom: 2px dashed #cc785c !important;
    color: #cc785c !important;
    padding: 0 1px;
}

/* Dosya Ağacı Stilleri */
.tree-item {
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.tree-item:hover {
    background-color: #f5f0e8;
}

.tree-item.active {
    background-color: #efe9de;
    border-left-color: #cc785c;
}

.tree-folder {
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.tree-folder:hover {
    background-color: #f5f0e8;
}

.tree-folder.active {
    background-color: #efe9de;
    border-left-color: #e8a55a;
}

/* Dark Mode Override */
.dark body {
    background-color: #181715;
    color: #a09d96;
}

.dark .sidebar {
    background-color: #181715;
    border-color: #252320;
}

.dark .tree-item:hover {
    background-color: #252320;
}

.dark .tree-item.active {
    background-color: #252320;
    border-left-color: #cc785c;
}

.dark .tree-folder:hover {
    background-color: #252320;
}

.dark .tree-folder.active {
    background-color: #252320;
    border-left-color: #e8a55a;
}

.dark textarea,
.dark [contenteditable="true"] {
    color: #a09d96 !important;
}

.dark .prose {
    color: #a09d96 !important;
}

.dark .prose strong,
.dark .prose h1,
.dark .prose h2,
.dark .prose h3 {
    color: #f5f0e8 !important;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #faf9f5;
}

::-webkit-scrollbar-thumb {
    background: #e6dfd8;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #dcd5ce;
}

.dark ::-webkit-scrollbar-track {
    background: #181715;
}

.dark ::-webkit-scrollbar-thumb {
    background: #252320;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #2d2b28;
}

/* Dropdown etkileşimi: hover yalnızca gerçek imleçli (mouse) cihazlarda çalışır */
@media (hover: hover) and (pointer: fine) {
    .dropdown-container:hover .dropdown-menu {
        display: block;
    }
}

/* Dokunmatik ve tıklama ile açma (JS, .open sınıfını yönetir) */
.dropdown-container.open .dropdown-menu {
    display: block;
}

/* Mobil tarayıcı adres çubuğu (100vh) sorunu düzeltmesi */
@supports (height: 100dvh) {
    body.flex {
        height: 100dvh;
    }
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e6dfd8;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    min-width: 180px;
    overflow: hidden;
}

.dark .context-menu {
    background: #252320;
    border-color: #2d2b28;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.context-menu-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #3d3d3a;
    transition: background 0.2s;
}

.dark .context-menu-item {
    color: #faf9f5;
}

.context-menu-item:hover {
    background-color: #f5f0e8;
}

.dark .context-menu-item:hover {
    background-color: #2d2b28;
}

/* ToC Panel */
#tocPanel {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 200px;
    max-height: 70vh;
    background: #f5f0e8;
    backdrop-filter: blur(8px);
    border: 1px solid #e6dfd8;
    border-radius: 12px;
    padding: 12px;
    font-size: 11px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    z-index: 5;
    transition: all 0.3s ease;
    transform: translateX(250px);
    opacity: 0;
    pointer-events: none;
}

#tocPanel.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.dark #tocPanel {
    background: #3d3d3a;
    border-color: #2d2b28;
}

.toc-item {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    color: #6c6a64;
    transition: all 0.2s;
}

.dark .toc-item {
    color: #a09d96;
}

.toc-item:hover {
    background: #f5f0e8;
    color: #cc785c;
}

.dark .toc-item:hover {
    background: #2d2b28;
    color: #cc785c;
}

/* Modern Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #faf9f5;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    padding: 32px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.15);
    transform: translateY(10px);
    transition: transform 0.3s ease;
    border: 1px solid #e6dfd8;
}

.dark .modal-content {
    background: #181715;
    border-color: #252320;
    color: #faf9f5;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Find & Replace Panel */
.find-replace-panel {
    position: absolute;
    top: 50px;
    right: 20px;
    width: 300px;
    background: #faf9f5;
    border: 1px solid #e6dfd8;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: none;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}

.dark .find-replace-panel {
    background: #252320;
    border-color: #2d2b28;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.find-replace-panel.active {
    display: flex;
}

.find-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid #e6dfd8;
    border-radius: 6px;
    padding: 4px 8px;
}

.dark .find-input-group {
    background: #181715;
    border-color: #2d2b28;
}

.find-input-group input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 12px;
    flex: 1;
    color: inherit;
}

.find-btn {
    padding: 4px;
    border-radius: 4px;
    color: #6c6a64;
    transition: all 0.2s;
}

.find-btn:hover {
    background: #f5f0e8;
    color: #cc785c;
}

.dark .find-btn:hover {
    background: #2d2b28;
}

.find-count {
    font-size: 10px;
    color: #8e8b82;
    min-width: 40px;
    text-align: center;
}

/* Search Highlight */
.search-highlight {
    background-color: #ffeb3b !important;
    color: #000 !important;
    border-radius: 2px;
    box-shadow: 0 0 0 1px #fbc02d;
}

.search-highlight-active {
    background-color: #ff9800 !important;
    color: #fff !important;
    box-shadow: 0 0 0 2px #ef6c00;
}

.dark .search-highlight {
    background-color: #fbc02d !important;
    color: #000 !important;
}

.dark .search-highlight-active {
    background-color: #cc785c !important;
    color: #fff !important;
}

/* ============================================================================
   AISTACKEDIT - Premium Ek Özellikler Stilleri (Tabs, Snapshots & Mobile Switcher)
   ============================================================================ */

/* 1. Sürüm Geçmişi (Snapshots) Paneli */
#historyPanel {
    position: absolute;
    right: -280px;
    top: 0;
    width: 270px;
    height: 100%;
    background: #f5f0e8;
    border-left: 1px solid #e6dfd8;
    padding: 16px;
    z-index: 40;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.03);
}

#historyPanel:not(.hidden) {
    right: 0 !important;
}

.dark #historyPanel {
    background: #1e1d1a;
    border-color: #2a2824;
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.25);
}

/* 2. Sekmeler (Tabs Bar) Animasyonu ve Özelleştirmeleri */
#tabsBar::-webkit-scrollbar {
    display: none; /* Scrollbar gizle */
}

/* 3. Mobil Switcher Butonu & Responsive Altyapı */
#mobileStickySwitcher {
    display: none;
    box-shadow: 0 12px 30px rgba(204, 120, 92, 0.3);
}

/* Yalnızca mobilde görünen header elemanları (⋯ Araçlar menüsü vb.) */
.mobile-only {
    display: none;
}

/* Mobil Drawer Karartma Katmanı */
#sidebarBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.45);
    backdrop-filter: blur(2px);
    z-index: 35;
}

/* Ara kırılım (tablet 768-950px): header'ın sığması için ikincil kimlik öğeleri gizlenir */
@media (min-width: 768px) and (max-width: 950px) {

    .logo-text,
    #activePathDisplay {
        display: none !important;
    }

    #currentFileName {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    header {
        padding-left: 8px;
        padding-right: 8px;
    }
}

@media (max-width: 767px) {

    /* -- Yüzen panel değiştirici (FAB) -- */
    #mobileStickySwitcher {
        display: flex;
    }

    /* -- Mobil ⋯ menüsü görünür -- */
    .mobile-only {
        display: flex;
    }

    /* -- Tek panel düzeni: aktif panel tam genişlik kaplar -- */
    #leftPanel,
    #rightPanel {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        border-right: 0;
    }

    /* -- Header sadeleştirme: ikincil araçlar ⋯ menüsünde -- */
    #headerToolsGroup,
    #viewModeGroup,
    .logo-text,
    #currentFileName {
        display: none !important;
    }

    header {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* -- Sidebar → soldan kayan çekmece (drawer) -- */
    #sidebar,
    #sidebar.collapsed {
        position: fixed;
        top: 48px;
        bottom: 0;
        left: 0;
        width: min(80vw, 300px) !important;
        border-right-width: 1px;
        transform: translateX(-105%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 40;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.18);
    }

    #sidebar.mobile-open {
        transform: translateX(0);
    }

    #sidebarBackdrop.active {
        display: block;
    }

    /* -- Panel üst çubuğu araçları yatay kaydırılabilir -- */
    #editorToolbar,
    #previewToolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        max-width: 62vw;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #editorToolbar::-webkit-scrollbar,
    #previewToolbar::-webkit-scrollbar {
        display: none;
    }

    /* -- Dokunma hedeflerini büyüt -- */
    #editorToolbar button,
    #previewToolbar button {
        padding: 8px 10px;
        flex-shrink: 0;
    }

    .tree-item,
    .tree-folder {
        min-height: 42px;
    }

    /* -- ToC ve Bul & Değiştir panelleri ekrana sığsın -- */
    #tocPanel {
        right: 12px;
        width: min(240px, calc(100vw - 24px));
    }

    .find-replace-panel {
        left: 12px;
        right: 12px;
        width: auto;
    }

    /* -- Mobil ⋯ menüsü uzunsa kendi içinde kaydırılsın -- */
    #mobileToolsMenu > div {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* -- Klavye kısayolları penceresi: tuş kutuları -- */
.shortcut-key {
    font-family: 'Sofia Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.02em;
    color: #ffffff;
    background-color: #a9583e;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* -- Logo yazısı -- */
.logo-text {
    font-size: 1.1rem;
}
