/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --border-color: #30363d;
    --border-focus: #58a6ff;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --error: #f85149;
    --warning: #d29922;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Layout ===== */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}
.hero h1 {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}
.hero p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 500px;
    margin: 0 auto;
}

/* ===== Converter Card ===== */
.converter {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}
.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}
.upload-zone:focus-visible {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}
.upload-icon {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.upload-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.upload-text strong { color: var(--accent); }
.upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ===== Status ===== */
.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-top: 1rem;
    animation: fadeIn 0.2s ease;
}
.status.success {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--success);
}
.status.error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--error);
}
.status.processing {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--warning);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Progress Bar ===== */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== Preview ===== */
.preview-section {
    margin-top: 1.5rem;
    animation: fadeIn 0.3s ease;
}
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.preview-header h2 {
    font-size: 1rem;
    font-weight: 600;
}
.page-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}
.preview-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    outline: none;
}
.preview-container:focus-visible {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}
.preview-page {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.preview-page:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.preview-page-label {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

/* ===== Actions ===== */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: var(--font);
    outline: none;
}
.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--border-color); }

/* ===== Info Section ===== */
.info {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.info h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}
.info ol {
    list-style: none;
    counter-reset: step;
}
.info li {
    counter-increment: step;
    padding: 0.5rem 0 0.5rem 2rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.info li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    top: 0.55rem;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    main { padding: 1rem 0.75rem 2rem; }
    .converter { padding: 1rem; }
    .upload-zone { padding: 1.5rem 1rem; }
    .actions { flex-direction: column; }
    .btn { width: 100%; }
}

/* ===== Hidden utility ===== */
[hidden] { display: none !important; }
