/* ============ 家庭任务管理 - 全局样式 ============ */
:root {
  --primary: #5B8DEF;
  --primary-dark: #3E6FD8;
  --orange: #F2994A;
  --pink: #EB5A8D;
  --green: #27AE60;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --text: #2D3748;
  --text-light: #8A94A6;
  --border: #E6EAF2;
  --danger: #E5484D;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(45, 55, 72, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 18px;
  font-size: 15px; font-weight: 600; transition: all .15s;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: #EEF3FE; color: var(--primary); }
.btn.ghost:hover { background: #DFE9FD; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger-ghost { background: #FDEEEE; color: var(--danger); }
.btn.warm { background: var(--orange); }
.btn.warm:hover { background: #E08838; }

.input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; outline: none; background: #fff; transition: border .15s;
}
.input:focus { border-color: var(--primary); }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: rgba(45,55,72,.92); color: #fff; padding: 10px 22px;
  border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 999; max-width: 86vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: rgba(229,72,77,.95); }

/* modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30,36,50,.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 100%; max-width: 420px; box-shadow: 0 16px 48px rgba(0,0,0,.18);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal .row { margin-bottom: 14px; }
.modal label { display: block; font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ============ 首页 ============ */
.landing {
  max-width: 480px; margin: 0 auto; padding: 48px 20px;
  display: flex; flex-direction: column; gap: 22px;
}
.landing .logo { text-align: center; margin-bottom: 8px; }
.landing .logo .emoji { font-size: 56px; }
.landing .logo h1 { font-size: 26px; margin-top: 10px; }
.landing .logo p { color: var(--text-light); margin-top: 6px; font-size: 14px; }
.landing .card h2 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.landing .card .hint { font-size: 13px; color: var(--text-light); margin-top: 10px; }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }

.room-code-display {
  text-align: center; background: #F0F5FF; border: 1.5px dashed var(--primary);
  border-radius: 12px; padding: 18px; margin: 14px 0;
}
.room-code-display .code {
  font-size: 34px; font-weight: 800; letter-spacing: 6px; color: var(--primary-dark);
  font-family: "Consolas", monospace;
}
.warn-tip {
  background: #FFF7EC; color: #B96A14; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; line-height: 1.6;
}

/* ============ 房间页 ============ */
.topbar {
  background: #fff; box-shadow: 0 1px 0 var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.topbar .room-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar .code-chip {
  background: #EEF3FE; color: var(--primary-dark); font-weight: 700;
  padding: 4px 12px; border-radius: 999px; font-size: 13px; letter-spacing: 1px;
  cursor: pointer; user-select: none;
}
.topbar .spacer { flex: 1; }

.page { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }

/* --- 日历 --- */
.calendar-card { margin-bottom: 20px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head .title { font-size: 17px; font-weight: 700; }
.cal-nav { display: flex; gap: 8px; }
.cal-nav button {
  width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff; font-size: 15px; color: var(--text);
}
.cal-nav button:hover { border-color: var(--primary); color: var(--primary); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid .dow {
  text-align: center; font-size: 12px; color: var(--text-light);
  padding: 4px 0; font-weight: 600;
}
.cal-cell {
  aspect-ratio: 1 / .82; border-radius: 10px; border: 1.5px solid transparent;
  background: #FAFBFE; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer; transition: all .12s;
  min-height: 52px;
}
.cal-cell:hover { border-color: var(--primary); }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.empty:hover { border-color: transparent; }
.cal-cell .d { font-size: 14px; font-weight: 600; }
.cal-cell.today .d {
  background: var(--orange); color: #fff; width: 24px; height: 24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.cal-cell.selected { border-color: var(--primary); background: #EEF3FE; }
.cal-cell .badge {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: #E9EDF5; color: var(--text-light); font-weight: 600;
}
.cal-cell .badge.all-done { background: #E3F7EC; color: var(--green); }
.cal-cell .badge.has-todo { background: #FFF1E3; color: #C77420; }

/* --- 任务区 --- */
.task-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 14px; flex-wrap: wrap; gap: 10px;
}
.task-section-head h2 { font-size: 18px; }
.task-section-head .sub { color: var(--text-light); font-size: 13px; margin-left: 8px; font-weight: 400; }

.plans-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.plan-col {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.plan-col .plan-head {
  padding: 14px 16px; color: #fff; display: flex; align-items: center; gap: 8px;
}
.plan-col .plan-head .name { font-weight: 700; font-size: 16px; flex: 1; }
.plan-col .plan-head .stat { font-size: 12px; opacity: .9; }
.plan-head .icon-btn {
  background: rgba(255,255,255,.22); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 7px; font-size: 13px;
}
.plan-head .icon-btn:hover { background: rgba(255,255,255,.35); }
.plan-body { padding: 12px 14px 16px; flex: 1; }

.cat-block { margin-bottom: 14px; }
.cat-title {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-light);
}
.cat-title .line { flex: 1; height: 1px; background: var(--border); }
.cat-title .add-task-btn, .cat-title .del-cat-btn {
  border: none; background: none; color: var(--primary); font-size: 13px; font-weight: 600;
  padding: 2px 4px;
}
.cat-title .del-cat-btn { color: var(--text-light); }
.cat-title .del-cat-btn:hover { color: var(--danger); }

.task-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px;
  border-radius: 10px; transition: background .12s;
}
.task-item:hover { background: #F6F8FC; }
.task-item .chk {
  width: 21px; height: 21px; min-width: 21px; border-radius: 7px;
  border: 2px solid #C6CEDD; background: #fff; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; transition: all .12s;
}
.task-item .chk.done { background: var(--green); border-color: var(--green); }
.task-item .info { flex: 1; min-width: 0; }
.task-item .tname { font-size: 15px; word-break: break-all; }
.task-item .tname.done { text-decoration: line-through; color: var(--text-light); }
.task-item .tdesc { font-size: 12px; color: var(--text-light); margin-top: 2px; word-break: break-all; }
.task-item .ops { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.task-item:hover .ops, .task-item.touch .ops { opacity: 1; }
.task-item .ops button {
  border: none; background: none; font-size: 13px; color: var(--text-light);
  width: 26px; height: 26px; border-radius: 7px;
}
.task-item .ops button:hover { background: #EDF1F8; color: var(--text); }
.empty-tip { font-size: 13px; color: #B4BCCC; padding: 4px 10px; }

/* 任务元信息(时间/日期区间) */
.task-item .tmeta { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.task-item .tname .ptag {
  display: inline-block; font-size: 11px; font-weight: 700; line-height: 1.4;
  background: #EDE9FB; color: #6B4ED9; border-radius: 6px; padding: 0 6px; margin-right: 6px;
}
/* 项目卡片高亮 */
.task-item.project { background: linear-gradient(180deg,#FBF9FF,#FFFFFF); border: 1px solid #E7E0FA; }
.task-item.project:hover { background: #F4EFFE; }

/* 任务弹窗: 日期范围两列 */
.modal .row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-hint {
  font-size: 12px; color: var(--text-light); background: #F6F8FC;
  border-radius: 8px; padding: 8px 12px; margin-top: 4px; line-height: 1.5;
}
/* 星期多选 */
.weekday-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.weekday-pick button {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: #fff; font-size: 14px; color: var(--text); font-weight: 600; transition: all .12s;
}
.weekday-pick button:hover { border-color: var(--primary); }
.weekday-pick button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.add-cat-row { margin-top: 4px; }
.add-cat-row button {
  width: 100%; border: 1.5px dashed var(--border); background: none;
  border-radius: 10px; padding: 8px; color: var(--text-light); font-size: 13px;
}
.add-cat-row button:hover { border-color: var(--primary); color: var(--primary); }

.empty-room {
  text-align: center; padding: 60px 20px; color: var(--text-light);
}
.empty-room .emoji { font-size: 52px; margin-bottom: 14px; }

/* 计划模板选择 */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl-item {
  border: 2px solid var(--border); border-radius: 12px; padding: 14px 12px;
  text-align: center; cursor: pointer; transition: all .12s; background: #fff;
}
.tpl-item:hover { border-color: var(--primary); }
.tpl-item.active { border-color: var(--primary); background: #EEF3FE; }
.tpl-item .emoji { font-size: 26px; }
.tpl-item .tname { font-weight: 700; margin-top: 6px; font-size: 14px; }
.tpl-item .tcats { font-size: 11px; color: var(--text-light); margin-top: 4px; line-height: 1.5; }

/* ============ 统计页 ============ */
.stats-filter {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px;
}
.stats-filter .input { width: auto; }
.quick-range { display: flex; gap: 8px; }
.quick-range button {
  border: 1.5px solid var(--border); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; color: var(--text);
}
.quick-range button.active { border-color: var(--primary); background: #EEF3FE; color: var(--primary-dark); font-weight: 600; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.chart-card h3 { font-size: 15px; margin-bottom: 12px; }
.chart-box { position: relative; height: 300px; }

.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th, .stats-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-light); font-size: 13px; font-weight: 600; background: #FAFBFE; }
.stats-table .member-tag {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
}
.stats-table .dot { width: 9px; height: 9px; border-radius: 50%; }
.rate-bar { display: flex; align-items: center; gap: 8px; }
.rate-bar .bar { width: 90px; height: 7px; background: #EDF1F8; border-radius: 99px; overflow: hidden; }
.rate-bar .bar i { display: block; height: 100%; border-radius: 99px; background: var(--green); }

/* ============ 移动端适配 ============ */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .page { padding: 12px 10px 50px; }
  .card { padding: 14px; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 44px; border-radius: 8px; }
  .cal-cell .d { font-size: 13px; }
  .cal-cell .badge { font-size: 9px; padding: 1px 5px; }
  .plans-wrap { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-box { height: 240px; }
  .task-item .ops { opacity: 1; }
  .topbar-inner { padding: 10px 12px; }
  .topbar .room-name { font-size: 15px; }
  .landing { padding: 32px 16px; }
  .stats-table { font-size: 13px; }
  .stats-table th, .stats-table td { padding: 8px 6px; }
  .rate-bar .bar { width: 56px; }
}
