﻿/* ==========================================
   1. 全局初始化与变量定义
   ========================================== */
:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --primary-color: #3498db;      /* 优雅蓝：加密 */
    --primary-hover: #2980b9;
    --success-color: #2ecc71;      /* 翡翠绿：解密 */
    --success-hover: #27ae60;
    --border-color: #e2e8f0;
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直居中 */
    align-items: center;
    padding: 20px;
}

/* ==========================================
   2. 头部标题区域
   ========================================== */
header {
    margin-bottom: 2.5rem;
    text-align: center;
}

header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
    width: 100%;
}

/* 突出主要操作提示 */
header h2:first-child {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.8rem;
}

/* ==========================================
   3. 主体内容卡片
   ========================================== */
div.content {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1.5rem; /* 替代原有的 margin，现代布局首选 */
    max-width: 1000px;
    width: 100%;
}

/* 文本域美化 */
div.content>textarea {
    flex: 1;
    width: 100%;
    min-width: 280px;
    height: 14em;
    padding: 1.2rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    resize: none; /* 禁止手动拉伸破坏布局 */
    outline: none;
    transition: var(--transition);
    background-color: #fbfcfc;
    color: var(--text-main);
}

/* Textarea 聚焦效果 */
div.content>textarea:focus {
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
}

/* 右侧汉字/密文框聚焦时换个颜色提示 */
#encoded-area:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.15);
}

/* ==========================================
   4. 中间按钮区域
   ========================================== */
div.content>.buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

/* 统一现代按钮基础样式 (由于HTML写了内联样式，CSS加了!important进行强行覆盖) */
div.content>.buttons button {
    border-radius: var(--radius) !important;
    font-weight: 500 !important;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.06) !important;
    transition: var(--transition) !important;
    padding: 14px 28px !important; /* 稍微收紧，更显精致 */
}

/* 加密按钮悬停 */
#encode-btn:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3) !important;
}

/* 解密按钮悬停 */
#decode-btn:hover {
    background-color: var(--success-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(46, 204, 113, 0.3) !important;
}

/* 按钮按下反馈 */
div.content>.buttons button:active {
    transform: translateY(1px);
}

/* ==========================================
   5. 页脚区域
   ========================================== */
footer {
    margin-top: 2rem;
}
footer>p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================
   6. 响应式布局（完美适配手机端）
   ========================================== */
@media (max-width: 768px) {
    body {
        padding-top: 5%;
    }
    div.content {
        flex-direction: column;
        padding: 1.5rem;
    }
    div.content>.buttons {
        flex-direction: row;
        width: 100%;
    }
    div.content>.buttons button {
        flex: 1;
        padding: 12px 0 !important;
    }
    header h2 {
        font-size: 1rem;
    }
    header h2:first-child {
        font-size: 1.2rem;
    }
}