/* ════════════════════════════════════════════════════════════
   易效能 · 全局样式（原生 CSS 变量，无框架）
   版本：v1.1（2026-09-01）
   ════════════════════════════════════════════════════════════ */

:root {
  /* 主题（沿用 v1.0 母品牌 navy） */
  --navy: #1a2540;
  --navy-2: #243158;
  --accent: #2f6df6;
  --accent-soft: #e8effe;

  /* 文字 */
  --text: #1a1f2e;
  --text-2: #5a6478;
  --text-3: #98a1b3;

  /* 表面与边框 */
  --bg: #f5f6f9;
  --card: #ffffff;
  --border: #e4e7ee;

  /* 状态色（清单优先级映射：🔴P0 🟡P1 ⚪P2） */
  --p0: #d93026;
  --p1: #e8a33d;
  --p2: #98a1b3;
  --done: #2e9e5b;
  --danger: #d93026;

  /* 日课情绪/体力 */
  --energy-hi: #2e9e5b;
  --energy-mid: #e8a33d;
  --energy-lo: #d93026;

  /* 日历类别色标 */
  --cat-work: #2f6df6;
  --cat-family: #e8739a;
  --cat-personal: #6c5ce7;
  --cat-health: #2e9e5b;
  --cat-client: #e8913d;

  /* 布局 */
  --radius: 10px;
  --radius-sm: 6px;
  --topbar-h: 52px;
  --tabbar-h: 58px;
  --gap: 12px;
  --max-w: 640px;

  --shadow: 0 1px 3px rgba(20, 26, 44, 0.08);
  --shadow-lg: 0 6px 24px rgba(20, 26, 44, 0.12);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── 通用控件 ─────────────────────────────── */
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: background 0.15s, opacity 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--navy-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:active { background: rgba(0,0,0,0.05); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f0d0cd; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }

/* ── 提示条 ─────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%); z-index: 100;
  background: var(--navy); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: 14px; max-width: 90vw;
  box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease;
}
.toast.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── 登录页 ─────────────────────────────── */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 28px; font-weight: 700; color: var(--navy); letter-spacing: 2px; text-align: center; }
.login-sub { text-align: center; color: var(--text-2); font-size: 13px; margin: 6px 0 24px; }
.login-hint { margin-top: 16px; text-align: center; font-size: 12px; color: var(--text-3); }
.error-text { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

/* ── 应用壳 ─────────────────────────────── */
.app-view { max-width: var(--max-w); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--navy); color: #fff;
}
.topbar-brand { font-size: 16px; font-weight: 600; }
.topbar-actions .btn-ghost { color: rgba(255,255,255,0.85); font-size: 13px; padding: 6px 10px; }

.main { flex: 1; padding: var(--gap); padding-bottom: calc(var(--tabbar-h) + 20px); }

.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: var(--max-w);
  height: var(--tabbar-h); display: flex; background: #fff;
  border-top: 1px solid var(--border); z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--text-2);
}
.tab-btn::before {
  content: ""; width: 22px; height: 22px; border-radius: 7px;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  opacity: 0.75;
}
.tab-btn[data-tab="#/"]::before      { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 12h4l2-7 4 14 2-7h6'/%3E%3C/svg%3E"); }
.tab-btn[data-tab="#/lists"]::before   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.tab-btn[data-tab="#/rinke"]::before   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M17 7l1.4-1.4M5.6 18.4L7 17'/%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3C/svg%3E"); }
.tab-btn[data-tab="#/calendar"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M3 9h18'/%3E%3C/svg%3E"); }
.tab-btn[data-tab="#/persona"]::before  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.5-3.5 4.5-5 8-5s6.5 1.5 8 5'/%3E%3C/svg%3E"); }

.tab-btn.active { color: var(--accent); font-weight: 600; }
.tab-btn.active::before { opacity: 1; stroke: var(--accent); }

/* ── 卡片与通用区块 ─────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: var(--gap);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 16px 0 8px; }

.empty-hint { color: var(--text-3); font-size: 13px; padding: 12px 0; text-align: center; }

/* ── 今日看板 ─────────────────────────────── */
.board-grid { display: flex; flex-direction: column; gap: var(--gap); }
.board-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.board-section-head h3 { font-size: 14px; font-weight: 600; color: var(--text-2); }
.board-section-head .link { font-size: 12px; color: var(--accent); }

.today-list { list-style: none; }
.today-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.today-list li:last-child { border-bottom: none; }

.priority-badge {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
}
.priority-badge.p0 { background: var(--p0); }
.priority-badge.p1 { background: var(--p1); }
.priority-badge.p2 { background: var(--p2); }

.today-task-title { flex: 1; font-size: 14px; }
.today-task-title.done-text { text-decoration: line-through; color: var(--text-3); }

.checkbox {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff; position: relative;
  transition: all 0.15s;
}
.checkbox.checked { background: var(--done); border-color: var(--done); }
.checkbox.checked::after {
  content: ""; position: absolute; left: 6px; top: 2.5px;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.event-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.event-item:last-child { border-bottom: none; }
.event-time { flex: none; font-size: 13px; font-weight: 600; color: var(--text-2); width: 52px; }
.event-title { flex: 1; font-size: 14px; }
.event-cat { flex: none; font-size: 11px; color: #fff; border-radius: 10px; padding: 2px 8px; }
.event-cat.work { background: var(--cat-work); }
.event-cat.family { background: var(--cat-family); }
.event-cat.personal { background: var(--cat-personal); }
.event-cat.health { background: var(--cat-health); }
.event-cat.client { background: var(--cat-client); }

.entry-status-card { display: flex; gap: 10px; }
.entry-status {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; background: #fff; text-align: left;
}
.entry-status .es-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.entry-status .es-state { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.entry-status.done { border-color: var(--done); background: #f2faf5; }
.entry-status.done .es-state { color: var(--done); }

.quick-actions { display: flex; gap: 8px; }
.quick-actions .btn { flex: 1; }

/* ── 清单（四级树） ─────────────────────── */
.domain-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.domain-tab {
  padding: 6px 14px; border-radius: 16px; font-size: 13px;
  background: #fff; border: 1px solid var(--border); color: var(--text-2);
}
.domain-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.tree-goal { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin-bottom: var(--gap); overflow: hidden; }
.tree-goal-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  background: var(--navy); color: #fff; cursor: pointer;
}
.tree-goal-head .g-domain {
  flex: none; width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.18); font-size: 12px; font-weight: 700;
}
.tree-goal-head .g-title { flex: 1; font-weight: 600; font-size: 15px; }
.tree-goal-head .g-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,0.18); }
.tree-goal-body { padding: 8px 12px; }

.tree-project { margin: 6px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tree-project-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--accent-soft); cursor: pointer; border-radius: var(--radius-sm);
}
.tree-project-head .p-title { flex: 1; font-weight: 600; font-size: 14px; }
.tree-project-head .p-deadline { font-size: 12px; color: var(--text-2); }
.tree-project-body { padding: 6px 10px; }

.tree-list { margin: 6px 0; }
.tree-list-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer;
  border-radius: var(--radius-sm);
}
.tree-list-head:hover { background: var(--bg); }
.tree-list-head .l-title { flex: 1; font-weight: 500; font-size: 14px; }
.tree-list-body { padding: 2px 6px 6px; }

.tree-task {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: var(--radius-sm);
}
.tree-task:hover { background: var(--bg); }
.tree-task .t-title { flex: 1; font-size: 14px; }
.tree-task .t-title.done-text { text-decoration: line-through; color: var(--text-3); }
.tree-task .t-deadline { font-size: 12px; color: var(--text-3); flex: none; }
.tree-task .t-domain { flex: none; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; }

.row-actions { display: flex; gap: 4px; flex: none; }
.row-actions .btn { padding: 3px 7px; font-size: 12px; }

/* 折叠 */
.collapsed .tree-project-body, .collapsed .tree-list-body { display: none; }

/* ── 日课 ─────────────────────────────── */
.rinke-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.rinke-tab {
  flex: 1; padding: 9px 0; text-align: center; font-size: 14px; font-weight: 500;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2);
}
.rinke-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.rinke-form .field textarea { min-height: 96px; resize: vertical; }
.scale-row { display: flex; gap: 16px; margin-bottom: 14px; }
.scale { flex: 1; }
.scale > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.scale input[type="range"] { width: 100%; accent-color: var(--accent); }
.scale-val { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.rinke-history { list-style: none; }
.rinke-history li { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.rinke-history li:last-child { border-bottom: none; }
.rinke-history .rh-date { font-size: 14px; font-weight: 500; }
.rinke-history .rh-type { font-size: 12px; color: var(--text-3); }
.rinke-history .rh-preview { font-size: 12px; color: var(--text-2); flex: 1; text-align: right; margin: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 日历 ─────────────────────────────── */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav .cal-week-label { font-size: 15px; font-weight: 600; }
.cal-nav .cal-nav-btns { display: flex; gap: 6px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 10px; }
.cal-day-head { text-align: center; font-size: 11px; color: var(--text-2); padding: 4px 0; }
.cal-day {
  min-height: 56px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; position: relative; cursor: pointer;
}
.cal-day.today { border-color: var(--accent); background: var(--accent-soft); }
.cal-day .cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-day .cal-day-count { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--text-3); }
.cal-day .cal-day-dots { position: absolute; bottom: 3px; left: 3px; display: flex; gap: 2px; }
.cal-day .cal-day-dots .dot { width: 5px; height: 5px; border-radius: 50%; }

.cal-day-detail { margin-top: 8px; }
.cal-event {
  display: flex; align-items: center; gap: 8px; padding: 8px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.cal-event:last-child { border-bottom: none; }
.cal-event .ce-color { flex: none; width: 4px; align-self: stretch; border-radius: 2px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 26, 44, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }

/* ── 分身 ─────────────────────────────── */
.persona-card { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 16px; margin-bottom: var(--gap); box-shadow: var(--shadow); }
.persona-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.persona-avatar {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--navy); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 700;
}
.persona-name { font-size: 16px; font-weight: 600; }
.persona-type {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); margin-top: 2px;
}
.persona-role { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.persona-cap-title, .persona-profile-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 10px 0 6px; }
.persona-caps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.persona-caps li { font-size: 12px; background: var(--bg); border: 1px solid var(--border); padding: 4px 10px; border-radius: 12px; color: var(--text-2); }
.persona-profile { font-size: 13px; color: var(--text); white-space: pre-wrap; background: var(--bg); border-radius: var(--radius-sm); padding: 10px; }
.ai-params-note { font-size: 12px; color: var(--text-3); margin-top: 10px; }

/* ── 分身 · Wave 2.5 AI 面板 ─────────────────────── */
.persona-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.persona-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.persona-check { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent); }
.ai-panel { margin-top: var(--gap); }
.ai-panel-head { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.ai-offline-note { font-size: 12px; color: #b54708; background: #fff7e6; border: 1px solid #ffd591; border-radius: var(--radius-sm); padding: 8px 10px; margin: 8px 0; }
.cap-block { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.cap-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.cap-desc { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.cap-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cap-inline input[type="date"], .cap-inline select { font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); }
.cap-inline textarea { width: 100%; font-size: 13px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); resize: vertical; }
.ai-offline-tag { font-size: 12px; color: var(--text-3); }
.ai-busy { font-size: 12px; color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ai-result { margin-top: 14px; }
.ai-result-title { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.ai-text { font-size: 13px; line-height: 1.7; background: var(--bg); border-radius: var(--radius-sm); padding: 10px; white-space: normal; }
.ai-error { font-size: 13px; color: #d93026; background: #fdecea; border: 1px solid #f5b5ae; border-radius: var(--radius-sm); padding: 10px; }
.ai-sub { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.ai-task-list { list-style: none; }
.ai-task-list li { font-size: 13px; padding: 5px 0; display: flex; align-items: center; gap: 8px; }
.ai-deadline { font-size: 12px; color: var(--text-3); }
.ai-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ai-stats span { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 12px; }

/* ── 响应式：桌面 ─────────────────────────────── */
@media (min-width: 768px) {
  .topbar { border-radius: 0 0 10px 10px; }
  .tabbar { border-radius: 12px 12px 0 0; box-shadow: 0 -2px 10px rgba(0,0,0,0.04); }
  .cal-day { min-height: 72px; }
}
