:root {
    --primary-color: rgba(142, 142, 147, 0.8);
    --primary-gradient: linear-gradient(135deg, rgba(240, 240, 245, 0.7), rgba(220, 225, 235, 0.8));
    --card-bg: rgba(255, 255, 255, 0.65);
    --text-light: rgba(255, 255, 255, 0.95);
    --text-dark: rgba(30, 30, 35, 0.85);
    --disabled-color: rgba(120, 120, 130, 0.4);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --highlight-glow: 0 0 15px rgba(150, 150, 220, 0.2);
    --anim-duration: 0.3s;
    --button-bg: rgba(255, 255, 255, 0.8);
    --button-hover: rgba(255, 255, 255, 0.95);
    --button-primary: rgba(140, 160, 215, 0.4);
    --button-primary-hover: rgba(140, 160, 215, 0.6);
    --bg-color: #f0f2f5;
    --text-primary: rgba(30, 30, 35, 0.85);
    --text-secondary: rgba(80, 80, 90, 0.85);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* 背景效果 */
body::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 35%, rgba(180, 190, 230, 0.1) 0%, transparent 60%),
        radial-gradient(circle at 80% 10%, rgba(140, 160, 200, 0.08) 0%, transparent 60%);
    z-index: -1;
}

/* 浮动光球效果 */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.25;
    transition: all 3s ease-in-out;
    z-index: -1;
}

.orb.one {
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(160, 180, 255, 0.5), transparent 70%);
    animation: float1 20s infinite alternate;
}

.orb.two {
    bottom: -150px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(180, 200, 255, 0.5), transparent 70%);
    animation: float2 25s infinite alternate;
}

@keyframes float1 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(50px, 30px) rotate(10deg); }
}

@keyframes float2 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(30px, -50px) rotate(-15deg); }
}

/* 顶部导航栏 */
header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(230, 240, 255, 0.8);
    position: relative;
    z-index: 10;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(to right, rgba(30, 30, 35, 0.9), rgba(80, 100, 160, 0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, rgba(140, 160, 215, 0.7), rgba(180, 200, 255, 0.3));
    border-radius: 2px;
}

.logo-icon {
    font-size: 1.8rem;
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--anim-duration) ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--button-bg);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(200, 200, 220, 0.5);
}

.btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-primary {
    background: var(--button-primary);
    color: var(--text-dark);
}

.btn-primary:hover {
    background: var(--button-primary-hover);
}

/* 主要内容区域 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* 链接卡片网格 */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
    position: relative;
}

.link-card {
    height: 120px;
    background: var(--card-bg);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: all var(--anim-duration) ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.link-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.9), rgba(220, 225, 235, 0.5));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.5;
}

.link-card:hover {
    transform: translateY(-5px) scale(1.02);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(255, 255, 255, 0.1);
}

.link-card.hidden {
    background: rgba(240, 240, 245, 0.4);
    color: var(--disabled-color);
}

.link-card.hidden:hover {
    transform: none;
    box-shadow: var(--card-shadow);
}

.link-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.link-url {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 管理模式下的卡片样式 */
.edit-mode .link-card {
    padding-top: 2.5rem;
}

.card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity var(--anim-duration) ease;
}

.edit-mode .card-actions {
    opacity: 1;
}

.card-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(200, 210, 230, 0.5);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: all var(--anim-duration) ease;
}

.card-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

/* 增加上移/下移按钮样式 */
.card-btn.move-up, .card-btn.move-down {
    background: rgba(144, 202, 249, 0.3);
}

.card-btn.move-up:hover, .card-btn.move-down:hover {
    background: rgba(144, 202, 249, 0.5);
}

.card-btn.edit {
    background: rgba(144, 202, 249, 0.3);
}

.card-btn.hide {
    background: rgba(158, 158, 158, 0.3);
}

.card-btn.delete {
    background: rgba(229, 115, 115, 0.3);
}

.card-btn.edit:hover {
    background: rgba(144, 202, 249, 0.5);
}

.card-btn.hide:hover {
    background: rgba(158, 158, 158, 0.5);
}

.card-btn.delete:hover {
    background: rgba(229, 115, 115, 0.5);
}

/* 添加新链接区域 */
.add-link-section {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(245, 248, 255, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(220, 230, 250, 0.8);
    display: none;
    position: relative;
}

.add-link-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to right, rgba(140, 160, 215, 0.5), rgba(180, 200, 255, 0.2));
    border-radius: 5px 5px 0 0;
}

.edit-mode .add-link-section {
    display: block;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(200, 200, 220, 0.5);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font-size: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--anim-duration) ease;
}

.form-input:focus {
    outline: none;
    border-color: rgba(140, 160, 215, 0.7);
    box-shadow: 0 0 0 2px rgba(140, 160, 215, 0.3);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 模态弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(240, 240, 245, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--anim-duration) ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 90%;
    max-width: 400px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(245, 248, 255, 0.9));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all var(--anim-duration) ease;
    position: relative;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1.5px;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 1), rgba(220, 225, 235, 0.5));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.5;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    background: linear-gradient(to right, var(--text-primary), rgba(80, 100, 160, 0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error-message {
    color: #e53935;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
}

/* 增强移动端适配，特别是竖屏状态 */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .logo {
        font-size: 1.2rem;
        max-width: 60%; /* 限制最大宽度 */
    }
    
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .logo-text {
        display: block; /* 确保标题显示 */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis; /* 超出部分显示省略号 */
    }
    
    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* 专门针对非常窄的屏幕（如iPhone竖屏状态）添加额外适配 */
@media (max-width: 480px) {
    header {
        padding: 0.8rem;
        flex-wrap: wrap; /* 允许元素换行 */
    }
    
    .logo {
        font-size: 1.1rem;
        width: 100%; /* 竖屏状态下标题占满宽度 */
        margin-bottom: 0.5rem; /* 添加一些底部间距 */
        justify-content: center; /* 居中显示 */
    }
    
    /* 调整按钮在窄屏下的位置 */
    #adminBtn {
        margin-left: auto; /* 将按钮推到右侧 */
        margin-right: auto; /* 居中显示按钮 */
        margin-top: 0.3rem;
    }
    
    /* 调整标题文本样式 */
    .logo-text {
        display: inline; /* 内联显示确保可见 */
        max-width: calc(100% - 2rem); /* 确保不会溢出 */
    }
    
    /* 调整卡片网格 */
    .links-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
    
    .link-card {
        height: 110px;
        padding: 1rem;
    }
}

/* 添加一个专门用于iPhone的修复 */
@media only screen 
and (device-width: 390px) 
and (device-height: 844px) 
and (-webkit-device-pixel-ratio: 3) 
and (orientation: portrait) {
    /* iPhone 14 Pro特定修复 */
    .logo {
        display: flex !important; /* 强制显示 */
        justify-content: center !important;
    }
    
    .logo-text {
        display: inline !important; /* 强制显示文本 */
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    header {
        height: auto; /* 允许header高度自适应 */
        min-height: 110px; /* 确保有足够的高度 */
        flex-direction: column; /* 垂直排列 */
        justify-content: center;
        align-items: center;
    }
}

/* 动画效果 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* 编辑模态窗 */
.modal-form-group {
    margin-bottom: 1.2rem;
}

/* 添加无链接时的状态 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    margin-top: 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* 添加装饰几何形状 */
.decoration {
    position: absolute;
    z-index: -1;
    pointer-events: none;
}

.decoration-shape {
    position: absolute;
    border-radius: 24px;
    background: linear-gradient(45deg, rgba(160, 180, 255, 0.2), rgba(140, 160, 215, 0.15));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transform: rotate(-5deg);
    animation: float-shape 15s infinite alternate ease-in-out;
}

.decoration-shape.one {
    width: 200px;
    height: 200px;
    top: 15%;
    right: -50px;
    background: linear-gradient(45deg, rgba(160, 210, 250, 0.15), rgba(140, 190, 235, 0.1));
    animation-duration: 20s;
}

.decoration-shape.two {
    width: 150px;
    height: 150px;
    bottom: 20%;
    left: -30px;
    background: linear-gradient(45deg, rgba(180, 160, 240, 0.15), rgba(160, 140, 220, 0.1));
    transform: rotate(10deg);
    animation-duration: 18s;
}

.decoration-shape.three {
    width: 100px;
    height: 100px;
    top: 60%;
    right: 10%;
    background: linear-gradient(45deg, rgba(250, 180, 180, 0.15), rgba(230, 160, 160, 0.1));
    transform: rotate(-15deg);
    animation-duration: 22s;
}

.decoration-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.decoration-circle.one {
    width: 30px;
    height: 30px;
    top: 25%;
    left: 15%;
    animation: float-circle 12s infinite alternate ease-in-out;
}

.decoration-circle.two {
    width: 20px;
    height: 20px;
    bottom: 30%;
    right: 25%;
    animation: float-circle 15s infinite alternate-reverse ease-in-out;
}

.decoration-circle.three {
    width: 15px;
    height: 15px;
    top: 70%;
    left: 30%;
    animation: float-circle 10s infinite alternate ease-in-out;
}

@keyframes float-shape {
    0% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(2deg); }
    100% { transform: translateY(5px) rotate(-8deg); }
}

@keyframes float-circle {
    0% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(-10px); opacity: 0.9; }
    100% { transform: translateY(5px); opacity: 0.7; }
}

/* 美化卡片颜色 */
.links-grid {
    position: relative;
}

/* 为不同卡片添加微妙的颜色变化 */
.link-card:nth-child(3n+1)::before {
    background: linear-gradient(to bottom right, rgba(180, 200, 255, 0.9), rgba(220, 225, 235, 0.5));
    opacity: 0.6;
}

.link-card:nth-child(3n+2)::before {
    background: linear-gradient(to bottom right, rgba(180, 230, 210, 0.9), rgba(220, 240, 235, 0.5));
    opacity: 0.6;
}

.link-card:nth-child(3n+3)::before {
    background: linear-gradient(to bottom right, rgba(250, 210, 180, 0.9), rgba(240, 230, 220, 0.5));
    opacity: 0.6;
}

/* 标题编辑按钮样式 */
.title-edit-btn {
    display: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(200, 210, 230, 0.5);
    font-size: 0.8rem;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    cursor: pointer;
    transition: all var(--anim-duration) ease;
}

.title-edit-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

.edit-mode .title-edit-btn {
    display: flex;
}

/* 加载状态指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 240, 245, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--anim-duration) ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.5);
    border-top: 5px solid var(--button-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}