/* 每日评分 · 样式 */
:root {
  --bg: #f2f3f5;
  --bg-elev: #ffffff;
  --bg-sunk: #eaecf0;
  --ink: #12161c;
  --ink-2: #545e6b;
  --ink-3: #8b94a2;
  --ink-4: #c5cbd4;
  --line: #e6e8ed;
  --line-2: #eff1f4;
  --accent: #1d9d57;
  --ring-bg: #ebedf1;
  --shadow: 0 1px 1px rgba(18, 22, 28, .04), 0 8px 22px -14px rgba(18, 22, 28, .28);
  --shadow-pop: 0 10px 40px -12px rgba(18, 22, 28, .28);
  --r-lg: 20px;
  --r-md: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --maxw: 560px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --bg-elev: #181b21;
    --bg-sunk: #101318;
    --ink: #eef1f5;
    --ink-2: #a6b0be;
    --ink-3: #7d8797;
    --ink-4: #39414e;
    --line: #262b35;
    --line-2: #1e222a;
    --accent: #2fb671;
    --ring-bg: #242932;
    --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 22px -14px rgba(0, 0, 0, .9);
    --shadow-pop: 0 10px 40px -12px rgba(0, 0, 0, .85);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-touch-callout: none; }
b, strong { font-weight: 650; }

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部 ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  #topbar { background: var(--bg); }
}

.tb {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  transition: background .15s;
}
.icon-btn:active { background: var(--bg-sunk); }
.icon-btn:disabled { opacity: .25; pointer-events: none; }
.icon-btn.small { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.danger { color: #d05252; }

.date-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 0;
  background: transparent;
  padding: 4px 6px;
  border-radius: 12px;
}
.date-btn:active { background: var(--bg-sunk); }
.date-btn b {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: .2px;
  line-height: 1.25;
}
.date-btn span { font-size: 11.5px; color: var(--ink-3); line-height: 1.2; }

.tb-title b { font-size: 17px; }

.pill {
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
}
.pill:active { opacity: .7; }

/* ---------- 主区域 ---------- */

#view {
  flex: 1;
  padding: 4px 14px calc(84px + var(--safe-b));
}

.group { margin-top: 18px; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 6px 8px;
}
.gname { font-size: 13px; font-weight: 650; color: var(--ink-2); letter-spacing: .4px; }
.gavg { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.card {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.empty {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: var(--ink-3);
  font-size: 13.5px;
  text-align: center;
  box-shadow: var(--shadow);
}

.banner {
  margin: 6px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(240, 140, 18, .12);
  color: #a2650c;
  font-size: 12.5px;
  line-height: 1.4;
}

/* ---------- 今日 · 总览 ---------- */

.hero {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.hero-ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring { width: 88px; height: 88px; display: block; }
.ring circle { transition: stroke-dashoffset .45s cubic-bezier(.3, .8, .3, 1), stroke .35s; }

.hero-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.hero-center b {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
}
.hero-center i { font-style: normal; font-size: 9px; color: var(--ink-3); margin-top: 3px; }

.hero-body { min-width: 0; flex: 1; }
.hero-rate { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.hero-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.hero-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 8px;
  line-height: 1.5;
  max-width: 200px;
}

.delta { font-variant-numeric: tabular-nums; }
.delta.up { color: #17784a; }
.delta.down { color: #c43c3c; }
@media (prefers-color-scheme: dark) {
  .delta.up { color: #4cc98a; }
  .delta.down { color: #f0776f; }
}

/* ---------- 指标卡 ---------- */

.metric {
  background: var(--bg-elev);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 11px 13px 13px;
  margin-bottom: 8px;
}

.metric-head { display: flex; align-items: center; gap: 7px; min-height: 24px; }
.metric-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-val {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-width: 22px;
  text-align: right;
}

.tag {
  flex: none;
  font-size: 10px;
  line-height: 1.6;
  padding: 0 5px;
  border-radius: 5px;
  color: var(--ink-3);
  background: var(--bg-sunk);
}

.segs { display: flex; gap: 3px; margin-top: 9px; }
.seg {
  flex: 1;
  height: 26px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--sc);
  opacity: .17;
  transition: opacity .15s ease, transform .12s ease;
}
.seg.is-done { opacity: .42; }
.seg.is-on {
  opacity: 1;
  transform: scaleY(1.24);
  border-radius: 6px;
  box-shadow: 0 3px 10px -3px var(--sc);
}
.seg:active { transform: scaleY(.86); }

@media (prefers-color-scheme: dark) {
  .seg { opacity: .24; }
  .seg.is-done { opacity: .5; }
}

/* ---------- 备注 ---------- */

.note-card { padding: 12px 13px; }
.note-card textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.note-card textarea::placeholder { color: var(--ink-4); }

.save-hint {
  margin: 14px 4px 0;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}
.save-hint.is-warn { color: #c8791a; }

.day-actions { text-align: center; margin-top: 14px; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
}
.link-btn:active { background: var(--bg-sunk); }
.link-btn.danger { color: #cf4444; }

/* ---------- 一周热力表 ---------- */

.heat { padding: 12px 10px 8px; margin-top: 6px; }

.hrow {
  display: grid;
  grid-template-columns: 50px repeat(7, 1fr) 36px;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}
.hrow:last-child { margin-bottom: 0; }

.hhead { margin-bottom: 7px; }
.hday {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 10px;
  color: var(--ink-3);
  line-height: 1.1;
}
.hday b { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.hday.is-today { color: var(--accent); }
.hday.is-today b { color: var(--accent); }

.hname {
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 2px;
}
.hweek {
  font-size: 11px;
  color: var(--ink-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: 2px;
}

.hcell {
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--bg-sunk);
}
.hcell.is-empty { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

.htotal { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--line-2); }
.htotal .hcell { font-size: 10.5px; font-weight: 600; }
.htotal .hname { font-weight: 650; color: var(--ink); }

/* ---------- 统计块 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.stat {
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 10px 11px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat span { font-size: 10.5px; color: var(--ink-3); }
.stat b {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat b i { font-style: normal; font-size: 10.5px; color: var(--ink-3); font-weight: 500; }

.insight { margin-top: 10px; padding: 13px 15px; }
.insight-line { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.insight-line b { color: var(--ink); }

/* ---------- 月历 ---------- */

.cal-card { padding: 12px 10px 10px; margin-top: 6px; }
.cal-wd {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 6px;
}
.cal-wd span {
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-3);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.cal-cell {
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 11px;
  background: var(--line-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1.05;
  transition: transform .12s;
}
.cal-cell:active { transform: scale(.94); }
.cal-cell.is-empty { background: var(--line-2); }
.cal-cell.is-empty .cal-num { color: var(--ink-3); }
.cal-cell.is-out { background: transparent; }
.cal-cell.is-future { background: transparent; box-shadow: none; }
.cal-cell.is-future .cal-num { color: var(--ink-4); }
.cal-cell.is-today { box-shadow: 0 0 0 2px var(--ink); }
.cal-num { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-score { font-size: 9px; font-weight: 600; opacity: .92; letter-spacing: -.2px; font-variant-numeric: tabular-nums; }

/* ---------- 横向条形 ---------- */

.bars { padding: 14px 15px 6px; }
.bar-row {
  display: grid;
  grid-template-columns: 38px 1fr 30px;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}
.bar-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.bar-track {
  height: 8px;
  border-radius: 99px;
  background: var(--line-2);
  overflow: hidden;
}
.bar-track i {
  display: block;
  height: 100%;
  border-radius: 99px;
  min-width: 0;
  transition: width .35s cubic-bezier(.3, .8, .3, 1);
}
.bar-val {
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

/* ---------- 设置 ---------- */

.set-section { margin-top: 18px; }
.set-section:first-child { margin-top: 4px; }
.section-title {
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 600;
  padding: 0 6px 8px;
  letter-spacing: .4px;
}
.set-card { padding: 6px 14px; }
.set-group { padding: 8px 0 2px; }
.set-group + .set-group { border-top: 1px solid var(--line-2); }
.set-group-name {
  font-size: 11px;
  color: var(--ink-3);
  padding: 6px 0 2px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 0;
}
.set-row + .set-row { border-top: 1px solid var(--line-2); }
.set-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: var(--ink-4);
  position: relative;
  transition: background .18s;
  margin: 0 0 0 4px;
  border: 0;
}
.sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s cubic-bezier(.3, .8, .3, 1);
}
.sw:checked { background: var(--accent); }
.sw:checked::after { transform: translateX(18px); }

.add-metric {
  display: flex;
  gap: 6px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line-2);
  margin-top: 8px;
}
.add-metric input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  outline: 0;
}
.add-metric input:focus { border-color: var(--ink-4); background: var(--bg-elev); }
.add-metric select {
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 13px;
  max-width: 84px;
}

.btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.danger { color: #cf4444; }
.btn.danger.solid { background: #cf4444; color: #fff; border-color: transparent; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }

.btn-row { display: flex; gap: 8px; padding: 12px 0 4px; }
.btn-row .btn { flex: 1; }

.data-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line-2);
}
.data-line:last-child { border-bottom: 0; }
.data-line span { color: var(--ink-3); }
.data-line b { font-weight: 600; }

.fine {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.65;
  margin: 10px 0 4px;
}
.fine.warn-text { color: #c8791a; }

.guide p {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.75;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
}
.guide p:last-child { border-bottom: 0; }
.guide b { color: var(--ink); }
.guide code {
  font-size: 11.5px;
  background: var(--bg-sunk);
  padding: 1px 5px;
  border-radius: 5px;
}

.about { padding-top: 4px; padding-bottom: 4px; }

/* ---------- 底部标签栏 ---------- */

#tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6px 10px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line-2);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  #tabs { background: var(--bg); }
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0 2px;
  color: var(--ink-3);
  font-size: 10.5px;
  border-radius: 12px;
  transition: color .18s;
}
.tab.is-on { color: var(--ink); }
.tab.is-on svg { stroke-width: 2.3; }
.tab:active { background: var(--bg-sunk); }

/* ---------- 弹层 ---------- */

#sheetRoot {
  position: fixed;
  inset: 0;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
#sheetRoot.is-open { opacity: 1; pointer-events: auto; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, .45);
  backdrop-filter: blur(2px);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  padding: 6px 18px calc(18px + var(--safe-b));
  transform: translateY(101%);
  transition: transform .26s cubic-bezier(.2, .9, .25, 1);
  box-shadow: var(--shadow-pop);
}
#sheetRoot.is-open .sheet { transform: translateY(0); }

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--ink-4);
  opacity: .5;
  margin: 6px auto 12px;
}
.sheet-head { padding-bottom: 12px; }
.sheet-date { font-size: 15px; font-weight: 650; }
.sheet-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.sheet-total { font-size: 13px; margin-top: 4px; font-weight: 600; }
.sheet-body { padding: 2px 0 6px; }

.sheet-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.sheet-row b { font-variant-numeric: tabular-nums; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.sheet-note {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--bg-sunk);
  font-size: 13px;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.sheet-foot {
  display: flex;
  gap: 8px;
  padding-top: 14px;
}
.sheet-foot .btn { flex: 1; }

.or {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 12px 0;
}

textarea.raw {
  width: 100%;
  height: 130px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-sunk);
  padding: 10px;
  font-size: 11.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  resize: none;
  outline: 0;
}

/* ---------- 轻提示 ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  z-index: 80;
  transform: translate(-50%, 8px);
  background: #14181d;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  padding: 9px 16px;
  border-radius: 999px;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  #toast { background: #e9edf2; color: #12161c; }
}
#toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 小屏兜底 ---------- */

@media (max-width: 350px) {
  #view { padding-left: 10px; padding-right: 10px; }
  .hrow { grid-template-columns: 44px repeat(7, 1fr) 32px; gap: 3px; }
  .hcell { height: 25px; font-size: 11px; }
  .hero-ring, .ring { width: 76px; height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
