* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

a {
    text-decoration: none;
}

img, video {
    max-width: 100%;
}

body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #edf2ff, #f8fafc);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 28px;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
    margin: 0 0 12px;
    font-size: 24px;
    line-height: 1.4;
}

.subtext {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.7;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.auth-form label {
    font-size: 14px;
    font-weight: 600;
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    outline: none;
    font-size: 15px;
}

.auth-form input:focus {
    border-color: #3b82f6;
}

.auth-form button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    padding: 11px 18px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s ease;
    min-height: 42px;
    text-align: center;
    white-space: nowrap;
}

.btn.primary,
.auth-form button {
    background: #2563eb;
    color: #fff;
}

.btn.primary:hover,
.auth-form button:hover {
    background: #1d4ed8;
}

.btn.secondary {
    background: #eef2f7;
    color: #1f2937;
}

.btn.secondary:hover {
    background: #e2e8f0;
}

.view-switch {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.view-switch .btn.active {
    background: #2563eb;
    color: #fff;
}

.btn.mini {
    padding: 8px 12px;
    font-size: 13px;
    background: #2563eb;
    color: #fff;
    min-height: 36px;
}

.btn.mini.secondary {
    background: #eef2f7;
    color: #111827;
}

.btn.danger {
    background: #dc2626;
    color: #fff;
}

.btn.archive {
    background: #f59e0b;
    color: #fff;
}

.btn.restore {
    background: #10b981;
    color: #fff;
}

.storage-select {
    min-width: 180px;
    padding: 10px 12px;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    color: #111827;
    outline: none;
    min-height: 42px;
}

.alert {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
}

.alert.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    width: 100%;
}

.topbar-main {
    min-width: 0;
}

.topbar h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.3;
    word-break: break-word;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.container {
    padding: 20px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.upload-panel,
.file-section,
.thumb-mode-panel,
.feed-mode-panel {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05);
    margin-bottom: 18px;
    width: 100%;
    overflow: hidden;
}

.feed-mode-panel {
    padding: 0;
    background: #000;
}

.upload-panel h2,
.file-section h2,
.thumb-mode-panel h2 {
    margin: 0;
    font-size: 20px;
}

.upload-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
    width: 100%;
}

.upload-form input[type="file"] {
    flex: 1 1 260px;
    min-width: 240px;
    padding: 8px 10px;
    min-height: 44px;
    max-width: 100%;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
}

.hint {
    color: #6b7280;
    font-size: 13px;
    margin-top: 10px;
    line-height: 1.7;
    word-break: break-word;
}

.countdown-box {
    margin-top: 12px;
    padding: 10px 12px;
    background: #eff6ff;
    border-radius: 12px;
    color: #1d4ed8;
    display: inline-block;
    max-width: 100%;
}

.upload-progress-panel {
    margin-top: 14px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.upload-progress-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.upload-progress-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.upload-progress-meta {
    font-size: 12px;
    color: #6b7280;
}

.upload-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}

.upload-progress-bar-inner {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.upload-progress-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-progress-item {
    padding: 10px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.upload-progress-item.working {
    border-color: #bfdbfe;
}

.upload-progress-item.success {
    border-color: #bbf7d0;
}

.upload-progress-item.error {
    border-color: #fecaca;
}

.upload-progress-item-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
}

.upload-progress-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    min-width: 0;
    flex: 1;
    word-break: break-all;
}

.upload-progress-item-phase {
    font-size: 12px;
    color: #2563eb;
    white-space: nowrap;
}

.upload-progress-item-detail {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
    word-break: break-all;
}

.upload-progress-item-bar {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-item-bar-inner {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    border-radius: 999px;
    transition: width 0.15s linear;
}

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

.count {
    display: inline-block;
    padding: 6px 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
}

.empty-box {
    background: #f8fafc;
    border: 1px dashed #d1d5db;
    border-radius: 14px;
    padding: 20px;
    color: #6b7280;
    text-align: center;
}

.hidden {
    display: none !important;
}

.image-grid,
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.image-card,
.video-card,
.thumb-card {
    background: #fafafa;
    border: 1px solid #edf2f7;
    border-radius: 16px;
    overflow: hidden;
    min-width: 0;
}

.thumb-card {
    cursor: pointer;
}

.image-thumb-wrap,
.thumb-media-wrap,
.video-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #e5e7eb;
    overflow: hidden;
}

.video-cover {
    cursor: pointer;
}

.image-thumb,
.thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: transform 0.25s ease, opacity 0.25s ease;
    opacity: 0;
}

.image-thumb.is-loaded,
.thumb-image.is-loaded {
    opacity: 1 !important;
}

.image-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 14px;
    background: linear-gradient(135deg, #eef2f7, #e5e7eb);
    pointer-events: none;
    padding: 8px;
    text-align: center;
}

.image-thumb.is-loaded + .image-loading,
.thumb-image.is-loaded + .image-loading {
    display: none;
}

.video-poster-wrap,
.video-cover {
    background: linear-gradient(135deg, #0f172a, #334155);
}

.video-poster-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 14px;
    color: #fff;
    text-align: center;
}

.video-play-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    padding-left: 3px;
}

.video-thumb-name {
    font-size: 13px;
    line-height: 1.6;
    word-break: break-all;
}

.file-meta {
    padding: 12px;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
    word-break: break-all;
}

.file-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: 14px;
    background: #fafafa;
    border: 1px solid #edf2f7;
}

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

.archived-row {
    background: #f8fafc;
}

.viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
}

.viewer-stage {
    width: 100vw;
    height: 100dvh;
    padding: 56px 16px 64px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-stage img,
.viewer-stage video {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

#viewerVideo,
#viewerImage {
    display: none;
    background: #000;
}

.viewer-close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 2;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 34px;
    cursor: pointer;
    z-index: 2;
}

.viewer-nav.left {
    left: 18px;
}

.viewer-nav.right {
    right: 18px;
}

.viewer-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(90vw, 900px);
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 14px;
    text-align: center;
    backdrop-filter: blur(4px);
    word-break: break-word;
}

.feed-list {
    height: calc(100dvh - 110px);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: #000;
}

.feed-item {
    position: relative;
    height: calc(100dvh - 110px);
    scroll-snap-align: start;
    background: #000;
}

.feed-media-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
}

.feed-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

.feed-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px 16px 22px;
    background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0));
    pointer-events: none;
}

.feed-title {
    color: #fff;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.upload-result-box {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    font-size: 14px;
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: anywhere;
}

@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
        gap: 12px;
    }

    .topbar h1 {
        font-size: 22px;
        margin-bottom: 4px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .view-switch {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .view-switch .btn {
        width: 100%;
    }

    .container {
        padding: 10px;
    }

    .upload-panel,
    .file-section,
    .thumb-mode-panel,
    .feed-mode-panel {
        padding: 12px;
        border-radius: 14px;
        margin-bottom: 14px;
    }

    .upload-form {
        gap: 8px;
        margin-top: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .upload-form input[type="file"] {
        min-width: 0;
        width: 100%;
        padding: 8px 10px;
        min-height: 44px;
        border-radius: 10px;
    }

    .storage-select,
    .upload-form .btn.primary {
        width: 100%;
        min-height: 42px;
    }

    .image-grid,
    .video-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .thumb-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .file-actions .btn,
    .file-actions a.btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        padding: 6px 8px;
        font-size: 12px;
    }

    .file-row {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .viewer-stage {
        padding: 52px 8px 72px;
    }

    .viewer-nav {
        width: 42px;
        height: 42px;
        font-size: 26px;
    }

    .viewer-nav.left {
        left: 8px;
    }

    .viewer-nav.right {
        right: 8px;
    }

    .viewer-close {
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
        font-size: 24px;
    }

    .viewer-caption {
        font-size: 12px;
        padding: 8px 10px;
        border-radius: 12px;
    }

    .feed-list {
        height: calc(100dvh - 160px);
    }

    .feed-item {
        height: calc(100dvh - 160px);
    }
}

@media (max-width: 520px) {
    .container {
        padding: 8px;
    }

    .upload-panel,
    .file-section,
    .thumb-mode-panel,
    .feed-mode-panel {
        padding: 10px;
        margin-bottom: 12px;
    }

    .image-grid,
    .video-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .thumb-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .file-actions .btn,
    .file-actions a.btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .feed-list {
        height: calc(100dvh - 170px);
    }

    .feed-item {
        height: calc(100dvh - 170px);
    }
}