@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

        body {
            font-family: 'Inter', sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }

        /* 헤더 타이틀: 창 너비에 따라 글자 크기 자동 조절 */
        .app-header-title {
            font-size: clamp(0.65rem, 0.42rem + 2.8vw, 1.25rem);
            line-height: 1.25;
        }
        @media (min-width: 1024px) {
            .app-header-title { font-size: 1.125rem; line-height: 1.2; }
        }
        @media (min-width: 1280px) {
            .app-header-title { font-size: 1.25rem; }
        }
        .dark body { background-color: #0f172a; color: #f1f5f9; }

        .markdown-body {
            line-height: 1.6;
            word-wrap: break-word;
            cursor: text;
            font-size: var(--md-app-font-size, 16px);
        }

        :root {
            --code-bg-color: #1e293b;
            --code-text-color: #f8fafc;
        }

        .markdown-body h1 { font-size: calc(var(--md-app-font-size, 16px) * 2.25); font-weight: 800; margin-top: 1.5rem; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.5rem; }
        .markdown-body h2 { font-size: calc(var(--md-app-font-size, 16px) * 1.875); font-weight: 700; margin-top: 1.25rem; margin-bottom: 0.75rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.3rem; }
        .markdown-body h3 { font-size: calc(var(--md-app-font-size, 16px) * 1.5); font-weight: 600; margin-top: 1rem; margin-bottom: 0.5rem; }
        .markdown-body h4 { font-size: calc(var(--md-app-font-size, 16px) * 1.25); font-weight: 600; margin-top: 0.9rem; margin-bottom: 0.45rem; }
        .markdown-body h5 { font-size: calc(var(--md-app-font-size, 16px) * 1.1); font-weight: 600; margin-top: 0.85rem; margin-bottom: 0.4rem; }
        .markdown-body p { margin-bottom: 1rem; }
        .markdown-body ul, .markdown-body ol { margin-bottom: 1rem; padding-left: 1.5rem; list-style-position: outside; }
        .markdown-body ul { list-style-type: disc; }
        .markdown-body ol { list-style-type: decimal; }
        .markdown-body li.task-list-item {
            list-style: none;
            margin-left: -1.25rem;
        }
        .markdown-body li.task-list-item input[type="checkbox"] {
            margin-right: 0.45rem;
            vertical-align: middle;
        }
        /* 라이트 모드: 코드 블록 회색 배경, 검정 글씨. 형광펜 효과 제거 */
        .markdown-body code { padding: 0.2rem 0.4rem; border-radius: 0.25rem; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; background-color: #e2e8f0; color: #1e293b; }
        .markdown-body pre { background-color: #e2e8f0; color: #1e293b; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; margin-bottom: 1rem; }
        .markdown-body pre code { background-color: transparent !important; padding: 0; color: inherit; }
        .markdown-body blockquote { border-left: 4px solid #cbd5e1; padding-left: 1rem; color: #64748b; font-style: italic; margin-bottom: 1rem; }
        .markdown-body img { max-width: 100%; border-radius: 0.5rem; margin: 1rem 0; }
        .markdown-body a { color: #3b82f6; text-decoration: underline; }
        .markdown-body b, .markdown-body strong { font-weight: 700; }
        .markdown-body table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 1rem;
            border: 2px solid #94a3b8;
        }
        .markdown-body th,
        .markdown-body td {
            border: 1px solid #94a3b8;
            padding: 0.45rem 0.65rem;
            text-align: left;
            vertical-align: top;
        }
        .markdown-body th[align="left"],
        .markdown-body td[align="left"] { text-align: left; }
        .markdown-body th[align="center"],
        .markdown-body td[align="center"] { text-align: center; }
        .markdown-body th[align="right"],
        .markdown-body td[align="right"] { text-align: right; }
        .markdown-body thead th {
            background-color: #e2e8f0;
            font-weight: 700;
        }
        .markdown-body .md-footnotes {
            margin-top: 1.25rem;
            font-size: 0.92em;
            color: #334155;
        }
        .markdown-body .md-footnotes ol {
            margin: 0.5rem 0 0;
            padding-left: 1.25rem;
        }
        .markdown-body .md-footnote-ref a,
        .markdown-body .md-footnote-backref {
            color: #2563eb;
            text-decoration: none;
            font-weight: 700;
        }
        .markdown-body .md-footnote-ref a:hover,
        .markdown-body .md-footnote-backref:hover {
            text-decoration: underline;
        }

        /* KaTeX (다크 모드에서도 본문과 대비) */
        .markdown-body .katex { font-size: 1.05em; }
        .dark .markdown-body .katex { color: #e2e8f0; }

        /* Dark mode markdown */
        .dark .markdown-body h1, .dark .markdown-body h2 { border-bottom-color: #334155; }
        .dark .markdown-body code { background-color: #334155; color: #e2e8f0; }
        .dark .markdown-body pre { background-color: var(--code-bg-color); color: var(--code-text-color); }
        .dark .markdown-body pre code { background-color: transparent !important; padding: 0; color: inherit; }
        .dark .markdown-body blockquote { border-left-color: #475569; color: #94a3b8; }
        .dark .markdown-body a { color: #60a5fa; }
        .dark .markdown-body table {
            border-color: #64748b;
        }
        .dark .markdown-body th,
        .dark .markdown-body td {
            border-color: #64748b;
        }
        .dark .markdown-body thead th {
            background-color: #1e293b;
        }
        .dark .markdown-body .md-footnotes {
            color: #cbd5e1;
        }
        .dark .markdown-body .md-footnote-ref a,
        .dark .markdown-body .md-footnote-backref {
            color: #93c5fd;
        }

        #drop-zone.drag-over {
            background-color: rgba(59, 130, 246, 0.1);
            border: 2px dashed #3b82f6;
        }
        .dark #drop-zone.drag-over {
            background-color: rgba(96, 165, 250, 0.15);
            border-color: #60a5fa;
        }

        @media print {
            .no-print { display: none !important; }
            html, body {
                height: auto !important;
                overflow: visible !important;
                background-color: white !important;
            }
            body.printing-active > *:not(#print-root) { display: none !important; }
            body.printing-active #print-root { display: block !important; }
            body, .markdown-body { background-color: white !important; color: #1e293b !important; }
            .print-area { padding: 0 !important; margin: 0 !important; width: 100% !important; max-width: none !important; }
            .sidebar-container { display: none !important; }
            #print-root {
                position: static !important;
                inset: auto !important;
                width: auto !important;
                min-height: auto !important;
                padding: 0 !important;
                margin: 0 !important;
                overflow: visible !important;
                background: white !important;
            }
            #print-root .markdown-body {
                width: auto !important;
                max-width: none !important;
                margin: 0 !important;
                padding: 0 !important;
                overflow: visible !important;
            }
            #print-root pre,
            #print-root blockquote,
            #print-root table,
            #print-root img {
                break-inside: avoid;
                page-break-inside: avoid;
            }
        }

        #print-root {
            display: none;
        }

        #editor-textarea {
            font-family: 'JetBrains Mono', monospace;
            resize: none;
        }

        .custom-scrollbar {
            scrollbar-width: auto;
            scrollbar-color: #94a3b8 #e2e8f0;
        }
        .custom-scrollbar::-webkit-scrollbar {
            width: 16px;
            height: 16px;
        }
        .custom-scrollbar::-webkit-scrollbar-track {
            background: #e2e8f0;
            border-left: 1px solid #cbd5e1;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
            border-radius: 999px;
            border: 3px solid #e2e8f0;
            min-height: 56px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
        }
        .dark .custom-scrollbar {
            scrollbar-color: #cbd5e1 #0f172a;
        }
        .dark .custom-scrollbar::-webkit-scrollbar-track {
            background: #0f172a;
            border-left: 1px solid #334155;
        }
        .dark .custom-scrollbar::-webkit-scrollbar-thumb {
            background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 100%);
            border-color: #0f172a;
        }
        .dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(180deg, #f8fafc 0%, #cbd5e1 100%);
        }

        /* 편집창 전용 라이트 모드 (버튼으로 토글) */
        #content-viewport.editor-light-mode {
            background-color: #f8fafc;
        }
        #content-viewport.editor-light-mode #viewer-edit-ta {
            background-color: #ffffff;
            color: #1e293b;
            caret-color: #0f172a;
        }
        #content-viewport.editor-light-mode #viewer-edit-ta::placeholder {
            color: #94a3b8;
        }
        #content-viewport.editor-light-mode.custom-scrollbar::-webkit-scrollbar-track { background: #e2e8f0; }
        #content-viewport.editor-light-mode.custom-scrollbar::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%); border-color: #e2e8f0; }

        .scroll-jump-rail {
            position: absolute;
            top: 50%;
            right: 14px;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            gap: 10px;
            z-index: 15;
            pointer-events: none;
        }

        .scroll-jump-btn {
            pointer-events: auto;
            min-width: 52px;
            padding: 10px 12px;
            border-radius: 12px;
            border: 1px solid rgba(148, 163, 184, 0.6);
            background: rgba(255, 255, 255, 0.92);
            color: #0f172a;
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0.03em;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
            backdrop-filter: blur(6px);
            transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
        }

        .scroll-jump-btn:hover {
            transform: translateX(-2px);
            background: #ffffff;
            border-color: rgba(59, 130, 246, 0.45);
        }

        .scroll-jump-btn:active {
            transform: translateX(0);
        }

        .dark .scroll-jump-btn {
            background: rgba(15, 23, 42, 0.88);
            color: #f8fafc;
            border-color: rgba(148, 163, 184, 0.35);
            box-shadow: 0 10px 24px rgba(2, 6, 23, 0.35);
        }

        .dark .scroll-jump-btn:hover {
            background: rgba(30, 41, 59, 0.96);
            border-color: rgba(96, 165, 250, 0.5);
        }

        /* View mode: tighten sub-toolbar footprint when edit tools are hidden */
        #toolbar.toolbar-view-compact {
            padding-top: 0.2rem !important;
            padding-bottom: 0.2rem !important;
            gap: 0 !important;
        }

        @media (max-width: 640px) {
            .scroll-jump-rail {
                right: 8px;
                gap: 8px;
            }

            .scroll-jump-btn {
                min-width: 46px;
                padding: 9px 10px;
                font-size: 11px;
            }
        }
        
        /* Sidebar Transitions */
        #sidebar {
            transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .sidebar-collapsed {
            width: 4.5rem !important; /* 축소된 너비 */
        }

        .sidebar-collapsed .sidebar-text,
        .sidebar-collapsed #db-search,
        .sidebar-collapsed .search-icon-only {
            display: none !important;
        }

        .sidebar-collapsed .sidebar-header-btns {
            flex-direction: column;
            align-items: center;
            gap: 0.5rem;
        }

        .sidebar-collapsed .doc-action-btns {
            display: none !important;
        }

        .sidebar-collapsed .doc-item-inner {
            justify-content: center;
        }

        /* Header AI toggle buttons - purple tone */
        #btn-scholar-ai,
        #btn-sspimg-ai {
            background: #eef2ff !important;
            border: 1px solid #a5b4fc !important;
            color: #4338ca !important;
            font-weight: 700 !important;
        }

        #btn-scholar-ai:hover,
        #btn-sspimg-ai:hover {
            background: #e0e7ff !important;
            border-color: #818cf8 !important;
        }
