:root {
    --bg-color: #f4f1ea; /* Paper like off-white */
    --text-color: #1a1a1a;
    --accent-color: #c44536; /* Deep red for brand */
    --secondary-color: #197278; /* Teal */
    --font-title: 'Noto Serif SC', serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-soft: 0 10px 30px rgba(0,0,0,0.05);
    --shadow-hard: 0 4px 0px rgba(0,0,0,0.1);

    /* 核心主题色系统 - 恢复红色 #c44536 */
    --color-primary-50: #F9ECEB;
    --color-primary-100: #F2D1CE;
    --color-primary-200: #E6A39C;
    --color-primary-300: #D9756B;
    --color-primary-400: #CD4739;
    --color-primary-500: #c44536; /* 主色 */
    --color-primary-600: #A33A2D;
    --color-primary-700: #822E24;
    --color-primary-800: #61221B;
    --color-primary-900: #401712;

    --primary-color: var(--color-primary-500);
    --text-muted: #666666;
    
    /* 弥散阴影系统 (使用红色调混合) */
    --shadow-sm: 0 1px 1px rgba(196, 69, 54, 0.02);
    --shadow-md: 0 2px 8px rgba(196, 69, 54, 0.04), 0 4px 16px rgba(196, 69, 54, 0.06);
    --shadow-lg: 0 8px 24px rgba(196, 69, 54, 0.08);
    
    /* Bento 行高 */
    --bento-row: 200px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    background-image: url("https://www.transparenttextures.com/patterns/p6.png"); /* Simple paper grain */
    color: var(--text-color);
    font-family: var(--font-mono);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Film Grain Texture */
body::after {
    content: "";
    position: fixed;
    top: -150%;
    left: -150%;
    width: 300%;
    height: 300%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.05;
    pointer-events: none;
    z-index: 9999;
    animation: noise 0.2s infinite;
}

@keyframes noise {
    0% { transform: translate(0,0) }
    10% { transform: translate(-5%,-5%) }
    20% { transform: translate(-10%,5%) }
    30% { transform: translate(5%,-10%) }
    40% { transform: translate(-5%,15%) }
    50% { transform: translate(-10%,5%) }
    60% { transform: translate(15%,0) }
    70% { transform: translate(0,10%) }
    80% { transform: translate(-15%,0) }
    90% { transform: translate(10%,5%) }
    100% { transform: translate(5%,0) }
}

h1, h2, h3, .serif {
    font-family: var(--font-title);
    font-weight: 700;
}

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: var(--bento-row);
    gap: 20px;
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.bento-item {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 30px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
}

.bento-item:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    background: rgba(255, 255, 255, 0.95);
}

/* Specific Bento Sizes */
.item-large { 
    grid-column: span 2; 
    grid-row: span 2; 
    background: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);
}
.item-wide { grid-column: span 2; }
.item-tall { grid-row: span 2; }

/* 仅用于需要比所在轨道高度少 10px 的卡片 */
.item-tall-shrink {
    align-self: start;
    height: calc(100% - 10px);
}

/* Skills Section Artistry */
.skills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.skill-tag {
    padding: 6px 12px;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 100px;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.3s ease;
}

.skill-tag:hover {
    transform: scale(1.08);
    background: rgba(196, 69, 54, 0.12);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(196, 69, 54, 0.1);
}

@media (prefers-color-scheme: dark) {
    .skill-tag {
        background: rgba(30, 30, 30, 0.7);
        border-color: rgba(255, 255, 255, 0.1);
    }
    .skill-tag:hover {
        background: rgba(196, 69, 54, 0.2);
    }
}

.skills-decoration {
    position: absolute;
    bottom: -10px;
    right: -10px;
    opacity: 0.05;
    font-family: var(--font-mono);
    font-size: 3rem;
    transform: rotate(-15deg);
    pointer-events: none;
    user-select: none;
}

/* Social Links Artistry */
.social-link-item {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 8px;
    border-radius: 12px;
}

.social-link-item:hover {
    background: rgba(0,0,0,0.03);
    transform: translateX(5px);
}

/* Project Experience Placeholder */
.project-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    border: 2px dashed rgba(0,0,0,0.05);
    border-radius: 16px;
    margin-top: 15px;
    color: #999;
    font-style: italic;
}

/* Buttons with Elastic Animation */
.btn-primary {
    display: inline-block;
    padding: 12px 28px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-weight: 700;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm), 0 4px 12px rgba(196, 69, 54, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm), 0 8px 20px rgba(196, 69, 54, 0.3);
    background-color: var(--color-primary-600);
}

/* Personal Intro Styling - More Radical Asymmetry */
.intro-section {
    padding: 60px 40px;
    max-width: 1300px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    gap: 80px;
    position: relative;
}

.intro-text {
    z-index: 2;
}

.intro-text h1 {
    font-size: 5.5rem;
    margin-bottom: 30px;
    line-height: 0.9;
    letter-spacing: -2px;
    position: relative;
    left: -20px; /* Staggered left */
}

.intro-image {
    position: relative;
    z-index: 1;
}

.intro-image img {
    width: 110%; /* Overflowing */
    height: 500px;
    object-fit: cover;
    border-radius: 40px;
    filter: sepia(0.2) contrast(1.1) grayscale(0.3);
    box-shadow: 40px 40px 0px var(--secondary-color);
    transform: rotate(-2deg);
    transition: transform 0.5s ease;
}

.intro-image:hover img {
    transform: rotate(0deg) scale(1.02);
}

/* Overlapping effect */
.overlap-box {
    position: absolute;
    top: -40px;
    left: -60px;
    background: var(--accent-color);
    color: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 250px;
    font-size: 1.1rem;
    transform: rotate(-8deg);
    box-shadow: 10px 10px 0px var(--text-color);
    z-index: 3;
}

.brand-lottie {
    position: absolute;
    right: -50px;
    bottom: -50px;
    width: 200px;
    height: 200px;
    opacity: 0.8;
    z-index: 0;
}

/* Markdown Body Styling */
.markdown-body {
    font-family: var(--font-mono);
    font-size: 0.95rem;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-family: var(--font-title);
}
.markdown-body code {
    background: #eee;
    padding: 2px 5px;
    border-radius: 4px;
}
.markdown-body pre {
    background: #2d2d2d;
    color: #ccc;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 15px 0;
}
/* Comments Section Styling */
#comments-section {
    background: rgba(255, 255, 255, 0.5);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

#comments-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('https://www.transparenttextures.com/patterns/p6.png');
    opacity: 0.1;
    pointer-events: none;
    border-radius: 24px;
}

#comment-input {
    background: rgba(255, 255, 255, 0.8);
    border: 1px dashed #ccc;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#comment-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.comment-item {
    transition: all 0.3s ease;
    padding: 20px;
    border-radius: 12px;
}

.comment-item:hover {
    background: rgba(0,0,0,0.02);
}

.like-btn {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dropdown Menu */
.dropdown-menu {
    position: fixed;
    background: white;
    min-width: 140px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 8px 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0,0,0,0.05);
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: #f8f9fa;
    color: var(--accent-color);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 1200;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal-content {
    background: white;
    border-radius: 24px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px; right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-family: var(--font-mono);
}

.form-group input:focus {
    border-color: var(--accent-color);
    outline: none;
}

.btn-secondary {
    display: inline-block;
    padding: 12px 28px;
    background-color: transparent;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--color-primary-50);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.user-profile-btn {
    transition: all 0.3s;
    border: 1px solid transparent;
}

.user-profile-btn:hover {
    background: rgba(196, 69, 54, 0.05) !important;
    border-color: var(--accent-color);
    color: var(--accent-color) !important;
}
.m-dialog-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2147483647;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 当对话框打开时，降低导航相关元素层级，防止遮挡 */
body.dialog-open .main-nav,
body.dialog-open .menu-toggle,
body.dialog-open .mobile-menu-panel,
body.dialog-open .dropdown-menu {
    z-index: 0 !important;
    pointer-events: none;
}

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

.m-dialog {
    background: var(--bg-color);
    background-image: url("https://www.transparenttextures.com/patterns/p6.png");
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.m-dialog-overlay.active .m-dialog {
    transform: scale(1) translateY(0);
}

.m-dialog-title {
    font-family: var(--font-title);
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--accent-color);
}

.m-dialog-body {
    font-size: 1rem;
    margin-bottom: 25px;
    color: var(--text-color);
    line-height: 1.6;
}

.m-dialog-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    margin-bottom: 20px;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.8);
}

.m-dialog-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.m-dialog-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: var(--font-mono);
}

.m-dialog-btn-primary {
    background: var(--accent-color);
    color: white;
}

.m-dialog-btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
}

.m-dialog-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

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

.social-link-item {
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 10px;
}

.social-link-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(5px);
}

.social-link-item:hover span:first-child {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.social-link-item span:first-child {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Navigation Refactor */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 20px 0;
    transition: all 0.3s ease;
    background: rgba(244, 241, 234, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    color: var(--text-color);
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    margin-left: 30px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
    display: inline-flex;
    align-items: center;
}

.nav-links a:hover {
    color: var(--accent-color);
}

/* Mobile Toggle Button */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 10px;
    transition: all 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* Toggle Animation to X */
.menu-toggle.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Mobile Menu Panel */
.mobile-menu-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh;
    background: var(--bg-color);
    background-image: url("https://www.transparenttextures.com/patterns/p6.png");
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
    z-index: 1050;
}

.mobile-menu-panel.active {
    right: 0;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.mobile-nav-links a {
    font-size: 1.8rem;
    font-family: var(--font-title);
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.3s;
}

.mobile-nav-links a:hover {
    color: var(--accent-color);
}

/* Responsive Visibility */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: flex; }
    
    .nav-container { padding: 0 20px; }
    
    /* Intro Section Adjustments */
    .intro-section {
        grid-template-columns: 1fr;
        padding-top: 100px;
        gap: 40px;
        text-align: center;
    }
    
    .intro-image {
        grid-row: 1; /* Move image to top */
    }
    
    .intro-image img {
        width: 100%;
        height: 350px;
        left: 0;
    }
    
    .overlap-box {
        left: 50%;
        transform: translateX(-50%) rotate(-5deg);
        top: -20px;
        width: 200px;
        padding: 15px;
        font-size: 0.9rem;
    }
    
    .intro-text h1 {
        font-size: 3.5rem;
        left: 0;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
    .item-large, .item-wide, .item-tall {
        grid-column: span 1;
        grid-row: span 1;
    }
    .intro-section {
        flex-direction: column;
        text-align: center;
    }
    .intro-text h1 {
        font-size: 2.5rem;
    }
}
