/* ============================================================
   打卡 App — 样式（移动优先）
   ============================================================ */

:root {
  --bg:        #f7f4ee;
  --surface:   #ffffff;
  --surface-2: #f1ece2;
  --ink:       #2f2b25;
  --ink-soft:  #837b6d;
  --line:      #e6e0d4;
  --accent:    #b98a4b;   /* 温暖的琥珀色 */
  --accent-ink:#7a5a2c;
  --ok:        #6f9e6a;   /* 完成 */
  --ok-bg:     #e6f0e2;
  --miss:      #d8cfc0;   /* 未打（浅） */
  --danger:    #c05a4d;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(60,50,35,.06), 0 4px 16px rgba(60,50,35,.05);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #1c1a17;
    --surface:   #262320;
    --surface-2: #2f2b27;
    --ink:       #ece6da;
    --ink-soft:  #a49b8b;
    --line:      #38332d;
    --accent:    #d0a463;
    --accent-ink:#e8c78d;
    --ok:        #7fb377;
    --ok-bg:     #2c3a29;
    --miss:      #423c34;
    --danger:    #e07a6c;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 14px) 18px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .06em; }
.status {
  position: absolute; right: 16px; bottom: 12px;
  font-size: 11px; color: var(--miss); transition: color .3s;
}
.status.online  { color: var(--ok); }
.status.offline { color: var(--danger); }

/* ---------- 主区 ---------- */
.main { flex: 1; padding: 16px 14px 96px; }
.view { animation: fade .2s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

/* ---------- 日期 / 周期切换条 ---------- */
.date-nav {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.date-nav__center { flex: 1; text-align: center; }
.date-nav__title { font-size: 17px; font-weight: 700; }
.date-nav__sub   { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.nav-btn {
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 10px;
  background: var(--surface-2); color: var(--ink);
  font-size: 22px; line-height: 1;
  display: grid; place-items: center;
  transition: background .15s, opacity .15s;
}
.nav-btn:active { background: var(--line); }
.nav-btn:disabled { opacity: .28; cursor: default; }

/* ---------- 今日：成员卡片（单列） ---------- */
.member-cards { display: flex; flex-direction: column; gap: 12px; }
.mcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px 14px;
  box-shadow: var(--shadow);
}
.mcard__name {
  font-size: 15.5px; font-weight: 650; margin-bottom: 11px;
  display: flex; align-items: center; gap: 8px;
}
.mcard__count {
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  background: var(--surface-2); padding: 2px 8px; border-radius: 999px;
}
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 11px;
  padding: 10px 4px 9px;
  font-size: 13.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all .15s ease;
  user-select: none;
}
.chip__mark { font-size: 12px; height: 14px; line-height: 14px; opacity: 0; }
.chip.on {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}
.chip.on .chip__mark { opacity: 1; }
.chip:active { transform: scale(.94); }

/* ---------- 可点日期 / 期数（弹日历、弹浮层） ---------- */
.date-nav__center { position: relative; }
button.date-nav__center { background: none; font: inherit; color: inherit; width: 100%; text-align: center; }
.date-nav__center--tap { cursor: pointer; }
.date-nav__center--tap .date-nav__title::after {
  content: '▾'; font-size: .62em; color: var(--ink-soft);
  margin-left: 5px; vertical-align: middle;
}
.picker-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}

/* ---------- 每日经文 ---------- */
.verse {
  margin: 0 0 16px; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 16px 16px 18px;
}
.verse::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.verse__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.verse__badge {
  font-size: 11.5px; font-weight: 600; color: var(--accent-ink);
  background: var(--surface-2); padding: 2px 9px; border-radius: 999px;
}
.verse__ref { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.verse__text { font-size: 14.5px; line-height: 1.85; color: var(--ink); letter-spacing: .01em; }
.verse--rest { text-align: center; color: var(--ink-soft); font-size: 13.5px; padding: 22px 16px; }
.verse--rest::before { display: none; }

/* ---------- 底部浮层（周期选择） ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet.hidden { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(20,16,10,.4); animation: fade .2s ease; }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px 14px calc(20px + var(--safe-bottom));
  max-height: 72vh; display: flex; flex-direction: column;
  animation: sheetup .24s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
.sheet__grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 10px; }
.sheet__title { font-size: 14px; font-weight: 700; text-align: center; margin-bottom: 10px; color: var(--ink-soft); }
.sheet__list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 6px; }
.sheet__item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-radius: 12px; background: var(--surface-2);
  font-size: 15px; color: var(--ink); border: 1.5px solid transparent; cursor: pointer;
}
.sheet__item--active { border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.sheet__item small { color: var(--ink-soft); font-size: 12.5px; font-weight: 500; }
.sheet__item:active { background: var(--line); }

/* ---------- 统计：数字表 ---------- */
.stats-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.st-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.st-row:last-child { border-bottom: none; }
.st-row--head { background: var(--surface-2); }
.st-cell {
  padding: 10px 4px; text-align: center; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.st-cell--name { text-align: left; padding-left: 14px; font-weight: 600; font-size: 14px; }
.st-row--head .st-cell { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.st-num { font-weight: 700; }
.st-num small { font-weight: 500; color: var(--ink-soft); font-size: 11px; }

/* 完成度着色（数字格背景深浅） */
.st-cell[data-r] { border-radius: 8px; }
.st-cell[data-r="hi"]  { color: var(--ok); }
.st-cell[data-r="mid"] { color: var(--accent-ink); }
.st-cell[data-r="lo"]  { color: var(--danger); }

/* ---------- 统计：方格矩阵 ---------- */
.matrix-wrap { display: flex; flex-direction: column; gap: 18px; }
.matrix {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 12px 14px;
}
.matrix__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
}
.matrix__title { font-size: 14px; font-weight: 700; }
.matrix__legend { font-size: 11px; color: var(--ink-soft); }
.mx-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mx-grid {
  display: grid;
  gap: 3px;
  min-width: max-content;
}
.mx-namecell {
  font-size: 12.5px; font-weight: 600;
  padding-right: 8px; white-space: nowrap;
  display: flex; align-items: center;
}
.mx-daynum {
  font-size: 9.5px; color: var(--ink-soft);
  text-align: center; height: 14px; line-height: 14px;
  font-variant-numeric: tabular-nums;
}
.mx-cell {
  width: 15px; height: 15px; border-radius: 4px;
  background: var(--miss);
}
.mx-cell.on    { background: var(--ok); }
.mx-cell.today { box-shadow: 0 0 0 2px var(--accent); }
.mx-cell.future { background: transparent; border: 1px dashed var(--line); }
.mx-rowtail {
  font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
  padding-left: 8px; display: flex; align-items: center; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 成员管理 ---------- */
.add-form { display: flex; gap: 8px; margin-bottom: 16px; }
.add-input {
  flex: 1; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 11px; padding: 12px 14px; font-size: 15px;
}
.add-input:focus { outline: none; border-color: var(--accent); }
.add-btn {
  border: none; background: var(--accent); color: #fff;
  border-radius: 11px; padding: 0 18px; font-size: 15px; font-weight: 600;
}
.add-btn:active { filter: brightness(.94); }
.member-manage { list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mm-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 1px solid var(--line);
}
.mm-row:last-child { border-bottom: none; }
.mm-name { font-size: 15px; font-weight: 550; }
.mm-del {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--danger); border-radius: 9px; padding: 6px 12px; font-size: 13px;
}
.mm-del:active { background: var(--surface-2); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tab {
  border: none; background: none; color: var(--ink-soft);
  padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11.5px; transition: color .15s;
}
.tab__ico { font-size: 19px; line-height: 1; }
.tab--active { color: var(--accent); }

/* ---------- 空状态 / 提示 ---------- */
.hint { color: var(--ink-soft); font-size: 12.5px; text-align: center; margin: 18px 6px 0; line-height: 1.6; }
.empty {
  text-align: center; color: var(--ink-soft); font-size: 14px;
  padding: 48px 20px; line-height: 1.7;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px;
  z-index: 50; box-shadow: var(--shadow);
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 6px);} to {opacity:1;} }

/* ---------- 加载遮罩 ---------- */
.loading { text-align: center; color: var(--ink-soft); padding: 60px 0; font-size: 14px; }
