body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: #ffffff;
    color: #333333;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    background-color: #f4f4f4;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
    height: 50px;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

header h1 {
    margin: 0;
    font-size: 1.5em;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button, select {
    padding: 5px 10px;
    cursor: pointer;
    border: 1px solid #ccc;
    background: white;
    border-radius: 3px;
    font-size: 13px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

button:hover, select:hover {
    background: #f0f0f0;
}

#snow-btn.active {
    background: #4CAF50 !important;
    color: white !important;
}

input[type="checkbox"] {
    margin-right: 5px;
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
    background: white;
    min-width: 300px;
    transition: background-color 0.3s ease;
}

.tabs {
    display: flex;
    background-color: #eee;
    border-bottom: 1px solid #ccc;
    position: relative;
    transition: background-color 0.3s ease;
}

.tab {
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    flex: 1;
    transition: background 0.2s;
    color: #333;
}

.tab:hover {
    background-color: #ddd;
}

.tab.active {
    background-color: #ddd;
    font-weight: bold;
    border-bottom: 2px solid #333;
}

.status-bar {
    margin-left: auto;
    display: flex;
    gap: 15px;
    padding: 10px 15px;
    font-size: 12px;
    color: #666;
    background: #f9f9f9;
    border-left: 1px solid #ccc;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.editors {
    flex: 1;
    position: relative;
    background: white;
    transition: background-color 0.3s ease;
}

.editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.editor.active {
    display: block;
}

.CodeMirror {
    height: 100% !important;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

.console-container {
    display: none;
    height: 20%;
    background-color: #1e1e1e;
    color: #fff;
    border-top: 2px solid #444;
    flex-direction: column;
}

.js-active .console-container {
    display: flex;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: #333;
    border-bottom: 1px solid #555;
    font-size: 12px;
}

.console-header button {
    background: #555;
    border: none;
    color: #ccc;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.console-header button:hover {
    background: #666;
    color: white;
}

.console {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.4;
}

.console div {
    margin: 2px 0;
    padding: 2px 0;
}

.resizer {
    width: 4px;
    background: #ccc;
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.resizer:hover {
    background: #999;
}

.preview-container {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    transition: background-color 0.3s ease;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f4f4f4;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    color: #333;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.preview-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

.preview-size-btn {
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
}

.preview-size-btn:hover {
    opacity: 1;
    background: #d0d0d0;
}

.preview-size-btn.active {
    opacity: 1;
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.preview-header button {
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

.preview-header button:hover {
    background: #d0d0d0;
}

.preview-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #f0f0f0;
    padding: 10px;
    overflow: auto;
}

.preview-wrapper.desktop iframe {
    width: 100%;
    height: 100%;
    max-width: none;
}

.preview-wrapper.tablet iframe {
    width: 768px;
    height: 100%;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    border-radius: 8px;
}

.preview-wrapper.mobile iframe {
    width: 375px;
    height: 100%;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    border-radius: 8px;
}

iframe {
    width: 100%;
    flex: 1;
    border: none;
    background: white;
}

#toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 200px;
    animation: slideIn 0.3s ease;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.toast.success {
    border-left: 4px solid #4CAF50;
}

.toast.error {
    border-left: 4px solid #f44336;
}

.toast.info {
    border-left: 4px solid #2196F3;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.fullscreen-overlay.active {
    display: flex;
}

.fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #333;
    color: white;
    border-bottom: 1px solid #555;
}

.fullscreen-header button {
    background: #555;
    color: white;
    border: 1px solid #777;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

.fullscreen-header button:hover {
    background: #666;
}

#fullscreen-preview {
    flex: 1;
    width: 100%;
    border: none;
}

.CodeMirror-hints {
    z-index: 1001 !important;
}

.CodeMirror-focused .CodeMirror-selected {
    background: rgba(102, 126, 234, 0.2) !important;
}

.console::-webkit-scrollbar {
    width: 8px;
}

.console::-webkit-scrollbar-track {
    background: #333;
}

.console::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.console::-webkit-scrollbar-thumb:hover {
    background: #666;
}

button:focus {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.drag-over {
    border: 2px dashed #667eea !important;
    background: rgba(102, 126, 234, 0.1) !important;
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideInModal 0.3s ease;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    transition: background-color 0.3s ease;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.4em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #e9ecef;
    color: #333;
}

.modal-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h3 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1em;
    font-weight: 600;
}

.setting-item {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    transition: border-color 0.2s;
}

.setting-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.project-buttons {
    flex-direction: row;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-btn.primary {
    background: #667eea;
    color: white;
}

.settings-btn.primary:hover {
    background: #5a6fd8;
}

.settings-btn.success {
    background: #28a745;
    color: white;
}

.settings-btn.success:hover {
    background: #218838;
}

.settings-btn.danger {
    background: #dc3545;
    color: white;
}

.settings-btn.danger:hover {
    background: #c82333;
}

.link-result {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.link-result.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.link-result.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.setting-item input[type="text"], 
.setting-item input[type="password"],
.setting-item textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 5px;
    box-sizing: border-box;
    font-family: 'Courier New', monospace;
}

.setting-item input[type="text"]:focus, 
.setting-item input[type="password"]:focus,
.setting-item textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.setting-item textarea {
    resize: vertical;
    min-height: 60px;
}

#saved-links-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
}

.saved-link-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 13px;
}

.saved-link-item:last-child {
    margin-bottom: 0;
}

.saved-link-item .link-name {
    font-weight: bold;
    color: #495057;
    margin-bottom: 5px;
}

.saved-link-item .link-url {
    color: #667eea;
    word-break: break-all;
    margin-bottom: 5px;
    cursor: pointer;
}

.saved-link-item .link-date {
    color: #6c757d;
    font-size: 11px;
}

.saved-link-item .link-actions {
    margin-top: 8px;
}

.saved-link-item .link-actions button {
    font-size: 11px;
    padding: 3px 8px;
    margin-right: 5px;
}

/* QR Code Modal Styles */
.qr-code-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

#qr-code-display {
    min-height: 300px;
    min-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}

#qr-code-display svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 280px !important;
    max-height: 280px !important;
    min-width: 200px !important;
    min-height: 200px !important;
    display: block !important;
}

#qr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #6c757d;
}

#qr-loading p {
    margin: 0;
    font-style: italic;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInModal {
    from { opacity: 0; transform: translateY(-50px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    .controls { gap: 5px; }
    button, select { padding: 4px 8px; font-size: 12px; }
    main { flex-direction: column; }
    .editor-container, .preview-container { flex: none; height: 50vh; }
    .resizer { width: 100%; height: 4px; cursor: row-resize; }
    .status-bar { display: none; }
    .modal-content { width: 95%; margin: 10px; }
    .modal-header, .modal-body { padding: 15px; }
    .project-buttons { flex-direction: column; }
    .settings-btn { width: 100%; justify-content: center; }
    .preview-size-btn { display: none; }
    .preview-wrapper { padding: 0; }
    .preview-wrapper iframe { width: 100% !important; border-radius: 0; box-shadow: none; }
    
    /* Исправление скролла на мобильных */
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .editor-container, .preview-container {
        overflow: hidden;
        position: relative;
    }
    
    .editors {
        overflow: hidden;
        position: relative;
    }
    
    .CodeMirror {
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .preview-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        /* Разрешаем скролл внутри превью */
        touch-action: auto;
    }
    
    iframe {
        overflow-scrolling: touch;
        -webkit-overflow-scrolling: touch;
        /* Разрешаем все touch действия в iframe */
        touch-action: auto;
    }
    
    /* Предотвращение перехвата скролла редактором */
    .CodeMirror-scroll {
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        /* Ограничиваем touch действия только вертикальным скроллом */
        touch-action: pan-y;
    }
    
    /* Фиксация header на мобильных */
    header {
        position: sticky;
        top: 0;
        z-index: 100;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Предотвращаем touch действия в header */
        touch-action: manipulation;
    }
}

@media (max-width: 480px) {
    header h1 { font-size: 1.2em; }
    .controls { flex-wrap: wrap; gap: 4px; }
    button, select { font-size: 11px; padding: 4px 6px; }
}

/* Эффект снегопада */
.snowflake {
    position: fixed;
    top: -50px;
    color: #fff;
    user-select: none;
    pointer-events: none;
    z-index: 1000;
    font-size: 1em;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    animation-fill-mode: forwards;
}

@keyframes snowfall {
    0% {
        transform: translateY(-50px) translateX(0px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 50px)) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes snowfall-reverse {
    0% {
        transform: translateY(-50px) translateX(0px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 50px)) translateX(-100px) rotate(-360deg);
        opacity: 0;
    }
}