:root {
    --primary-color: #007aff;
    --primary-hover: #0056b3;
    --bg-color: #f5f5f7;
    --text-color: #1d1d1f;
    --text-secondary: #86868b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --sidebar-width: 280px;
    --transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #f5f5f7;
    --text-secondary: #a1a1a6;
    --glass-bg: rgba(28, 28, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 0.5s ease;
    max-width: 100vw;
}

html {
    overflow-x: hidden;
}

/* 背景裝飾 */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(88, 86, 214, 0.1));
    filter: blur(80px);
    border-radius: 50%;
    animation: move 20s infinite alternate;
}

.blob-1 { top: -100px; right: -100px; }
.blob-2 { bottom: -100px; left: -100px; animation-delay: -5s; }

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(50px, 50px) scale(1.1); }
}

/* 玻璃擬態面板 */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
}

/* 頂部導航 */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    transition: var(--transition);
}

.logo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary-color), #5856d6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.desktop-nav {
    display: flex;
    gap: 32px;
    margin-left: 48px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    opacity: 0.7;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    opacity: 1;
    color: var(--primary-color);
}

.top-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.lang-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 10px;
}

.lang-btn {
    background: none;
    border: none;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.lang-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.menu-toggle-btn {
    display: block;
    font-size: 20px;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
}

/* 內容容器 */
.content-wrapper {
    max-width: 1200px;
    margin: 100px auto 120px;
    padding: 0 24px;
}

.page-section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 首頁英雄區塊 */
.hero-section {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 32px;
    margin-bottom: 48px;
}

.profile-card {
    border-radius: 24px;
    overflow: hidden;
    transition: var(--transition);
}

.card-header {
    position: relative;
    height: 160px;
}

.header-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-wrapper {
    position: absolute;
    bottom: -50px;
    left: 24px;
    width: 100px;
    height: 100px;
    border-radius: 28px;
    padding: 4px;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 24px;
}

.card-body {
    padding: 64px 24px 24px;
}

.name-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.name-badge h1 {
    font-size: 28px;
    font-weight: 800;
}

.badge {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.bio {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 24px;
}

.stats-row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    background: none;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    transition: var(--transition);
}

.stat-item:hover {
    background: rgba(0,0,0,0.05);
}

.stat-item i {
    font-size: 18px;
    color: var(--primary-color);
}

.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: block;
    text-align: center;
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* 最新動態滾動 */
.latest-updates {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.scroll-container {
    flex: 1;
    overflow-x: auto;
    display: flex;
    gap: 16px;
    padding-bottom: 8px;
}

.scroll-container::-webkit-scrollbar {
    height: 4px;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.scroll-item {
    min-width: 200px;
    max-width: 220px;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.scroll-item:hover {
    transform: translateY(-4px);
}

.item-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-preview {
    font-size: 0.85rem;
    opacity: 0.7;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-date {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: auto;
}

/* 好友網格 */
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 20px;
    transition: var(--transition);
}

.friend-card:hover {
    transform: translateY(-5px);
    background: rgba(255,255,255,0.9);
}

.f-avatar {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    object-fit: cover;
}

.f-info {
    flex: 1;
}

.f-name {
    font-weight: 700;
    font-size: 16px;
}

.f-bio {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-go {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.btn-go:hover {
    background: var(--primary-color);
    color: white;
}

/* 子頁面樣式 */
.sub-page {
    border-radius: 24px;
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* 動態列表 */
.dynamic-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card {
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.post-card::after {
    content: '点击展开';
    display: block;
    font-size: 0.8rem;
    opacity: 0.4;
    margin-top: 8px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.post-card.expanded::after {
    content: '点击收起';
}

.post-card.expanded {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
    opacity: 0.6;
}

.post-edited {
    font-size: 0.8rem;
}

.post-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.post-content {
    line-height: 1.6;
    max-height: 4.8em;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0.8;
}

.post-card.expanded .post-content {
    max-height: 600px;
    opacity: 1;
}

.post-img {
    width: 100%;
    border-radius: 12px;
    margin-top: 12px;
    cursor: pointer;
}

.post-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

/* 留言板表單 */
.guestbook-form {
    margin-bottom: 32px;
}

.guestbook-form textarea {
    width: 100%;
    height: 120px;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 16px;
    padding: 16px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    margin-bottom: 12px;
    transition: var(--transition);
}

.guestbook-form textarea:focus {
    outline: none;
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0,122,255,0.1);
}

.form-footer {
    display: flex;
    justify-content: flex-end;
}

.site-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
}

/* 側邊欄 */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100%;
    z-index: 2000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.close-btn {
    font-size: 28px;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-links a {
    text-decoration: none;
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-links a:hover, .sidebar-links a.active-link {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 16px 0;
}

.sidebar-footer {
    margin-top: auto;
}

.auth-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
}

.auth-btn.logout {
    background: #ff3b30;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 1500;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* 移動端導航欄 */
.mobile-nav-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 48px);
    max-width: 500px;
    height: 64px;
    border-radius: 32px;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    transition: var(--transition);
}

.nav-item i {
    font-size: 20px;
}

.nav-item.active {
    color: var(--primary-color);
}

/* 更多菜單 */
.more-menu {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 200px;
    border-radius: 20px;
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

.more-menu.active {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.more-menu a {
    text-decoration: none;
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.more-menu a:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* 模態框 */
.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 24px;
}

.modal-mask.active {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 400px;
    border-radius: 28px;
    padding: 32px;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
}

.input-group input {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(0,0,0,0.03);
    font-family: inherit;
}

.modal-btns {
    display: flex;
    gap: 12px;
}

.modal-btns .primary-btn {
    flex: 1;
    width: auto;
    display: block;
}

.modal-btns .secondary-btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
}

/* 轉跳彈窗 */
.redirect-icon {
    text-align: center;
    margin-bottom: 16px;
    font-size: 32px;
    color: var(--primary-color);
}

.url-display {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.04);
    padding: 10px 14px;
    border-radius: 10px;
    margin: 16px 0 24px;
    word-break: break-all;
    line-height: 1.4;
}

/* 作品集 */
.works-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.work-card {
    border-radius: 16px;
    padding: 20px;
    overflow: hidden;
}

.work-img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 16px;
    object-fit: cover;
    max-height: 200px;
}

.work-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.work-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.work-link {
    display: inline-block;
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
}

/* 留言板 */
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    border-radius: 14px;
    padding: 16px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.comment-region {
    font-weight: 600;
    color: var(--primary-color);
}

.comment-content {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 管理員按鈕 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header .section-title {
    margin-bottom: 0;
}

#addFriendBtn, #addWorkBtn, #editContactBtn {
    display: none;
}

.admin-card-btns {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 2;
}

.friend-card, .work-card {
    position: relative;
}

.card-edit-btn, .card-del-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: var(--transition);
}

.card-edit-btn {
    background: rgba(0, 122, 255, 0.15);
    color: var(--primary-color);
}

.card-edit-btn:hover {
    background: var(--primary-color);
    color: white;
}

.card-del-btn {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
}

.card-del-btn:hover {
    background: #ff3b30;
    color: white;
}

.card-del-btn-inline {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 4px;
    transition: var(--transition);
}

.card-del-btn-inline:hover {
    background: #ff3b30;
    color: white;
}

.card-del-btn-inline.del {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.post-admin-btns {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* 聯繫方式 */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(0,0,0,0.02);
}

.contact-item i {
    font-size: 18px;
    color: var(--primary-color);
    width: 24px;
    text-align: center;
}

.contact-edit-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.contact-edit-row input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.03);
    font-family: inherit;
    font-size: 14px;
}

/* 響應式佈局 */
@media (max-width: 992px) {
    .hero-section {
        grid-template-columns: 1fr;
    }
    
    .desktop-nav {
        display: none;
    }
    
    .mobile-nav-bar {
        display: flex;
    }
    
    .site-footer {
        padding-bottom: 100px;
    }

    .friends-grid {
        grid-template-columns: 1fr;
    }

    .content-wrapper {
        overflow-x: hidden;
    }
}

@media (max-width: 600px) {
    .content-wrapper {
        padding: 0 16px;
        overflow-x: hidden;
    }
    
    .sub-page {
        padding: 24px 16px;
        overflow: hidden;
    }

    .scroll-item {
        min-width: 150px;
        max-width: 170px;
        padding: 14px;
        flex-shrink: 0;
    }

    .item-title {
        font-size: 0.85rem;
    }

    .item-preview {
        font-size: 0.78rem;
        -webkit-line-clamp: 2;
    }

    .scroll-container {
        gap: 10px;
    }

    .latest-updates {
        padding: 16px;
        overflow: hidden;
    }

    .friends-section {
        padding: 0;
    }

    .friends-grid {
        gap: 12px;
    }

    .post-card {
        padding: 16px;
    }

    .post-content {
        max-height: 3.6em;
    }

    .post-card.expanded .post-content {
        max-height: 400px;
    }

    .friend-card {
        gap: 12px;
        padding: 14px;
    }

    .f-avatar {
        width: 50px;
        height: 50px;
    }

    .f-name {
        font-size: 14px;
    }

    .f-bio {
        font-size: 12px;
    }

    .work-card {
        padding: 16px;
    }

    .work-title {
        font-size: 1rem;
    }

    .comment-item {
        padding: 14px;
    }

    .url-display {
        font-size: 12px;
        padding: 8px 12px;
    }
}
