:root {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --focus: #f0f6fc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.noscript-warning {
    max-width: 800px;
    margin: 1rem auto 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--warning);
    border-radius: 6px;
    color: var(--warning);
    background: rgba(210, 153, 34, 0.08);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: calc(2rem + env(safe-area-inset-top)) calc(2rem + env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)) calc(2rem + env(safe-area-inset-left));
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--bg-secondary);
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

body.file-drag-active::before {
    content: '';
    position: fixed;
    inset: 0;
    border: 2px solid var(--accent);
    background: rgba(88, 166, 255, 0.06);
    pointer-events: none;
    z-index: 10;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.icon-small {
    width: 16px;
    height: 16px;
}

.file-label {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.file-label:hover {
    color: var(--accent-hover);
}

.supported {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.drop-feedback {
    min-height: 1.25rem;
    margin-top: 0.75rem;
    color: var(--warning);
    font-size: 0.875rem;
    text-align: center;
}

.drop-feedback:not(.visible) {
    display: none;
}

.demo-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

.trust-points {
    margin-top: 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.trust-point {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.trust-point .icon-small {
    flex-shrink: 0;
    margin-top: 0.2rem;
    color: var(--accent);
}

.trust-point h2 {
    font-size: 0.875rem;
    line-height: 1.3;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.trust-point p {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.metadata-risks,
.faq {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.section-heading {
    margin-bottom: 1rem;
}

.section-heading h2 {
    font-size: 1.125rem;
    line-height: 1.3;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.section-heading p {
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.risk-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.risk-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(33, 38, 45, 0.45);
}

.risk-item .icon-small {
    flex-shrink: 0;
    margin-top: 0.2rem;
    color: var(--warning);
}

.risk-item h3,
.faq-item h3 {
    font-size: 0.9375rem;
    line-height: 1.35;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.risk-item p,
.faq-item p {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.faq-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.faq-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
}

#file-input {
    display: none;
}

/* Visually hidden, but still announced by screen readers. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* File List */
.file-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.file-icon.jpeg,
.file-icon.jpg {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

.file-icon.png {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.file-icon.webp {
    background: rgba(0, 188, 212, 0.2);
    color: #00bcd4;
}

.file-icon.gif {
    background: rgba(156, 39, 176, 0.2);
    color: #ba68c8;
}

.file-icon.pdf {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.file-icon.docx {
    background: rgba(88, 166, 255, 0.18);
    color: #79b8ff;
}

.file-icon.xlsx {
    background: rgba(63, 185, 80, 0.18);
    color: #56d364;
}

.file-icon.pptx {
    background: rgba(255, 171, 66, 0.18);
    color: #ffab42;
}

.file-icon.epub {
    background: rgba(210, 153, 34, 0.18);
    color: #d29922;
}

.file-icon.mp3 {
    background: rgba(35, 134, 54, 0.18);
    color: #3fb950;
}

.file-icon.office-legacy {
    background: rgba(139, 148, 158, 0.18);
    color: #c9d1d9;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.25rem;
}

.metadata-count {
    color: var(--warning);
    overflow-wrap: anywhere;
}

.metadata-count.clean {
    color: var(--success);
}

.metadata-count.visual-pending {
    color: var(--accent);
}

.metadata-count.visual-warning {
    color: var(--warning);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Status */
.file-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-pending {
    color: var(--text-muted);
}

.status-loading {
    color: var(--accent);
}

.status-processing {
    color: var(--accent);
}

.status-done {
    color: var(--success);
}

.status-warning {
    color: var(--warning);
}

.status-error {
    color: var(--danger);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Actions */
.actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.actions.hidden {
    display: none;
}

.btn {
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.button-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Footer */
footer {
    margin-top: 3rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.privacy-note {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}

.source-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.github-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.metadata-section {
    margin-bottom: 1.5rem;
}

.metadata-section:last-child {
    margin-bottom: 0;
}

.metadata-note {
    margin-bottom: 1.5rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.875rem;
    background: rgba(88, 166, 255, 0.05);
}

.metadata-note strong {
    color: var(--text);
    font-weight: 600;
}

.metadata-section h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.metadata-table {
    width: 100%;
    border-collapse: collapse;
}

.metadata-table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.metadata-table td:first-child {
    color: var(--text-muted);
    width: 40%;
    padding-right: 1rem;
}

.metadata-table tr:last-child td {
    border-bottom: none;
}

.no-metadata {
    color: var(--success);
    text-align: center;
    padding: 2rem;
}

.metadata-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.visual-proof-summary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(88, 166, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.visual-proof-summary strong {
    color: var(--text);
    font-weight: 600;
}

.visual-proof-matched strong {
    color: var(--success);
}

.visual-proof-pending strong {
    color: var(--accent);
}

.visual-proof-changed strong,
.visual-proof-unavailable strong {
    color: var(--warning);
}

.visual-proof-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.visual-proof-figure {
    min-width: 0;
}

.visual-proof-frame {
    aspect-ratio: 4 / 3;
    min-height: 120px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background:
        linear-gradient(45deg, rgba(139, 148, 158, 0.14) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(139, 148, 158, 0.14) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(139, 148, 158, 0.14) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(139, 148, 158, 0.14) 75%),
        var(--bg);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.visual-proof-frame img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.visual-proof-figure figcaption {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.visual-proof-figure figcaption span {
    color: var(--text);
    font-weight: 600;
}

.visual-proof-figure figcaption small {
    font-size: inherit;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    }

    .file-item {
        flex-wrap: wrap;
    }

    .file-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    .actions {
        flex-direction: column;
    }

    .trust-points {
        grid-template-columns: 1fr;
    }

    .risk-grid {
        grid-template-columns: 1fr;
    }

    .privacy-note {
        align-items: flex-start;
        text-align: left;
    }

    .visual-proof-grid {
        grid-template-columns: 1fr;
    }
}
