:root {
    --ui-bg: #f4f7fb;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f8fafc;
    --ui-border: #e4e9f2;
    --ui-border-strong: #d7deea;
    --ui-text: #172033;
    --ui-muted: #667085;
    --ui-primary: #4f46e5;
    --ui-primary-dark: #4338ca;
    --ui-primary-soft: #eef2ff;
    --ui-success: #16a34a;
    --ui-danger: #dc2626;
    --ui-danger-dark: #b91c1c;
    --ui-danger-soft: #fef2f2;
    --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
    --ui-shadow: 0 12px 32px rgba(31, 42, 68, .08);
    --ui-radius-sm: 9px;
    --ui-radius: 14px;
    --ui-radius-lg: 20px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--ui-bg);
}

body.app-page,
body.auth-page,
body.share-admin-page {
    min-height: 100vh;
    margin: 0;
    color: var(--ui-text);
    background:
        radial-gradient(circle at 5% 0%, rgba(79, 70, 229, .06), transparent 28rem),
        var(--ui-bg);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    line-height: 1.55;
}

a {
    color: var(--ui-primary);
    text-underline-offset: 3px;
}

/* 顶部导航 */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 72px;
    padding: 0 max(24px, calc((100vw - 1240px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: var(--ui-text);
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid rgba(228, 233, 242, .9);
    box-shadow: 0 4px 18px rgba(31, 42, 68, .04);
    backdrop-filter: blur(14px);
}

.header h1 {
    margin: 0;
    color: var(--ui-text);
    font-size: 20px;
    font-weight: 750;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ui-text);
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(145deg, #6366f1, #4338ca);
    border-radius: 12px;
    box-shadow: 0 7px 18px rgba(79, 70, 229, .24);
    font-size: 18px;
    font-weight: 800;
}

.brand-copy {
    display: grid;
    line-height: 1.1;
}

.brand-copy strong {
    font-size: 17px;
    letter-spacing: .01em;
}

.brand-copy small {
    margin-top: 4px;
    color: #98a2b3;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .16em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ui-muted);
    font-size: 14px;
}

.user-chip {
    margin-right: 6px;
    padding: 7px 11px;
    color: #344054;
    background: var(--ui-surface-soft);
    border: 1px solid var(--ui-border);
    border-radius: 999px;
}

.user-info a {
    height: 36px;
    margin: 0;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    color: #475467;
    text-decoration: none;
    border-radius: var(--ui-radius-sm);
    transition: color .18s ease, background .18s ease;
}

.user-info a:hover {
    color: var(--ui-primary);
    background: var(--ui-primary-soft);
}

/* 页面容器 */
.main-container {
    width: calc(100% - 40px);
    max-width: 1240px;
    margin: 30px auto 56px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.dashboard-shell {
    display: grid;
    gap: 18px;
}

.success,
.error {
    margin: 0 0 16px;
    padding: 13px 16px;
    border: 1px solid;
    border-left-width: 4px;
    border-radius: 11px;
    font-size: 14px;
}

.success {
    color: #067647;
    background: #ecfdf3;
    border-color: #abefc6;
}

.error {
    color: #b42318;
    background: #fef3f2;
    border-color: #fecdca;
}

/* 容量卡片 */
.storage-info {
    margin: 0;
    padding: 20px 22px;
    display: grid;
    gap: 14px;
    color: var(--ui-text);
    background: linear-gradient(115deg, #ffffff 0%, #f8f8ff 100%);
    border: 1px solid var(--ui-border);
    border-left: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-sm);
}

.storage-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.storage-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.storage-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--ui-primary);
    background: var(--ui-primary-soft);
    border-radius: 12px;
    font-size: 20px;
}

.storage-label {
    display: grid;
    gap: 2px;
}

.storage-label strong {
    font-size: 15px;
}

.storage-label span,
.storage-percent {
    color: var(--ui-muted);
    font-size: 13px;
}

.storage-percent strong {
    color: var(--ui-text);
    font-size: 18px;
}

.storage-bar {
    height: 9px;
    margin: 0;
    overflow: hidden;
    background: #e8ecf4;
    border-radius: 999px;
}

.storage-used {
    height: 100%;
    min-width: 0;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: inherit;
    transition: width .35s ease;
}

/* 工具栏 */
.toolbar {
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-sm);
}

.toolbar-copy h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -.01em;
}

.toolbar-copy p {
    margin: 4px 0 0;
    color: var(--ui-muted);
    font-size: 13px;
}

.toolbar-actions,
.form-actions,
.file-actions-container,
.file-item > .file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 统一按钮系统 */
.btn,
.btn-action,
.btn-cancel,
.btn-danger,
.btn-create-share,
.form-actions button,
.file-actions button,
.toolbar button {
    height: 38px;
    min-width: 84px;
    margin: 0;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    appearance: none;
    color: #fff;
    background: var(--ui-primary);
    border: 1px solid var(--ui-primary);
    border-radius: var(--ui-radius-sm);
    box-shadow: var(--ui-shadow-sm);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.btn:hover,
.btn-action:hover,
.btn-create-share:hover,
.form-actions button:hover,
.file-actions button:hover,
.toolbar button:hover {
    color: #fff;
    background: var(--ui-primary-dark);
    border-color: var(--ui-primary-dark);
    box-shadow: 0 6px 14px rgba(79, 70, 229, .18);
    transform: translateY(-1px);
}

.btn:focus-visible,
.btn-action:focus-visible,
.btn-cancel:focus-visible,
.btn-danger:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(99, 102, 241, .2);
    outline-offset: 2px;
}

.toolbar button {
    height: 42px;
    width: 136px;
    min-width: 136px;
    padding: 0 17px;
    font-size: 14px;
}

.btn-secondary,
.toolbar button.btn-secondary,
.btn-cancel,
.form-actions button[type="button"] {
    color: #344054;
    background: #fff;
    border-color: var(--ui-border-strong);
    box-shadow: none;
}

.btn-secondary:hover,
.toolbar button.btn-secondary:hover,
.btn-cancel:hover,
.form-actions button[type="button"]:hover {
    color: var(--ui-text);
    background: #f8fafc;
    border-color: #c8d0dd;
    box-shadow: none;
}

.btn-danger,
button.btn-danger {
    color: var(--ui-danger);
    background: var(--ui-danger-soft);
    border-color: #fecaca;
}

.btn-danger:hover,
button.btn-danger:hover {
    color: #fff;
    background: var(--ui-danger);
    border-color: var(--ui-danger);
    box-shadow: 0 6px 14px rgba(220, 38, 38, .16);
}

.file-item .btn-action,
.file-item button.btn-action {
    height: 36px;
    width: 82px;
    min-width: 82px;
    padding: 0 12px;
    color: #475467;
    background: #fff;
    border-color: var(--ui-border-strong);
    box-shadow: none;
}

.file-item .btn-action:hover,
.file-item button.btn-action:hover {
    color: var(--ui-primary);
    background: var(--ui-primary-soft);
    border-color: #c7d2fe;
    box-shadow: none;
}

.file-item .btn-danger,
.file-item button.btn-danger {
    color: var(--ui-danger);
    background: var(--ui-danger-soft);
    border-color: #fecaca;
}

.file-item .btn-danger:hover,
.file-item button.btn-danger:hover {
    color: #fff;
    background: var(--ui-danger);
    border-color: var(--ui-danger);
}

.file-item form {
    margin: 0;
    display: inline-flex !important;
}

/* 面包屑 */
.breadcrumb {
    padding: 12px 16px;
    color: var(--ui-muted);
    background: #fff;
    border: 1px solid var(--ui-border);
    border-radius: 11px;
    font-size: 13px;
}

.breadcrumb a {
    font-weight: 600;
    text-decoration: none;
}

/* 文件列表 */
.file-list {
    overflow: hidden;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-sm);
}

.file-item {
    padding: 19px 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    border-bottom: 1px solid #edf0f5;
    transition: background .16s ease;
}

.file-item:hover {
    background: #fbfcff;
}

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

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

.file-main {
    min-width: 0;
    margin: 0 0 7px;
    display: flex;
    align-items: center;
    gap: 11px;
}

.file-icon,
.folder-icon {
    width: 38px;
    height: 38px;
    margin: 0;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--ui-primary);
    background: var(--ui-primary-soft);
    border-radius: 11px;
    font-size: 18px;
}

.folder-icon {
    color: #b45309;
    background: #fff7ed;
}

.file-name,
.folder-link {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-link:hover {
    color: var(--ui-primary);
}

.file-size {
    margin: 0 0 0 auto;
    padding: 4px 9px;
    flex: 0 0 auto;
    color: #475467;
    background: var(--ui-surface-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.file-remark,
.file-source,
.file-meta {
    margin: 4px 0 0 49px;
    overflow: hidden;
    color: var(--ui-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-source a,
.file-meta a {
    color: #4f46e5;
    text-decoration: none;
}

.download-count {
    color: #067647;
    font-weight: 700;
}

.empty-folder {
    min-height: 250px;
    padding: 52px 24px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    color: var(--ui-muted);
    text-align: center;
}

.empty-folder::before {
    content: "⌑";
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    color: #818cf8;
    background: var(--ui-primary-soft);
    border-radius: 18px;
    font-size: 28px;
}

.empty-folder::after {
    content: "上传文件或创建文件夹开始使用";
    color: #98a2b3;
    font-size: 12px;
}

/* 弹窗与表单 */
.modal {
    padding: 24px;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: min(100%, 560px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 26px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: var(--ui-radius-lg);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.modal-content h3 {
    margin: 0 0 6px;
    font-size: 20px;
}

.modal-subtitle {
    margin: 0 0 22px;
    color: var(--ui-muted);
    font-size: 13px;
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    margin-bottom: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}

.form-group input,
.form-group select,
.login-container input {
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 13px;
    color: var(--ui-text);
    background: #fff;
    border: 1px solid var(--ui-border-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    transition: border .18s ease, box-shadow .18s ease;
}

.form-group input[type="file"] {
    padding: 8px;
    background: var(--ui-surface-soft);
}

.form-group input:focus,
.form-group select:focus,
.login-container input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .11);
    outline: none;
}

.form-group small,
#shareCodeHint {
    display: block;
    margin-top: 6px;
    color: var(--ui-muted);
    font-size: 12px;
}

.form-actions {
    margin-top: 22px;
    justify-content: flex-end;
}

.progress-info {
    margin-bottom: 10px;
    color: #344054;
    font-size: 13px;
}

.progress-bar-container {
    height: 10px;
    background: #e8ecf4;
}

.progress-bar {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.upload-speed,
.upload-time {
    color: var(--ui-muted);
    font-size: 12px;
}

/* 登录/注册 */
body.auth-page {
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at 12% 12%, rgba(129, 140, 248, .24), transparent 30rem),
        radial-gradient(circle at 88% 85%, rgba(56, 189, 248, .18), transparent 28rem),
        #f5f7ff;
}

.auth-shell {
    width: min(100%, 940px);
    min-height: 560px;
    display: grid;
    grid-template-columns: 1.08fr .92fr;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 26px;
    box-shadow: 0 28px 80px rgba(51, 65, 85, .17);
}

.auth-intro {
    position: relative;
    padding: 52px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(145deg, #312e81 0%, #4f46e5 55%, #6366f1 100%);
}

.auth-intro::before,
.auth-intro::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 50%;
}

.auth-intro::before {
    width: 330px;
    height: 330px;
    right: -170px;
    top: -110px;
}

.auth-intro::after {
    width: 220px;
    height: 220px;
    left: -120px;
    bottom: -90px;
}

.auth-brand,
.auth-copy,
.auth-footnote {
    position: relative;
    z-index: 1;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 750;
}

.auth-brand .brand-mark {
    color: #4338ca;
    background: #fff;
    box-shadow: none;
}

.auth-copy h1 {
    margin: 0 0 14px;
    max-width: 360px;
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.15;
    letter-spacing: -.035em;
}

.auth-copy p {
    max-width: 360px;
    margin: 0;
    color: rgba(255, 255, 255, .74);
    font-size: 15px;
}

.auth-footnote {
    color: rgba(255, 255, 255, .58);
    font-size: 12px;
}

.login-container {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 64px 54px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
}

.login-container h2 {
    margin: 0 0 8px;
    color: var(--ui-text);
    text-align: left;
    font-size: 27px;
    letter-spacing: -.02em;
}

.auth-subtitle {
    margin: 0 0 30px;
    color: var(--ui-muted);
    font-size: 14px;
}

.login-container form {
    display: grid;
    gap: 16px;
}

.auth-field label {
    display: block;
    margin-bottom: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}

.login-container button {
    width: 100%;
    height: 46px;
    margin-top: 4px;
    color: #fff;
    background: linear-gradient(100deg, #4f46e5, #6366f1);
    border: 0;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(79, 70, 229, .2);
    font-size: 14px;
    font-weight: 700;
}

.login-container button:hover {
    background: linear-gradient(100deg, #4338ca, #4f46e5);
}

/* 管理端分享页 */
.share-admin-shell {
    max-width: 960px;
}

.page-heading {
    margin-bottom: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.page-heading h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.02em;
}

.page-heading p {
    margin: 5px 0 0;
    color: var(--ui-muted);
    font-size: 13px;
}

.file-info-card,
.share-form,
.share-info {
    margin: 0 0 18px;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--ui-border);
    border-left: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-sm);
}

.file-info-card p,
.share-info p {
    margin: 9px 0;
    color: #475467;
    word-break: break-word;
}

.share-info h3,
.share-form h3 {
    margin: 0 0 14px;
}

.share-form ul {
    margin: 12px 0 22px;
    padding-left: 20px;
    color: var(--ui-muted);
}

.share-form li + li {
    margin-top: 7px;
}

.share-info form {
    margin-top: 18px;
}

.warning-box {
    margin-top: 18px;
    padding: 15px 17px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 11px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .file-item {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .file-actions-container,
    .file-item > .file-actions {
        padding-left: 49px;
        justify-content: flex-start;
    }

    .auth-shell {
        grid-template-columns: 1fr;
        width: min(100%, 520px);
    }

    .auth-intro {
        min-height: 220px;
        padding: 34px;
    }

    .auth-copy h1 {
        margin-top: 34px;
        font-size: 30px;
    }

    .auth-footnote {
        display: none;
    }
}

@media (max-width: 640px) {
    body.auth-page {
        padding: 0;
        place-items: stretch;
    }

    .header {
        position: static;
        min-height: auto;
        padding: 14px 16px;
        flex-direction: row;
    }

    .brand-copy small,
    .user-chip,
    .user-info a:first-of-type {
        display: none;
    }

    .user-info {
        margin: 0;
    }

    .user-info a {
        height: 34px;
        padding: 0 9px;
    }

    .main-container {
        width: calc(100% - 24px);
        margin: 18px auto 36px;
    }

    .storage-info,
    .toolbar,
    .file-item,
    .file-info-card,
    .share-form,
    .share-info {
        padding: 16px;
    }

    .toolbar,
    .storage-summary,
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .toolbar button {
        width: 100%;
        min-width: 0;
    }

    .file-main {
        align-items: flex-start;
    }

    .file-name {
        overflow: visible;
        white-space: normal;
        word-break: break-word;
    }

    .file-size {
        margin-left: 0;
    }

    .file-remark,
    .file-source,
    .file-meta {
        margin-left: 0;
        white-space: normal;
        word-break: break-word;
    }

    .file-actions-container,
    .file-item > .file-actions {
        padding-left: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .file-item .btn-action,
    .file-item button.btn-action,
    .file-item form {
        width: 100%;
        min-width: 0;
    }

    .modal {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 22px 18px;
        border-radius: 20px;
    }

    .auth-shell {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .auth-intro {
        min-height: 190px;
        padding: 28px;
    }

    .auth-copy h1 {
        margin-top: 26px;
        font-size: 27px;
    }

    .auth-copy p {
        display: none;
    }

    .login-container {
        padding: 38px 28px 48px;
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
