:root {
    --primary: #e74c3c;
    --primary-hover: #c0392b;
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --bg-surface: #ffffff;
    --bg-input: #f1f3f5;
    --text: #1a1a2e;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border: #e9ecef;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-surface: #16213e;
    --bg-input: #1a1a2e;
    --text: #e8e8e8;
    --text-secondary: #a0a0b0;
    --text-muted: #5a5a7a;
    --border: #2a2a4a;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.2rem;
}

.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: all var(--transition);
}
.theme-toggle:hover { background: var(--border); }

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
.sun-icon { display: none; }
.moon-icon { display: block; }

/* Main content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

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

/* Hero */
.hero {
    text-align: center;
    padding: 48px 0 40px;
}
.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

/* Tool Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding-bottom: 40px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: attr(data-color);
    opacity: 0;
    transition: opacity var(--transition);
}
.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}
.tool-card:hover::before { opacity: 1; }

.tool-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--text);
    opacity: 0.8;
}
.tool-card:hover .tool-icon { opacity: 1; }

.tool-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.tool-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Tool View */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 8px 0;
    margin-bottom: 16px;
    font-family: inherit;
    transition: color var(--transition);
}
.back-btn:hover { color: var(--text); }

.tool-header {
    margin-bottom: 32px;
}
.tool-header h1,
.tool-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.tool-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
    position: relative;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.03);
}
.upload-zone svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.upload-zone h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.upload-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Options Panel */
.options-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 20px;
}

.option-group {
    margin-bottom: 20px;
}
.option-group:last-child { margin-bottom: 0; }
.option-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.option-group input[type="text"],
.option-group input[type="number"],
.option-group input[type="password"],
.option-group input[type="color"],
.option-group select,
.option-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border var(--transition);
    outline: none;
}
.option-group input:focus,
.option-group select:focus,
.option-group textarea:focus {
    border-color: var(--primary);
}

.option-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.radio-option {
    flex: 1;
    min-width: 100px;
}
.radio-option input { display: none; }
.radio-option label {
    display: block;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 0;
}
.radio-option input:checked + label {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.08);
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* Page Thumbnails */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.page-thumb {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    text-align: center;
    cursor: grab;
    transition: all var(--transition);
    position: relative;
    user-select: none;
}
.page-thumb:hover { border-color: var(--primary); }
.page-thumb.selected { border-color: var(--primary); background: rgba(231, 76, 60, 0.05); }
.page-thumb.sortable-ghost { opacity: 0.4; }
.page-thumb.sortable-chosen { box-shadow: var(--shadow-hover); }

.page-thumb img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 8px;
    pointer-events: none;
}
.page-thumb .page-num {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.page-thumb .page-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}
.page-thumb:hover .page-actions { opacity: 1; }

.page-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all var(--transition);
}
.page-action-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* File List */
.file-list {
    margin-top: 16px;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: grab;
}
.file-item .file-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: var(--primary);
}
.file-item .file-info {
    flex: 1;
    min-width: 0;
}
.file-item .file-name {
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-item .file-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.file-item .file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
    transition: color var(--transition);
}
.file-item .file-remove:hover { color: var(--primary); }
.file-item.sortable-ghost { opacity: 0.4; }

/* Progress */
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.progress-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-hover);
    min-width: 300px;
}
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-card h3 { font-size: 1rem; margin-bottom: 4px; }
.progress-card p { color: var(--text-secondary); font-size: 0.85rem; }

/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-hover);
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { border-left: 4px solid #2ecc71; }
.toast.error { border-left: 4px solid #e74c3c; }
.toast.info { border-left: 4px solid #3498db; }

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

/* Results */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    margin-top: 24px;
}
.result-card .result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: #2ecc71;
}
.result-card h3 { font-size: 1.2rem; margin-bottom: 8px; }
.result-card .result-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Extracted Text */
.text-output {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-top: 16px;
}

/* Compression stats bar */
.stats-bar {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}
.stat-item {
    text-align: center;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.75rem; }
    .tools-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .tool-card { padding: 20px 16px; }
    .navbar { padding: 12px 16px; }
    main { padding: 20px 16px; }
    .upload-zone { padding: 40px 20px; }
    .option-row { grid-template-columns: 1fr; }
}

/* Color Picker Fix */
input[type="color"] {
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Add more button */
.add-more-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition);
    position: relative;
}
.add-more-zone:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.add-more-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Checkbox styled */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* Nav actions group */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Donate nav button */
.donate-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary), #c0392b);
    color: #fff;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}
.donate-nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}
.donate-nav-btn svg {
    fill: #fff;
    stroke: none;
}

/* Donate Page */
.donate-page {
    max-width: 900px;
    margin: 0 auto;
}

.donate-hero {
    text-align: center;
    padding: 20px 0 40px;
}
.donate-heart {
    margin-bottom: 20px;
    animation: heartbeat 1.5s ease-in-out infinite;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    60% { transform: scale(1); }
}
.donate-hero h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
}
.donate-hero p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto;
}

/* Donate Grid */
.donate-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 32px;
}

.donate-card {
    flex: 0 1 300px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.donate-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}

.donate-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.donate-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.donate-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 18px;
    flex: 1;
}

.btn-donate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    width: 100%;
}
.btn-donate:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.donate-footer-note {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* PDF Editor */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.editor-tool {
    width: 36px; height: 36px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 6px;
    color: var(--text);
    transition: all var(--transition);
}
.editor-tool:hover { border-color: var(--primary); }
.editor-tool.active { border-color: var(--primary); background: var(--primary); color: white; }
.editor-tool svg { width: 18px; height: 18px; }
.toolbar-sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }
.toolbar-option {
    display: flex; align-items: center; gap: 4px;
    color: var(--text-secondary); font-size: 0.8rem;
}
.toolbar-option input[type="number"] {
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
}
.toolbar-option input[type="color"] {
    width: 32px; height: 32px; border: 1px solid var(--border);
    border-radius: 6px; cursor: pointer; padding: 2px; background: var(--bg-input);
}

.editor-workspace {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    overflow: auto;
    max-height: 72vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.editor-page {
    position: relative;
    display: inline-block;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    background: white;
}
.editor-page img { display: block; max-width: 100%; height: auto; user-select: none; }
.editor-page canvas,
#editor-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
#editor-overlay { z-index: 2; cursor: default; }
.editor-page canvas { z-index: 1; pointer-events: none; }

.editor-element { position: absolute; cursor: move; }
.editor-element.selected { outline: 2px solid var(--primary); outline-offset: 2px; }
.editor-el-text { white-space: pre-wrap; pointer-events: all; user-select: none; }
.editor-el-img { pointer-events: all; }
.editor-el-img img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.editor-el-rect { pointer-events: all; box-sizing: border-box; }
.editor-el-hl { pointer-events: all; }

.editor-resize-handle {
    position: absolute; bottom: -5px; right: -5px;
    width: 12px; height: 12px;
    background: var(--primary); border: 2px solid white;
    border-radius: 2px; cursor: nwse-resize; z-index: 3;
}
.editor-draw-preview {
    position: absolute; border: 2px dashed var(--primary);
    pointer-events: none; box-sizing: border-box;
}
.editor-text-popup {
    position: absolute;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 100;
    min-width: 220px;
}
.editor-text-popup textarea {
    width: 100%; padding: 8px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text);
    font-family: inherit; font-size: 0.9rem; resize: vertical;
}
.editor-page-nav {
    display: flex; align-items: center; justify-content: center;
    gap: 16px; margin: 16px 0;
}
.editor-elements-list {
    display: flex; flex-direction: column; gap: 4px; margin: 12px 0;
    max-height: 160px; overflow-y: auto;
}
.editor-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; background: var(--bg-card);
    border: 2px solid transparent; border-radius: var(--radius-sm);
    font-size: 0.85rem; cursor: pointer; transition: all var(--transition);
}
.editor-list-item:hover { background: var(--bg-input); }
.editor-list-item.selected { border-color: var(--primary); }
.editor-list-swatch {
    display: inline-block; width: 12px; height: 12px;
    border-radius: 3px; flex-shrink: 0;
}
.editor-list-del {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.3rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.editor-list-del:hover { color: #e74c3c; }

@media (max-width: 768px) {
    .donate-card { flex-basis: 100%; }
    .donate-nav-btn span { display: none; }
}

/* Organize PDF (merge + reorder + split) */
.org-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.org-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.org-add-btn { position: relative; overflow: hidden; cursor: pointer; }
.org-add-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.org-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-secondary); }
.org-legend-item { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.org-hint { margin-top: 12px; color: var(--text-secondary); font-size: 0.85rem; }

.org-thumb { border-left: 4px solid var(--file-color, var(--border)); }
.org-thumb img { transition: transform var(--transition); }
.org-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.org-thumb .page-num .org-src { font-weight: 400; color: var(--text-muted); font-size: 0.7rem; }
.org-thumb .page-actions { z-index: 2; }
.org-remove:hover { background: #c0392b !important; border-color: #c0392b !important; }

.org-cut-marker {
    display: none;
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translate(100%, -50%);
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    z-index: 3;
    pointer-events: none;
    white-space: nowrap;
}
.org-thumb.org-cut { border-right: 3px dashed var(--primary); }
.org-thumb.org-cut .org-cut-marker { display: block; }
.org-grid { gap: 22px; }

.org-summary-row { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.org-summary { color: var(--text-secondary); font-size: 0.9rem; padding-bottom: 10px; }
.org-warn { color: var(--primary); }

/* Community (discussions + suggestions) */
.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color var(--transition);
}
.nav-link:hover { color: var(--text); }

.comm-page { max-width: 820px; margin: 0 auto; }
.comm-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.comm-tab {
    padding: 10px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.comm-tab:hover { color: var(--text); }
.comm-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.comm-blurb { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 16px; }

.comm-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.comm-bar .btn { padding: 10px 20px; font-size: 0.9rem; }
.comm-bar select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

.comm-form { margin-top: 16px; }
.comm-form .option-group { margin-bottom: 12px; }
.comm-form textarea { resize: vertical; }
.comm-form-row { display: flex; gap: 12px; align-items: flex-start; }
.comm-form-row .option-group { flex: 1; max-width: 260px; margin-bottom: 0; }
.comm-form-row .btn { margin-left: auto; padding: 10px 24px; }
.comm-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

#comm-list { margin-top: 16px; }
.comm-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: border-color var(--transition);
}
.comm-row:hover { border-color: var(--text-muted); }
.comm-row-main { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.comm-row-main h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.comm-excerpt {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.comm-meta { color: var(--text-muted); font-size: 0.78rem; }
.comm-meta strong { color: var(--text-secondary); }
.comm-meta a { color: inherit; text-decoration: none; }
.comm-meta a:hover { color: var(--primary); }

.comm-vote {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 44px;
    padding: 6px 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}
.comm-vote:hover { border-color: var(--primary); color: var(--primary); }
.comm-vote.voted { background: var(--primary); border-color: var(--primary); color: #fff; }

.comm-back { text-decoration: none; }
.comm-op {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.comm-op-main { flex: 1; min-width: 0; }
.comm-op h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; overflow-wrap: anywhere; }
.comm-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
    line-height: 1.55;
    margin-top: 10px;
}
.comm-quote { color: #2e9e5b; }
.comm-ref { color: var(--primary); text-decoration: none; }
.comm-ref:hover { text-decoration: underline; }
.comm-post {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: border-color 0.4s ease;
}
.comm-post .comm-body { margin-top: 6px; }
.comm-post.comm-flash { border-color: var(--primary); }
.comm-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }
#comm-more { display: block; margin: 16px auto 0; }

@media (max-width: 768px) {
    .nav-actions { gap: 10px; }
    .nav-link { font-size: 0.8rem; }
    .comm-row { padding: 12px; gap: 10px; }
    .comm-op { padding: 14px; }
}
@media (max-width: 520px) {
    .logo span { display: none; }
}

/* Tool cards are links */
a.tool-card { text-decoration: none; color: inherit; }

/* How-to text under each tool */
.tool-seo {
    max-width: 720px;
    margin: 48px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}
.tool-seo:empty { display: none; }
.tool-seo h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.tool-seo ol { padding-left: 20px; margin-bottom: 12px; }

/* Share prompt after a download */
.share-card {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 200;
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    animation: fadeIn 0.3s ease;
}
.share-card strong { font-size: 0.95rem; }
.share-card p { font-size: 0.85rem; color: var(--text-secondary); margin: 4px 0 12px; }
.share-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
.share-close:hover { color: var(--text); }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.share-buttons a,
.share-buttons button {
    padding: 7px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
}
.share-buttons a:hover,
.share-buttons button:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (max-width: 520px) {
    .share-card { left: 16px; bottom: 16px; }
}

/* Donation cards with brand logos */
.donate-card-logo { background: #fff; border: 1px solid var(--border); overflow: hidden; }
.donate-card-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* One color per tool */
.tool-card::before { background: var(--c, var(--primary)); }
.tool-card .tool-icon {
    width: 52px;
    height: 52px;
    padding: 10px;
    border-radius: 12px;
    color: var(--c, var(--text));
    background: color-mix(in srgb, var(--c, var(--text)) 13%, transparent);
    opacity: 1;
}
.tool-card:hover { border-color: var(--c, transparent); }
.tool-header h1 { border-left: 5px solid var(--c, var(--primary)); padding-left: 14px; }
.tool-more { margin-top: 14px; line-height: 1.9; }
.tool-more a { color: var(--c, var(--primary)); text-decoration: none; font-weight: 600; }
.tool-more a:hover { text-decoration: underline; }

/* Home: reasons + FAQ */
.why-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    padding: 8px 0 40px;
}
.why-item { padding: 20px 4px; border-top: 3px solid var(--primary); }
.why-item h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.why-item p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.faq { max-width: 760px; margin: 0 auto; padding-bottom: 40px; }
.faq h2 { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: 20px; }
.faq details {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 8px;
}
.faq summary { font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.faq details p { margin-top: 10px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.55; }
