:root {
    --primary: #0891B2;
    --primary-dark: #0E7490;
    --primary-light: #22D3EE;
    --secondary: #06B6D4;
    --cta: #059669;
    --cta-dark: #047857;
    --background: #ECFEFF;
    --surface: #FFFFFF;
    --surface-elevated: #F0FDFA;
    --text-primary: #164E63;
    --text-secondary: #0F766E;
    --text-muted: #5EEAD4;
    --border: #CFFAFE;
    --border-dark: #A5F3FC;
    --success: #059669;
    --warning: #D97706;
    --error: #DC2626;
    
    --font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition-fast: 150ms ease-out;
    --transition-base: 200ms ease-out;
    --transition-slow: 300ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 var(--radius-md) 0;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

.header {
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

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

.logo-icon {
    color: var(--primary);
}

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

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    padding: 8px 14px;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cta);
    border: 1px solid var(--border);
}

.upload-section {
    margin-bottom: 32px;
}

.upload-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    text-align: center;
    margin-bottom: 32px;
}

.upload-area {
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--surface-elevated);
}

.upload-area:hover,
.upload-area:focus-visible,
.upload-area.dragover {
    border-color: var(--primary-dark);
    background: var(--background);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-area:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

.upload-illustration {
    color: var(--primary);
    margin-bottom: 16px;
    transition: transform var(--transition-base);
}

.upload-area:hover .upload-illustration {
    transform: translateY(-4px);
}

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

.upload-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-name {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-xl);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-block;
}

.btn-primary {
    margin-top: 24px;
    padding: 14px 32px;
    background: var(--cta);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-base);
    min-height: 52px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--cta-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

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

.btn-help-text {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-secondary {
    margin-top: 32px;
    padding: 14px 32px;
    background: var(--surface);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-base);
    min-height: 52px;
}

.btn-secondary:hover {
    background: var(--background);
    transform: translateY(-2px);
}

.btn-secondary:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.feature {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    transition: all var(--transition-base);
}

.feature:hover {
    border-color: var(--border-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--background);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 16px;
}

.feature h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.feature p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.loading-overlay.active {
    display: flex;
}

.loading-card {
    text-align: center;
    padding: 48px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 400px;
}

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

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

.loading-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.results-section {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-title::before {
    content: '';
    width: 4px;
    height: 28px;
    background: var(--cta);
    border-radius: 2px;
}

.language-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    margin-bottom: -2px;
    min-height: 48px;
}

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

.tab-btn:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.results-content {
    display: grid;
    gap: 20px;
}

.result-card {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.result-card.significance {
    border-left-color: var(--primary);
}

.result-card.medication {
    border-left-color: var(--cta);
}

.result-card.takeaways {
    border-left-color: var(--warning);
}

.result-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.markdown-content {
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 0.9375rem;
}

.markdown-content p {
    margin-bottom: 12px;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content ol,
.markdown-content ul {
    margin: 12px 0;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 8px;
    padding-left: 4px;
}

.markdown-content li:last-child {
    margin-bottom: 0;
}

.markdown-content strong {
    color: var(--primary-dark);
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.markdown-content code {
    background: var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.85em;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .upload-card {
        padding: 24px 16px;
    }
    
    .upload-area {
        padding: 32px 16px;
    }
    
    .upload-title {
        font-size: 1.125rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .results-section {
        padding: 24px 16px;
    }
    
    .language-tabs {
        flex-wrap: wrap;
        border-bottom: none;
        gap: 8px;
    }
    
    .tab-btn {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 0;
    }
    
    .tab-btn.active {
        border-color: var(--primary);
        background: var(--background);
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

.error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideIn var(--transition-base);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--surface);
    padding: 6px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.nav-tab:hover {
    color: var(--primary);
    background: var(--background);
}

.nav-tab:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.nav-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.tab-panel {
    display: none;
    animation: fadeIn var(--transition-base);
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.explore-section {
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.explore-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.explore-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.reports-list {
    display: grid;
    gap: 12px;
}

.report-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.report-item:hover {
    border-color: var(--primary);
    background: var(--background);
    transform: translateX(4px);
}

.report-item:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.report-icon {
    width: 40px;
    height: 40px;
    background: var(--background);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.report-info {
    flex: 1;
    min-width: 0;
}

.report-filename {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.report-arrow {
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.report-item:hover .report-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.loading-spinner.small {
    width: 24px;
    height: 24px;
    border-width: 3px;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9375rem;
}

.explore-header {
    margin-bottom: 24px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    transition: all var(--transition-fast);
}

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

.btn-back:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.explore-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .main-nav {
        flex-direction: column;
    }
    
    .nav-tab {
        width: 100%;
    }
    
    .report-item {
        padding: 12px 16px;
    }
    
    .explore-section {
        padding: 16px;
    }
}