.editor-body {
    height: auto;
    overflow-y: auto;
}

@media (min-width: 1024px) {
    .editor-container {
        height: calc(100vh - 120px);
        /* Fill most of the screen */
        min-height: 750px;
        margin: 10px auto 20px auto;
        max-width: 98%;
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        overflow: hidden;
        /* Contain the scroll within */
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    }
}

@media (min-width: 1500px) {
    .editor-container {
        height: calc(100vh - 140px);
        min-height: 850px;
    }
}

@media (min-width: 1920px) {
    .editor-container {
        min-height: 1800px;
    }
}

/* Fallback styling for the raw textarea (prevents white box flash) */
#latexEditor {
    width: 100%;
    height: 100%;
    background: #2f3a4c;
    color: #f8f8f2;
    border: none;
    resize: none;
    padding: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    box-sizing: border-box;
    display: block;
    /* Ensure it takes space */
}

.editor-container,
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    background: var(--darker-bg);
}

.editor-panel,
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.editor-panel {
    border-right: 1px solid var(--glass-border);
    width: 50%;
    min-width: 420px;
    flex: none;
    height: auto;
    display: flex;
    flex-direction: column;
    container-type: inline-size;
    container-name: editor;

    /* Animation Init */
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Container Queries for Toolbar - Responding to manual shrinking */
@container editor (max-width: 600px) {
    .panel-label {
        padding: 0 8px;
        gap: 4px;
    }

    .panel-label-right {
        gap: 6px;
    }

    .toggle-btn {
        padding: 5px 10px;
    }
}

@container editor (max-width: 520px) {
    .btn-version span {
        display: none;
    }

    .template-name-display {
        max-width: 80px;
        padding: 2px 8px;
    }
}

@container editor (max-width: 350px) {
    .template-name-display {
        display: none !important;
    }
}

@container editor (max-width: 250px) {
    .btn-version {
        display: none;
    }
}

@container editor (max-width: 200px) {
    .btn-version {
        display: none;
    }
}

.resizer {
    width: 12px;
    background: #0f172a;
    cursor: col-resize;
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s, border-color 0.2s;

    /* Animation Init */
    opacity: 0;
    transition: opacity 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.resizer:hover {
    background: #1e293b;
    border-color: rgba(99, 102, 241, 0.3);
}

.resizer-handle {
    width: 18px;
    height: 38px;
    background: #334155;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 101;
    cursor: col-resize;
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.resizer:hover .resizer-handle {
    background: #6366f1;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.resizer-handle span {
    line-height: 0.8;
}

.resizer-dots-top,
.resizer-dots-bottom {
    color: rgba(255, 255, 255, 0.15);
    font-size: 1.5rem;
    font-family: monospace;
    letter-spacing: -2px;
    writing-mode: vertical-rl;
    user-select: none;
    pointer-events: none;
}

.resizer:hover .resizer-dots-top,
.resizer:hover .resizer-dots-bottom {
    color: rgba(99, 102, 241, 0.4);
}

/* Editor Toggle Pill */
.editor-toggle-pill {
    display: flex;
    background: #242e3c;
    padding: 3px;
    border-radius: 20px;
    gap: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 1;
    min-width: 0;
}

.toggle-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 17px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 1;
}

.toggle-btn.active {
    background: #7063f3;
    color: white;
    box-shadow: 0 4px 12px rgba(112, 99, 243, 0.2);
}

.toggle-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    gap: 8px;
}

.coming-soon-badge {
    background: linear-gradient(135deg, #fb7185 0%, #f43f5e 100%);
    color: white;
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.3);
}

/* Editor Views */
.editor-view {
    display: none;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.editor-view.active {
    display: flex;
    flex-direction: column;
}

/* CodeMirror Overrides */
.CodeMirror {
    flex: 1;
    height: 100% !important;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    background: #2f3a4c !important;
}

.CodeMirror-gutters {
    background: #2f3a4c !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding-right: 8px;
}

.CodeMirror-linenumber {
    color: #6272a4 !important;
    padding-left: 12px !important;
}

/* Error Gutter & Line Highlighting */
.error-line-highlight {
    background: rgba(239, 68, 68, 0.15) !important;
}

.error-gutter-marker {
    color: #ef4444;
    font-weight: bold;
    font-size: 1.2rem;
    padding-left: 5px;
    line-height: normal;
}

.error-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #ef4444;
}

/* Fix Preview Panel & PDF Viewer */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #2f3a4c;
    overflow: hidden;

    /* Animation Init */
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pdf-viewer {
    flex: 1;
    background: #2f3a4c;
    position: relative;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    scroll-behavior: smooth;
    user-select: none;
}

.pdf-viewer::-webkit-scrollbar {
    display: none;
}

.pdf-viewer.grab {
    cursor: grab;
}

.pdf-viewer.grabbing {
    cursor: grabbing;
}

.pdf-inner-container {
    padding: 60px;
    min-width: 100%;
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #2f3a4c;
}

.pdf-canvas-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: transparent;
    transform-origin: top center;
    will-change: transform, filter;
    transition: filter 0.3s ease;
}

.pdf-canvas-container canvas {
    display: block;
    background: white;
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.pdf-viewport-wrapper {
    position: relative;
    transform-origin: top center;
    will-change: transform;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Loading Overlay */
.pdf-preview-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 30px;
    padding: 0;
    z-index: 5;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: #39465a;
    padding: 24px 40px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.loader-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #7063f3;
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

.loader-status {
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

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

/* Skeleton Loader */
.skeleton-container {
    width: 595px;
    /* Slightly less than standard container for better fit */
    aspect-ratio: 1 / 1.414;
    /* A4 Ratio */
    height: auto;
    background: white;
    padding: 60px;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
    overflow: hidden;
}

.skeleton-shimmer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.skeleton-top-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.skeleton-header {
    height: 35px;
    width: 65%;
    background: #f1f5f9;
    border-radius: 4px;
}

.skeleton-subheader {
    height: 12px;
    width: 45%;
    background: #f1f5f9;
    border-radius: 4px;
}

.skeleton-section-title {
    height: 18px;
    width: 30%;
    background: #e2e8f0;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line {
    height: 10px;
    width: 100%;
    background: #f1f5f9;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 70%;
}

.skeleton-line.mid {
    width: 85%;
}

.skeleton-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* PDF Dark Mode Filter */
.pdf-dark-mode {
    filter: invert(1) hue-rotate(180deg) brightness(1.1) !important;
}

/* Toolbar logic adjustments */
.zoom-value {
    cursor: default;
    user-select: none;
}

/* Preview Toolbar */
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2f3a4c;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 44px;
    /* Thinner header */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.toolbar-left,
.toolbar-middle,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Reduced gap */
}

.toolbar-middle {
    gap: 4px;
}

.divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 8px;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    /* Thinner padding */
    border-radius: 6px;
}

.page-info {
    font-size: 0.75rem;
    /* Smaller font */
    color: #94a3b8;
    min-width: 40px;
    text-align: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    /* Thinner padding */
    border-radius: 6px;
}

.zoom-value {
    font-size: 0.75rem;
    /* Smaller font */
    color: #94a3b8;
    min-width: 40px;
    text-align: center;
    cursor: default;
    user-select: none;
}

.btn-recompile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #7063f3;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 110px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(112, 99, 243, 0.3);
}

.btn-recompile svg {
    width: 14px;
    /* Smaller icon */
    height: 14px;
}

.btn-recompile:hover:not(:disabled) {
    background: #5d52d9;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(112, 99, 243, 0.4);
}

.btn-recompile:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-recompile.loading .btn-content {
    display: none;
}

.btn-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-recompile.loading .btn-loader {
    display: flex !important;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

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

.error-badge {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon svg {
    width: 16px;
    /* Smaller icons */
    height: 16px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-icon-sm {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-sm:hover {
    color: white;
}

.page-nav {
    display: flex;
    align-items: center;
    background: #0f172a;
    padding: 4px 8px;
    border-radius: 4px;
    gap: 8px;
}

.page-info {
    color: #cbd5e1;
    font-size: 0.8rem;
    font-family: monospace;
    min-width: 40px;
    text-align: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-value {
    color: #94a3b8;
    font-size: 0.8rem;
    font-family: monospace;
    min-width: 40px;
    text-align: center;
}

.preview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.preview-placeholder span {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
    opacity: 0.2;
}

/* Panel Labels & Layout */
.panel-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2f3a4c;
    color: #b1bdce;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 16px;
    height: 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-label-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-width: 0;
}

.template-name-display {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-transform: none;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 200px;
}

/* Custom Alert Modal */
.alert-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.alert-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.alert-modal-content {
    position: relative;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: alert-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes alert-pop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.alert-modal-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.alert-modal-message {
    color: #f8fafc;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 30px;
}

.btn-alert-ok {
    background: #7063f3;
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(112, 99, 243, 0.3);
}

.btn-alert-ok:hover {
    background: #5d52d9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(112, 99, 243, 0.4);
}

/* Template Version Controls */
.template-version-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-version {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.btn-version svg {
    width: 12px;
    height: 12px;
}

.btn-version:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    transform: translateY(-1px);
}

/* Error Panel */
.error-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(69, 10, 10, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 16px;
    max-height: 250px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    padding: 0;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(239, 68, 68, 0.1);
    animation: error-slide-up 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes error-slide-up {
    from {
        transform: translateY(100%) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

.error-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.terminal-icon {
    width: 18px;
    height: 18px;
    color: #fca5a5;
}

.error-header h3 {
    color: #fca5a5;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.error-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compilation-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 10px #ef4444;
    animation: status-pulse 1.5s infinite;
}

@keyframes status-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.status-text {
    color: #fca5a5;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.btn-close-error {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fca5a5;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-error:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    transform: rotate(90deg);
}

.btn-close-error svg {
    width: 16px;
    height: 16px;
}

.error-list {
    padding: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #fecaca;
    line-height: 1.6;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(239, 68, 68, 0.3) transparent;
}

.error-list::-webkit-scrollbar {
    width: 6px;
}

.error-list::-webkit-scrollbar-thumb {
    background: rgba(239, 68, 68, 0.3);
    border-radius: 3px;
}

/* Error Summary - First Line */
.error-summary {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fecaca;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-summary strong {
    color: #f87171;
    font-weight: 700;
}

.error-summary::before {
    content: "⚠";
    font-size: 1.2rem;
}

/* Light Mode Overrides for Error Panel */
[data-theme="light"] .error-panel {
    background: rgba(254, 242, 242, 0.85);
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .error-header {
    background: rgba(239, 68, 68, 0.05);
}

[data-theme="light"] .error-header h3,
[data-theme="light"] .terminal-icon {
    color: #b91c1c;
}

[data-theme="light"] .compilation-status-badge {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="light"] .status-text {
    color: #b91c1c;
}

[data-theme="light"] .error-list {
    color: #7f1d1d;
}

[data-theme="light"] .btn-close-error {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #b91c1c;
}

.error-item {
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
}

.error-line {
    color: #f87171;
    font-weight: 700;
    white-space: nowrap;
}

.error-msg {
    color: #fecaca;
}

/* Navbar actions */
.editor-actions {
    display: flex;
    gap: 12px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Mobile View Toggle (Hidden on Desktop) */
.mobile-view-toggle {
    display: none;
}

@media (max-width: 400px) {

    .ai-builder-workspace .editor-panel,
    .ai-builder-workspace .preview-panel {
        min-height: 300px;
    }

    .ai-builder-workspace .panel-label {
        background: #2f3a4c;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        height: 40px;
        display: flex;
        align-items: center;
        padding: 0px 3px;
        color: #b1bdce;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1.5px;
    }
}

@media (max-width: 1147px) {

    .editor-body,
    .ai-builder-body {
        height: auto;
        overflow: auto;
    }

    .editor-container {
        flex-direction: column !important;
        height: auto;
        overflow: visible;
        min-height: 100vh;
    }

    .editor-panel {
        width: 100% !important;
        height: auto;
        min-height: 50px;
        min-width: 0 !important;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        display: flex !important;
        flex: none !important;
        /* Reset horizontal animation for mobile to prevent navbar shifting */
        transform: translateY(20px) !important;
        opacity: 0 !important;
        transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    }

    .preview-panel {
        width: 100% !important;
        height: auto;
        min-height: 400px;
        display: flex !important;
        flex: none !important;
        overflow: visible;
        /* Reset horizontal animation for mobile */
        transform: translateY(20px) !important;
        opacity: 0 !important;
        transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
        transition-delay: 0.2s !important;
    }

    /* Ensure they return to 0 transform when visible */
    .panels-visible .editor-panel,
    .panels-visible .preview-panel {
        transform: translateY(0) !important;
        opacity: 1 !important;
    }

    .resizer {
        display: flex !important;
        width: 100% !important;
        height: 32px !important;
        cursor: row-resize !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        background: #0f172a !important;
        border-left: none !important;
        border-right: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        position: relative !important;
        z-index: 1000 !important;
        padding: 0 10px !important;
        touch-action: none !important;
    }

    .resizer-dots-top,
    .resizer-dots-bottom {
        display: block !important;
        writing-mode: horizontal-tb !important;
        color: rgba(255, 255, 255, 0.2) !important;
        font-size: 1.2rem !important;
        letter-spacing: 2px !important;
        flex: 1 !important;
        pointer-events: none !important;
    }

    .resizer-dots-top {
        text-align: right !important;
        padding-right: 20px !important;
    }

    .resizer-dots-bottom {
        text-align: left !important;
        padding-left: 20px !important;
    }

    .resizer-handle {
        width: 100px !important;
        height: 36px !important;
        background: #7063f3 !important;
        border-radius: 20px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        transform: none !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
        touch-action: none !important;
        transition: transform 0.2s, background 0.2s;
    }

    .resizer.resizer-active .resizer-handle {
        background: #8b80f9 !important;
        transform: scale(1.1) !important;
        box-shadow: 0 0 20px rgba(112, 99, 243, 0.4) !important;
    }

    .resizer.resizer-active {
        background: #1e293b !important;
    }

    .resizer-handle span {
        line-height: 0.6 !important;
        font-size: 1.2rem !important;
        color: white !important;
    }

    .resizer-handle .left-arrow {
        transform: rotate(90deg) !important;
    }

    .resizer-handle .right-arrow {
        transform: rotate(90deg) !important;
    }
}

@media (max-width: 768px) {
    .btn-recompile {
        min-width: unset;
        padding: 6px 9px !important;
    }

    .editor-toggle-pill {
        display: flex;
        background: #242e3c;
        padding: 4px 5px;
        border-radius: 20px;
        gap: 1px;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .toggle-btn {
        padding: 4px 5px;
    }

    .panel-label {
        padding: 4px 8px;
        height: 38px;
        gap: 8px;
    }

    .panel-label-right {
        gap: 8px;
        flex: 1;
        justify-content: flex-end;
    }

    .template-name-display {
        font-size: 0.65rem;
        max-width: 180px;
        padding: 2px 10px;
    }

    .template-version-controls {
        display: flex;
        gap: 6px;
    }

    .btn-version {
        padding: 5px 10px;
        gap: 6px;
        font-size: 0.7rem;
    }

    .btn-version span {
        display: inline !important;
    }

    .CodeMirror {
        font-size: 0.8rem;
    }

    .pdf-inner-container {
        padding: 0px !important;
    }
}

@media (max-width: 545px) {

    #fitWidthBtn,
    #fitPageBtn,
    .page-controls,
    .divider {
        display: none !important;
    }

    .btn-recompile {
        padding: 4px 8px !important;
        font-size: 0.75rem !important;
        min-width: unset !important;
        gap: 4px !important;
    }

    .btn-recompile i,
    .btn-recompile svg {
        width: 12px !important;
        height: 12px !important;
    }

    .btn-icon {
        padding: 4px !important;
    }

    .btn-icon svg {
        width: 14px !important;
        height: 14px !important;
    }

    .preview-toolbar {
        padding: 0 8px !important;
        height: 40px !important;
        justify-content: space-between !important;
    }

    .toolbar-left,
    .toolbar-middle,
    .toolbar-right {
        gap: 4px !important;
    }
}

@media (max-width: 390px) {
    .template-name-display {
        display: none !important;
    }
}

/* Panel Visibility Toggle */
.panels-visible .editor-panel,
.panels-visible .preview-panel {
    opacity: 1;
    transform: translateX(0);
}

.panels-visible .resizer {
    opacity: 1;
}

/* Staggered Toolbar Entrance */
.panel-label,
.preview-toolbar {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.panels-visible .panel-label,
.panels-visible .preview-toolbar {
    opacity: 1;
    transform: translateY(0);
}

.panels-visible .panel-label {
    transition-delay: 0.4s;
}

.panels-visible .preview-toolbar {
    transition-delay: 0.6s;
}

/* No Template/Resume Overlays */
.no-template-overlay {
    position: absolute;
    inset: 0;
    background: #2f3a4c;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    z-index: 90;
    text-align: center;
}

.no-template-content {
    max-width: 400px;
    animation: fadeIn 0.5s ease;
}

.no-template-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    color: #7063f3;
}

.no-template-title {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.no-template-overlay p {
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.no-template-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #7063f3;
    color: white !important;
    text-decoration: none !important;
    padding: 12px 32px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(112, 99, 243, 0.2);
    border: none;
    cursor: pointer;
}

.no-template-btn:hover {
    background: #5d52d9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(112, 99, 243, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure overlays sync with Light Mode */
[data-theme="light"] .no-template-overlay {
    background: #f1f5f9;
}

[data-theme="light"] .no-template-title {
    color: #1e293b;
}

[data-theme="light"] .no-template-overlay p {
    color: #475569;
}

[data-theme="light"] .no-template-btn {
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

/* ============================================
   EDITOR PAGE - Light Mode Overrides
   These MUST be at the end of the file to override
   the hardcoded dark backgrounds above.
   ============================================ */

/* CRITICAL: Navbar override for editor page */
[data-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .panel-label {
    background: #ffffff !important;
    color: #475569 !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .preview-toolbar {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03) !important;
}

[data-theme="light"] .editor-container,
[data-theme="light"] .workspace {
    background: #f1f5f9 !important;
}

[data-theme="light"] .editor-panel {
    border-right-color: #e2e8f0 !important;
}

[data-theme="light"] .preview-panel {
    background: #e2e8f0 !important;
}

[data-theme="light"] .pdf-viewer {
    background: #e2e8f0 !important;
}

[data-theme="light"] .pdf-inner-container {
    background: #e2e8f0 !important;
}

[data-theme="light"] .resizer {
    background: #e2e8f0 !important;
    border-left: 1px solid #cbd5e1 !important;
    border-right: 1px solid #cbd5e1 !important;
}

[data-theme="light"] .resizer:hover {
    background: #cbd5e1 !important;
}

[data-theme="light"] .resizer-handle {
    background: #94a3b8 !important;
    border-color: #cbd5e1 !important;
}

[data-theme="light"] .resizer:hover .resizer-handle {
    background: #4f46e5 !important;
}

[data-theme="light"] .resizer-dots-top,
[data-theme="light"] .resizer-dots-bottom {
    color: rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .btn-icon {
    color: #475569 !important;
}

[data-theme="light"] .btn-icon:hover {
    background: #f1f5f9 !important;
    color: #1e293b !important;
}

[data-theme="light"] .page-controls,
[data-theme="light"] .zoom-controls {
    background: #f1f5f9 !important;
}

[data-theme="light"] .page-info,
[data-theme="light"] .zoom-value {
    color: #475569 !important;
}

[data-theme="light"] .editor-toggle-pill {
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .toggle-btn {
    color: #64748b !important;
}

[data-theme="light"] .toggle-btn.active {
    background: #4f46e5 !important;
    color: white !important;
}

[data-theme="light"] .template-name-display {
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    color: #475569 !important;
}

[data-theme="light"] .divider {
    background: #e2e8f0 !important;
}

[data-theme="light"] .loader-content {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .loader-status {
    color: #1e293b !important;
}

[data-theme="light"] .pdf-preview-loader {
    background: rgba(255, 255, 255, 0.3) !important;
}

[data-theme="light"] .skeleton-container {
    background: #ffffff !important;
    border: 1px solid #e2e8f0;
}

[data-theme="light"] .skeleton-header,
[data-theme="light"] .skeleton-subheader,
[data-theme="light"] .skeleton-line {
    background: #f1f5f9 !important;
}

[data-theme="light"] .skeleton-section-title {
    background: #e2e8f0 !important;
}

[data-theme="light"] .skeleton-shimmer {
    background: linear-gradient(90deg,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.05) 50%,
            rgba(0, 0, 0, 0) 100%);
}

[data-theme="light"] #latexEditor {
    background: #ffffff !important;
    color: #1e293b !important;
}

[data-theme="light"] .CodeMirror {
    background: #ffffff !important;
    color: #1e293b !important;
}

[data-theme="light"] .CodeMirror-gutters {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .CodeMirror-linenumber {
    color: #94a3b8 !important;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}