/* Шрифты */
@font-face {
    font-family: 'Manrope';
    src: url('/manrope/manrope-variable.ttf') format('truetype');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono/JetBrainsMono-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

/* Alpine.js: скрыть элементы до инициализации */
[x-cloak] {
    display: none !important;
}

/* Базовые стили */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0d1117;
    color: #e6edf3;
}

code, pre, .monaco-editor {
    font-family: 'JetBrains Mono', monospace !important;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #161b22;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    /* CSS Custom Properties for panel widths */
    --panel-files: 20%;
    --panel-editor: 40%;
    --panel-chat: 40%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    min-height: 48px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

/* Бургер-меню: скрыто на десктопе, показывается на мобильных */
.mobile-burger,
.mobile-back-btn,
.mobile-project-name {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-burger,
    .mobile-back-btn {
        display: flex !important;
    }

    .mobile-project-name {
        display: flex !important;
        align-items: center;
        gap: 4px;
        font-size: 13px;
        color: #9ca3af;
        max-width: 120px;
        overflow: hidden;
    }

    .mobile-project-name span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 48px);
}

/* Сайдбар - файлы */
.sidebar-files {
    width: var(--panel-files);
    min-width: 150px;
    max-width: 50%;
    background: #0d1117;
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Дерево файлов */
.file-tree {
    font-size: 13px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.1s;
}

.file-item:hover {
    background: #161b22;
}

.file-item.active {
    background: #1f6feb33;
}

.file-item .icon {
    margin-right: 8px;
    font-size: 16px;
    color: #8b949e;
}

.file-item.folder .icon {
    color: #f0c674;
}

.file-item.file .icon {
    color: #7ee787;
}

.file-item .name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .indent {
    width: 16px;
    flex-shrink: 0;
}

/* Индикатор истории версий */
.file-item .history-badge {
    background: #6366f1;
    color: white;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 6px;
    min-width: 16px;
    text-align: center;
}

.file-item.has-history .name {
    color: #a5b4fc;
}

/* Центральная панель - редактор */
.editor-panel {
    width: var(--panel-editor);
    min-width: 200px;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.editor-tabs {
    display: flex;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    overflow-x: auto;
    flex-shrink: 0;
}

.editor-tab {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
    border-right: 1px solid #30363d;
    cursor: pointer;
    white-space: nowrap;
}

.editor-tab:hover {
    background: #1c2128;
}

.editor-tab.active {
    background: #0d1117;
    border-bottom: 2px solid #1f6feb;
}

.editor-tab .close {
    margin-left: 8px;
    opacity: 0.5;
    font-size: 14px;
}

.editor-tab .close:hover {
    opacity: 1;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#monaco-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Превью markdown */
.markdown-preview {
    padding: 24px 32px;
    overflow-y: auto;
    line-height: 1.6;
}

.markdown-preview h1 { font-size: 2em; border-bottom: 1px solid #30363d; padding-bottom: 0.3em; }
.markdown-preview h2 { font-size: 1.5em; border-bottom: 1px solid #30363d; padding-bottom: 0.3em; }
.markdown-preview h3 { font-size: 1.25em; }
.markdown-preview code { background: #161b22; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.markdown-preview pre { background: #161b22; padding: 16px; border-radius: 8px; overflow-x: auto; }
.markdown-preview pre code { background: none; padding: 0; }
.markdown-preview blockquote { border-left: 4px solid #30363d; padding-left: 16px; color: #8b949e; margin-left: 0; }
.markdown-preview a { color: #58a6ff; }
.markdown-preview table { border-collapse: collapse; width: 100%; }
.markdown-preview th, .markdown-preview td { border: 1px solid #30363d; padding: 8px 12px; }
.markdown-preview th { background: #161b22; }

/* Сайдбар - чат */
.sidebar-chat {
    width: var(--panel-chat);
    min-width: 250px;
    max-width: 60%;
    background: #0d1117;
    border-left: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 8px 12px;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0; /* Позволяет flex-детям сжиматься */
}

.chat-header > div:first-child {
    flex: 1;
    min-width: 0; /* Важно для truncate */
    overflow: hidden;
}

.chat-header .sidebar-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header > button:last-child {
    flex-shrink: 0; /* Кнопка "+" не сжимается */
}

.chat-history-menu {
    width: 280px;
}

/* Chat History Panel - Full Screen */
.chat-history-panel {
    position: absolute;
    top: 49px; /* После header */
    left: 0;
    right: 0;
    bottom: 0;
    background: #0d1117;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid #30363d;
    background: #161b22;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.chat-history-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 8px;
    background: #161b22;
    border: 1px solid #30363d;
}

.chat-history-item:hover {
    background: #21262d;
    border-color: #3d444d;
}

.chat-history-item.active {
    background: #1f6feb22;
    border-color: #1f6feb;
}

.chat-history-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-history-title {
    flex: 1;
    font-weight: 500;
    color: #e6edf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #8b949e;
}

.chat-history-item-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-history-item-meta .material-symbols-outlined {
    font-size: 14px;
}

/* AI Todo List */
.ai-todos {
    border-bottom: 1px solid #30363d;
    background: #161b22;
    font-size: 13px;
}

.ai-todos-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    color: #8b949e;
    font-weight: 500;
    transition: background 0.2s;
}

.ai-todos-header:hover {
    background: #21262d;
}

.ai-todos-list {
    padding: 0 12px 10px;
    max-height: 200px;
    overflow-y: auto;
}

.ai-todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    color: #e6edf3;
}

.ai-todo-item.completed {
    opacity: 0.6;
}

.ai-todo-item.in-progress {
    color: #58a6ff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
}

.chat-message {
    margin-bottom: 16px;
}

.chat-message.user {
    text-align: right;
}

.chat-message .bubble {
    display: inline-block;
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
}

.chat-message.user .bubble {
    background: #1f6feb;
    color: white;
}

.chat-message.assistant .bubble {
    background: #21262d;
    color: #e6edf3;
}

.chat-message .bubble pre {
    background: #161b22;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.chat-message .bubble code {
    font-size: 12px;
}

.chat-input-wrapper {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #30363d;
    flex-shrink: 0;
    background: #0d1117;
}

.chat-input {
    display: flex;
    gap: 8px;
}

.chat-input textarea {
    flex: 1;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 10px 14px;
    color: #e6edf3;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
}

.chat-input textarea:focus {
    border-color: #1f6feb;
}

.chat-input button {
    background: #238636;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input button:hover {
    background: #2ea043;
}

/* Скрываем переключатель prompt/turbo глобально (turbo по умолчанию) */
.mode-toggle-cli {
    display: none !important;
}

/* ===== Обрезка длинных названий ===== */
.truncate-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Названия задач AI */
.ai-todo-item {
    max-width: 100%;
}

.ai-todo-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Названия в истории чатов */
.chat-history-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Названия табов редактора */
.editor-tab {
    max-width: 200px;
}

.editor-tab span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Названия файлов в дереве */
.file-item .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Названия в dropdown */
.dropdown-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Inline todos в чате */
.inline-todo-item {
    max-width: 100%;
}

.inline-todo-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Названия проектов в карточках */
.nav-card-title {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.btn-icon {
    padding: 4px;
    background: transparent;
    color: #8b949e;
}

.btn-icon:hover {
    background: #30363d;
    color: #e6edf3;
}

.btn-primary {
    background: #238636;
    color: white;
}

.btn-primary:hover {
    background: #2ea043;
}

.btn-secondary {
    background: #21262d;
    color: #e6edf3;
    border: 1px solid #30363d;
}

.btn-secondary:hover {
    background: #30363d;
}

/* Material Icons */
.material-symbols-outlined {
    font-size: 20px;
    vertical-align: middle;
}

/* Dropdown */
.dropdown {
    position: relative;
    z-index: 50;
}

.dropdown > button {
    cursor: pointer !important;
    pointer-events: auto !important;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px 0;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1000;
    margin-top: 4px;
    /* Alpine.js x-show контролирует видимость */
}

.dropdown-menu.show {
    display: block !important;
}

.dropdown-menu.right-0 {
    left: auto;
    right: 0;
}

/* Скрываем по умолчанию через Alpine x-show */
[x-cloak] {
    display: none !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
}

.dropdown-item:hover {
    background: #30363d;
}

/* Модалки */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 12px;
    color: #e6edf3;
    font-size: 14px;
    outline: none;
    margin-bottom: 16px;
}

.modal-input:focus {
    border-color: #1f6feb;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Меню добавления */
.add-menu-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    margin-bottom: 20px;
    margin-top: 16px;
}

button.add-menu-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 20px 14px !important;
    background: #161b22 !important;
    border: 2px solid #30363d !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    min-height: 130px !important;
}

button.add-menu-item:hover {
    background: #1c2128 !important;
    border-color: #1f6feb !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 25px rgba(31, 111, 235, 0.15) !important;
}

button.add-menu-item .add-menu-icon {
    font-size: 38px !important;
    margin-bottom: 10px !important;
    display: block !important;
}

button.add-menu-item .add-menu-label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #e6edf3 !important;
    margin-bottom: 5px !important;
    display: block !important;
}

button.add-menu-item .add-menu-desc {
    font-size: 12px !important;
    color: #8b949e !important;
    line-height: 1.4 !important;
    display: block !important;
}

/* Состояние загрузки */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8b949e;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #30363d;
    border-top-color: #1f6feb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* AI Working Overlay */
.ai-working-overlay {
    background: linear-gradient(135deg, #1a1f2e 0%, #0d1117 100%);
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.ai-working-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-working-animation {
    width: 48px;
    height: 48px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-working-text {
    flex: 1;
}

.ai-stop-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #dc2626;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-stop-btn:hover {
    background: #b91c1c;
    transform: scale(1.02);
}

.ai-working-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
    background-size: 200% 100%;
    animation: progress-shimmer 1.5s ease-in-out infinite;
    width: 100%;
}

@keyframes progress-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Tools Summary (компактный блок) */
.tools-summary {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.tools-summary-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tools-summary-header:hover {
    background: #21262d;
}

.tools-summary-list {
    border-top: 1px solid #30363d;
    padding: 8px;
    background: #0d1117;
    max-height: 200px;
    overflow-y: auto;
}

.tools-summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
}

.tools-summary-item:hover {
    background: #21262d;
}

/* Tool calls (legacy - для совместимости) */
.tool-call {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.tool-call-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #21262d;
    font-size: 12px;
    font-weight: 500;
}

.tool-call-content {
    padding: 12px;
    font-size: 12px;
}

/* Inline todos in chat */
.inline-todos {
    background: #1a1625;
    border: 1px solid #6b46c1;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.inline-todos-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #251f35;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.inline-todos-header:hover {
    background: #2d2645;
}

.inline-todos-list {
    padding: 8px 12px;
}

.inline-todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    transition: opacity 0.2s;
}

.inline-todo-item.done {
    opacity: 0.7;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s;
    z-index: 100;
}

.resize-handle:hover,
.resize-handle.active {
    background: #1f6feb;
}

.resize-handle-right {
    right: -3px;
}

.resize-handle-left {
    left: -3px;
}

/* При ресайзе отключаем выделение текста */
body.resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

body.resizing * {
    cursor: col-resize !important;
}

body.resizing iframe,
body.resizing .monaco-editor {
    pointer-events: none;
}

/* Responsive: мобильные */
@media (max-width: 1024px) {
    .app-container {
        --panel-files: 0%;
        --panel-editor: 50%;
        --panel-chat: 50%;
    }

    .sidebar-files {
        position: absolute;
        left: 0;
        top: 48px;
        bottom: 0;
        width: 280px !important;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .sidebar-files.show {
        transform: translateX(0);
    }

    .resize-handle {
        display: none;
    }
}

/* lg:hidden для мобильных кнопок */
.lg\\:hidden {
    display: none;
}

@media (max-width: 1024px) {
    .lg\\:hidden {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .app-container {
        --panel-editor: 100%;
        --panel-chat: 0%;
    }

    /* sidebar-chat стили перенесены в основной мобильный медиа-блок ниже */

    .editor-panel {
        width: 100% !important;
    }
}

/* ===== DIFF VIEW ===== */
.diff-view {
    font-family: 'JetBrains Mono', monospace;
}

.diff-line {
    display: flex;
    align-items: stretch;
    min-height: 22px;
    line-height: 22px;
}

.diff-line-num {
    width: 50px;
    min-width: 50px;
    padding: 0 8px;
    text-align: right;
    color: #6e7681;
    background: #161b22;
    border-right: 1px solid #30363d;
    user-select: none;
    font-size: 12px;
}

.diff-line-sign {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-weight: bold;
    user-select: none;
}

.diff-line-content {
    flex: 1;
    padding: 0 12px;
    white-space: pre;
    overflow-x: auto;
}

/* Добавленные строки - зелёный */
.diff-line.diff-added {
    background: rgba(46, 160, 67, 0.15);
}

.diff-line.diff-added .diff-line-num {
    background: rgba(46, 160, 67, 0.25);
    color: #3fb950;
}

.diff-line.diff-added .diff-line-sign {
    color: #3fb950;
}

.diff-line.diff-added .diff-line-content {
    color: #7ee787;
}

/* Удалённые строки - красный */
.diff-line.diff-removed {
    background: rgba(248, 81, 73, 0.15);
}

.diff-line.diff-removed .diff-line-num {
    background: rgba(248, 81, 73, 0.25);
    color: #f85149;
}

.diff-line.diff-removed .diff-line-sign {
    color: #f85149;
}

.diff-line.diff-removed .diff-line-content {
    color: #ffa198;
}

/* Контекст (без изменений) */
.diff-line.diff-context {
    background: transparent;
}

.diff-line.diff-context .diff-line-sign {
    color: #484f58;
}

.diff-line.diff-context .diff-line-content {
    color: #8b949e;
}

/* Просмотр версии файла */
.version-content-view {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #e6edf3;
    tab-size: 4;
}

/* Monaco Editor - подсветка изменений при обновлении файла AI */
.highlight-added-line {
    background: rgba(46, 160, 67, 0.25) !important;
}

.highlight-changed-line {
    background: rgba(227, 179, 65, 0.25) !important;
}

.highlight-added-glyph {
    background: #3fb950;
    width: 4px !important;
    margin-left: 3px;
}

.highlight-changed-glyph {
    background: #e3b341;
    width: 4px !important;
    margin-left: 3px;
}

/* ============================================
   Генерация изображений
   ============================================ */

.image-modal {
    max-width: 520px;
    width: 100%;
}

.image-edit-modal {
    max-width: 700px;
}

.image-modal-content {
    padding: 1rem 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.modal-textarea {
    resize: vertical;
    min-height: 70px;
}

/* Пропорции */
.aspect-ratio-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.aspect-ratio-picker.compact {
    gap: 0.25rem;
}

.aspect-ratio-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 0.75rem;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
}

.aspect-ratio-btn:hover {
    background: #374151;
    color: #f3f4f6;
}

.aspect-ratio-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.aspect-ratio-btn .material-symbols-outlined {
    font-size: 1.25rem;
}

.aspect-ratio-picker.compact .aspect-ratio-btn {
    padding: 0.375rem 0.5rem;
}

.aspect-ratio-picker.compact .aspect-ratio-btn .text-xs {
    display: none;
}

/* Размеры */
.size-picker {
    display: flex;
    gap: 0.5rem;
}

.size-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 1rem;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 70px;
}

.size-btn:hover {
    background: #374151;
    color: #f3f4f6;
}

.size-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.size-btn .text-xs {
    font-size: 0.625rem;
}

.size-btn.active .text-xs {
    color: rgba(255, 255, 255, 0.7);
}

/* Редактирование - layout */
.image-edit-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .image-edit-layout {
        grid-template-columns: 1fr;
    }
}

.image-preview {
    width: 200px;
    height: 200px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview-placeholder {
    color: #4b5563;
}

.image-preview-placeholder .material-symbols-outlined {
    font-size: 3rem;
}

.image-edit-params {
    flex: 1;
}

/* Flex utilities */
.flex-1 {
    flex: 1;
}

/* Image Preview in Editor */
.image-preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #0d1117;
    background-image:
        linear-gradient(45deg, #161b22 25%, transparent 25%),
        linear-gradient(-45deg, #161b22 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #161b22 75%),
        linear-gradient(-45deg, transparent 75%, #161b22 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    overflow: auto;
    padding: 2rem;
}

.image-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ============ Document Preview (PDF, Office) ============ */
.document-preview-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #0d1117;
}

.document-preview-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

.document-preview-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #161b22;
    border-top: 1px solid #30363d;
}

.document-preview-toolbar .btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ============ File Preview Card ============ */
.file-preview-card {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    padding: 2rem;
}

.preview-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 1rem;
    padding: 3rem 4rem;
    max-width: 400px;
    width: 100%;
}

.preview-card-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
}

.preview-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f0f6fc;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.preview-card-path {
    font-size: 0.875rem;
    color: #8b949e;
    margin-bottom: 2rem;
    word-break: break-all;
}

.preview-card-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.preview-card-actions .btn {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}

.preview-card-hint {
    font-size: 0.75rem;
    color: #6e7681;
    margin-top: 0.5rem;
}

.btn-secondary {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.btn-secondary:hover {
    background: #30363d;
    border-color: #8b949e;
}

/* ============ File Manager ============ */
.fm-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border-radius: 0.75rem;
    border: 2px solid transparent;
    background: #161b22;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.fm-item:hover {
    background: #21262d;
    border-color: #30363d;
}

.fm-item:active {
    transform: scale(0.98);
}

.fm-item[draggable="true"] {
    cursor: grab;
}

.fm-item[draggable="true"]:active {
    cursor: grabbing;
}

.fm-item-icon {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    transition: transform 0.15s ease;
}

.fm-item:hover .fm-item-icon {
    transform: scale(1.05);
}

.fm-item-name {
    font-size: 0.8rem;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e6edf3;
}

.fm-item-check {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.fm-item:hover .fm-item-check,
.fm-item-check.visible {
    opacity: 1;
}

/* File type colors */
.fm-item-icon.bg-code {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.fm-item-icon.bg-style {
    background: rgba(168, 85, 247, 0.2);
    color: #a78bfa;
}

.fm-item-icon.bg-image {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.fm-item-icon.bg-doc {
    background: rgba(234, 179, 8, 0.2);
    color: #fbbf24;
}

.fm-item-icon.bg-data {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.fm-item-icon.bg-default {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

/* ============ File Manager Tree View ============ */
.fm-tree {
    padding: 0.5rem 0;
}

.fm-tree-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.1s ease;
    position: relative;
    user-select: none;
}

.fm-tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.fm-tree-item.selected {
    background: rgba(59, 130, 246, 0.2);
}

.fm-tree-item.drop-target {
    background: rgba(34, 197, 94, 0.2);
    outline: 2px solid rgba(34, 197, 94, 0.5);
    outline-offset: -2px;
}

.fm-tree-item[draggable="true"] {
    cursor: grab;
}

.fm-tree-item[draggable="true"]:active {
    cursor: grabbing;
}

.fm-tree-arrow {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.fm-tree-arrow:hover {
    background: rgba(255, 255, 255, 0.1);
}

.fm-tree-arrow.expanded {
    transform: rotate(90deg);
}

.fm-tree-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.fm-tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.fm-tree-actions {
    display: none;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.fm-tree-item:hover .fm-tree-actions {
    display: flex;
}

/* ============================================
   FILE MANAGER - LIST VIEW
   ============================================ */

.fm-list {
    background: #0d1117;
}

.fm-list-breadcrumb {
    font-size: 0.875rem;
}

.fm-list-header {
    background: #161b22;
    position: sticky;
    top: 0;
    z-index: 1;
}

.fm-list-row {
    transition: background-color 0.1s;
}

.fm-list-row:hover {
    background-color: rgba(48, 54, 61, 0.5);
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Улучшенные базовые мобильные стили */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices - увеличиваем touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-icon {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }

    .file-item {
        padding: 12px 16px;
        min-height: 48px;
    }

    .dropdown-item {
        padding: 14px 16px;
        min-height: 48px;
    }

    /* Убираем hover эффекты, делаем active */
    .file-item:hover {
        background: transparent;
    }

    .file-item:active {
        background: #161b22;
    }

    .dropdown-item:hover {
        background: transparent;
    }

    .dropdown-item:active {
        background: #30363d;
    }

    /* Показываем actions всегда на touch */
    .fm-tree-item .fm-tree-actions {
        display: flex;
    }
}

/* ===== BOTTOM NAVIGATION для телефонов ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #161b22;
    border-top: 1px solid #30363d;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-bottom-nav-items {
    display: flex;
    height: 100%;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #8b949e;
    text-decoration: none;
    transition: color 0.2s;
    padding: 8px;
    cursor: pointer;
    background: none;
    border: none;
}

.mobile-nav-item:active {
    background: rgba(255, 255, 255, 0.05);
}

.mobile-nav-item.active {
    color: #58a6ff;
}

.mobile-nav-item .material-symbols-outlined {
    font-size: 24px;
    margin-bottom: 2px;
}

.mobile-nav-item span:last-child {
    font-size: 10px;
    font-weight: 500;
}

/* Индикатор активности AI / новых сообщений */
.mobile-nav-item .nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 20px);
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ===== Header адаптация ===== */
@media (max-width: 768px) {
    .app-header {
        padding: 0 10px;
        height: 44px;
        min-height: 44px;
    }

    /* Скрываем logo текст на маленьких экранах */
    .app-header .text-lg {
        display: none;
    }

    /* Компактный header */
    .app-header .gap-4 {
        gap: 6px;
    }

    /* Показываем только Plan/Do на мобильных */
    .mode-toggle {
        display: flex;
        padding: 2px;
    }

    .mode-toggle .mode-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .mode-toggle .mode-btn .material-symbols-outlined {
        font-size: 14px;
    }

    /* Показываем текст План/Делать в кнопках режима на мобильных */
    .mode-toggle .mode-btn .hidden {
        display: inline !important;
        margin-left: 2px;
        font-size: 11px;
    }

    /* CLI mode toggle скрыт на мобильных (также скрыт глобально ниже) */
    .mode-toggle-cli {
        display: none !important;
    }

    /* Скрываем токены в header */
    .app-header .text-sm.text-gray-500 {
        display: none;
    }

    /* Скрываем выбор провайдера в header на мобильных */
    .app-header > div:last-child > .dropdown {
        display: none;
    }

    /* Скрываем dropdown выбора проекта на мобильных */
    .app-header > div:first-child > .dropdown {
        display: none;
    }

    /* Компактные кнопки в header */
    .app-header .btn-icon {
        padding: 6px;
        min-height: 36px;
        min-width: 36px;
    }

    .app-header .btn-secondary {
        padding: 4px 8px;
        font-size: 12px;
    }

    .app-header .btn-secondary .material-symbols-outlined {
        font-size: 16px;
    }

    /* Показываем мобильное название проекта */
    .mobile-project-name {
        display: flex !important;
        align-items: center;
        gap: 4px;
        font-size: 13px;
        color: #9ca3af;
        max-width: 180px;
        overflow: hidden;
    }

    .mobile-project-name span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Показываем бургер и кнопку назад на мобильных */
    .app-header .mobile-burger,
    .app-header .mobile-back-btn {
        display: flex !important;
    }

    /* Скрываем выбор модели в чате на мобильных (он есть в меню "Ещё") */
    .chat-input-wrapper > .flex.items-center.gap-2 {
        display: none !important;
    }

    /* Скрываем кнопки history и settings на мобильных (есть в меню Ещё) */
    .app-header .btn-icon[title="Чекпоинты (история)"],
    .app-header .btn-icon[title="Настройки"] {
        display: none;
    }

    /* Скрываем bottom navigation - вместо него бургер-меню */
    .mobile-bottom-nav {
        display: none !important;
    }

    /* Контейнер приложения на мобильных - простой подход */
    .app-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
    }

    /* Header статичный */
    .app-header {
        flex-shrink: 0;
    }

    /* Основной контент - на весь экран */
    .app-main {
        flex: 1;
        overflow: hidden;
    }

    /* Сайдбары на мобильных - на весь экран */
    .sidebar-files,
    .sidebar-chat {
        position: fixed;
        top: 44px;
        bottom: 0;
        width: 100% !important;
        max-width: 100%;
        z-index: 500;
    }

    .sidebar-files {
        left: 0;
        transform: translateX(-100%);
    }

    .sidebar-chat {
        right: 0;
        transform: translateX(100%);
    }

    .sidebar-files.show,
    .sidebar-chat.show {
        transform: translateX(0);
    }

    /* Overlay при открытом сайдбаре */
    .mobile-overlay {
        position: fixed;
        top: 44px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 400;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }

    /* Редактор на весь экран */
    .editor-panel {
        width: 100% !important;
        min-width: 0;
        height: auto !important;
        max-height: none !important;
        overflow: hidden;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    /* Toolbar редактора на мобильных - всегда виден */
    .editor-panel > .flex.items-center.justify-between {
        flex-shrink: 0;
        min-height: 48px;
    }

    /* Контент редактора */
    .editor-content {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    /* FAB кнопки на мобильных */
    .fixed.bottom-6.right-6 {
        bottom: 24px;
        right: 16px;
    }
}

/* ===== Планшет (768px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .app-container {
        --panel-files: 0%;
        --panel-editor: 55%;
        --panel-chat: 45%;
    }

    .sidebar-files {
        position: fixed;
        left: 0;
        top: 48px;
        bottom: 0;
        width: 300px !important;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .sidebar-files.show {
        transform: translateX(0);
    }

    /* Overlay для планшета */
    .mobile-overlay {
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ===== Модальные окна на мобильных ===== */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        min-width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        max-height: 90vh;
        overflow-y: auto;
        animation: slideUp 0.3s ease;
    }

    /* Фиксируем кнопки моделей - равная ширина */
    .modal .flex.gap-2 > .flex-1 {
        flex: 1 1 0;
        min-width: 0;
        text-align: center;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .modal-title {
        font-size: 18px;
        text-align: center;
        padding-bottom: 12px;
        border-bottom: 1px solid #30363d;
        margin-bottom: 20px;
    }

    /* Drag handle для модалки */
    .modal::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #484f58;
        border-radius: 2px;
        margin: 0 auto 16px;
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 12px;
    }

    .modal-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }

    .modal-input {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 14px;
    }

    /* Меню добавления - мобильная сетка */
    .add-menu-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    button.add-menu-item {
        flex-direction: row !important;
        padding: 16px !important;
        min-height: auto !important;
        text-align: left !important;
    }

    button.add-menu-item .add-menu-icon {
        font-size: 32px !important;
        margin-bottom: 0 !important;
        margin-right: 16px !important;
        flex-shrink: 0 !important;
    }

    /* Image modals */
    .image-modal,
    .image-edit-modal {
        max-width: 100%;
    }

    .image-edit-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .image-preview {
        width: 100%;
        height: 150px;
    }
}

/* ===== Чат на мобильных ===== */
@media (max-width: 768px) {
    .chat-messages {
        padding: 12px;
    }

    .chat-message .bubble {
        max-width: 90%;
        font-size: 15px;
    }

    .chat-input-wrapper {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .chat-input {
        gap: 6px;
    }

    .chat-input textarea {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 8px 10px;
        min-height: 40px;
        max-height: 100px;
    }

    .chat-input button {
        min-width: 40px;
        min-height: 40px;
        padding: 12px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    /* AI Working overlay */
    .ai-working-overlay {
        margin: 12px;
        padding: 12px;
    }

    .ai-working-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .ai-stop-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Редактор на мобильных ===== */
@media (max-width: 768px) {
    .editor-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .editor-tabs::-webkit-scrollbar {
        display: none;
    }

    .editor-tab {
        padding: 12px 16px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .editor-tab .close {
        padding: 4px;
        margin-left: 8px;
    }

    /* Toolbar редактора */
    .editor-panel > .flex.items-center {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }

    /* Markdown preview */
    .markdown-preview {
        padding: 16px;
    }

    .markdown-preview h1 {
        font-size: 1.5em;
    }

    .markdown-preview h2 {
        font-size: 1.25em;
    }

    .markdown-preview pre {
        padding: 12px;
        font-size: 12px;
    }
}

/* ===== File tree на мобильных ===== */
@media (max-width: 768px) {
    .file-tree {
        font-size: 15px;
    }

    .file-item {
        padding: 14px 16px;
    }

    .file-item .icon {
        font-size: 20px;
        margin-right: 12px;
    }

    .file-item .history-badge {
        font-size: 11px;
        padding: 2px 8px;
    }

    .sidebar-header {
        padding: 16px;
    }

    .sidebar-actions .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===== Dropdowns на мобильных ===== */
@media (max-width: 768px) {
    .dropdown-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 20px 20px 0 0;
        padding: 16px 0;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        max-height: 70vh;
        overflow-y: auto;
        animation: slideUp 0.3s ease;
    }

    .dropdown-menu::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #484f58;
        border-radius: 2px;
        margin: 0 auto 12px;
    }

    .dropdown-item {
        padding: 16px 20px;
    }
}

/* ===== Папки и карточки проектов на мобильных ===== */
@media (max-width: 640px) {
    .grid.grid-cols-1 {
        gap: 12px;
    }

    /* Карточки папок/проектов */
    .bg-gray-900.rounded-xl {
        padding: 12px;
    }

    .bg-gray-900.rounded-xl .w-12.h-12 {
        width: 40px;
        height: 40px;
    }

    /* Breadcrumbs */
    .flex.items-center.gap-2.px-6 {
        padding: 12px 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .flex.items-center.gap-2.px-6::-webkit-scrollbar {
        display: none;
    }
}

/* ===== Diff view на мобильных ===== */
@media (max-width: 768px) {
    .diff-line-num {
        width: 35px;
        min-width: 35px;
        padding: 0 4px;
        font-size: 10px;
    }

    .diff-line-sign {
        width: 16px;
        min-width: 16px;
    }

    .diff-line-content {
        padding: 0 8px;
        font-size: 12px;
    }
}

/* ===== Safe areas для устройств с вырезом ===== */
@supports (padding: env(safe-area-inset-top)) {
    .app-header {
        padding-top: env(safe-area-inset-top);
    }

    @media (max-width: 768px) {
        .app-header {
            height: calc(44px + env(safe-area-inset-top));
            min-height: calc(44px + env(safe-area-inset-top));
        }

        .sidebar-files,
        .sidebar-chat {
            top: calc(44px + env(safe-area-inset-top));
            bottom: env(safe-area-inset-bottom);
        }

        .mobile-overlay {
            top: calc(44px + env(safe-area-inset-top));
            bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ===== Landscape режим на телефонах ===== */
@media (max-width: 896px) and (max-height: 450px) and (orientation: landscape) {
    .app-main {
        height: calc(100vh - 44px);
    }

    .sidebar-files,
    .sidebar-chat {
        bottom: 0;
    }

    .modal {
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ===== Скрываем элементы на разных размерах ===== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

/* Только для планшетов (769px - 1024px) */
.tablet-only {
    display: none;
}

@media (min-width: 769px) and (max-width: 1024px) {
    .tablet-only {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .show-mobile-flex {
        display: flex !important;
    }

    .show-mobile-inline-flex {
        display: inline-flex !important;
    }
}

/* ===== Улучшенные анимации для мобильных ===== */
@media (prefers-reduced-motion: no-preference) {
    .sidebar-files,
    .sidebar-chat {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-overlay {
        transition: opacity 0.3s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-files,
    .sidebar-chat,
    .modal,
    .dropdown-menu {
        transition: none;
        animation: none;
    }
}

/* ===== Дополнительные мобильные улучшения ===== */

/* Компактный header на маленьких телефонах */
@media (max-width: 400px) {
    .app-header .btn-secondary {
        padding: 6px 8px;
        font-size: 12px;
    }

    .app-header .btn-secondary .material-symbols-outlined {
        font-size: 16px;
    }

    /* Скрываем текст в dropdown */
    .app-header .btn-secondary > span:not(.material-symbols-outlined) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Улучшаем прокрутку чата на iOS */
.chat-messages {
    -webkit-overflow-scrolling: touch;
}

/* Предотвращаем pull-to-refresh при скролле в сайдбарах */
.sidebar-files,
.sidebar-chat {
    overscroll-behavior: contain;
}

/* Лучше отображаем code blocks на мобильных */
@media (max-width: 768px) {
    .chat-message .bubble pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chat-message .bubble code {
        word-break: break-word;
    }
}

/* Улучшаем отображение файлового менеджера на мобильных */
@media (max-width: 768px) {
    .fm-item {
        padding: 0.75rem 0.5rem;
    }

    .fm-item-icon {
        width: 48px;
        height: 48px;
    }

    .fm-item-name {
        font-size: 0.75rem;
    }
}

/* FAB кнопки на мобильных - меньше и компактнее */
@media (max-width: 768px) {
    .fixed.bottom-6.right-6 .w-14 {
        width: 48px;
        height: 48px;
    }

    .fixed.bottom-6.right-6 .w-12 {
        width: 40px;
        height: 40px;
    }
}

/* Улучшаем отображение снапшотов на мобильных */
@media (max-width: 768px) {
    .modal[style*="max-width: 700px"],
    .modal[style*="max-width: 1000px"] {
        max-width: 100% !important;
    }
}

/* Скрываем скроллбары на мобильных для более чистого вида */
@media (max-width: 768px) {
    .sidebar-content::-webkit-scrollbar,
    .chat-messages::-webkit-scrollbar,
    .editor-tabs::-webkit-scrollbar {
        display: none;
    }

    .sidebar-content,
    .chat-messages,
    .editor-tabs {
        scrollbar-width: none;
    }
}

/* Фикс для iOS safe area в модальных окнах */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .modal {
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
        }
    }
}

/* ===== Карточки навигации (папки и проекты) ===== */
.nav-card {
    position: relative;
    background: linear-gradient(145deg, #1a1f2e 0%, #131720 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.nav-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255,255,255,0.1), transparent 50%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.nav-card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.folder-glow {
    background: radial-gradient(circle at center, rgba(234, 179, 8, 0.15) 0%, transparent 50%);
}

.project-glow {
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, transparent 50%);
}

.nav-card:hover .nav-card-glow {
    opacity: 1;
}

.nav-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.nav-card-folder:hover {
    border-color: rgba(234, 179, 8, 0.3);
    box-shadow: 0 20px 40px -15px rgba(234, 179, 8, 0.2);
}

.nav-card-project:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 20px 40px -15px rgba(59, 130, 246, 0.2);
}

.nav-card-content {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 12px;
}

.nav-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.3);
}

.nav-card-icon .material-symbols-outlined {
    font-size: 28px;
    transition: transform 0.3s ease;
}

.nav-card:hover .nav-card-icon .material-symbols-outlined {
    transform: scale(1.1);
}

.folder-icon {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(234, 179, 8, 0.1) 100%);
    color: #eab308;
}

.project-icon {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%);
    color: #3b82f6;
}

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

.nav-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #f0f6fc;
    margin: 0 0 10px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.nav-card-meta {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-card-dot {
    opacity: 0.4;
}

/* Новые стили для статистики и даты */
.nav-card-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.nav-card-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #9ca3af;
}

.nav-card-stat .material-symbols-outlined {
    font-size: 16px;
    opacity: 0.7;
}

.nav-card-folder .nav-card-stat .material-symbols-outlined {
    color: #eab308;
}

.nav-card-project .nav-card-stat .material-symbols-outlined {
    color: #3b82f6;
}

.nav-card-date {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6b7280;
}

.nav-card-date .material-symbols-outlined {
    font-size: 14px;
    opacity: 0.6;
}

/* Декоративный угловой элемент */
.nav-card-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    overflow: hidden;
    pointer-events: none;
}

.nav-card-corner::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 40px;
    height: 40px;
    transform: rotate(45deg);
    transition: all 0.3s ease;
}

.nav-card-folder .nav-card-corner::before {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.3) 0%, rgba(234, 179, 8, 0.1) 100%);
}

.nav-card-project .nav-card-corner::before {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(59, 130, 246, 0.1) 100%);
}

.nav-card:hover .nav-card-corner::before {
    top: -15px;
    right: -15px;
}

.nav-card-actions {
    position: relative;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.2s ease;
}

.nav-card:hover .nav-card-actions {
    opacity: 1;
    transform: translateY(0);
}

.nav-card-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-card-btn .material-symbols-outlined {
    font-size: 18px;
}

.nav-card-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f0f6fc;
}

.nav-card-btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Мобильная адаптация карточек */
@media (max-width: 640px) {
    .nav-card {
        padding: 16px;
        border-radius: 14px;
    }

    .nav-card-icon {
        width: 42px;
        height: 42px;
        border-radius: 10px;
    }

    .nav-card-icon .material-symbols-outlined {
        font-size: 22px;
    }

    .nav-card-title {
        font-size: 14px;
    }

    .nav-card-actions {
        opacity: 1;
        transform: none;
    }

    .nav-card-btn {
        width: 28px;
        height: 28px;
    }

    .nav-card-btn .material-symbols-outlined {
        font-size: 16px;
    }
}
