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

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-success-dark: #15803d;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-border-active: #2563eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Layout ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* ===== Header ===== */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
}

.header .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ===== Footer ===== */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1rem 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.footer-links {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition);
    padding: 0 0.5rem;
}

.footer-links a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.footer-links .separator {
    color: var(--color-border);
    margin: 0 0.25rem;
}

.footer .copyright {
    margin-top: 0.5rem;
}


/* ===== Card ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.hero p {
    color: var(--color-text-muted);
    font-size: 1rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}

.btn--primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn--success {
    background: var(--color-success);
    color: #fff;
}

.btn--success:hover:not(:disabled) {
    background: var(--color-success-dark);
}

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

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

.btn--large {
    padding: 0.85rem 2rem;
    font-size: 1rem;
}

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}

.drop-zone--hover {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.04);
}

.drop-zone__icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.drop-zone__text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.drop-zone__or {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.drop-zone__hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ===== Preview ===== */
.preview-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid var(--color-border);
}

/* ===== Settings ===== */
.settings {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings__label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.difficulty-buttons {
    display: flex;
    gap: 0.5rem;
}

.diff-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: border-color var(--transition), background var(--transition);
}

.diff-btn:hover {
    border-color: var(--color-primary);
}

.diff-btn--active {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.06);
    color: var(--color-primary);
}

.diff-btn small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.diff-btn--active small {
    color: var(--color-primary);
}

.settings__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid #fecaca;
}

/* ===== Processing ===== */
.processing-card {
    text-align: center;
    padding: 3rem 2rem;
}

.processing-card h2 {
    margin-bottom: 2rem;
}

.progress-container {
    max-width: 480px;
    margin: 0 auto 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--color-bg);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, #60a5fa 100%);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-top: 0.75rem;
}

.step-text {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.processing-animation {
    display: flex;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.estimated-time {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* Process steps visualization */
.process-steps {
    max-width: 600px;
    margin: 2.5rem auto 2rem;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    border-radius: 8px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    transition: all 0.3s ease;
}

.step.in-progress {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.05);
}

.step.complete {
    border-color: var(--color-success);
    background: rgba(22, 163, 74, 0.05);
}

.step-icon {
    font-size: 2rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.step.in-progress .step-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

.step.complete .step-icon {
    animation: bounce 0.5s ease-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes bounce {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.step-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: var(--color-text);
}

.step-status {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-align: center;
}

.step.in-progress .step-status {
    color: var(--color-primary);
    font-weight: 600;
}

.step.complete .step-status {
    color: var(--color-success);
    font-weight: 600;
}

@media (max-width: 640px) {
    .process-steps {
        flex-direction: column;
        gap: 0.5rem;
    }

    .step {
        flex-direction: row;
        justify-content: flex-start;
        padding: 0.75rem;
    }

    .step-icon {
        font-size: 1.5rem;
        min-width: 2rem;
    }

    .step-label,
    .step-status {
        text-align: left;
    }
}

/* ===== Result ===== */
.result-info {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--color-primary);
    color: #fff;
}

.badge--outline {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comparison__panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
}

.comparison__image {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    object-fit: contain;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.answers {
    border-top: 1px solid var(--color-border);
    padding-top: 1.25rem;
}

.answers h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.answers ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.answers li {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 0.85rem;
}

.answers li strong {
    display: inline-block;
    min-width: 5em;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.35rem;
    }

    .card {
        padding: 1.25rem;
    }

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

    .settings__actions {
        flex-direction: column;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }

    .difficulty-buttons {
        flex-direction: column;
    }
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.a4-image {
    max-width: 100%;
    border: 1px solid #ddd;
}
