* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* THEME */
body {
    background: #f5f7fb;
    color: #111;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.dark {
    background: #0f1115;
    color: #fff;
}

/* TOPBAR */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #ddd;
    background: white;
    transition: background 0.2s, border-color 0.2s;
}

body.dark .topbar {
    background: #1a1d24;
    border-color: #333;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.logo {
    width: 28px;
    height: 28px;
}

.theme {
    display: flex;
    align-items: center;
    gap: 12px;
}

#themeLabel {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* TOGGLE SWITCH */
.switch {
    position: relative;
    width: 46px;
    height: 24px;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s;
}

.slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

input:checked + .slider {
    background: #3b82f6;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* MAIN LAYOUT */
.layout {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* PANELS */
.panel {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #ddd;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    transition: background 0.2s, border-color 0.2s;
}

body.dark .panel {
    background: #1a1d24;
    border-color: #333;
}

.panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

/* PDF PREVIEW */
.preview-container {
    flex: 1;
    min-height: 0;
    margin-top: 10px;
}

iframe {
    width: 100%;
    height: 65vh;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f0f0f0;
    transition: border-color 0.2s, background 0.2s;
}

body.dark iframe {
    border-color: #444;
    background: #2a2d35;
}

/* FILE INPUT */
input[type="file"] {
    padding: 10px;
    border: 1px dashed #ddd;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    background: transparent;
    transition: border-color 0.2s;
}

body.dark input[type="file"] {
    border-color: #444;
    color: #fff;
}

/* OUTPUT */
pre {
    flex: 1;
    overflow: auto;
    background: rgba(0,0,0,0.04);
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 10px 0 0 0;
    max-height: 65vh;
    transition: background 0.2s;
}

body.dark pre {
    background: rgba(255,255,255,0.05);
}

/* STATUS */
.status {
    margin: 10px 0;
    padding: 8px 12px;
    background: rgba(59,130,246,0.1);
    border-radius: 6px;
    font-size: 0.85rem;
    color: #3b82f6;
    transition: background 0.2s;
}

body.dark .status {
    background: rgba(59,130,246,0.15);
}

/* BUTTON */
button {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s, opacity 0.2s;
}

button:hover:not(:disabled) {
    background: #2563eb;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* FOOTER — с поддержкой темы */
.footer {
    margin-top: auto;
    display: flex;
    justify-content: space-around;
    padding: 24px 20px;
    background: #f0f2f5;
    color: #555;
    border-top: 1px solid #ddd;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

body.dark .footer {
    background: #0a0c10;
    color: #888;
    border-top-color: #1a1d24;
}

.footer a {
    color: #7ab7ff;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer div {
    line-height: 1.5;
}

/* GitHub icon in footer */
.author-link {
    display: flex;
    align-items: center;
    gap: 6px;
}

.github-icon {
    width: 16px;
    height: 16px;
    filter: invert(0.6);
    transition: filter 0.2s;
}

body.dark .github-icon {
    filter: invert(0.5);
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
    
    .topbar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    iframe, pre {
        height: 50vh;
        max-height: 50vh;
    }
    
    .footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .brand {
        justify-content: center;
    }
    
    .theme {
        justify-content: center;
    }
    
    .author-link {
        justify-content: center;
    }
}
