/* ============================================================
   Life OS 2.0 — Design System v2
   低饱和莫兰迪色系 + 黑白基础配色
   基础层用暖白/墨黑灰，类目用专属莫兰迪色区分
   ============================================================ */
:root {
  /* 黑白基础层（暖调黑白灰） */
  --bg: #F4F2EE;            /* 暖白灰底 */
  --surface: #FFFFFF;       /* 卡片纯白 */
  --surface-2: #FAF9F6;     /* 次级面（输入框等） */
  --border: #E6E2DA;        /* 暖灰描边 */
  --text: #3B3733;          /* 墨黑偏暖 */
  --text-2: #79736A;        /* 次级文字 */
  --text-3: #A8A195;        /* 弱化文字 */
  --shadow: 0 1px 3px rgba(59, 55, 51, .06);
  --shadow-lg: 0 18px 44px rgba(59, 55, 51, .16);

  /* 主色：莫兰迪灰绿 */
  --accent: #849B8A;
  --accent-soft: #EDF2EE;
  --accent-deep: #657D6C;
  --danger: #C08A7A;        /* 莫兰迪陶土红 */
  --ok: #7FA08A;            /* 莫兰迪绿 */

  --radius: 16px;
  --radius-s: 10px;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1240px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, #9DB2A0, #71896F);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
  box-shadow: 0 3px 8px rgba(113, 137, 111, .3);
}
.brand b { font-size: 15px; letter-spacing: .01em; }
.brand small { display: block; color: var(--text-3); font-size: 11px; font-weight: 400; }

.nav-sec { margin-top: 14px; }
.nav-sec .sec-title { font-size: 11px; color: var(--text-3); letter-spacing: .08em; padding: 0 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none;
  padding: 8px 10px; border-radius: var(--radius-s); font-size: 13.5px; color: var(--text-2); text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sb-close { display: none; }

/* ---------- 移动端自适应（手机抽屉式导航） ---------- */
.topbar { display: none; }
.scrim { display: none; }
@media (max-width: 768px) {
  .topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 60;
  }
  .topbar .hamburger { border: 0; background: none; font-size: 20px; color: var(--text); padding: 2px 6px; line-height: 1; }
  .topbar .brand-mini { font-size: 15px; display: flex; align-items: center; gap: 7px; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 252px; z-index: 80;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sb-close { display: inline-flex; margin-left: auto; border: 0; background: none; font-size: 17px; color: var(--text-3); padding: 4px 8px; }
  .main { padding: 16px 14px 90px; max-width: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(59, 55, 51, .42); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .card { overflow-x: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 18px; }
}

/* ---------- 通用卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title h3 { font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.card-title .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { font-size: 21px; display: flex; align-items: center; gap: 9px; }
.page-head p { color: var(--text-2); font-size: 13px; margin-top: 3px; }

/* ---------- 按钮 ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: var(--radius-s); font-size: 13px; transition: .15s; }
.btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(132, 155, 138, .3); }
.btn-primary:hover { opacity: .92; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { border: none; background: none; color: var(--text-3); padding: 4px 6px; }
.btn-ghost:hover { color: var(--accent-deep); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 标签 / 徽章 ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 7px; background: var(--bg); color: var(--text-2); white-space: nowrap; }

/* ---------- 进度条 ---------- */
.pbar { height: 7px; background: #EDEBE6; border-radius: 99px; overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 99px; transition: width .4s; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px; border-bottom: 1px solid #F0EEE9; font-size: 13.5px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }

/* ---------- 列表条目 ---------- */
.item-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid #F0EEE9; }
.item-row:last-child { border-bottom: 0; }
.item-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row.done .grow { text-decoration: line-through; color: var(--text-3); }

.checkbox { width: 19px; height: 19px; border: 1.6px solid #C9C4BA; border-radius: 7px; background: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; padding: 0; transition: background .15s, border-color .15s; }
.checkbox.on { background: var(--ok); border-color: var(--ok); }

/* ---------- 表单 / 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(59, 55, 51, .35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: 560px; max-width: 100%; max-height: 86vh; overflow-y: auto; padding: 22px 24px; box-shadow: var(--shadow-lg); }
.modal-body { font-size: 13px; color: var(--text-2); }
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; color: var(--text-2); }
.form-field label .req { color: var(--danger); }
.form-field .hint2 { font-size: 11px; color: var(--text-3); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: var(--surface-2); outline: none; transition: border-color .15s, background .15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); background: #fff; }
.form-field textarea { min-height: 66px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Dashboard ---------- */
.dash-hero { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.dash-hero h2 { font-size: 22px; }
.dash-hero .quote { color: var(--text-2); font-size: 13px; font-style: italic; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .lb { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.quick-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.qa-btn { display: flex; align-items: center; gap: 6px; border: 1px dashed var(--border); background: var(--surface); border-radius: 12px; padding: 8px 13px; font-size: 13px; color: var(--text-2); transition: .15s; }
.qa-btn:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }

.focus-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .focus-cards { grid-template-columns: 1fr; } }
.focus-card { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-s); padding: 12px 14px; background: var(--surface-2); cursor: pointer; transition: .15s; }
.focus-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.focus-card b { font-size: 13.5px; }
.focus-card .meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.inbox-input { display: flex; gap: 8px; margin-bottom: 8px; }
.inbox-input input { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; outline: none; background: var(--surface-2); transition: border-color .15s, background .15s; }
.inbox-input input:focus { border-color: var(--accent); background: #fff; }

/* ---------- Area 色块页 ---------- */
.area-banner { border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; }
.area-banner h2 { font-size: 20px; }
.area-banner p { font-size: 13px; opacity: .75; margin-top: 2px; }

/* Goal 详情闭环 */
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.chain .node { background: var(--accent-soft); color: var(--accent-deep); padding: 3px 10px; border-radius: 99px; font-weight: 600; }

.empty { text-align: center; color: var(--text-3); padding: 26px 0; font-size: 13px; }
.section-label { font-size: 12px; color: var(--text-3); letter-spacing: .05em; margin: 18px 0 8px; text-transform: uppercase; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 13px; font-size: 12.5px; color: var(--text-2); transition: .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #3B3733; color: #FAF9F6; padding: 9px 18px; border-radius: 12px; font-size: 13px; z-index: 200; box-shadow: 0 8px 24px rgba(59,55,51,.28); }

.week-dots { display: flex; gap: 4px; }
.week-dots .wd { width: 16px; height: 16px; border-radius: 5px; background: #EDEBE6; font-size: 0; border: 0; padding: 0; cursor: pointer; }
.week-dots .wd.on { background: var(--ok); }
.week-dots .wd.today { outline: 2px solid var(--accent); outline-offset: 1px; }

canvas.chart { max-height: 240px; }

/* ---------- 自定义确认弹窗（替代原生 confirm，避免被沙盒拦截） ---------- */
.confirm-box { width: 380px; max-width: 100%; padding: 20px 22px; }
.confirm-box p { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.confirm-box .modal-actions { margin-top: 16px; }

/* ---------- Tasks 日历视图 ---------- */
.cal-wrap { padding: 18px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-header b { font-size: 16px; color: var(--text); }
.cal-weekdays { margin-bottom: 8px; }
.cal-weekday { text-align: center; font-size: 12px; color: var(--text-3); font-weight: 500; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-cell { min-height: 110px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 8px; display: flex; flex-direction: column; transition: .15s; }
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.empty { background: transparent; border-color: transparent; pointer-events: none; }
.cal-cell.today { border-color: var(--accent); background: var(--accent-soft); }
.cal-day { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.cal-add { border: none; background: none; color: var(--text-3); width: 20px; height: 20px; border-radius: 5px; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.cal-add:hover { background: var(--accent); color: #fff; }
.cal-tasks { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.cal-task { display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 5px; border-radius: 6px; cursor: pointer; color: var(--text); }
.cal-task:hover { background: rgba(132, 155, 138, .12); }
.cal-task.done span { text-decoration: line-through; color: var(--text-3); }
.cal-task .checkbox { width: 15px; height: 15px; border-radius: 5px; font-size: 10px; flex-shrink: 0; }
