:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-body: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-sidebar: rgba(255, 255, 255, 0.9);
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: rgba(229, 231, 235, 0.6);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --font-sans: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-sidebar: rgba(30, 41, 59, 0.9);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-sans); color: var(--text-main); height: 100vh; overflow: hidden; }

/* 全局背景图层 */
#app-background {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    background-image: url('que.jfif'); /* 默认背景图 */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease;
}

/* 玻璃拟态基础 */
.card, .sidebar, .weather-badge {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-container { display: flex; height: 100vh; background: rgba(0,0,0,0.02); }
.sidebar { width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1.5rem; transition: all 0.3s; z-index: 10; }
.main-content { flex: 1; overflow-y: auto; padding: 2rem; position: relative; }

/* 导航 */
.logo-area { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; margin-bottom: 3rem; color: var(--primary); }
.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 0.95rem; font-weight: 500; transition: all 0.2s; text-align: left; width: 100%; position: relative; }
.nav-item:hover { background: rgba(0,0,0,0.05); color: var(--text-main); }
.nav-item.active { background: var(--primary); color: white; box-shadow: var(--shadow-md); }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.badge { position: absolute; right: 10px; font-size: 0.7rem; background: var(--danger); color: white; padding: 2px 6px; border-radius: 4px; }

/* 通用组件 */
.card { background: var(--bg-card); border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border); transition: transform 0.2s, border-color 0.2s; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 8px; cursor: pointer; font-weight: 500; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-full { width: 100%; }
.btn-danger-sm { background: var(--danger); color: white; border: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
.icon-btn, .icon-btn-sm { background: transparent; border: 1px solid var(--border); color: var(--text-main); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.icon-btn { width: 36px; height: 36px; }
.icon-btn-sm { width: 28px; height: 28px; border: none; }
.icon-btn:hover, .icon-btn-sm:hover { background: rgba(0,0,0,0.1); }
.hidden { display: none !important; }

/* 页面切换动画 */
.page-section { display: none; opacity: 0; animation: fadeIn 0.4s ease forwards; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 头部与天气 */
.section-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.section-header h1 { font-size: 1.8rem; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.weather-container { position: relative; }
.weather-badge { cursor: pointer; padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; font-weight: 500; display: flex; align-items: center; gap: 8px; transition: 0.2s; }
.weather-badge:hover { border-color: var(--primary); color: var(--primary); }
#city-input-wrapper { position: absolute; top: 110%; right: 0; width: 200px; z-index: 20; background: var(--bg-card); padding: 8px; border-radius: 8px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
#city-input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; background: rgba(255,255,255,0.5); color: var(--text-main); }

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; grid-template-rows: auto auto auto; }
.stat-card { display: flex; align-items: center; gap: 1rem; }
.stat-card.hover-action { cursor: pointer; }
.stat-card.hover-action:hover { transform: translateY(-3px); border-color: var(--primary); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; }
.bg-blue { background: #3b82f6; } .bg-green { background: #10b981; } .bg-purple { background: #8b5cf6; }
.stat-info .label { display: block; font-size: 0.85rem; color: var(--text-muted); }
.stat-info .value { font-size: 1.5rem; font-weight: 700; }
.text-up { color: var(--success); font-size: 1rem; margin-left: 5px; }
.chart-card { grid-column: span 2; height: 320px; }
.chart-container { position: relative; height: 100%; width: 100%; }
.todo-card { grid-row: span 2; display: flex; flex-direction: column; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.count-badge { font-size: 0.8rem; background: rgba(0,0,0,0.05); padding: 2px 8px; border-radius: 10px; color: var(--text-muted); }
.todo-input input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.5); color: var(--text-main); margin-bottom: 10px; }
.task-list { list-style: none; overflow-y: auto; flex: 1; }
.task-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: grab; }
.task-item.completed span { text-decoration: line-through; color: var(--text-muted); }
.task-delete { margin-left: auto; color: var(--danger); opacity: 0; cursor: pointer; }
.task-item:hover .task-delete { opacity: 1; }
.countdown-card { grid-column: span 1; }
.countdown-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cd-timer { font-family: monospace; font-weight: 700; color: var(--primary); }

/* 密码生成器 */
.password-container { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.password-output { display: flex; gap: 10px; margin-bottom: 1rem; }
#generated-password { flex: 1; padding: 1rem; font-size: 1.5rem; font-family: monospace; border: 2px solid var(--border); border-radius: 8px; background: rgba(255,255,255,0.5); color: var(--text-main); text-align: center; outline: none; }
.strength-meter { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 10px; display: flex; align-items: center; }
.strength-bar { flex: 1; height: 100%; background: #e5e7eb; }
#strength-fill { height: 100%; transition: width 0.3s, background 0.3s; }
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
input[type="range"] { width: 60%; accent-color: var(--primary); }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.custom-checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#password-history-list { list-style: none; font-family: monospace; color: var(--text-muted); max-height: 200px; overflow-y: auto; }
#password-history-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hist-pass { word-break: break-all; font-size: 0.9rem; flex: 1; }
.hist-time { font-size: 0.75rem; white-space: nowrap; opacity: 0.7; }
.hist-copy { background: none; border: none; cursor: pointer; color: var(--primary); opacity: 0.5; transition: 0.2s; padding: 4px; }
.hist-copy:hover { opacity: 1; background: rgba(0,0,0,0.05); border-radius: 4px; }

/* 图标工场 */
.icon-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.upload-card { border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; height: 300px; transition: 0.2s; }
.upload-card:hover { border-color: var(--primary); background: rgba(79, 70, 229, 0.05); }
.preview-row { display: flex; gap: 20px; align-items: flex-end; }
.browser-mockup { background: #e5e7eb; border-radius: 8px 8px 0 0; overflow: hidden; margin-bottom: 1rem; flex: 1; }
.browser-tab { background: white; width: 140px; padding: 8px 12px; border-radius: 8px 8px 0 0; display: flex; align-items: center; gap: 8px; font-size: 0.8rem; margin-top: 8px; margin-left: 10px; }
.fav-mini { width: 16px; height: 16px; object-fit: contain; }
.app-mockup { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.app-icon-wrapper { width: 60px; height: 60px; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
#preview-app-icon { width: 100%; height: 100%; object-fit: cover; }

/* 模态框 */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 100; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { width: 400px; max-width: 90%; animation: popIn 0.3s ease; display: flex; flex-direction: column; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-body { margin-bottom: 1.5rem; }
.sound-select-group { margin-bottom: 1rem; }
#rest-sound-select { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-body); color: var(--text-main); margin-top: 5px; }
.time-presets { display: flex; gap: 10px; margin: 15px 0; }
.preset-btn { flex: 1; padding: 8px; border: 1px solid var(--border); background: var(--bg-body); border-radius: 6px; cursor: pointer; color: var(--text-main); }
.preset-btn:hover { border-color: var(--primary); color: var(--primary); }
.custom-time-input input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; background: var(--bg-body); color: var(--text-main); }
.timer-display-area { text-align: center; margin-top: 15px; padding: 15px; background: rgba(0,0,0,0.05); border-radius: 8px; }
#rest-countdown-display { font-size: 2rem; font-weight: 700; color: var(--primary); display: block; margin-bottom: 10px; font-family: monospace; }
.cropper-wrapper { overflow: hidden; border-radius: 8px; }

/* Toast */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--text-main); color: var(--bg-card); padding: 12px 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 8px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 响应式 */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .chart-card { grid-column: span 2; }
}
@media (max-width: 768px) {
    .app-container { flex-direction: column; height: auto; overflow: auto; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 1rem; height: auto; position: sticky; top: 0; }
    .nav-menu { flex-direction: row; }
    .nav-item span { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .chart-card { grid-column: span 1; }
    .icon-workspace { grid-template-columns: 1fr; }
}