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

:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-elevated: #334155;
    --border: #334155;
    --border-strong: #475569;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

.screen {
    min-height: 100vh;
}

/* ============ Login Screen ============ */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#loginScreen[hidden] {
    display: none;
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
}

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

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
    background: var(--border-strong);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

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

/* ============ App Header ============ */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    margin-bottom: 32px;
}

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

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-left .logo {
    font-size: 24px;
}

.user-badge {
    background: var(--bg-elevated);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.login-time {
    font-size: 11px;
    color: var(--text-subtle);
    padding-right: 4px;
}

/* ============ Upload Section ============ */
.upload-section {
    margin-bottom: 32px;
}

.drop-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.01);
}

.drop-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-zone-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 8px;
}

.drop-zone:hover .upload-icon,
.drop-zone.dragover .upload-icon {
    color: var(--primary);
}

.drop-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
}

.drop-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.drop-subtitle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.drop-subtitle a:hover {
    text-decoration: underline;
}

.drop-subtitle kbd {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    font-family: inherit;
}

/* Upload Progress */
.progress-container {
    margin-top: 16px;
}

.progress-item {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.progress-filename {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

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

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

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.15s;
}

.progress-fill.done {
    background: var(--success);
}

.progress-fill.error {
    background: var(--danger);
}

/* ============ Files Section ============ */
.files-section {
    margin-bottom: 32px;
}

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

.section-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.section-title h2 {
    font-size: 20px;
    font-weight: 600;
}

.file-count {
    color: var(--text-muted);
    font-size: 14px;
}

.search-input {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    width: 260px;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Batch bar */
.batch-bar {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary);
    padding: 10px 16px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.batch-buttons {
    display: flex;
    gap: 8px;
}

/* File list */
.file-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    transition: background 0.1s;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: var(--bg-elevated);
}

.file-item.selected {
    background: rgba(59, 130, 246, 0.1);
}

.file-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

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

.file-name {
    display: block;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.loading, .empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state {
    font-size: 15px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.page-info {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============ Skill Section ============ */
.skill-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 32px;
}

.skill-section h2 {
    font-size: 22px;
    margin-bottom: 12px;
}

.skill-section h3 {
    font-size: 17px;
    margin-top: 24px;
    margin-bottom: 10px;
    color: var(--text);
}

.skill-section h4 {
    font-size: 14px;
    margin-top: 16px;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-weight: 500;
}

.skill-intro {
    color: var(--text-muted);
    margin-bottom: 8px;
    font-size: 14px;
}

.skill-section code {
    background: var(--bg);
    color: #93c5fd;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
}

.skill-section pre {
    background: var(--bg);
    padding: 14px 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.skill-section pre code {
    background: transparent;
    color: var(--text);
    padding: 0;
    font-size: 13px;
    line-height: 1.6;
}

.skill-notes {
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.skill-notes li {
    margin-bottom: 4px;
}

/* ============ Footer ============ */
.app-footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 13px;
    text-align: center;
}

.app-footer code {
    color: var(--primary);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    color: var(--text);
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    max-width: 400px;
    animation: slideIn 0.3s;
    border-left: 4px solid var(--primary);
    font-size: 14px;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============ Preview Modal ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 24px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius);
    object-fit: contain;
}

.modal-body pre {
    width: 100%;
    max-height: 70vh;
    overflow: auto;
    background: var(--bg);
    color: var(--text);
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid var(--border);
    margin: 0;
}

/* ============ Share modal ============ */
.share-form .form-group {
    margin-bottom: 14px;
}
.share-form input[type="number"],
.share-form input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}
.share-result {
    margin-top: 20px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.share-result-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.share-url-row {
    display: flex;
    gap: 8px;
}
.share-url-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 13px;
    background: white;
}
.share-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.share-existing {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.share-existing-title {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}
.share-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}
.share-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.share-list-info {
    flex: 1;
    min-width: 0;
}
.share-list-file {
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.share-list-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }
    .search-input {
        width: 100%;
    }
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    .file-item {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .file-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
