:root {
  --bg: #f4efe6;
  --bg-elev: #fffaf3;
  --surface: #ffffff;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --muted: #78716c;
  --line: rgba(28, 25, 23, 0.1);
  --accent: #8a5a2b;
  --accent-soft: rgba(138, 90, 43, 0.12);
  --gold: #b8893e;
  --chip: #efe8dc;
  --chip-on: #1c1917;
  --chip-on-ink: #faf6ef;
  --danger: #9a3b2f;
  --ok: #3d6b4f;
  --shadow: 0 12px 40px rgba(28, 25, 23, 0.08);
  --radius: 22px;
  --font-ui: "Outfit", "Noto Sans TC", sans-serif;
  --font-serif: "Newsreader", "Noto Serif TC", serif;
  --nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141210;
  --bg-elev: #1c1916;
  --surface: #221f1c;
  --ink: #f5f0e8;
  --ink-soft: #e7e0d4;
  --muted: #a8a29a;
  --line: rgba(245, 240, 232, 0.1);
  --accent: #e8b86d;
  --accent-soft: rgba(232, 184, 109, 0.14);
  --gold: #e8b86d;
  --chip: #2a2622;
  --chip-on: #f5f0e8;
  --chip-on-ink: #1c1917;
  --danger: #e08a7a;
  --ok: #8fbf9a;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; }

.app-shell {
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}
@media (min-width: 480px) {
  body { background: #0f0e0c; }
  :root:not([data-theme="dark"]) body { background: #d9d0c3; }
  .app-shell {
    min-height: 100dvh;
    box-shadow: var(--shadow);
  }
}

.screen { padding: 20px 20px calc(var(--nav-h) + 24px); animation: rise 0.35s ease; }
.screen.no-nav { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px;
  padding-top: env(safe-area-inset-top, 0px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: #161412 url("./icons/favicon.svg") center / 100% 100% no-repeat;
  flex: 0 0 auto;
}
.brand-name { font-weight: 600; letter-spacing: 0.08em; font-size: 13px; text-transform: uppercase; }
.eyebrow {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.date-line { color: var(--muted); font-size: 13px; }

h1, .h1 { font-family: var(--font-serif); font-weight: 500; font-size: 28px; letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.lede { color: var(--ink-soft); margin-top: 8px; font-size: 15px; }
.zh { font-family: var(--font-ui); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; width: 100%; height: 52px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 500; font-size: 15px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.btn.small { width: auto; height: 40px; padding: 0 16px; font-size: 13px; }
.linkish { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.welcome { min-height: 100dvh; display: flex; flex-direction: column; padding: 28px 24px calc(28px + env(safe-area-inset-bottom)); }
.welcome-hero { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 36px; }
.welcome .mark { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 28px; }
.welcome h1 { font-size: 42px; }
.welcome .tag { margin-top: 14px; color: var(--muted); font-size: 15px; max-width: 20em; }
.welcome .tag strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }

.progress { display: flex; gap: 6px; margin: 8px 0 20px; }
.progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.progress i.on { background: var(--accent); }

.choice-list { display: grid; gap: 10px; }
.choice {
  text-align: left; padding: 16px 16px;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); transition: border-color 0.15s, background 0.15s;
}
.choice .t { font-weight: 550; font-size: 16px; display: block; }
.choice .d { color: var(--muted); font-size: 13px; margin-top: 2px; display: block; }
.choice.on { border-color: var(--ink); background: var(--accent-soft); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-grid .choice { padding: 14px 12px; }
.group-label { margin: 18px 0 8px; }

.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 430px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); z-index: 20;
}
.nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 10px; letter-spacing: 0.04em; padding: 6px 0;
}
.nav button.on { color: var(--ink); }
.nav svg { width: 22px; height: 22px; }

.streak {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 600;
}

.struggle-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; margin: 0 -20px; padding-left: 20px; padding-right: 20px; scrollbar-width: none; }
.struggle-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 12px; border-radius: 999px;
  background: var(--chip); color: var(--ink-soft); font-size: 13px;
  border: 1px solid transparent;
}
.chip.on { background: var(--chip-on); color: var(--chip-on-ink); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  margin-top: 8px;
}
.card .meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.card .num { font-variant-numeric: tabular-nums; letter-spacing: 0.12em; color: var(--gold); font-size: 12px; font-weight: 600; }
.card .cat { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.sub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.affirm {
  font-family: var(--font-serif);
  font-size: 28px; font-weight: 400; letter-spacing: -0.03em;
  line-height: 1.35; font-variation-settings: "opsz" 72;
}
.actions { display: flex; gap: 8px; margin-top: 22px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--ink-soft);
}
.icon-btn.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.icon-btn svg { width: 20px; height: 20px; }
.spacer { flex: 1; }

.micro {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
}
.micro label {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  font-size: 14px; line-height: 1.45; color: var(--ink-soft);
}
.micro input { display: none; }
.check {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px;
  border-radius: 7px; border: 1.5px solid var(--muted);
  display: grid; place-items: center;
}
.micro input:checked + .check { background: var(--ok); border-color: var(--ok); color: white; }
.micro input:checked ~ span { text-decoration: line-through; color: var(--muted); }
.micro .label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 12px);
  transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: 0.25s ease; z-index: 40;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.cat-list { display: grid; gap: 10px; }
.cat-row {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; background: var(--surface); border-radius: 18px;
  border: 1px solid var(--line); width: 100%;
}
.cat-row .num { color: var(--gold); font-weight: 600; font-size: 13px; width: 28px; }
.cat-row .t { font-weight: 550; display: block; }
.cat-row .d { color: var(--muted); font-size: 13px; }
.cat-row .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.chev { color: var(--muted); }

.sub-list { display: grid; gap: 8px; }
.aff-row {
  width: 100%; text-align: left; padding: 16px 18px;
  background: var(--surface); border-radius: 16px; border: 1px solid var(--line);
}
.aff-row .s { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.aff-row .q { font-family: var(--font-serif); font-size: 18px; line-height: 1.4; }

.settings { display: grid; gap: 10px; }
.setting {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px; background: var(--surface);
  border-radius: 16px; border: 1px solid var(--line);
}
.setting .t { font-weight: 550; display: block; }
.setting .d { font-size: 12px; color: var(--muted); }
.toggle {
  width: 44px; height: 26px; border-radius: 999px; background: var(--chip);
  position: relative; flex: 0 0 auto;
}
.toggle.on { background: var(--ok); }
.toggle i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: white; transition: left 0.15s;
}
.toggle.on i { left: 21px; }

.profile-summary { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tagp { background: var(--chip); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink-soft); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.time-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.time-row input[type="time"] {
  background: var(--chip); border: 0; border-radius: 10px; padding: 8px 10px;
}

.footer-note { margin-top: 28px; color: var(--muted); font-size: 12px; text-align: center; }
