:root {
    --bg-color: #000;
    --text-color: #0F0;
    --dim-color: rgba(0, 255, 0, 0.7);
    --border-color: #0F0;
    --highlight-color: #FFF;
    --font-stack: 'Courier New', Courier, monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-stack);
    overflow-x: hidden;
    line-height: 1.6;
}

/* 背景 Canvas */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.8;
}

/* 扫描线效果 */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.2)
    );
    background-size: 100% 4px;
    z-index: 999;
    pointer-events: none;
    opacity: 0.6;
}

/* 容器 - 左右布局 */
.container {
    max-width: 98%; /* 更宽的流式布局 */
    margin: 0 auto;
    padding: 10px; /* 减少内边距 */
    position: relative;
    z-index: 1;
    min-height: 100vh; /* 移动端最小高度 */
    display: flex;
    flex-direction: column;
}

.main-layout {
    display: flex;
    flex-direction: column;
    gap: 15px; /* 减少间距 */
    flex: 1;
}

@media (min-width: 1024px) {
    .container {
        height: 100vh; /* 桌面端固定高度 */
        overflow: hidden;
    }

    .main-layout {
        flex-direction: row;
        align-items: flex-start;
        height: 100%;
        overflow: hidden; /* 桌面端内部滚动 */
    }

    .sidebar {
        width: 280px; /* 缩小侧边栏宽度 */
        flex-shrink: 0;
        height: 100%;
        overflow-y: auto; /* 侧边栏内部滚动 */
    }

    .content {
        flex: 1;
        min-width: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .works-box {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* 内部滚动 */
    }
    
    .works-grid {
        flex: 1;
        overflow-y: auto; /* 作品列表独立滚动 */
        padding-right: 5px; /* 滚动条空间 */
        align-content: start; /* 内容靠上 */
    }
}

/* 通用盒子样式 */
.terminal-box {
    background: rgba(0, 20, 0, 0.85);
    border: 1px solid var(--border-color);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    padding: 15px; /* 减少内边距 */
    margin-bottom: 0;
    border-radius: 4px;
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    /* 移除 height: 100% 避免在非flex环境下撑开 */
}

@media (min-width: 1024px) {
    .terminal-box {
        height: 100%; /* 大屏下撑满高度 */
    }
}

.terminal-header {
    border-bottom: 1px dashed var(--dim-color);
    padding-bottom: 8px; /* 减少高度 */
    margin-bottom: 15px; /* 减少间距 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.terminal-title {
    font-weight: bold;
    font-size: 1.1rem; /* 稍微缩小 */
    text-shadow: 0 0 5px var(--text-color);
}

.terminal-controls span {
    display: inline-block;
    width: 10px; /* 缩小控件 */
    height: 10px;
    border-radius: 50%;
    margin-left: 5px;
}
.red { background: #ff5f56; }
.yellow { background: #ffbd2e; }
.green { background: #27c93f; }

/* 个人信息 */
.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: left;
    gap: 15px; /* 减少间距 */
}

.avatar-wrapper {
    position: relative;
    margin-bottom: 8px;
    align-self: center;
}

.avatar {
    width: 120px; /* 缩小头像 */
    height: 120px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--border-color);
    object-fit: cover;
}

.profile-info {
    width: 100%;
}

.name {
    font-size: 1.6rem; /* 缩小名字 */
    margin-bottom: 5px;
    text-shadow: 0 0 10px var(--text-color);
    text-align: center;
}

.role {
    color: var(--dim-color);
    font-size: 0.9rem;
    margin-bottom: 10px;
    white-space: pre-wrap;
    line-height: 1.4;
    text-align: left;
}

.typing-container {
    min-height: 1.6em;
    margin-bottom: 15px;
    color: #FFF;
    font-size: 0.85rem;
    white-space: pre-wrap;
    line-height: 1.4;
    word-break: break-word;
    text-align: left;
}

.cursor {
    display: inline-block;
    width: 6px;
    height: 1em;
    background-color: var(--text-color);
    animation: blink 1s infinite;
    vertical-align: middle;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px; /* 减少间距 */
    width: 100%;
}

.contact-item {
    border: 1px solid var(--dim-color);
    padding: 8px; /* 减少内边距 */
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.contact-item:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 15px var(--border-color);
    color: #FFF;
}

.label {
    display: block;
    font-size: 0.75rem;
    color: var(--dim-color);
    margin-bottom: 4px;
}

/* 作品列表 */
.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); /* 缩小卡片最小宽度 */
    gap: 15px; /* 减少间距 */
}

.work-card {
    border: 1px solid var(--dim-color);
    background: rgba(0, 10, 0, 0.8);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: auto; /* 自适应高度 */
}

.work-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.4);
    border-color: #FFF;
}

.work-image {
    width: 100%;
    height: 130px; /* 缩小图片高度 */
    object-fit: cover;
    border-bottom: 1px solid var(--dim-color);
    filter: grayscale(80%) contrast(1.2);
    transition: filter 0.3s;
}

.work-card:hover .work-image {
    filter: grayscale(0%) contrast(1);
}

.work-content {
    padding: 10px; /* 减少内边距 */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.work-title {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #FFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 作品描述文本处理 */
.work-desc {
    font-size: 0.8rem;
    color: var(--dim-color);
    margin-bottom: 10px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 减少行数 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    white-space: pre-wrap;
}

#modal-desc {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* 名字字符块特效 */
.char-block {
    display: inline-block;
    padding: 1px 3px;
    margin: 0 1px;
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid var(--dim-color);
    color: var(--highlight-color);
    text-shadow: 0 0 5px var(--text-color);
    transition: all 0.3s;
    font-size: 1.5rem; /* 随名字缩小 */
}

.char-block:hover {
    background: var(--text-color);
    color: #000;
    transform: translateY(-3px);
    box-shadow: 0 0 10px var(--text-color);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.tag {
    font-size: 0.75rem;
    border: 1px solid var(--dim-color);
    padding: 2px 6px;
    border-radius: 2px;
}

.download-btn {
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: auto;
    font-family: var(--font-stack);
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.download-btn:hover {
    background: var(--text-color);
    color: #000;
    box-shadow: 0 0 10px var(--text-color);
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* 更深的背景 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.modal-content {
    width: 100%;
    max-width: 900px; /* 加宽 */
    max-height: 90vh;
    overflow-y: auto;
    background: #000;
    border: 2px solid #0F0; /* 加粗边框 */
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.4), inset 0 0 20px rgba(0, 255, 0, 0.1); /* 内外发光 */
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 10px;
}

@media (min-width: 768px) {
    /* 保持 modal 上下布局，移除原来的左右布局代码 */
    .modal-image-container {
        width: 100%;
    }
}

.modal-image-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 20, 0, 0.5);
    min-height: 300px;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 60vh; /* 限制最大高度，避免过长 */
    width: auto;      /* 保持比例 */
    border: 1px solid var(--dim-color);
    display: block;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
}

/* 轮播图控件 */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-color);
    border: 1px solid var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 10;
    user-select: none;
}

.carousel-btn:hover {
    background: var(--text-color);
    color: #000;
    box-shadow: 0 0 10px var(--text-color);
}

.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border: 1px solid var(--text-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.carousel-dot.active {
    background: var(--text-color);
    box-shadow: 0 0 5px var(--text-color);
}


.modal-info h2 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    color: #FFF;
    text-shadow: 0 0 10px #0F0;
    border-bottom: 1px dashed var(--dim-color);
    padding-bottom: 10px;
}

.modal-info p {
    margin-bottom: 25px;
    color: #ccc;
    line-height: 1.8;
    font-size: 1rem;
}

.modal-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
}

.modal-actions .download-btn {
    display: inline-block;
    padding: 12px 30px;
    font-size: 1.1rem;
    letter-spacing: 1px;
    font-weight: bold;
    background: rgba(0, 255, 0, 0.1);
}

.close-btn {
    cursor: pointer;
    color: #ff5f56;
    font-weight: bold;
    font-size: 1.5rem;
    padding: 0 10px;
}

.close-btn:hover {
    text-shadow: 0 0 5px red;
    color: #FFF;
}

/* Loader 样式 */
.loader {
    text-align: center;
    padding: 20px;
    color: var(--text-color);
    font-weight: bold;
    letter-spacing: 2px;
    animation: pulse 1.5s infinite;
}

.loader.hidden {
    display: none;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* 动画 */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .main-layout {
        gap: 20px;
    }

    /* 移动端 sidebar 调整 */
    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
    }
    
    .profile-section {
        flex-direction: column;
        text-align: center; /* 移动端可以居中，或者保持左对齐视喜好而定，这里保持左对齐的一致性但头像居中 */
    }
    
    .role, .typing-container {
        text-align: left; /* 保持左对齐以增加可读性 */
    }

    .works-grid {
        grid-template-columns: 1fr; /* 单列 */
        gap: 20px;
    }

    .terminal-box {
        padding: 15px;
    }

    .name {
        font-size: 1.5rem;
    }

    .avatar {
        width: 120px;
        height: 120px;
    }

    /* 模态框适配 */
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 85vh;
        border-width: 1px; /* 边框变细 */
    }
    
    .modal-image-container {
        min-height: 200px;
    }
    
    .modal-info h2 {
        font-size: 1.5rem;
    }
}