/* 小简卡记 · 网页版样式（移动优先，5 主题 + 深浅色） */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--on-surface);
  font-size: 15px;
  overscroll-behavior-y: none;
}

/* ---------- 主题变量 ---------- */
:root {
  --h: 122;
  --primary: hsl(var(--h), 46%, 40%);
  --primary-weak: hsl(var(--h), 46%, 94%);
  --on-primary: #fff;
  --bg: #f4f5f4;
  --surface: #ffffff;
  --surface-2: #f0f1f0;
  --on-surface: #17201a;
  --on-surface-variant: #6b746c;
  --border: #e2e5e2;
  --error: #c62828;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}
html[data-dark="dark"] {
  --primary: hsl(var(--h), 52%, 66%);
  --primary-weak: hsl(var(--h), 24%, 20%);
  --on-primary: #0b120c;
  --bg: #101312;
  --surface: #1a1e1c;
  --surface-2: #232825;
  --on-surface: #e6eae6;
  --on-surface-variant: #9aa39c;
  --border: #2c322e;
  --error: #ef5350;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; }
#topbar {
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
#title { font-size: 18px; font-weight: 700; }
#subtitle { font-size: 12px; color: var(--on-surface-variant); margin-top: 2px; min-height: 14px; }
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 96px; }

/* 底部导航 */
#tabbar {
  display: grid; grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid var(--border); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  border: 0; background: none; padding: 7px 0 6px; font-size: 10px; color: var(--on-surface-variant);
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; font-family: inherit;
}
#tabbar button .ic { font-size: 19px; line-height: 1; }
#tabbar button.on { color: var(--primary); font-weight: 700; }

/* 通用 */
.wrap { padding: 14px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.muted { color: var(--on-surface-variant); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.bold { font-weight: 700; }
.primary { color: var(--primary); }
.err { color: var(--error); }
.spacer { height: 10px; }
h2.sec { font-size: 15px; margin: 16px 0 6px; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

button.btn {
  font-family: inherit; font-size: 15px; border-radius: 12px; border: 1px solid var(--primary);
  background: var(--primary); color: var(--on-primary); padding: 11px 16px; cursor: pointer; font-weight: 600;
}
button.btn.block { width: 100%; display: block; }
button.btn.ghost { background: none; color: var(--primary); }
button.btn.danger { border-color: var(--error); background: none; color: var(--error); }
button.chip {
  font-family: inherit; font-size: 13px; border-radius: 18px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--on-surface);
}
button.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
input, textarea, select {
  font-family: inherit; font-size: 15px; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--on-surface); outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); }
label.fld { display: block; font-size: 12px; color: var(--on-surface-variant); margin: 8px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* 进度条 */
.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.macro { margin: 7px 0; }
.macro .thead { display: flex; justify-content: space-between; font-size: 13px; }
.macro .thead .v { color: var(--on-surface-variant); }

/* 列表条目 */
.item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); margin: 6px 0;
}
.item .ic { font-size: 22px; width: 26px; text-align: center; }
.item .nm { font-weight: 600; }
.item .sub { font-size: 12px; color: var(--on-surface-variant); }
.item .kcal { font-weight: 700; font-size: 16px; }
.del { border: 0; background: none; color: var(--error); font-size: 15px; cursor: pointer; font-family: inherit; padding: 4px 6px; }

/* 拍照 */
.shot { width: 100%; border-radius: 12px; display: block; border: 1px solid var(--border); }
.drophint { font-size: 12px; color: var(--on-surface-variant); margin-top: 4px; }

/* 日历 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal .h { text-align: center; font-size: 11px; color: var(--on-surface-variant); padding: 2px 0; }
.cal .c { text-align: center; padding: 5px 0; border-radius: 9px; cursor: pointer; min-height: 40px; }
.cal .c .d { font-size: 14px; }
.cal .c .k { font-size: 9px; color: var(--on-surface-variant); }
.cal .c.today .d { color: var(--primary); font-weight: 700; }
.cal .c.sel { background: var(--primary); }
.cal .c.sel .d, .cal .c.sel .k { color: var(--on-primary); }

/* 弹窗 */
#modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
#modal-root.on { display: block; }
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; margin: 0 auto;
  border-radius: 18px 18px 0 0; padding: 16px; max-height: 88dvh; overflow-y: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 10px; font-size: 16px; }
.sheet .acts { display: flex; gap: 10px; margin-top: 14px; }
.sheet .acts .btn { flex: 1; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: #333c; color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 13px;
  z-index: 90; max-width: 86%; text-align: center; backdrop-filter: blur(4px);
}
.fab {
  position: fixed; right: calc(50% - 320px + 18px); bottom: calc(66px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary);
  font-size: 26px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25); z-index: 30;
}
@media (max-width: 660px) { .fab { right: 18px; } }
