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

:root {
    --primary: #2dd4bf;
    --primary-dark: #0f766e;
    --primary-darker: #065f55;
    --bg: #0a0a0a;
    --surface: #171717;
    --surface-hover: #1f1f1f;
    --border: #262626;
    --text: #f0fdfa;
    --text-dim: #99a3a1;
    --danger: #ef4444;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    padding: 2rem 1rem 1rem;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

header h1 span {
    color: var(--primary);
}

header p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

main {
    width: 100%;
    max-width: 480px;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary-dark);
    color: var(--text);
}

.tab-btn:hover:not(.active) {
    color: var(--text);
}

/* Panel */
.panel {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.panel.active {
    display: flex;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(45, 212, 191, 0.05);
}

.dropzone-icon {
    font-size: 2.5rem;
}

.dropzone-text {
    font-size: 0.95rem;
    color: var(--text-dim);
}

.dropzone-text strong {
    color: var(--primary);
}

.folder-btn {
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

#file-input, #folder-input {
    display: none;
}

/* Code display */
.code-display {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.code-display .label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.8rem;
}

.code-value {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--primary);
    margin-bottom: 1rem;
    user-select: all;
}

.code-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* File list */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

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

.file-item .file-details {
    flex: 1;
    min-width: 0;
}

.file-item .file-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-size {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

.file-item .remove-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.file-item .remove-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.file-item .download-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 6px;
    background: var(--primary-dark);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.file-item .download-btn:hover:not(:disabled) {
    background: var(--primary-darker);
}

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

.empty-msg {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--primary-dark);
    color: var(--text);
}

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

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

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-lg {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

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

/* Code input */
.code-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.code-input-group label {
    font-size: 0.9rem;
    color: var(--text-dim);
}

#code-input {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
    width: 200px;
    padding: 0.6rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--primary);
    outline: none;
    text-transform: uppercase;
}

#code-input:focus {
    border-color: var(--primary);
}

#code-input::placeholder {
    color: var(--border);
    letter-spacing: 0.1em;
}

/* Status */
.status {
    text-align: center;
    padding: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Progress */
.progress-container {
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
}

.progress-header .progress-label {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 1rem;
}

.progress-header .progress-pct {
    color: var(--primary);
    font-weight: 600;
}

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

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.15s linear;
    width: 0%;
}

.progress-speed {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.4rem;
    text-align: right;
}

/* Error */
.error-msg {
    padding: 0.8rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 500px) {
    header h1 {
        font-size: 1.4rem;
    }

    .code-value {
        font-size: 2.2rem;
    }

    #code-input {
        font-size: 1.6rem;
        width: 170px;
    }

    main {
        padding: 0.75rem;
    }
}
