/* ============================================================
   pdf.tools — Design System
   Dark, minimal, tool-first aesthetic.
   ============================================================ */

/* --- Reset & Base --- */

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

/* Light theme overrides */
[data-theme="light"] {
    --bg-root: #fafafa;
    --bg-surface: #ffffff;
    --bg-raised: #f4f4f5;
    --bg-hover: #e4e4e7;
    --bg-input: #ffffff;
    --border: #e4e4e7;
    --border-subtle: #f0f0f2;
    --border-hover: #a1a1aa;
    --text-primary: #09090b;
    --text-secondary: #3f3f46;
    --text-muted: #71717a;
    --text-dim: #a1a1aa;
    --accent-bg: rgba(99, 102, 241, 0.06);
    --accent-bg-hover: rgba(99, 102, 241, 0.10);
    --success-bg: rgba(52, 211, 153, 0.06);
    --error-bg: rgba(248, 113, 113, 0.06);
}

:root {
    /* Palette */
    --bg-root: #09090b;
    --bg-surface: #0f0f12;
    --bg-raised: #18181b;
    --bg-hover: #1e1e23;
    --bg-input: #131316;

    --border: #27272a;
    --border-subtle: #1e1e23;
    --border-hover: #3f3f46;
    --border-focus: #6366f1;

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-dim: #52525b;

    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-bg: rgba(99, 102, 241, 0.08);
    --accent-bg-hover: rgba(99, 102, 241, 0.14);

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.08);
    --success-border: rgba(52, 211, 153, 0.2);

    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.08);
    --error-border: rgba(248, 113, 113, 0.2);

    --danger: #ef4444;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition: 150ms ease;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-root);
    color: var(--text-secondary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

img, svg {
    display: block;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Layout --- */

.main {
    flex: 1;
    padding: 2rem 1rem 4rem;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.container-tool {
    max-width: 640px;
}

/* --- Header --- */

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.back-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.back-link svg {
    width: 14px;
    height: 14px;
}

.back-link:hover {
    color: var(--text-secondary);
}

/* Badge */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.badge-local {
    background: rgba(52, 211, 153, 0.08);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.15);
}

.badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Intro --- */

.intro {
    text-align: center;
    padding: 2rem 0 2.5rem;
}

.intro-text {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.7;
}

.intro-text strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.hero-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin-bottom: 0.625rem;
}

.site-footer,
.tool-footer {
    padding: 14px 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-dim);
    margin-top: auto;
}

.site-footer a,
.tool-footer a {
    color: var(--text-muted);
    transition: color var(--transition);
}

.site-footer a:hover,
.tool-footer a:hover {
    color: var(--text-secondary);
}

.footer-sep {
    color: var(--text-dim);
    user-select: none;
}

/* --- Tool Grid (Index) --- */

.tool-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    background: var(--border-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-surface);
    transition: background var(--transition);
    cursor: pointer;
}

.tool-card:hover {
    background: var(--bg-hover);
}

.tool-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--accent-bg);
    color: var(--accent);
    flex-shrink: 0;
}

.tool-card-icon svg {
    width: 18px;
    height: 18px;
}

.tool-card-body {
    flex: 1;
    min-width: 0;
}

.tool-card-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.tool-card-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.tool-card-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    flex-shrink: 0;
    transition: color var(--transition), transform var(--transition);
}

.tool-card:hover .tool-card-arrow {
    color: var(--text-muted);
    transform: translateX(2px);
}

/* --- Footer Info --- */

.footer-info {
    padding: 2.5rem 0 0;
}

.footer-info-items {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.footer-info-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

.footer-info-divider {
    width: 1px;
    height: 12px;
    background: var(--border);
}

/* --- Tool Page --- */

.tool-main {
    padding-top: 1.5rem;
}

.tool-header {
    margin-bottom: 1.5rem;
}

.tool-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Drop Zone --- */

.drop-zone {
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-surface);
    margin-bottom: 1.5rem;
}

.drop-zone:hover,
.drop-zone.drag-active {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-zone-icon {
    width: 40px;
    height: 40px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.drop-zone:hover .drop-zone-icon {
    color: var(--accent);
}

.drop-zone-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.drop-zone-browse {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.drop-zone-hint {
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* --- File List --- */

.file-list {
    margin-bottom: 1.5rem;
}

.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.file-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-mono);
}

.file-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: background var(--transition);
}

.file-item:hover {
    background: var(--bg-hover);
}

/* --- Tool Options --- */

.tool-options {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 1.5rem;
}

.option-group {
    margin-bottom: 16px;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-mono);
}

.option-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.option-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* --- Form Elements --- */

.input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input::placeholder {
    color: var(--text-dim);
}

.input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.input.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

.input-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    font-family: var(--font-mono);
}

/* Radio */

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.radio-item input[type="radio"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-hover);
    border-radius: 50%;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    transition: border-color var(--transition);
}

.radio-item input[type="radio"]:checked {
    border-color: var(--accent);
}

.radio-item input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.radio-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Checkbox */

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-hover);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    transition: border-color var(--transition), background var(--transition);
}

.checkbox-item input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid var(--bg-root);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Range */

.range-input {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    appearance: none;
    cursor: pointer;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    cursor: pointer;
}

.range-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.range-value {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Button group */

.btn-group {
    display: flex;
    gap: 6px;
}

.btn-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.btn-option:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-option.active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
}

.btn-option-sub {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.btn-option.active .btn-option-sub {
    color: var(--accent);
    opacity: 0.7;
}

/* --- Buttons --- */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 28px;
    background: var(--accent);
    color: var(--bg-root);
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--bg-raised);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition);
    font-family: var(--font-sans);
}

.btn-text:hover {
    color: var(--accent-hover);
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition);
    font-family: var(--font-mono);
}

.btn-text-danger:hover {
    color: var(--danger);
}

/* Download button (used in JS) */

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-download:hover {
    background: var(--accent-bg-hover);
    border-color: rgba(99, 102, 241, 0.35);
}

.btn-download svg {
    width: 14px;
    height: 14px;
}

.btn-download-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-raised);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-download-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-download-secondary svg {
    width: 14px;
    height: 14px;
}

/* --- Process Section --- */

.process-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Spinner */

.spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

.spinner-track {
    opacity: 0.15;
}

.spinner-head {
    opacity: 0.8;
}

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

/* --- Progress --- */

.progress-section {
    margin-bottom: 1.5rem;
}

.progress-track {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease-in-out;
}

.progress-text {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 8px;
    font-family: var(--font-mono);
}

/* --- Results --- */

.results-section,
.error-section {
    margin-bottom: 1.5rem;
}

.result-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.result-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

.result-error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}

.result-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto 8px;
}

.result-success .result-icon {
    color: var(--success);
}

.result-error .result-icon {
    color: var(--error);
}

.result-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.result-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* --- Text Result --- */

.text-result {
    margin-top: 16px;
}

.text-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.text-result-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-mono);
}

.text-output {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.text-output::-webkit-scrollbar {
    width: 5px;
}

.text-output::-webkit-scrollbar-track {
    background: transparent;
}

.text-output::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.text-output pre {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    font-family: var(--font-mono);
    line-height: 1.6;
}

/* --- Footer --- */


/* --- Focus --- */

*:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* --- Animations --- */

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

.fade-in {
    animation: fadeIn 0.25s ease-out;
}

/* --- Responsive --- */

@media (min-width: 640px) {
    .main {
        padding: 2.5rem 1.5rem 5rem;
    }

    .header-inner {
        padding: 0 1.5rem;
    }

    .tool-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer-info-items {
        gap: 20px;
    }

    .drop-zone {
        padding: 3.5rem 2rem;
    }
}

@media (min-width: 960px) {
    .main {
        padding: 3rem 2rem 6rem;
    }

    .header-inner {
        padding: 0 2rem;
    }

    .tool-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .intro {
        padding: 2.5rem 0 3rem;
    }
}

/* Mobile tweaks */

@media (max-width: 639px) {
    .intro {
        padding: 1.5rem 0 2rem;
    }

    .intro-text {
        font-size: 13px;
    }

    .tool-card {
        padding: 12px 14px;
    }

    .footer-info-divider {
        display: none;
    }

    .footer-info-items {
        flex-direction: column;
        gap: 8px;
    }

    .option-row {
        grid-template-columns: 1fr;
    }

    .badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .radio-group {
        flex-direction: column;
        gap: 10px;
    }

    .btn-group {
        flex-direction: column;
    }

    .download-buttons {
        flex-direction: column;
        align-items: stretch;
    }
}

/* File remove button */
.remove-file-btn:hover {
    color: var(--danger) !important;
}

/* Page thumb selection */
.page-thumb.selected {
    border-color: var(--accent);
    background: var(--accent-bg);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}
