/* ===== 色彩與設計變數（與 Mint Focus 同系列，主色換成薄荷綠） ===== */
:root {
  --ink: #1D1C1A;
  --ink-2: #5F5C56;
  --ink-3: #9C988F;
  --bg-a: #F4EFE8;
  --bg-b: #E6E7DD;
  --line: rgba(29, 28, 26, .07);

  --glass: linear-gradient(150deg, rgba(255, 255, 255, .66) 0%, rgba(255, 255, 255, .30) 55%, rgba(255, 255, 255, .44) 100%);
  --glass-solid: rgba(255, 255, 255, .72);
  --glass-soft: rgba(255, 255, 255, .42);
  --rim: rgba(255, 255, 255, .78);
  --rim-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .95),
    inset 0 -1px 0 rgba(255, 255, 255, .45),
    inset 1px 0 0 rgba(255, 255, 255, .35),
    inset -1px 0 0 rgba(255, 255, 255, .2);
  --inner-glow:
    inset 0 18px 28px -22px rgba(255, 255, 255, .95),
    inset 0 -22px 30px -24px rgba(255, 255, 255, .8);
  --drop: 0 28px 50px -30px rgba(74, 62, 44, .38), 0 4px 12px -6px rgba(74, 62, 44, .10);
  --drop-sm: 0 10px 22px -12px rgba(74, 62, 44, .35), 0 2px 5px -2px rgba(74, 62, 44, .12);
  --well: inset 0 2px 5px rgba(74, 62, 44, .10), inset 0 -1px 0 rgba(255, 255, 255, .7);
  --seg-on: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .7));
  --seg-on-shadow: inset 0 1px 0 #fff, inset 0 -2px 4px rgba(74, 62, 44, .06), var(--drop-sm);
  --sheet-bg: linear-gradient(150deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .7));
  --sheet-solid: rgba(246, 244, 239, .97);
  --shine: rgba(255, 255, 255, .55);
  --empty-cell: rgba(29, 28, 26, .05);

  --solid: #1E1D1B;
  --on-solid: #FFFFFF;

  /* 薄荷主色 */
  --orb-a: #4FBEAA;
  --orb-b: #BDEDE2;
  --accent: #58B8A5;
  --accent-deep: #2A8070;
  --tint: rgba(110, 205, 186, .24);
  --blob1: #CDEDE3;
  --blob2: #DDE4D2;
  --blob3: #F4DCD8;
  --blob4: #F3EAD2;
  --quit: #E07B6A;

  --danger: #C8574F;
  --radius-lg: 30px;
  --radius: 22px;
  --radius-sm: 16px;
  --font: 'Noto Sans TC', -apple-system, 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --num: 'Outfit', 'Noto Sans TC', system-ui, sans-serif;
  color-scheme: light;
}

html.dark {
  --ink: #F3EFE8;
  --ink-2: #B7B1A7;
  --ink-3: #7E796F;
  --bg-a: #1B1916;
  --bg-b: #151714;
  --line: rgba(255, 255, 255, .08);
  --glass: linear-gradient(150deg, rgba(255, 255, 255, .11) 0%, rgba(255, 255, 255, .04) 55%, rgba(255, 255, 255, .07) 100%);
  --glass-solid: rgba(255, 255, 255, .10);
  --glass-soft: rgba(255, 255, 255, .06);
  --rim: rgba(255, 255, 255, .12);
  --rim-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    inset 0 -1px 0 rgba(255, 255, 255, .05),
    inset 1px 0 0 rgba(255, 255, 255, .06),
    inset -1px 0 0 rgba(255, 255, 255, .04);
  --inner-glow:
    inset 0 18px 28px -22px rgba(255, 255, 255, .14),
    inset 0 -22px 30px -24px rgba(255, 255, 255, .08);
  --drop: 0 28px 50px -30px rgba(0, 0, 0, .8), 0 4px 12px -6px rgba(0, 0, 0, .4);
  --drop-sm: 0 10px 22px -12px rgba(0, 0, 0, .7);
  --well: inset 0 2px 6px rgba(0, 0, 0, .35), inset 0 -1px 0 rgba(255, 255, 255, .05);
  --seg-on: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .1));
  --seg-on-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), var(--drop-sm);
  --sheet-bg: linear-gradient(150deg, rgba(48, 46, 42, .94), rgba(34, 33, 30, .92));
  --sheet-solid: rgba(38, 37, 34, .98);
  --shine: rgba(255, 255, 255, .08);
  --empty-cell: rgba(255, 255, 255, .05);
  --solid: #F3EEE6;
  --on-solid: #1D1C1A;
  --blob1: #173F37;
  --blob2: #26302A;
  --blob3: #3A2A2A;
  --blob4: #2E2B20;
  --tint: rgba(79, 190, 170, .14);
  color-scheme: dark;
}

/* ===== 基礎 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-b);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .3; cursor: default; }
svg { display: block; }
[hidden] { display: none !important; }
h2, h3, p { margin: 0; }

.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: linear-gradient(165deg, var(--bg-a) 10%, var(--bg-b) 90%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); }
.b1 { width: 50vmax; height: 50vmax; top: -16vmax; right: -12vmax; background: var(--blob1); opacity: .95; }
.b2 { width: 48vmax; height: 48vmax; bottom: -18vmax; left: -14vmax; background: var(--blob2); }
.b3 { width: 26vmax; height: 26vmax; bottom: 6%; right: 8%; background: var(--blob3); opacity: .8; }
.b4 { width: 30vmax; height: 30vmax; top: 30%; left: 18%; background: var(--blob4); opacity: .7; }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

/* ===== 液態玻璃 ===== */
.card, .tabs, .sheet-inner, .toast, .date-nav, .update-bar {
  position: relative;
  isolation: isolate;
  background: var(--glass);
  border: 1px solid var(--rim);
  box-shadow: var(--rim-shadow), var(--inner-glow), var(--drop);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
}
.card::before, .card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
}
.card::before { background: radial-gradient(120% 70% at 15% -10%, var(--shine), transparent 55%); }
.card::after { background: radial-gradient(70% 60% at 95% 105%, var(--tint), transparent 70%); }

/* ===== 頂部 ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; box-shadow: var(--drop-sm); }
.brand strong { display: block; font-family: var(--num); font-weight: 500; font-size: 19px; letter-spacing: -.2px; }
.brand small { color: var(--ink-3); font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 999px; }
.tabs button {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: background .25s, color .25s, box-shadow .25s;
}
.tabs button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.active { background: var(--solid); color: var(--on-solid); box-shadow: var(--drop-sm); }

/* ===== 卡片內容 ===== */
.card { border-radius: var(--radius-lg); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 15px; font-weight: 500; letter-spacing: .3px; }
.card-head small, .muted { color: var(--ink-3); font-size: 12px; }
.eyebrow { font-size: 11px; letter-spacing: 1.6px; font-weight: 500; color: var(--ink-3); text-transform: uppercase; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 4px 12px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.section-title small { color: var(--ink-3); font-weight: 400; }
.section-title:first-child { margin-top: 0; }

.view { display: none; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ===== 按鈕 ===== */
.main-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 150px; padding: 15px 28px; border-radius: 999px;
  font-size: 15px; font-weight: 500; letter-spacing: .5px;
  background: var(--solid); color: var(--on-solid);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 18px 30px -16px rgba(20, 18, 14, .6);
  transition: transform .15s;
}
.main-btn:active { transform: scale(.97); }
.main-btn.small { min-width: 0; padding: 11px 22px; font-size: 14px; }

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--rim);
  box-shadow: var(--rim-shadow), var(--inner-glow), var(--drop-sm);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--ink-2); transition: transform .15s, color .2s;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 34px; height: 34px; background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.icon-btn.small svg { width: 17px; height: 17px; }

.ghost-btn {
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--glass-solid); border: 1px solid var(--rim); color: var(--ink);
  box-shadow: var(--rim-shadow), var(--drop-sm);
  transition: transform .15s;
}
.ghost-btn:active { transform: scale(.97); }
.ghost-btn.small { padding: 7px 15px; font-size: 13px; }
.ghost-btn.danger, .text-btn.danger { color: var(--danger); }
.text-btn { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 4px 2px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.btn-group { display: flex; gap: 8px; }
.btn-group.wrap { flex-wrap: wrap; }

/* 分段控制 */
.seg {
  display: flex; gap: 4px; padding: 5px; border-radius: 999px;
  background: var(--glass-soft); box-shadow: var(--well);
}
.seg button {
  flex: 1; padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap; transition: background .3s, color .3s, box-shadow .3s;
}
.seg button.active { color: var(--ink); background: var(--seg-on); box-shadow: var(--seg-on-shadow); }
.seg.dot-active button.active::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%;
  background: var(--orb-a); box-shadow: 0 0 8px var(--orb-a); vertical-align: 1px;
}
.seg.small { padding: 4px; }
.seg.small button { padding: 5px 12px; }

/* 膠囊 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 15px; border-radius: 999px; font-size: 13px;
  background: var(--glass-solid); border: 1px solid var(--rim); color: var(--ink-2);
  box-shadow: var(--rim-shadow); transition: all .25s;
}
.chip.active { background: var(--solid); color: var(--on-solid); border-color: transparent; box-shadow: var(--drop-sm); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }

/* 輸入 */
textarea, input.plain, select.plain {
  width: 100%; border: 1px solid transparent; outline: none;
  background: var(--glass-soft); border-radius: var(--radius-sm);
  box-shadow: var(--well);
  padding: 11px 14px; font-size: 14px; line-height: 1.5;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea { resize: vertical; min-height: 72px; }
textarea:focus, input.plain:focus { background: var(--glass-solid); border-color: var(--rim); box-shadow: var(--rim-shadow), 0 0 0 4px var(--tint); }
input[type="date"].plain, input[type="time"].plain { min-height: 44px; -webkit-appearance: none; appearance: none; }
::placeholder { color: var(--ink-3); }

.stepper {
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px; flex: none;
  background: var(--glass-soft); box-shadow: var(--well);
}
.stepper button {
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px; color: var(--ink);
  background: var(--seg-on); box-shadow: var(--seg-on-shadow);
}
.stepper button:active { transform: scale(.92); }
.stepper input {
  width: 52px; border: 0; background: none; text-align: center; outline: none;
  font-family: var(--num); font-size: 20px; font-weight: 300; -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper span { font-size: 12px; color: var(--ink-3); margin-right: 6px; white-space: nowrap; }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 50px; height: 30px; border-radius: 99px; position: relative;
  background: var(--glass-soft); box-shadow: var(--well); transition: background .3s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #F1EEE9 70%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .06), 0 3px 8px rgba(40, 32, 20, .25);
  transition: transform .35s cubic-bezier(.3, 1.4, .5, 1);
}
.switch:checked { background: var(--solid); }
.switch:checked::after { transform: translateX(20px); }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-top: 1px solid var(--line);
}
.card-head + .row { border-top: 0; }
.row.col { flex-direction: column; align-items: stretch; }
.row-text { display: grid; gap: 3px; min-width: 0; }
.row-text strong { font-size: 14px; font-weight: 500; }
.row-text small { font-size: 12px; color: var(--ink-3); line-height: 1.55; }

/* ===== 習慣圖示泡泡 ===== */
.hicon {
  --c: var(--accent);
  position: relative; display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  color: color-mix(in srgb, var(--c) 70%, #1D1C1A);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .25) 62%),
    radial-gradient(circle at 60% 75%, var(--c), transparent 80%);
  box-shadow: inset 0 -5px 10px -4px rgba(255, 255, 255, .8), 0 10px 18px -12px var(--c);
}
html.dark .hicon { color: color-mix(in srgb, var(--c) 60%, #fff); background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, .18), rgba(255, 255, 255, .03) 62%), radial-gradient(circle at 60% 75%, color-mix(in srgb, var(--c) 70%, transparent), transparent 80%); }
.hicon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hicon .emoji { font-size: 21px; line-height: 1; }
.hicon.sm { width: 34px; height: 34px; }
.hicon.sm svg { width: 17px; height: 17px; }
.hicon.sm .emoji { font-size: 16px; }

/* ===== 今天 ===== */
.date-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px; margin-bottom: 20px; border-radius: 999px; }
.date-label { text-align: center; }
.date-label strong { display: block; font-family: var(--num); font-size: 20px; font-weight: 300; letter-spacing: -.3px; }
.date-label small { font-size: 12px; color: var(--ink-3); }
.date-label button { color: inherit; }

.today-grid { display: grid; grid-template-columns: 1fr 330px; gap: 22px; align-items: start; }
.side { display: grid; gap: 22px; }
.habit-list { display: grid; gap: 12px; }

.habit {
  --c: var(--accent);
  display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; border-radius: 26px;
}
.habit::after { background: radial-gradient(60% 90% at 100% 50%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%); }
.habit-main { flex: 1; min-width: 0; display: grid; gap: 3px; text-align: left; }
.habit-name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-meta { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.habit-meta .streak { color: var(--ink-2); }
.habit.is-done .habit-name { color: var(--ink-2); }
.habit.is-fail .habit-meta .state { color: var(--danger); }

.prog { position: relative; width: 58px; height: 58px; flex: none; }
.prog svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.prog circle { fill: none; stroke-width: 4; }
.prog .track { stroke: var(--line); }
.prog .bar { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset .5s cubic-bezier(.2, .8, .2, 1); }
.prog-num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; font-family: var(--num); }
.prog-num b { font-size: 16px; font-weight: 400; }
.prog-num small { display: block; font-size: 10px; color: var(--ink-3); }

.log-btn {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%;
  background: var(--solid); color: var(--on-solid);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 12px 22px -12px rgba(20, 18, 14, .6);
  transition: transform .15s, background .3s;
}
.log-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.log-btn:active { transform: scale(.9); }
.habit.is-done .log-btn { background: var(--c); color: #fff; }
.log-btn.quit { background: var(--glass-solid); color: var(--quit); border: 1px solid var(--rim); box-shadow: var(--rim-shadow), var(--drop-sm); }
.log-btn.quit span { font-size: 12px; font-weight: 500; }

.rest-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* 今日小結：深色卡片 */
.card.mini {
  background: linear-gradient(150deg, rgba(34, 33, 30, .92), rgba(24, 23, 21, .86));
  border-color: rgba(255, 255, 255, .08);
  color: #F3EFE8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--drop);
}
.card.mini::before { background: radial-gradient(90% 60% at 10% -10%, rgba(255, 255, 255, .10), transparent 60%); }
.card.mini::after { background: radial-gradient(50% 70% at 100% 100%, var(--orb-a), transparent 70%); opacity: .35; }
.card.mini .card-head h2 { color: #F3EFE8; }
.card.mini .card-head small { color: rgba(243, 239, 232, .55); }
html.dark .card.mini { background: linear-gradient(150deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05)); }
.mini-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.mini-nums strong { display: block; font-family: var(--num); font-weight: 300; font-size: 26px; letter-spacing: -.5px; }
.mini-nums small { font-size: 12px; color: rgba(243, 239, 232, .55); }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-strip div { display: grid; gap: 6px; justify-items: center; font-size: 11px; color: rgba(243, 239, 232, .55); }
.week-strip i { display: block; width: 100%; aspect-ratio: 1; max-width: 32px; border-radius: 10px; background: rgba(255, 255, 255, .08); }
.week-strip .today-mark { color: #F3EFE8; font-weight: 500; }

.empty-state { text-align: center; padding: 48px 20px; }
.empty-state h3 { font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--ink-3); margin-bottom: 20px; }
.empty-art {
  width: 104px; height: 104px; margin: 0 auto 20px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, var(--orb-b), var(--orb-a) 60%, transparent 72%);
  filter: blur(4px); opacity: .85;
}
.templates { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }

/* ===== 回顧 ===== */
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.review-head .seg { flex: none; }
.review-head .date-nav { flex: 1; margin: 0; min-width: 240px; }
.filter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.filter-row .chips { flex: 1; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 18px 20px; }
.kpi small { font-size: 12px; color: var(--ink-3); }
.kpi strong { display: block; margin-top: 8px; font-family: var(--num); font-size: 30px; font-weight: 200; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi em { font-style: normal; font-size: 13px; color: var(--ink-2); letter-spacing: 0; margin-left: 2px; }

.review-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; align-items: start; }

.donut { position: relative; width: min(210px, 60vw); aspect-ratio: 1; margin: 6px auto 4px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 14; }
.donut .track { stroke: var(--line); }
.donut .bar { stroke: var(--accent); stroke-linecap: round; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-family: var(--num); font-weight: 200; font-size: 40px; letter-spacing: -1px; }
.donut-center small { font-size: 12px; color: var(--ink-3); }

.status-list { display: grid; gap: 10px; }
.status-item {
  --c: var(--accent);
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--glass-solid); border: 1px solid var(--rim); box-shadow: var(--rim-shadow);
}
.status-item .row-text { flex: 1; }
.status-item .val { font-family: var(--num); font-size: 14px; white-space: nowrap; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 99px; background: var(--glass-soft); box-shadow: var(--well); color: var(--ink-2); white-space: nowrap; }
.badge.done { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-deep); box-shadow: none; }
.badge.fail { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); box-shadow: none; }
html.dark .badge.done { color: var(--orb-b); }
.note-line { font-size: 12px; color: var(--ink-2); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* 月曆 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-h { text-align: center; font-size: 11px; color: var(--ink-3); padding-bottom: 4px; }
.cal-d {
  position: relative; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--num); font-size: 13px; color: var(--ink-2);
  background: var(--empty-cell);
  transition: transform .15s;
}
.cal-d.has { color: var(--ink); }
.cal-d.hi { color: #fff; }
html.dark .cal-d.hi { color: #0f1a17; }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-d.lapse::after { content: ''; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--quit); }
.cal-d.off { background: transparent; color: var(--ink-3); opacity: .5; }
button.cal-d:active { transform: scale(.94); }

.legend-scale { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 14px; font-size: 11px; color: var(--ink-3); }
.legend-scale i { width: 12px; height: 12px; border-radius: 4px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bars li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 10px; font-size: 14px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bars .v { font-family: var(--num); }
.bars .v small { color: var(--ink-3); margin-left: 4px; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--glass-soft); box-shadow: var(--well); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 99px; }

/* 年度格 */
.year-scroll { overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.year { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: 16px repeat(7, auto); gap: 3px; min-width: 600px; }
.year .ym { font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: visible; }
.year i { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--empty-cell); }
.year i.off { background: transparent; }
.year i.lapse { box-shadow: inset 0 0 0 1.5px var(--quit); }

.month-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 150px; padding-top: 10px; }
.month-bars div { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; text-align: center; }
.month-bars .col { position: relative; border-radius: 8px; background: var(--glass-soft); box-shadow: var(--well); overflow: hidden; }
.month-bars .col i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 8px; }
.month-bars small { font-size: 10px; color: var(--ink-3); font-family: var(--num); }

/* ===== 習慣管理 ===== */
.manage-list { display: grid; gap: 10px; }
.manage-item { --c: var(--accent); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 24px; }
.manage-item .row-text { flex: 1; }
.manage-item .row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind-tag { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent-deep); font-weight: 500; }
.kind-tag.quit { background: color-mix(in srgb, var(--quit) 20%, transparent); color: var(--quit); }
html.dark .kind-tag { color: var(--orb-b); }
html.dark .kind-tag.quit { color: #F5B0A3; }
.add-btn {
  width: 100%; margin-top: 12px; padding: 14px; border-radius: var(--radius);
  border: 1.5px dashed color-mix(in srgb, var(--ink) 18%, transparent); color: var(--ink-2); font-size: 14px; font-weight: 500;
  background: var(--glass-soft);
}
.add-btn:hover { color: var(--ink); }
.archive-card { margin-top: 26px; }
.archive-card .manage-item { background: var(--glass-soft); box-shadow: var(--well); border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.archive-card .manage-item::before, .archive-card .manage-item::after { display: none; }

/* ===== 設定 ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.span-2 { grid-column: 1 / -1; }

/* ===== 對話框 ===== */
dialog.sheet {
  border: 0; padding: 0; background: transparent;
  width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  box-sizing: border-box; color: var(--ink); overflow: visible;
}
dialog.sheet::backdrop { background: rgba(40, 32, 22, .22); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog.sheet[open] { animation: pop .4s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.sheet-inner {
  display: grid; gap: 10px; padding: 24px; border-radius: var(--radius-lg);
  grid-auto-rows: max-content; align-content: start;
  background: var(--sheet-bg);
  max-height: calc(100dvh - 24px); min-height: 0; box-sizing: border-box;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
}
.sheet-inner h2 { font-size: 21px; font-weight: 500; }
.field-label { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-top: 8px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sheet-actions {
  display: flex; align-items: center; gap: 8px; position: sticky; bottom: 0; z-index: 2;
  margin: 8px -24px 0; padding: 18px 24px max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--sheet-solid) 35%);
}
.spacer { flex: 1; }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; max-height: 148px; overflow-y: auto; padding: 4px; border-radius: var(--radius-sm); background: var(--glass-soft); box-shadow: var(--well); }
.icon-grid button { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; color: var(--ink-2); }
.icon-grid button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-grid button.active { background: var(--solid); color: var(--on-solid); }
.emoji-row { display: flex; gap: 8px; align-items: center; }
.emoji-row input { width: 150px; text-align: center; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7), 0 6px 12px -6px rgba(0, 0, 0, .35); }
.swatches button.active { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  width: 30px; height: 30px; border: 0; border-radius: 50%; padding: 0; background: none;
}
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 3px solid rgba(255, 255, 255, .75); border-radius: 50%; }
.swatch::-moz-color-swatch { border: 3px solid rgba(255, 255, 255, .75); border-radius: 50%; }

.day-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-pick.month { grid-template-columns: repeat(7, 1fr); }
.day-pick button { aspect-ratio: 1; max-height: 42px; border-radius: 12px; font-size: 13px; font-family: var(--num); background: var(--glass-soft); box-shadow: var(--well); color: var(--ink-2); }
.day-pick button.active { background: var(--solid); color: var(--on-solid); box-shadow: var(--drop-sm); }
.time-row { display: flex; align-items: center; gap: 8px; }
.time-row input { flex: 1; }

.goal-history { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.goal-history li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); padding: 8px 12px; border-radius: 12px; background: var(--glass-soft); }
.goal-history li b { font-family: var(--num); font-weight: 400; color: var(--ink); white-space: nowrap; }
.goal-history li span { flex: 1; }
.goal-history li.current { box-shadow: inset 0 0 0 1.5px var(--accent); }

.log-items { display: grid; gap: 6px; }
.log-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 14px; background: var(--glass-soft); font-size: 13px; }
.log-item .t { font-family: var(--num); color: var(--ink-3); }
.log-item .n { flex: 1; min-width: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { padding: 7px 13px; border-radius: 99px; font-size: 13px; font-family: var(--num); background: var(--glass-solid); border: 1px solid var(--rim); box-shadow: var(--rim-shadow); }

/* ===== 提示 ===== */
.toast {
  position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); z-index: 50;
  transform: translate(-50%, -150%); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 22px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--sheet-bg);
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.2), opacity .3s; pointer-events: none;
  max-width: calc(100% - 32px);
}
.toast:not(:has(button)) { padding-right: 22px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { padding: 6px 14px; border-radius: 99px; background: var(--solid); color: var(--on-solid); font-size: 13px; }

.update-bar {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 40; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 20px; border-radius: 999px; font-size: 14px;
  background: var(--sheet-bg); white-space: nowrap;
}

/* ===== 手機版 ===== */
@media (max-width: 860px) {
  .today-grid, .review-grid, .settings-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .app { padding-top: max(16px, env(safe-area-inset-top)); }
  .topbar { margin-bottom: 16px; }
  .tabs {
    position: fixed; z-index: 20; left: 16px; right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    justify-content: space-around; padding: 6px;
    background: var(--sheet-bg);
  }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; padding: 8px 0; font-size: 11px; }
  .tabs button svg { width: 22px; height: 22px; }
  .card { padding: 18px; border-radius: 26px; }
  .today-grid, .side, .review-grid, .settings-grid { gap: 14px; }
  .kpis { gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 14px 16px; }
  .kpi strong { font-size: 26px; }
  .date-nav { margin-bottom: 14px; }
  .habit { gap: 12px; padding: 12px; }
  .prog { width: 52px; height: 52px; }
  .review-head .seg { width: 100%; }
  .review-head .date-nav { min-width: 0; width: 100%; }
  .cal { gap: 4px; }
  .cal-d { border-radius: 10px; font-size: 12px; }
  .update-bar { bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* iOS 會放大字級小於 16px 的輸入框，導致視窗看似跳動。 */
  input, textarea, select { font-size: 16px; }

  /* 手機上的表單像底部抽屜：操作列留在底部，表單內容可獨立捲動。 */
  dialog.sheet {
    position: fixed; top: auto; right: 0; bottom: 0; left: 0;
    width: 100vw; max-width: none; max-height: calc(100dvh - 12px);
    margin: 0; border-radius: 28px 28px 0 0; overflow: hidden;
  }
  .sheet-inner {
    max-height: calc(100dvh - 12px); padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
  }
}

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

.month-bars .col { width: 100%; }
.habit > button:first-child { flex: none; border-radius: 50%; }
.mini-nums strong small { font-size: 14px; color: rgba(243, 239, 232, .5); }
.donut-center strong small { font-size: 16px; color: var(--ink-3); }
