:root {
    color-scheme: light dark;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --accent-color: #4f46e5;
    --bg-color: #f3f4f6;
    --bg-gradient-1: rgba(99, 102, 241, 0.15);
    --bg-gradient-2: rgba(168, 85, 247, 0.15);
    --header-bg: white;
    --header-border: rgba(0, 0, 0, 0.05);
    --upload-bg: #fcfcfc;
    --upload-hover: #eff6ff;
    --file-list-bg: #f8fafc;
    --file-card-bg: white;
    --file-card-border: rgba(0, 0, 0, 0.02);
    --file-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --file-card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --session-code-bg: #f3f4f6;
    --session-code-hover: #e5e7eb;
    --progress-overlay-bg: rgba(255, 255, 255, 0.9);
    --toast-bg: #1f2937;
    --toast-color: white;
    --spinner-border: #e5e7eb;
    --time-badge-bg: #fee2e2;
    --time-badge-color: #ef4444;
}

[data-theme="dark"] {
    color-scheme: dark;
    --primary-gradient: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --glass-bg: rgba(30, 30, 40, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-color: #818cf8;
    --bg-color: #111827;
    --bg-gradient-1: rgba(99, 102, 241, 0.25);
    --bg-gradient-2: rgba(168, 85, 247, 0.25);
    --header-bg: #1f2937;
    --header-border: rgba(255, 255, 255, 0.1);
    --upload-bg: #1f2937;
    --upload-hover: #374151;
    --file-list-bg: #111827;
    --file-card-bg: #1f2937;
    --file-card-border: rgba(255, 255, 255, 0.05);
    --file-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --file-card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --session-code-bg: #374151;
    --session-code-hover: #4b5563;
    --progress-overlay-bg: rgba(31, 41, 55, 0.9);
    --toast-bg: #f3f4f6;
    --toast-color: #1f2937;
    --spinner-border: #4b5563;
    --time-badge-bg: rgba(239, 68, 68, 0.2);
    --time-badge-color: #f87171;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    height: 60px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 10;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.brand {
    font-weight: 800;
    font-size: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.header-icon-btn {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.header-icon-btn:hover {
    transform: scale(1.1);
}

.header-icon-btn:active {
    transform: scale(0.95);
}

.github-link {
    color: var(--text-primary);
    opacity: 0.7;
    transition: all 0.2s;
    text-decoration: none;
}

.github-link:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.lang-switcher {
    display: flex;
    background: var(--session-code-bg);
    padding: 2px;
    border-radius: 8px;
    gap: 2px;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.lang-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.lang-btn.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .lang-btn.active {
    background: var(--header-bg);
    color: var(--accent-color);
}

.lang-btn .lang-flag {
    font-size: 1.1rem;
}

.session-code {
    font-family: 'SF Mono', monospace;
    background: var(--session-code-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-code:hover {
    background: var(--session-code-hover);
    color: var(--text-primary);
}

.session-code:active {
    transform: scale(0.95);
}

.session-code:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    background: var(--session-code-hover);
}

/* Main Layout */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Upload Zone (Left/Top) */
.upload-section {
    width: 30%;
    background: var(--header-bg);
    border-right: 1px solid var(--header-border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.drop-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--upload-bg);
    cursor: pointer;
    text-align: center;
}

.drop-zone:hover {
    background: var(--upload-hover);
}

.drop-zone.dragover {
    background: var(--upload-hover);
    transform: scale(0.98);
}

.drop-zone:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -4px;
    background: var(--upload-hover);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s;
}

.drop-zone:hover .upload-icon {
    transform: scale(1.1) rotate(5deg);
}

.upload-text {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Download Zone (Right/Bottom) */
.file-list-section {
    width: 70%;
    background: var(--file-list-bg);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    transition: background 0.3s ease;
    position: relative;
}

#fileListContent {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.footer-container {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--header-bg);
    border-top: 1px solid var(--header-border);
    text-align: center;
    transition: background 0.3s ease, border-color 0.3s ease;
    color: var(--text-secondary);
    line-height: 1.6;
}

.mobile-footer {
    display: none;
}

.desktop-footer {
    display: block;
}

.file-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
}

#fileItems {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.file-card {
    background: var(--file-card-bg);
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    box-shadow: var(--file-card-shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--file-card-border);
    text-decoration: none;
    color: inherit;
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--file-card-hover-shadow);
}

.file-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.file-name {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.4;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
}

.time-badge {
    background: var(--time-badge-bg);
    color: var(--time-badge-color);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-shrink: 0;
    min-width: 7em;
    font-variant-numeric: tabular-nums;
}

.time-badge.safe {
    background: white;
    color: #3b82f6;
}

[data-theme="dark"] .time-badge.safe {
    background: #1f2937;
    color: #60a5fa;
}

.countdown-timer {
    font-family: 'SF Mono', 'Roboto Mono', monospace;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-height: 400px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s;
}

.empty-state:hover .empty-icon {
    transform: scale(1.1) rotate(-5deg);
}

/* Mobile Layout */
@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .main-container {
        flex-direction: column;
    }

    .mobile-footer {
        display: block;
        background: var(--header-bg);
        border-top: 1px solid var(--header-border);
        margin-top: auto;
    }

    .desktop-footer {
        display: none;
    }

    .upload-section {
        width: 100%;
        height: 30vh;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--header-border);
    }

    .file-list-section {
        width: 100%;
        padding: 0;
        flex: 1;
    }

    #fileListContent {
        overflow: visible;
    }

    .file-card {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "icon name"
            "empty meta";
        gap: 0.25rem 1rem;
        align-items: center;
        padding: 1rem 1.25rem;
    }

    .file-icon {
        grid-area: icon;
        font-size: 1.75rem;
    }

    .file-name {
        grid-area: name;
        font-size: 0.95rem;
    }

    .file-meta {
        grid-area: meta;
        justify-content: flex-start;
        gap: 1rem;
    }

    .drop-zone {
        flex-direction: column;
        gap: 0.5rem;
    }

    .upload-icon,
    .empty-icon {
        margin-bottom: 0.5rem;
        font-size: 2.5rem;
    }

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

/* Progress Overlay */
.progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--progress-overlay-bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--spinner-border);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.progress-container {
    width: 80%;
    max-width: 300px;
    height: 4px;
    background: var(--spinner-border);
    border-radius: 2px;
    margin-top: 1.5rem;
    overflow: hidden;
    display: none;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: var(--toast-bg);
    color: var(--toast-color);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Delete All Button */
.delete-all-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    transform: translateY(100px);
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 90;
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #ef4444;
    opacity: 0;
    visibility: hidden;
}

.delete-all-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.delete-all-btn:hover {
    transform: scale(1.1);
    background: #fff;
    color: #dc2626;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.delete-all-btn:active {
    transform: scale(0.95);
}

@keyframes fallDown {
    0% {
        transform: translateY(0) rotate(0);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(20deg);
        opacity: 0;
    }
}

.falling {
    animation: fallDown 0.8s cubic-bezier(0.5, 0, 0.7, 0.4) forwards !important;
    pointer-events: none;
}

/* Text Input Button */
.text-input-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.text-input-btn:hover {
    transform: scale(1.1);
    background: #fff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.text-input-btn:active {
    transform: scale(0.95);
}

[data-theme="dark"] .text-input-btn {
    background: #1f2937;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .text-input-btn:hover {
    background: #374151;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    padding: 20px;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    background: var(--file-card-bg);
    width: 70%;
    height: 70%;
    border-radius: 1.5rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    border: 1px solid var(--glass-border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    opacity: 1;
}

.lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    max-height: 440px;
    overflow-y: auto;
    padding: 0.5rem;
}

.lang-option {
    padding: 0.75rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    background: var(--file-card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

.lang-option:hover {
    background: var(--glass-bg);
    border-color: var(--text-secondary);
}

.lang-option.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.lang-flag {
    font-weight: 600;
}

.text-textarea {
    flex: 1;
    width: 100%;
    border: 1px solid var(--header-border);
    border-radius: 1rem;
    padding: 1.5rem;
    font-family: inherit;
    font-size: 1.05rem;
    resize: none;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.text-textarea:focus {
    border-color: var(--accent-color);
}

.save-text-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.save-text-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.save-text-btn:active {
    transform: scale(0.98);
}

.save-text-btn:focus-visible,
.close-modal:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Approval Modal & Overlay */
.waiting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.waiting-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite;
}

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

.waiting-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.approval-modal {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(200%);
    background: var(--file-card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--file-card-border);
    z-index: 1500;
    width: 90%;
    max-width: 400px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    visibility: hidden;
    opacity: 0;
}

.approval-modal.show {
    transform: translateX(-50%) translateY(0);
    visibility: visible;
    opacity: 1;
}

.approval-header {
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.approval-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-approve,
.btn-reject {
    flex: 1;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve {
    background: var(--primary-gradient);
    color: white;
}

.btn-reject {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--header-border);
}

.btn-approve:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-reject:hover {
    background: var(--header-border);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        height: 80%;
        padding: 1.25rem;
    }
}

.disclaimer {
    color: inherit;
    display: inline;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s;
    vertical-align: baseline;
    margin: 0 0.4rem;
}

.footer-link:hover {
    color: var(--accent-color);
    opacity: 1;
}

.footer-icon {
    font-size: 0.8rem;
    opacity: 0.9;
}

.copyright {
    display: inline;
}