:root {
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --primary: #007aff;
    --danger: #ff3b30;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #e5e5ea;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 768px;
    margin: 0 auto;
    padding-bottom: 100px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

h1 {
    font-size: 20px;
    font-weight: 700;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    background: rgba(0,122,255,0.1);
}

.storage-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 20px;
}

.breadcrumb {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.crumb {
    cursor: pointer;
    color: var(--primary);
}

.crumb.active {
    color: var(--text);
    font-weight: 600;
}

.crumb::after {
    content: " / ";
    color: var(--text-secondary);
    margin: 0 4px;
}

.crumb:last-child::after {
    content: "";
}

.file-list {
    padding: 0 16px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s;
    gap: 12px;
}

.file-item:active {
    transform: scale(0.98);
}

.file-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon.folder {
    background: #e3f2fd;
    color: #1976d2;
}

.file-icon.image {
    background: #fce4ec;
    color: #c62828;
}

.file-icon.video {
    background: #f3e5f5;
    color: #7b1fa2;
}

.file-icon.document {
    background: #e8f5e9;
    color: #2e7d32;
}

.file-icon.other {
    background: #f5f5f5;
    color: #616161;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.btn-delete:active {
    background: rgba(255,59,48,0.1);
}

.upload-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    z-index: 50;
}

.upload-area.dragover {
    background: rgba(0,122,255,0.05);
    border-top-color: var(--primary);
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,122,255,0.3);
    transition: transform 0.1s;
    width: 100%;
    max-width: 400px;
    justify-content: center;
}

.upload-btn:active {
    transform: scale(0.96);
}

.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.progress-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 80%;
    max-width: 320px;
    text-align: center;
}

.progress-card p {
    margin-bottom: 16px;
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 85%;
    max-width: 360px;
}

.modal-card h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
    outline: none;
}

.modal-card input:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cancel {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 8px 16px;
    cursor: pointer;
}

.btn-confirm {
    background: var(--primary);
    color: white;
    border: none;
    font-size: 16px;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --card-bg: #2c2c2e;
        --text: #f5f5f7;
        --text-secondary: #98989d;
        --border: #3a3a3c;
    }
}

/* Preview overlay */
.preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.preview-container {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    color: white;
}

.preview-header h3 {
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-actions .icon-btn {
    color: white;
}

.preview-content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: auto;
}

.preview-content img,
.preview-content video {
    object-fit: contain;
}
