:root {
  --bg1: #0b1026; --bg2: #1b1242;
  --card: rgba(255,255,255,.06); --border: rgba(255,255,255,.10);
  --text: #eef0ff; --muted: #9aa3c7;
  --accent: #8b7bff; --accent2: #3fd0c9;
  --pos: #5ee39b; --neg: #ff7a7a;
  --radius: 20px;
}
body.light {
  --bg1: #f3f4fb; --bg2: #e9e4ff;
  --card: rgba(255,255,255,.75); --border: rgba(30,20,90,.08);
  --text: #1c1d33; --muted: #6b6f8f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Noto Sans TC", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  padding-bottom: 96px;
  overflow-x: hidden;
}
.bg-orb { position: fixed; border-radius: 50%; filter: blur(70px); opacity: .35; z-index: -1; }
.orb1 { width: 260px; height: 260px; background: #7b5cff; top: -60px; right: -80px; animation: float 12s ease-in-out infinite; }
.orb2 { width: 220px; height: 220px; background: #19c3b8; bottom: 80px; left: -90px; animation: float 15s ease-in-out infinite reverse; }
@keyframes float { 50% { transform: translate(20px, 30px); } }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; backdrop-filter: blur(16px); background: rgba(10,10,30,.25); }
body.light .topbar { background: rgba(255,255,255,.5); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .5px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 22px; cursor: pointer; transition: transform .15s; }
.icon-btn:active { transform: scale(.9); }

main { padding: 8px 14px; }
.view { display: none; animation: fadeUp .35s ease; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; backdrop-filter: blur(18px); }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.hero { background: linear-gradient(135deg, rgba(139,123,255,.35), rgba(63,208,201,.18)); }
.big { font-family: Inter; font-size: 38px; font-weight: 800; margin: 4px 0 14px; letter-spacing: -1px; }
.row3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.row3 div { display: flex; flex-direction: column; gap: 2px; }
.row3 b { font-size: 16px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.budget { margin-top: 14px; }
.budget-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.bar { height: 8px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
#budget-bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .8s cubic-bezier(.2,.8,.2,1); }
#budget-bar.over { background: linear-gradient(90deg, #ffb36b, var(--neg)); }

.donut-wrap { max-width: 220px; margin: 0 auto 10px; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.legend li:active { background: var(--card); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .amt { margin-left: auto; color: var(--muted); }

.list { list-style: none; padding: 0; margin: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer; position: relative; transition: transform .25s, opacity .25s; touch-action: pan-y; }
.item:active { transform: scale(.98); }
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-size: 15px; }
.item .meta small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.item .val { font-weight: 700; font-family: Inter; }
.day-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 16px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.filters { display: flex; gap: 8px; margin-bottom: 4px; }
input, select { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); font: inherit; font-size: 15px; outline: none; margin-bottom: 8px; }
input:focus, select:focus { border-color: var(--accent); }
select option { color: #111; }
.filters select { width: 40%; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { margin-bottom: 8px; }
.emoji-in { width: 56px; text-align: center; flex: none; }
input[type=color] { width: 52px; flex: none; padding: 4px; height: 46px; }

.btn-primary, .btn-ghost, .btn-danger { width: 100%; padding: 13px; border-radius: 14px; border: 0; font: inherit; font-weight: 700;
  font-size: 15px; cursor: pointer; transition: transform .15s, filter .15s; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5f8bff); color: #fff; box-shadow: 0 8px 24px rgba(123,92,255,.35); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(255,122,122,.15); color: var(--neg); }
.btn-primary.sm { width: auto; padding: 12px 18px; }
button:active { transform: scale(.96); }

.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 10px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; transition: .2s; }
.seg button.active { background: linear-gradient(135deg, var(--accent), #5f8bff); color: #fff; }

.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; text-align: center; }
.cal-head span { color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.cal-cell { aspect-ratio: 1/1.15; border-radius: 10px; padding: 4px 2px; font-size: 12px; display: flex; flex-direction: column;
  justify-content: space-between; cursor: pointer; border: 1px solid transparent; transition: transform .15s; }
.cal-cell:active { transform: scale(.92); }
.cal-cell.today { border-color: var(--accent2); }
.cal-cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139,123,255,.35); }
.cal-cell small { font-size: 10px; font-family: Inter; opacity: .9; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-around;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); backdrop-filter: blur(20px); background: rgba(12,12,35,.6);
  border-top: 1px solid var(--border); z-index: 10; }
body.light .tabbar { background: rgba(255,255,255,.7); }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; cursor: pointer; width: 60px; transition: color .2s; }
.tab span { font-size: 20px; transition: transform .2s; }
.tab.active { color: var(--text); }
.tab.active span { transform: translateY(-2px) scale(1.1); }
.fab { width: 58px; height: 58px; border-radius: 50%; border: 0; margin-top: -30px; font-size: 30px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 10px 30px rgba(123,92,255,.5); animation: pulse 3s infinite; }
@keyframes pulse { 50% { box-shadow: 0 10px 40px rgba(63,208,201,.55); } }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: linear-gradient(180deg, #1d1840, #120f2b);
  border-radius: 26px 26px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(110%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1); max-height: 92vh; overflow-y: auto; }
body.light .sheet { background: linear-gradient(180deg, #ffffff, #f2efff); }
.sheet.open { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--border); margin: 0 auto 12px; }
.amount { font-family: Inter; font-size: 42px; font-weight: 800; text-align: right; padding: 4px 6px 10px; }
.amount.income { color: var(--pos); }
.chips { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; margin-bottom: 12px; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; padding: 8px 2px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; transition: .2s; }
.chip span { font-size: 22px; }
.chip.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 25%, transparent); transform: translateY(-2px); }
.keypad { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 10px; }
.keypad button { padding: 14px; font: 600 20px Inter; border-radius: 14px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; }

.rem-actions { display: flex; gap: 6px; }
.rem-actions button { border: 0; border-radius: 10px; padding: 8px 10px; cursor: pointer; background: var(--card); color: var(--text); font-size: 16px; }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px); background: rgba(20,20,40,.92); color: #fff;
  padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .3s; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 完整資產管理樣式 (Ported from wealth-tracker) ---------- */
.w-subseg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 4px; margin-bottom: 14px; gap: 4px; }
.w-subseg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 4px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: .2s; }
.w-subseg button.active { background: linear-gradient(135deg, var(--accent), #5f8bff); color: #fff; }

.items-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 4px -6px; }
.items-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; min-width: 320px; }
.items-table th, .items-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.items-table th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.items-table tbody tr:hover { background: rgba(255,255,255,.03); }
.items-table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--pos) !important; }
.text-danger { color: var(--neg) !important; }
.text-muted { color: var(--muted); }

.stock-symbol-name strong { display: block; font-size: 14px; }
.stock-symbol-name small { color: var(--muted); font-size: 11px; }

.badge-profit { display: inline-block; padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-profit.pos { background: rgba(94, 227, 155, .15); color: var(--pos); }
.badge-profit.neg { background: rgba(255, 122, 122, .15); color: var(--neg); }

.action-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin: 0 2px; }
.action-btn:active { transform: scale(0.9); }
.action-btn.del { color: var(--neg); }

.mort-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.mort-sum-item { display: flex; flex-direction: column; padding: 10px 12px; background: rgba(255,255,255,.03); border-radius: 12px; border: 1px solid var(--border); }
.mort-sum-item .label { font-size: 11px; color: var(--muted); }
.mort-sum-item .value { font-family: Inter; font-size: 16px; font-weight: 700; margin-top: 4px; }

.progress-container { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--muted); }
.progress-bar-bg { height: 8px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 99px; transition: width .5s ease-out; }

.spinning { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ---------- 🐱 貓咪照護 (Cat Care Module) ---------- */
.cat-carousel { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 6px; -webkit-overflow-scrolling: touch; }
.cat-carousel::-webkit-scrollbar { display: none; }
.cat-pill { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: all .2s; }
.cat-pill span.avatar { font-size: 16px; }
.cat-pill.active { background: linear-gradient(135deg, rgba(255, 142, 178, 0.45), rgba(255, 185, 107, 0.35)); border-color: #ff8fb0; color: #fff; box-shadow: 0 4px 12px rgba(255, 143, 176, 0.3); }
.cat-pill.add-btn { border-style: dashed; opacity: .85; }

.cat-hero { background: linear-gradient(135deg, rgba(255, 142, 178, 0.28), rgba(139, 123, 255, 0.22)); border: 1px solid rgba(255, 142, 178, 0.3); }
.cat-hero-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cat-avatar-large { width: 62px; height: 62px; border-radius: 50%; background: linear-gradient(135deg, #ffd3e0, #ffb8c6); display: flex; align-items: center; justify-content: center; font-size: 34px; box-shadow: 0 6px 18px rgba(255, 143, 176, 0.35); flex-shrink: 0; }
body.light .cat-avatar-large { background: linear-gradient(135deg, #ffeef4, #ffd3e0); }
.cat-hero-info { flex: 1; min-width: 0; }
.cat-hero-name { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cat-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.12); color: var(--text); }
body.light .cat-tag { background: rgba(30, 20, 90, 0.08); }
.cat-tag.gender-m { color: #5fb5ff; background: rgba(95, 181, 255, 0.15); }
.cat-tag.gender-f { color: #ff85be; background: rgba(255, 133, 190, 0.15); }
.cat-tag.breed { color: #ffc272; background: rgba(255, 194, 114, 0.15); }

.cat-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.cat-stat-box { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 10px 8px; text-align: center; }
body.light .cat-stat-box { background: rgba(255,255,255,.6); }
.cat-stat-val { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.cat-stat-lbl { font-size: 11px; color: var(--muted); }

.sched-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px; gap: 10px; }
body.light .sched-item { background: rgba(255,255,255,.6); }
.sched-info { flex: 1; min-width: 0; }
.sched-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.sched-meta { font-size: 12px; color: var(--muted); }
.sched-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.sched-badge.overdue { background: rgba(255, 122, 122, 0.2); color: var(--neg); border: 1px solid rgba(255, 122, 122, 0.3); }
.sched-badge.due_today { background: rgba(255, 193, 99, 0.25); color: #ffbe4a; border: 1px solid rgba(255, 193, 99, 0.4); animation: pulse 2s infinite; }
.sched-badge.due_soon { background: rgba(255, 214, 102, 0.18); color: #ffd666; }
.sched-badge.normal { background: rgba(94, 227, 155, 0.15); color: var(--pos); }
.sched-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-done-check { background: linear-gradient(135deg, #5ee39b, #3fd0c9); border: 0; color: #0d2b1f; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 10px; cursor: pointer; transition: transform .15s; display: inline-flex; align-items: center; gap: 4px; }
.btn-done-check:active { transform: scale(.92); }

.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip { background: var(--card); border: 1px solid var(--border); border-radius: 99px; padding: 5px 12px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: all .2s; }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.record-card { display: flex; align-items: flex-start; gap: 12px; padding: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px; transition: background .15s; }
body.light .record-card { background: rgba(255,255,255,.6); }
.record-icon-wrap { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.06); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.record-card-main { flex: 1; min-width: 0; }
.record-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.record-card-title { font-size: 14px; font-weight: 600; }
.record-card-date { font-size: 11px; color: var(--muted); }
.record-card-details { font-size: 12px; color: var(--muted); margin-top: 2px; }
.record-card-tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.08); margin-right: 4px; }

.preset-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.preset-pill { font-size: 12px; padding: 4px 10px; border-radius: 8px; background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--text); cursor: pointer; }
.preset-pill:hover, .preset-pill:active { background: rgba(139, 123, 255, 0.25); border-color: var(--accent); }

