/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    --primary: #4f6ef7;
    --primary-dark: #3a56d4;
    --primary-light: #eef1ff;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --gray: #8e8e93;
    --gray-light: #f5f6fa;
    --border: #e9ecf0;
    --shadow: 0 2px 16px rgba(0,0,0,0.04);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body {
    font-family: var(--font);
    background: #f0f2f8;
    color: #1c1c1e;
    min-height: 100vh;
    padding: 16px;
    -webkit-font-smoothing: antialiased;
}
.app-container {
    max-width: 1300px;
    margin: 0 auto;
}

/* ===== iconfont 基础样式（确保所有 iconfont 图标显示正确） ===== */
.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.btn .iconfont {
    font-size: 14px;
    margin-right: 4px;
}
.btn-xs .iconfont {
    font-size: 12px;
}
.device-list li .icon .iconfont {
    font-size: 18px;
}
.empty-state .empty-icon {
    font-size: 48px;
    color: var(--border);
}

/* ===== 头部 ===== */
.app-header {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 12px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}
.logo span {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 30px;
    margin-left: 4px;
}
.device-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.device-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-dark);
}
.device-badge .dot {
    font-size: 8px;
    color: var(--success);
}
.device-badge .model {
    font-weight: 400;
    color: var(--gray);
    margin-left: 2px;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-light);
    color: #1c1c1e;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}
.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #27ae60;
    transform: translateY(-1px);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: var(--gray-light);
}
.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}
.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 6px;
}
.btn-share-selected {
    background: var(--success);
    color: #fff;
}
.btn-share-selected:hover {
    background: #27ae60;
}

/* ===== 主网格 ===== */
.main-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
}
@media (max-width: 820px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 侧边栏 ===== */
.sidebar {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-sidebar {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--primary-light);
}
.card-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.card-sidebar-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-dark);
}
.card-sidebar-title i {
    margin-right: 6px;
}
.card-sidebar-content {
    font-size: 13px;
    color: #1c1c1e;
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.card-sidebar-content .card-empty-tip {
    color: var(--gray);
    font-style: italic;
    font-size: 12px;
}
.card-sidebar-content .card-line {
    padding: 2px 0;
    border-bottom: 1px dashed rgba(0,0,0,0.04);
}
.card-sidebar-content .card-line .label {
    font-weight: 600;
    color: var(--primary);
    margin-right: 6px;
}

.sidebar-title {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}
.sidebar-title:hover {
    background: var(--gray-light);
}
.sidebar-title .count {
    background: var(--gray-light);
    padding: 0 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--gray);
}
.sidebar-title .arrow {
    font-size: 12px;
    transition: transform 0.3s;
}
.sidebar-title .arrow.open {
    transform: rotate(180deg);
}
.device-list-wrap {
    overflow-y: auto;
    max-height: 0;
    transition: max-height 0.35s ease;
}
.device-list-wrap.open {
    max-height: 600px;
}
.device-list {
    list-style: none;
    padding: 4px 0;
}
.device-list li {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 13px;
}
.device-list li:hover {
    background: var(--gray-light);
}
.device-list li.active {
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}
.device-list li .icon {
    font-size: 16px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.device-list li .info {
    flex: 1;
    min-width: 0;
}
.device-list li .info .name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-list li .info .model {
    font-size: 11px;
    color: var(--gray);
}
.device-list li .info .time {
    font-size: 10px;
    color: var(--gray);
    opacity: 0.6;
}
.device-list li .badge-current {
    background: var(--success);
    color: #fff;
    font-size: 9px;
    padding: 1px 8px;
    border-radius: 20px;
    font-weight: 600;
}
.device-list .empty-tip {
    padding: 30px 16px;
    text-align: center;
    color: var(--gray);
    font-size: 13px;
}

/* ===== 主内容 ===== */
.content {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    min-height: 500px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tabs .tab {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    margin-bottom: -2px;
}
.tabs .tab:hover {
    color: #1c1c1e;
    background: var(--gray-light);
}
.tabs .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tabs .tab i {
    margin-right: 6px;
}

/* ===== 面包屑 ===== */
.breadcrumb {
    padding: 4px 0 12px 0;
    font-size: 13px;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.breadcrumb .crumb {
    cursor: pointer;
    transition: var(--transition);
    color: var(--primary);
}
.breadcrumb .crumb:hover {
    text-decoration: underline;
}
.breadcrumb .crumb.current {
    color: #1c1c1e;
    cursor: default;
    font-weight: 600;
}
.breadcrumb .separator {
    color: var(--border);
    user-select: none;
}

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
    justify-content: space-between;
}
.toolbar .left {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.toolbar .right {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.search-box {
    display: flex;
    align-items: center;
    background: var(--gray-light);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    gap: 6px;
}
.search-box input {
    border: none;
    background: transparent;
    padding: 6px 0;
    font-size: 13px;
    outline: none;
    width: 140px;
}
.search-box input::placeholder {
    color: var(--gray);
}
.toolbar select {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    color: #1c1c1e;
    cursor: pointer;
}

/* ===== 资源网格 ===== */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (max-width: 1024px) {
    .resource-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .resource-grid { grid-template-columns: 1fr; }
}

.resource-card {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: var(--transition);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02);
    position: relative;
    cursor: pointer;
}
.resource-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79,110,247,0.08);
}
.resource-card .checkbox-wrap {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    z-index: 2;
}
.resource-card .checkbox-wrap.show {
    display: block;
}
.resource-card .checkbox-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.resource-card .type-tag {
    font-size: 11px;
    background: var(--gray-light);
    padding: 0 10px;
    border-radius: 20px;
    align-self: flex-start;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray);
}
.resource-card .type-tag i {
    margin-right: 4px;
}
.resource-card .type-tag.file { background: #d6eaf8; color: #2e86c1; }
.resource-card .type-tag.image { background: #d5f5e3; color: #1e8449; }
.resource-card .type-tag.video { background: #fdebd0; color: #ca6f1e; }
.resource-card .type-tag.link { background: #ebdef0; color: #6c3483; }
.resource-card .type-tag.text { background: #fadbd8; color: #922b21; }
.resource-card .type-tag.card { background: var(--primary-light); color: var(--primary-dark); }
.resource-card .name {
    font-weight: 600;
    font-size: 14px;
    word-break: break-word;
    margin-bottom: 4px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.resource-card .preview {
    margin: 6px 0 8px 0;
    background: var(--gray-light);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 140px;
    min-height: 60px;
    position: relative;
}
.resource-card .preview img {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
}
.resource-card .preview video {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 4px;
}
.resource-card .preview .link-preview {
    padding: 6px 10px;
    font-size: 12px;
    word-break: break-all;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}
.resource-card .preview .text-preview {
    padding: 6px 10px;
    font-size: 12px;
    color: #1c1c1e;
    overflow-y: auto;
    width: 100%;
    height: 100%;
    word-break: break-all;
    line-height: 1.4;
    text-align: left;
    background: #fafbfc;
}
.resource-card .preview .card-preview {
    padding: 6px 10px;
    font-size: 12px;
    color: #1c1c1e;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: #fafbfc;
    text-align: left;
    line-height: 1.5;
}
.resource-card .preview .card-preview .line {
    padding: 2px 0;
    border-bottom: 1px dashed #eee;
}
.resource-card .preview .card-preview .line .label {
    font-weight: 600;
    color: var(--primary);
}
.resource-card .meta {
    font-size: 11px;
    color: var(--gray);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 4px 0 6px 0;
}
.resource-card .meta .tag {
    background: var(--gray-light);
    padding: 0 6px;
    border-radius: 4px;
    font-size: 9px;
    color: var(--primary);
    font-weight: 500;
}
.resource-card .meta .tag.public { color: var(--success); }
.resource-card .meta .tag.shared { color: var(--warning); }
.resource-card .meta .from-device {
    color: var(--primary);
    font-weight: 500;
}
.resource-card .actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.resource-card .actions .btn {
    font-size: 11px;
    padding: 2px 8px;
}

/* 文件夹卡片 */
.resource-card.is-folder {
    background: var(--gray-light);
    border-color: var(--border);
}
.resource-card.is-folder:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.resource-card.is-folder .folder-icon {
    font-size: 32px;
    display: block;
    text-align: center;
    margin-bottom: 2px;
}
.resource-card.is-folder .name {
    text-align: center;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}
.empty-state .empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    color: var(--border);
}
.empty-state p {
    font-size: 16px;
}
.empty-state .sub {
    font-size: 13px;
    opacity: 0.7;
    margin-top: 4px;
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}
.modal-overlay.open {
    display: flex;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    max-width: 540px;
    width: 100%;
    padding: 24px 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}
@keyframes modalIn {
    0% { opacity:0; transform: scale(0.94) translateY(20px); }
    100% { opacity:1; transform: scale(1) translateY(0); }
}
.modal h2 {
    font-size: 18px;
    margin-bottom: 4px;
}
.modal h2 i {
    color: var(--primary);
    margin-right: 8px;
}
.modal .desc {
    color: var(--gray);
    font-size: 13px;
    margin-bottom: 16px;
}
.modal .form-group {
    margin-bottom: 14px;
}
.modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}
.modal .form-group input,
.modal .form-group textarea,
.modal .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
    font-family: inherit;
    background: #fff;
}
.modal .form-group input:focus,
.modal .form-group textarea:focus,
.modal .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.1);
}
.modal .form-group textarea {
    resize: vertical;
    min-height: 60px;
}
.modal .form-group .file-input-wrap {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray);
}
.modal .form-group .file-input-wrap:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.modal .form-group .file-input-wrap input[type="file"] {
    display: none;
}
.modal .file-status {
    font-size: 12px;
    color: var(--gray);
    margin-top: 4px;
}
.modal .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.device-check-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px 0;
}
.device-check-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}
.device-check-list label:hover {
    background: var(--gray-light);
}
.device-check-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.device-check-list .select-all {
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.device-check-list .select-all:hover {
    color: var(--primary-dark);
}

/* 详情弹窗 */
#detailModal .detail-preview {
    background: var(--gray-light);
    border-radius: var(--radius-sm);
    padding: 8px;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#detailModal .detail-preview img,
#detailModal .detail-preview video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    object-fit: contain;
}
#detailModal .detail-content {
    background: var(--gray-light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
#detailModal .detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
    width: 100%;
}
.toast {
    background: #1c1c1e;
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    font-size: 13px;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
    0% { opacity:0; transform: translateX(40px); }
    100% { opacity:1; transform: translateX(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    body { padding: 10px; }
    .app-header { padding: 10px 16px; }
    .logo { font-size: 17px; }
    .content { padding: 16px; }
    .modal { padding: 20px; }
    .search-box input { width: 100px; }
    .device-badge .model { display: none; }
}
@media (max-width: 480px) {
    .resource-grid { grid-template-columns: 1fr; }
    .toolbar .left, .toolbar .right { width: 100%; }
    .search-box input { width: 100%; }
}
/* 添加资源 Tab 样式 */
.add-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.add-tab {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    margin-bottom: -2px;
}
.add-tab:hover {
    color: #1c1c1e;
    background: var(--gray-light);
}
.add-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.add-tab-content {
    display: none;
}
.add-tab-content.active {
    display: block;
}
.batch-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.batch-item .content {
    flex: 1;
    word-break: break-all;
    line-height: 1.4;
}
.batch-item .content a {
    color: var(--primary);
    text-decoration: underline;
}
.batch-item .actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
}
.batch-item .copy-count {
    font-size: 11px;
    color: var(--gray);
    margin-right: 4px;
}