:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient-1: #f3f4f6;
    --bg-gradient-2: #e0e7ff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --card-bg: rgba(255, 255, 255, 0.85);
    
    /* 玻璃拟物风相关变量 */
    --glass-bg-header: rgba(255, 255, 255, 0.6);
    --glass-border-header: rgba(255, 255, 255, 0.3);
    --glass-bg-footer: rgba(255, 255, 255, 0.4);
    --glass-border-footer: rgba(255, 255, 255, 0.5);
    --glass-border-card: rgba(255, 255, 255, 0.5);
    
    --avatar-bg: rgba(255, 255, 255, 0.8);
    --avatar-shadow: rgba(99, 102, 241, 0.3);
    --loading-border: #cbd5e1;
    --separator: #cbd5e1;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #818cf8;
        --primary-hover: #6366f1;
        --bg-gradient-1: #0f172a;
        --bg-gradient-2: #1e1b4b;
        --text-main: #f8fafc;
        --text-muted: #94a3b8;
        --card-bg: rgba(30, 41, 59, 0.7);
        
        /* 玻璃拟物风相关变量 (深色) */
        --glass-bg-header: rgba(15, 23, 42, 0.5);
        --glass-border-header: rgba(255, 255, 255, 0.05);
        --glass-bg-footer: rgba(15, 23, 42, 0.4);
        --glass-border-footer: rgba(255, 255, 255, 0.05);
        --glass-border-card: rgba(255, 255, 255, 0.05);
        
        --avatar-bg: rgba(30, 41, 59, 0.8); /* 恢复成正常的深色背景，不需要再预反色了 */
        --avatar-shadow: rgba(0, 0, 0, 0.5); /* 深色模式下的阴影 */
        --loading-border: #334155;
        --separator: #475569;
    }
    
    .avatar {
        filter: invert(1) hue-rotate(180deg);
    }
}

* {
    box-sizing: border-box;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    margin: 0; 
    padding: 0; 
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    background-attachment: fixed;
    color: var(--text-main); 
    line-height: 1.6;
}

/* 顶部通栏玻璃拟物风 */
header { 
    background: var(--glass-bg-header); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 60px 20px; 
    border-bottom: 1px solid var(--glass-border-header);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

.hero {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: center;
    text-align: left;
}

.hero-left {
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.avatar-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    margin: 0 auto;
    padding: 8px; /* 增加内边距缩小图像实际尺寸 */
    background: var(--avatar-bg); /* 增加背景色防止透明部分过空 */
    box-shadow: 0 8px 16px var(--avatar-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    display: block;
    object-fit: contain;
}

h1 { 
    margin: 0; 
    font-size: 2.4rem; 
    font-weight: 800;
    background: linear-gradient(to right, var(--primary), #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-tagline {
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.container { 
    width: 90%; 
    max-width: 1000px; 
    margin: 40px auto; 
}

.section { 
    margin-bottom: 50px; 
}

h2 { 
    font-size: 1.5rem;
    color: var(--text-main); 
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

h2::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(to right, rgba(99, 102, 241, 0.3), transparent);
    margin-left: 15px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
}

.section-head h2 {
    margin-bottom: 0;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-manage-bar {
    display: none;
    align-items: center;
    gap: 12px;
    margin: 12px 0 18px;
    flex-wrap: wrap;
}

.quick-manage-bar.is-active {
    display: flex;
}

.quick-manage-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.quick-manage-tip {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.grid-list { 
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    list-style: none; 
    padding: 0; 
    margin: 0;
}

.card { 
    background: var(--card-bg); 
    backdrop-filter: blur(5px);
    padding: 25px; 
    border-radius: 16px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.02), 0 10px 15px -3px rgba(0,0,0,0.05); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    border: 1px solid var(--glass-border-card);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
}

.card:hover::before {
    opacity: 1;
}

.card a { 
    color: var(--primary); 
    text-decoration: none; 
    font-weight: 700; 
    font-size: 1.25em; 
    margin-bottom: 8px;
    display: inline-block;
}

.card-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
    padding: 4px;
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-title {
    display: inline-block;
}

.quick-card-body {
    display: flex;
    align-items: center;
    gap: 14px;
}

.quick-card-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.quick-card .card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-menu {
    position: absolute;
    top: 12px;
    right: 12px;
}

.quick-menu-button {
    border: 1px solid var(--glass-border-card);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.quick-card:hover .quick-menu-button {
    opacity: 1;
    transform: translateY(-1px);
}

.quick-menu-panel {
    position: absolute;
    top: 38px;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--glass-border-card);
    border-radius: 12px;
    padding: 6px;
    display: none;
    min-width: 120px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    z-index: 5;
}

.quick-menu.open .quick-menu-panel {
    display: block;
}

.quick-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.9rem;
}

.quick-menu-item:hover {
    background: rgba(99, 102, 241, 0.12);
}

.quick-menu-item.danger {
    color: #ef4444;
}

.quick-select {
    position: absolute;
    top: 12px;
    left: 12px;
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quick-select input {
    width: 16px;
    height: 16px;
}

.quick-drag {
    position: absolute;
    right: 12px;
    bottom: 12px;
    color: var(--text-muted);
    font-size: 1rem;
    display: none;
}

.manage-active .quick-select,
.manage-active .quick-drag {
    transition: box-shadow 0.2s ease;
}

.manage-active .quick-menu {
    display: none;
}

.manage-active .quick-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: grab;
    transition: none;
    will-change: transform;
    touch-action: none;
}

.quick-card.reorder-anim {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.quick-card.dragging-live {
    transform: scale(1.02);
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.18);
    opacity: 0.95;
    cursor: grabbing;
}

.quick-card.quick-placeholder {
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed var(--primary);
    box-shadow: none;
}

.manage-active .quick-card {
    cursor: grab;
}

.quick-card.dragging {
    opacity: 0.6;
}

.quick-card.drag-over {
    border-color: var(--primary);
}

.card.friend-card a {
    color: #ec4899; /* 粉红色区分友链 */
}
.friend-card:hover::before {
    background: #ec4899;
}

.card a:hover { 
    text-decoration: underline; 
    text-underline-offset: 4px;
}

.desc { 
    color: var(--text-muted); 
    font-size: 0.95em; 
    line-height: 1.5;
    flex-grow: 1;
}

.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px dashed var(--loading-border);
}

.icon-button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--glass-border-card);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.text-button {
    border: 1px solid var(--glass-border-card);
    background: transparent;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.text-button:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.primary-button {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
}

.modal.show {
    display: flex;
}

.modal-card {
    width: min(520px, 92vw);
    background: var(--card-bg);
    border: 1px solid var(--glass-border-card);
    border-radius: 20px;
    padding: 28px;
    position: relative;
    backdrop-filter: blur(12px);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--glass-border-card);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

.modal-subtitle {
    margin: 4px 0 18px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--glass-border-card);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-main);
    margin-bottom: 16px;
    outline: none;
    transition: border 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-row {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.form-row .form-input {
    margin-bottom: 0;
    flex: 1;
}

.form-row .file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-button {
    border: 1px solid var(--glass-border-card);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.file-button:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.icon-preview {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-top: 8px;
    overflow: hidden;
}

.icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.form-status {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 20px;
}

.form-status[data-tone="success"] {
    color: #16a34a;
}

.form-status[data-tone="warn"] {
    color: #f59e0b;
}

footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 50px;
    background: var(--glass-bg-footer);
    border-top: 1px solid var(--glass-border-footer);
    backdrop-filter: blur(5px);
}

footer .footer-content {
    margin-bottom: 10px;
}

.beian-info {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.85rem;
}

.beian-info a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s;
    display: flex;
    align-items: center;
}

.beian-info a:hover {
    color: var(--primary);
}

.beian-info .beian-separator {
    color: var(--separator);
}

.beian-psb-icon {
    margin-right: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* 代码块和文档样式 */
pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: var(--text-main);
    border: 1px solid var(--glass-border-card);
}

@media (prefers-color-scheme: dark) {
    pre {
        background: rgba(0, 0, 0, 0.3);
    }
}

code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    color: var(--primary);
}

@media (prefers-color-scheme: dark) {
    code {
        background: rgba(0, 0, 0, 0.3);
    }
}

/* 响应式调整 */
@media (max-width: 600px) {
    header { padding: 40px 20px; }
    .hero { grid-template-columns: 1fr; text-align: center; }
    .hero-left { justify-content: center; }
    h1 { font-size: 1.8rem; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .section-actions { width: 100%; justify-content: flex-start; }
    .grid-list { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; align-items: stretch; }
}

.card.is-clickable {
    cursor: pointer;
}