/* ===== 基础设置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f0f4f8;
    --text: #2d3748;
    --card: #ffffff;
    --header-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --header-text: #ffffff;
    --primary: #667eea;
    --primary-hover: #5a67d8;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --input-bg: #edf2f7;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --danger: #e53e3e;
    --success: #38a169;
    --warning: #d69e2e;
}

body.dark {
    --bg: #1a202c;
    --text: #e2e8f0;
    --card: #2d3748;
    --header-bg: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    --header-text: #e2e8f0;
    --primary: #4a5568;
    --primary-hover: #718096;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    --input-bg: #4a5568;
    --nav-bg: rgba(26, 32, 44, 0.95);
    --danger: #fc8181;
}

html { scroll-behavior: smooth; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* ===== 导航栏 ===== */
nav {
    position: sticky; top: 0; z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    align-items: center;
}
nav a {
    text-decoration: none;
    color: var(--text);
    background: var(--input-bg);
    padding: 6px 14px; border-radius: 20px;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.15s;
}
nav a:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
#themeToggle {
    margin-left: auto;
    background: var(--input-bg);
    border: none;
    padding: 6px 14px; border-radius: 20px;
    cursor: pointer; font-size: 1rem; color: var(--text);
}

/* ===== 头部 ===== */
header {
    background: var(--header-bg);
    color: var(--header-text);
    text-align: center; padding: 50px 20px 40px;
}
header h1 { font-size: 2.2rem; margin-bottom: 8px; }
header p { font-size: 1.05rem; opacity: 0.85; }

/* ===== 主区域 ===== */
main { max-width: 800px; margin: 40px auto; padding: 0 20px; }

.card {
    background: var(--card);
    border-radius: 14px; padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: background 0.3s;
}
.card h2 { margin-bottom: 15px; font-size: 1.3rem; }
.card p { margin-bottom: 10px; line-height: 1.7; }

/* ===== 通用表单样式 ===== */
input, textarea, button {
    font-family: inherit; font-size: 0.95rem;
}
input, textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 2px solid transparent;
    padding: 10px 14px; border-radius: 10px;
    outline: none;
    transition: border-color 0.2s;
}
input:focus, textarea:focus {
    border-color: var(--primary);
}
button {
    cursor: pointer;
    background: var(--primary);
    color: #fff; border: none;
    padding: 10px 20px; border-radius: 10px;
    transition: background 0.2s, transform 0.1s;
}
button:hover { background: var(--primary-hover); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 留言板 ===== */
.msg-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.msg-form textarea { resize: vertical; }
.msg-item {
    background: var(--input-bg);
    padding: 12px 16px; border-radius: 10px;
    margin-bottom: 10px; position: relative;
}
.msg-item .msg-name { font-weight: bold; color: var(--primary); font-size: 0.85rem; }
.msg-item .msg-time { font-size: 0.75rem; opacity: 0.5; margin-left: 10px; }
.msg-item .msg-content { margin-top: 6px; }
.msg-item .msg-del {
    position: absolute; top: 10px; right: 14px;
    background: none; color: var(--danger);
    padding: 4px 8px; font-size: 0.8rem;
}

/* ===== 猜数字 ===== */
.guess-box { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 15px 0; }
.guess-box input { width: 120px; }
#guessHint { font-size: 1.1rem; font-weight: bold; min-height: 24px; }

/* ===== 待办清单 ===== */
.todo-form { display: flex; gap: 10px; margin-bottom: 15px; }
.todo-form input { flex: 1; }
#todoList { list-style: none; }
#todoList li {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 10px;
    background: var(--input-bg); margin-bottom: 8px;
}
#todoList li.done .todo-text { text-decoration: line-through; opacity: 0.5; }
#todoList .todo-text { flex: 1; }
#todoList .todo-del {
    background: none; color: var(--danger);
    padding: 4px 8px; font-size: 0.85rem;
}
#todoCount { font-size: 0.85rem; opacity: 0.6; }

/* ===== 图片画廊 ===== */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery-grid img {
    width: 100%; height: 150px; object-fit: cover;
    border-radius: 10px; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.gallery-grid img:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }

/* 灯箱弹窗 */
.lightbox {
    display: none; position: fixed; z-index: 200;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    justify-content: center; align-items: center;
}
.lightbox.show { display: flex; }
.lightbox img {
    max-width: 90%; max-height: 90%;
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.lightbox-close {
    position: absolute; top: 20px; right: 30px;
    color: #fff; font-size: 36px; cursor: pointer;
    font-weight: bold; background: none;
}

/* ===== 天气 ===== */
.weather-form { display: flex; gap: 10px; margin-bottom: 15px; }
.weather-form input { flex: 1; }
.weather-card {
    background: var(--input-bg); border-radius: 14px;
    padding: 20px; text-align: center; display: none;
}
.weather-card.show { display: block; }
.weather-card .temp { font-size: 3rem; font-weight: bold; }
.weather-card .desc { font-size: 1.1rem; opacity: 0.7; margin-top: 5px; }
.weather-card .detail { display: flex; justify-content: center; gap: 30px; margin-top: 15px; font-size: 0.9rem; opacity: 0.7; }

/* ===== 导航链接 ===== */
.bookmark-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.bookmark-form input { flex: 1; min-width: 150px; }
.bookmark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.bm-card {
    background: var(--input-bg);
    padding: 16px; border-radius: 12px;
    text-align: center; text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.bm-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.bm-card .bm-icon { font-size: 2rem; margin-bottom: 6px; }
.bm-card .bm-title { font-weight: bold; }
.bm-card .bm-del {
    position: absolute; top: 4px; right: 8px;
    background: none; color: var(--danger);
    padding: 2px 6px; font-size: 0.75rem; cursor: pointer;
}

/* ===== 番茄钟 ===== */
.pomodoro-display {
    position: relative; width: 220px; height: 220px;
    margin: 20px auto;
}
.pomodoro-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--input-bg); stroke-width: 10; }
.ring-progress {
    fill: none; stroke: var(--success);
    stroke-width: 10; stroke-linecap: round;
    stroke-dasharray: 565.48; stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.3s;
}
.pomodoro-time {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem; font-weight: bold;
    font-family: "Courier New", monospace;
}
.pomodoro-label {
    position: absolute; top: 65%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem; opacity: 0.6;
}
.pomodoro-btns { display: flex; justify-content: center; gap: 12px; }

/* ===== 时钟 ===== */
#clock { font-size: 3rem; font-weight: bold; text-align: center; font-family: "Courier New", monospace; letter-spacing: 4px; }

/* ===== 底部 ===== */
footer { text-align: center; padding: 30px; opacity: 0.5; font-size: 0.85rem; }
footer a { color: var(--primary); }

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    nav { gap: 4px; padding: 8px 10px; }
    nav a { padding: 4px 10px; font-size: 0.8rem; }
    header h1 { font-size: 1.6rem; }
    .card { padding: 20px; }
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .bookmark-grid { grid-template-columns: repeat(2, 1fr); }
    .pomodoro-display { width: 180px; height: 180px; }
    .pomodoro-time { font-size: 2rem; }
}
