/* MarkForge theme system — CSS variables drive light/dark mode. */
:root {
    --app-bg: #F4F6FA;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --editor-bg: var(--surface-2);
    --border: #E2E8F0;
    --text: #0F172A;
    --text-2: #64748B;
    --muted: #94A3B8;
    --accent: #5B5FEF;
    --accent-hover: #4F46E5;
    --accent-soft: #EEF2FF;
    --success-bg: #DCFCE7;
    --success-text: #166534;
}

html.dark {
    --app-bg: #0F172A;
    --surface: #162033;
    --surface-2: #1B263B;
    --editor-bg: #111827;
    --border: #273449;
    --text: #E5E7EB;
    --text-2: #94A3B8;
    --muted: #64748B;
    --accent: #7C83FF;
    --accent-hover: #6366F1;
    --accent-soft: #202950;
    --success-bg: #123B2A;
    --success-text: #86EFAC;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--app-bg);
}

body {
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    transition: background-color .18s ease, color .18s ease;
}

/* Main application shell fills the viewport in both themes. */
main {
    min-height: 100vh;
    background: var(--app-bg);
}

header, [class*="bg-white"], [class*="bg-gray-800"] {
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.drop-zone, #drop-zone {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}

input, textarea {
    background-color: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

#markdown-output {
    background-color: var(--editor-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    font-family: 'JetBrains Mono', monospace;
}

.bg-gray-50, .dark\:bg-gray-900 {
    background-color: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

button, .text-gray-900, .dark\:text-gray-100 { color: var(--text); }
.text-gray-500, .dark\:text-gray-400 { color: var(--text-2) !important; }
.text-gray-400, .dark\:text-gray-500 { color: var(--muted) !important; }

.bg-indigo-600, .bg-indigo-500 { background-color: var(--accent) !important; }
.hover\:bg-indigo-700:hover { background-color: var(--accent-hover) !important; }
.border-indigo-500 { border-color: var(--accent) !important; }
.text-indigo-600, .text-indigo-500, .dark\:text-indigo-400 { color: var(--accent) !important; }

.bg-green-50, .dark\:bg-green-900\/30 { background-color: var(--success-bg) !important; }
.text-green-700, .dark\:text-green-300, .text-green-600 { color: var(--success-text) !important; }

.drop-highlight { border-color: var(--accent) !important; background: var(--accent-soft) !important; }

.rounded-xl, .rounded-lg { border-radius: 12px !important; }

.toggle-track { transition: background-color .18s ease; }
.toggle-track.active { background: var(--accent) !important; }
.toggle-track.active .toggle-knob { transform: translateX(18px); }
.toggle-knob { transition: transform .18s ease; }

* { scrollbar-color: var(--border) transparent; scrollbar-width: thin; }

.preview-content h1 { font-size: 1.75rem; font-weight: 700; margin: 1rem 0 0.5rem; }
.preview-content h2 { font-size: 1.4rem; font-weight: 600; margin: 0.8rem 0 0.4rem; }
.preview-content h3 { font-size: 1.15rem; font-weight: 600; margin: 0.6rem 0 0.3rem; }
.preview-content p { margin: 0.4rem 0; }
.preview-content ul { list-style: disc; padding-left: 1.5rem; margin: 0.4rem 0; }
.preview-content ol { list-style: decimal; padding-left: 1.5rem; margin: 0.4rem 0; }
.preview-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 0.5rem 0; opacity: 0.85; }
.preview-content code { background: var(--accent-soft); padding: 0.1rem 0.3rem; border-radius: 3px; font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
.preview-content pre { background: var(--surface-2); padding: 1rem; border-radius: 6px; overflow-x: auto; margin: 0.5rem 0; }
.preview-content pre code { background: none; padding: 0; }
.preview-content table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; display: block; overflow-x: auto; max-width: 100%; }
.preview-content th, .preview-content td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.preview-content hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.preview-content a { color: var(--accent); text-decoration: underline; }
.preview-content strong { font-weight: 700; }
.preview-content em { font-style: italic; }
.preview-content s, .preview-content del { text-decoration: line-through; opacity: 0.75; }

/* Markdown Previewer: task-list checkboxes (decorative, non-interactive) */
.preview-content li.task-list-item { list-style: none; }
.task-list-item-checkbox {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.45em;
    vertical-align: middle;
    position: relative;
    top: -0.1em;
    border: 1.5px solid var(--muted);
    border-radius: 3px;
    background: var(--surface-2);
}
.task-list-item-checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}
.task-list-item-checkbox.checked::after {
    content: '';
    position: absolute;
    left: 0.18em;
    top: 0.02em;
    width: 0.28em;
    height: 0.5em;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Markdown Previewer: remote images are never fetched — shown as a plain-text placeholder */
.md-image-placeholder {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 0.85em;
    vertical-align: top;
}
.md-image-placeholder-icon { font-size: 1.1em; line-height: 1.3; }
.md-image-placeholder-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.md-image-placeholder-alt { font-weight: 600; color: var(--text); }
.md-image-placeholder-url { word-break: break-all; color: var(--text-2); }

/* Shared site footer — homepage + legal pages */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--app-bg);
}
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* Homepage informational content (below the converter) */
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}
.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    float: right;
    color: var(--text-2);
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p {
    margin-top: 0.75rem;
    color: var(--text-2);
    line-height: 1.7;
}

/* Markdown Chunker: chunk result cards */
.chunk-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.chunk-card > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}
.chunk-card > summary::-webkit-details-marker { display: none; }
.chunk-card > summary::after {
    content: '+';
    color: var(--text-2);
    margin-left: auto;
}
.chunk-card[open] > summary::after { content: '\2212'; }
.chunk-card-title { font-weight: 600; font-size: 0.9rem; }
.chunk-card-meta { font-size: 0.75rem; color: var(--text-2); }
.chunk-warning { color: #B45309; font-weight: 600; }
html.dark .chunk-warning { color: #FBBF24; }
.chunk-card-body { padding: 0 1.1rem 1.1rem; }
.chunk-textarea {
    width: 100%;
    height: 12rem;
    resize: vertical;
    background: var(--editor-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: pre;
    overflow: auto;
}
.chunk-card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.chunk-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    transition: background-color .18s ease;
}
.chunk-action-btn:hover { background: var(--surface-2); }

/* Guides hub + guide articles */
.guide-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.guide-main { max-width: 760px; }
.guide-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin: 2.25rem 0 0.9rem;
}
.guide-content h2:first-of-type { margin-top: 0; }
.guide-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 1.5rem 0 0.5rem;
}
.guide-content p { margin: 0.9rem 0; line-height: 1.75; color: var(--text); }
.guide-content ul, .guide-content ol { padding-left: 1.5rem; margin: 0.9rem 0; }
.guide-content ul { list-style: disc; }
.guide-content ol { list-style: decimal; }
.guide-content li { margin: 0.4rem 0; line-height: 1.75; }
.guide-content a { color: var(--accent); text-decoration: underline; }
.guide-content strong { font-weight: 700; }
.guide-table-wrap { overflow-x: auto; margin: 1rem 0; }
.guide-content table { border-collapse: collapse; width: 100%; min-width: 420px; }
.guide-content th, .guide-content td { border: 1px solid var(--border); padding: 0.55rem 0.8rem; text-align: left; line-height: 1.5; }
.guide-content th { background: var(--surface-2); font-weight: 600; }
.guide-content code {
    background: var(--accent-soft);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
}
.guide-content pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.65;
}
.guide-content pre code { background: none; padding: 0; }
.guide-updated { color: var(--text-2); font-size: 0.875rem; margin-bottom: 0.5rem; }

/* Legal pages (Privacy / Terms) */
.legal-main { max-width: 840px; }
.legal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.legal-content h1 { color: var(--text); }
.legal-content h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 1.75rem 0 0.75rem;
}
.legal-content h2:first-of-type { margin-top: 0; }
.legal-content p { margin: 0.75rem 0; line-height: 1.7; color: var(--text); }
.legal-content ul { list-style: disc; padding-left: 1.5rem; margin: 0.75rem 0; }
.legal-content li { margin: 0.35rem 0; line-height: 1.7; }
.legal-content a { color: var(--accent); text-decoration: underline; }
.legal-content strong { font-weight: 700; }
.legal-updated { color: var(--text-2); font-size: 0.875rem; margin-bottom: 1.5rem; }
