:root {
  /* ── Brand ── */
  --brand:          #b5562c;   /* 磚紅 */
  --brand-hover:    #9e4a24;
  --brand-active:   #7d3a1c;
  --brand-tint-10:  #fdf0eb;   /* 背景強調 */
  --brand-tint-25:  #f5d5c5;   /* 標籤底色 */

  /* ── Neutral ── */
  --bg:        #faf8f5;        /* 米白·道林紙 */
  --paper:     #ffffff;        /* 紙白·卡片面 */
  --warm-100:  #f0ece6;
  --warm-200:  #ddd8d0;
  --warm-400:  #b0a89e;
  --warm-600:  #7a716a;
  --ink:       #1e1a17;        /* 碳黑·主文字 */
  --ink-soft:  #4a433d;        /* 煤灰·次要文字 */
  --ink-faint: #938b85;        /* 薄霧灰·提示文字 */

  /* ── Semantic ── */
  --success:   #3d7a50;        /* 森綠·收款 */
  --danger:    #c0392b;        /* 硃紅·欠款 */
  --warning:   #c07830;        /* 琥珀 */
  --info:      #3060a0;        /* 靛藍 */

  /* ── Spacing · 4px base ── */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-6:   24px;
  --space-8:   32px;
  --space-12:  48px;
  --space-16:  64px;

  /* ── Radius ── */
  --radius-badge:   4px;       /* 標籤 / badge */
  --radius-control: 6px;       /* 輸入框 / 按鈕 */
  --radius-card:    10px;      /* 卡片 */
  --radius-panel:   14px;      /* 大型面板 */

  /* ── Shadow · 模擬紙張層疊 ── */
  --shadow-card:       0 1px 3px rgba(30,26,23,0.08);
  --shadow-card-hover: 0 3px 8px rgba(30,26,23,0.12);
  --shadow-modal:      0 8px 32px rgba(30,26,23,0.18);

  /* ── Type ── */
  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Albert Sans", "Microsoft JhengHei", "Segoe UI", sans-serif;

  /* ── Motion ── */
  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   350ms;
  --ease-out:    cubic-bezier(0.25, 0.46, 0.45, 0.94);   /* 入場 */
  --ease-in:     cubic-bezier(0.55, 0.055, 0.675, 0.19);  /* 離場 */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);       /* 彈性・蓋章感 */

  /* ── Legacy aliases (既有 CSS 沿用的變數名) ── */
  --accent-fallback: var(--brand);
  --paper-sunk: var(--warm-100);
  --border:     var(--warm-200);
  --shadow-sm:  var(--shadow-card);
  --shadow-md:  var(--shadow-modal);
  --radius:     var(--radius-card);
  --radius-sm:  var(--radius-control);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

/* Gate */
.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  padding: 24px;
}
.gate-card {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  width: 400px;
  overflow: hidden;
}
.gate-form { padding: 36px 32px; }
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.gate-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-control);
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}
.gate-wordmark { font-family: var(--font-display); font-weight: 600; font-size: 19px; color: var(--ink); }
.gate-illustration { display: none; }
.gate-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 600;
  text-align: center;
}
.gate-hint { text-align: center; margin: -10px 0 16px; }
@media (min-width: 880px) {
  .gate-card { width: 880px; display: flex; align-items: stretch; }
  .gate-illustration { display: block; flex: 0 0 58%; min-height: 100%; }
  .gate-illustration svg { width: 100%; height: 100%; display: block; }
  .gate-form { flex: 1; padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .gate-card h1, .gate-hint { text-align: left; margin-left: 0; }
}
.my-trips { margin-bottom: 22px; }
.my-trips h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-weight: 600;
}
.my-trips .item-list li { padding: 8px 6px; cursor: pointer; border-radius: 8px; }
.my-trips .item-list li:hover { background: var(--paper-sunk); }
.gate-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.gate-divider {
  text-align: center;
  color: var(--ink-faint);
  margin: 18px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.gate-divider::before, .gate-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

input, select, textarea, button, .input {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--paper);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, .input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent, var(--accent-fallback)) 60%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, var(--accent-fallback)) 18%, transparent);
}
input, select, textarea, .input { flex: 1; }
textarea { resize: vertical; min-height: 56px; font-family: inherit; }
.input--error { border-color: var(--danger); }
.input--error + .input__hint, .input__hint--error { color: var(--danger); font-size: 12px; }

/* ---- Buttons ---- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent, var(--brand));
  color: #fffaf3;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  transition: background var(--duration-fast) var(--ease-out), transform 100ms var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), filter var(--duration-fast) var(--ease-out);
}
button:hover, .btn:hover { filter: brightness(0.92); }
button:active, .btn:active { transform: scale(0.97) translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn--primary {
  background: var(--brand);
  filter: none;
  box-shadow: 0 1px 3px rgba(30, 26, 23, 0.10);
}
.btn--primary:hover { background: var(--brand-hover); filter: none; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(30, 26, 23, 0.18); }
.btn--primary:active { background: var(--brand-hover); transform: scale(0.97) translateY(1px); box-shadow: none; }

.btn--secondary {
  background: transparent;
  border-color: var(--brand);
  color: var(--brand);
  filter: none;
}
.btn--secondary:hover { background: var(--brand-tint-10); filter: none; }

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-soft);
  filter: none;
}
.btn--ghost:hover { background: var(--paper-sunk); filter: none; }

.ghost-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fffaf3;
  border: 1px solid rgba(255, 250, 243, 0.45);
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.24); filter: none; }

/* App layout */
.app { position: relative; z-index: 1; }

.topbar {
  background: var(--accent, var(--accent-fallback));
  color: #fffaf3;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background-size: cover;
  background-position: center;
}
.topbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.trip-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin-right: 12px; }
.trip-code { font-size: 12px; opacity: 0.8; letter-spacing: 0.04em; }

.icon-btn { display: flex; align-items: center; gap: 6px; padding: 7px 12px; }
.icon-btn span:first-child { font-size: 15px; }
.icon-btn-label { font-size: 12px; }
@media (max-width: 560px) {
  .icon-btn-label { display: none; }
  .icon-btn { padding: 8px; }
}

.reminder-banner {
  margin: 0;
  padding: 11px 20px;
  background: #f3e2b8;
  color: #6b4d12;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #e6cf94;
}

/* ---- Navigation dock ---- */
.nav-dock {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  overflow-x: auto;
  position: relative;
  z-index: 1;
}

.tab-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 16px;
  white-space: nowrap;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-icon { font-size: 13px; opacity: 0.75; }
.tab-btn:hover { background: var(--paper-sunk); filter: none; }
.tab-btn.active {
  background: var(--accent, var(--accent-fallback));
  color: #fffaf3;
  border-color: transparent;
}
.tab-btn.active .tab-icon { opacity: 1; }

.tab-primary {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.tab-primary.active { border-color: transparent; }

main { max-width: 1440px; margin: 0 auto; padding: 24px 24px 60px; position: relative; z-index: 1; }

.agenda-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.agenda-sidebar, .agenda-main { min-width: 0; }
@media (max-width: 860px) {
  .agenda-layout { grid-template-columns: 1fr; }
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in var(--duration-fast) var(--ease-out); }
.tab-panel:not(#tab-agenda) { max-width: 760px; margin: 0 auto; }
#tab-team, #tab-personal { max-width: none; }
@keyframes panel-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- Sub-nav（多人協作／個人工具 內部分頁） ---- */
.sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 auto 18px;
  max-width: 760px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.sub-tab-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sub-tab-btn:hover { background: var(--paper-sunk); filter: none; }
.sub-tab-btn.active { background: var(--brand); color: #fffaf3; }
.sub-panel { display: none; max-width: 760px; margin: 0 auto; }
.sub-panel.active { display: block; animation: panel-in var(--duration-fast) var(--ease-out); }
#sub-kanban { max-width: none; }

/* ---- Card enter / leave (動態特效系統) ---- */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card--enter { animation: card-enter var(--duration-normal) var(--ease-out); }
.card--leave {
  opacity: 0;
  transform: translateX(20px);
  max-height: 0 !important;
  margin: 0 !important;
  padding-block: 0 !important;
  overflow: hidden;
  transition:
    opacity 150ms var(--ease-in),
    transform var(--duration-slow) var(--ease-in),
    max-height var(--duration-slow) var(--ease-in) 100ms,
    padding var(--duration-slow) var(--ease-in) 100ms,
    margin var(--duration-slow) var(--ease-in) 100ms;
}

/* ---- 招牌動畫：印章蓋下 ---- */
.stamp-wrapper { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.stamp-ring { position: absolute; inset: 0; border: 3px solid var(--brand); border-radius: 50%; box-sizing: border-box; opacity: 0; }
.stamp-bg { position: absolute; inset: 0; background: color-mix(in srgb, var(--brand) 15%, transparent); border-radius: 50%; opacity: 0; }
.stamp-inner { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.stamp--sm .stamp-ring { border-width: 2px; }

.is-stamping { animation: stamp-press 420ms var(--ease-out) both; }
.is-stamping .stamp-ring { animation: ink-spread 270ms var(--ease-out) 130ms both, ink-fade 300ms var(--ease-in) 840ms both; }
.is-stamping .stamp-bg { animation: ink-spread 300ms ease-out 130ms both, ink-fade 300ms var(--ease-in) 840ms both; }
.is-stamping .stamp-inner { animation: ink-text 90ms ease-out 80ms both; }
.is-stamping.stamp--ephemeral .stamp-inner { animation: ink-text 90ms ease-out 80ms both, ink-fade 300ms var(--ease-in) 840ms both; }

.is-stamping-check { animation: stamp-press-check 360ms ease-out both; }

@keyframes stamp-press {
  0%   { opacity: 0; transform: translateY(-26px) scale(1.3); animation-timing-function: var(--ease-spring); }
  20%  { opacity: 1; transform: translateY(0) scale(1); animation-timing-function: ease-in; }
  31%  { transform: translateY(0) scale(0.95); animation-timing-function: ease-out; }
  42%  { transform: translateY(0) scale(1.02); animation-timing-function: ease-in-out; }
  54%  { transform: translateY(0) scale(1); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes stamp-press-check {
  0%   { transform: translateY(-10px) scale(1.25); animation-timing-function: var(--ease-spring); }
  24%  { transform: translateY(0) scale(1); animation-timing-function: ease-out; }
  36%  { transform: scale(0.92); }
  48%  { transform: scale(1.05); }
  62%  { transform: scale(1); }
  100% { transform: scale(1); }
}
@keyframes ink-spread {
  from { clip-path: circle(0% at 50% 50%); opacity: 0; }
  to   { clip-path: circle(72% at 50% 50%); opacity: 1; }
}
@keyframes ink-fade { from { opacity: 1; } to { opacity: 0; } }
@keyframes ink-text { from { opacity: 0; } to { opacity: 1; } }

.stamp-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 26, 23, 0.18);
}
.stamp-overlay .stamp-wrapper { width: 180px; height: 180px; }
.stamp-overlay .stamp-label { font-size: 11px; letter-spacing: 0.26em; color: var(--brand); font-weight: 700; }
.stamp-overlay .stamp-code { font-family: var(--font-display); font-weight: 700; font-size: 38px; color: var(--brand); letter-spacing: 0.06em; }
.stamp-overlay .stamp-sub { font-size: 12px; color: var(--brand); font-weight: 600; opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 0; font-size: 17px; font-weight: 600; }
.card h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 600; }
.card__divider, .divider { border-top: 1px solid var(--warm-100); margin: 14px 0; }

/* ---- Badge (分類色標) ---- */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-badge);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.badge--food    { background: var(--brand-tint-10); color: var(--brand); }
.badge--transit { background: #e8f0fb; color: var(--info); }
.badge--stay    { background: #e8f5ee; color: var(--success); }
.badge--ticket  { background: #fef8ec; color: var(--warning); }
.badge--other   { background: var(--warm-100); color: var(--warm-600); }
.badge--salary   { background: #e8f5ee; color: var(--success); }
.badge--allowance{ background: #e8f0fb; color: var(--info); }
.badge--refund   { background: var(--brand-tint-10); color: var(--brand); }
html[data-theme="dark"] .badge--transit { background: color-mix(in srgb, var(--info) 18%, var(--paper)); }
html[data-theme="dark"] .badge--stay    { background: color-mix(in srgb, var(--success) 18%, var(--paper)); }
html[data-theme="dark"] .badge--ticket  { background: color-mix(in srgb, var(--warning) 18%, var(--paper)); }
html[data-theme="dark"] .badge--salary   { background: color-mix(in srgb, var(--success) 18%, var(--paper)); }
html[data-theme="dark"] .badge--allowance{ background: color-mix(in srgb, var(--info) 18%, var(--paper)); }

/* ---- Pill toggle（記帳 支出/收入） ---- */
.pill-toggle { display: inline-flex; background: var(--warm-100); border-radius: 999px; padding: 3px; gap: 2px; align-self: flex-start; }
.pill-toggle-btn {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}
.pill-toggle-btn:hover { filter: none; background: var(--paper-sunk); }
.pill-toggle-btn.active { background: var(--brand); color: #fffaf3; }
.pill-toggle-btn.active:hover { background: var(--brand-hover); }
.pill-toggle-btn[data-type="income"].active { background: var(--success); }
.pill-toggle-btn[data-type="income"].active:hover { background: var(--success); filter: brightness(0.92); }

/* ---- Ledger row ---- */
.ledger-row { align-items: center; }
.ledger-row .ledger-date { font-size: 12px; color: var(--ink-faint); width: 70px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ledger-row .ledger-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger-row .ledger-amount.income { color: var(--success); }
.ledger-row .ledger-amount.expense { color: var(--ink); }
.ledger-row .ledger-actions { display: flex; gap: 4px; flex-shrink: 0; }
.edit-btn {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand-tint-25);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}
.edit-btn:hover { background: var(--brand-tint-10); filter: none; }

/* ---- Trend chart（近 6 個月，純 CSS bar） ---- */
.trend-chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.trend-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar-track { width: 100%; max-width: 36px; height: 100px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.trend-bar-seg { width: 100%; border-radius: 3px; min-height: 2px; }
.trend-bar-seg.income { background: var(--success); }
.trend-bar-seg.expense { background: var(--brand); }
.trend-bar-label { font-size: 11px; color: var(--ink-faint); }
.trend-bar-net { font-size: 11px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row label { display: flex; flex-direction: column; font-size: 12px; gap: 4px; color: var(--ink-soft); }
.row label.grow { flex: 1; }

.form-grid { display: flex; flex-direction: column; gap: 10px; }

.item-list { list-style: none; padding: 0; margin: 0; }
.item-list li {
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.item-list li:last-child { border-bottom: none; }
.item-meta { color: var(--ink-faint); font-size: 12px; }
.item-meta a { color: var(--accent, var(--accent-fallback)); }

/* ---- Empty state illustration（插畫系統） ---- */
.empty-state {
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center;
  gap: 6px !important;
  padding: 22px 12px 26px !important;
  border-bottom: none !important;
}
.empty-state .empty-art {
  width: 100%;
  max-width: 200px;
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, var(--warm-100), color-mix(in srgb, var(--warm-200) 55%, var(--warm-100)));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  margin-bottom: 6px;
}
.empty-state .empty-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--ink); }
.empty-state .empty-sub { font-size: 12px; color: var(--ink-faint); }
html[data-theme="dark"] .empty-state .empty-art { background: linear-gradient(180deg, var(--warm-100), var(--warm-200)); opacity: 0.85; }
.delete-btn {
  background: transparent;
  color: #a6442c;
  border: 1px solid #e4c3b6;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}
.delete-btn:hover { background: #f7e6e0; filter: none; }

.checkbox-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0; }
.checkbox-list label { display: flex; align-items: center; gap: 4px; font-size: 13px; }

.hint { font-size: 12px; color: var(--ink-faint); }

.balance-positive { color: #2e7d4f; font-weight: bold; }
.balance-negative { color: #b3422c; font-weight: bold; }

.category-chart { display: flex; flex-direction: column; gap: 10px; }
.category-bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.category-bar-label { width: 60px; flex-shrink: 0; color: var(--ink-soft); }
.category-bar-track { flex: 1; background: var(--paper-sunk); border-radius: 4px; height: 14px; overflow: hidden; }
.category-bar-fill { height: 100%; background: var(--accent, var(--accent-fallback)); }
.category-bar-value { width: 90px; flex-shrink: 0; text-align: right; color: var(--ink-soft); }

.checklist-item { display: flex; align-items: center; gap: 8px; }
.checklist-item.done span { text-decoration: line-through; color: var(--ink-faint); }
.checklist-item.overdue:not(.done) span { color: #b3422c; font-weight: bold; }
.checklist-due { font-size: 11px; color: var(--ink-faint); margin-left: 4px; }

.week-summary { display: flex; gap: 20px; flex-wrap: wrap; }
.week-summary-stat { text-align: center; min-width: 90px; }
.week-summary-stat .value { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--accent, var(--accent-fallback)); }
.week-summary-stat .label { font-size: 12px; color: var(--ink-soft); }

.calendar-cell.conflict { border-top-color: var(--danger); border-top-style: solid; }
.calendar-items li.conflict { background: color-mix(in srgb, var(--danger) 14%, var(--paper)); color: var(--danger); }

#searchInput { width: 100%; margin-bottom: 8px; }

.note-item { flex-direction: column; align-items: stretch; }
.note-author { font-weight: bold; font-size: 13px; }
.note-time { font-size: 11px; color: var(--ink-faint); }

.calendar-card { padding: 14px; }
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 4px;
}
.calendar-month-label { font-family: var(--font-display); font-weight: 600; font-size: 17px; min-width: 110px; text-align: center; }
.calendar-month-stats {
  text-align: center;
  font-size: 12px;
  color: var(--warm-600);
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--warm-100);
  padding-top: 14px;
}
.ghost-btn-light {
  background: var(--paper-sunk);
  color: var(--accent, var(--accent-fallback));
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  padding: 0;
}
.ghost-btn-light:hover { background: var(--border); filter: none; }

/* ── 月份切換箭頭（圓形・磚紅 hover） ── */
.cal-nav {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.cal-nav:hover { background: var(--brand-tint-10); color: var(--brand); filter: none; }

.calendar-weekdays, .calendar-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.calendar-weekdays {
  border-bottom: 1px solid var(--brand);
  padding-bottom: 10px;
  margin-bottom: 4px;
}
.calendar-weekdays div {
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
}
.calendar-weekdays div:first-child, .calendar-weekdays div:last-child { color: var(--warm-400); }
.calendar-cell {
  border: none;
  border-top: 1px dashed color-mix(in srgb, var(--warm-600) 15%, transparent);
  border-radius: 0;
  min-height: 96px;
  padding: 9px 6px;
  cursor: pointer;
  vertical-align: top;
  background: var(--paper);
  transition: background 0.15s ease;
}
.calendar-cell:hover { background: var(--brand-tint-10); box-shadow: none; }
.calendar-cell.adjacent {
  cursor: default;
  background: var(--bg);
  opacity: 0.55;
}
.calendar-cell.adjacent:hover { background: var(--bg); box-shadow: none; }
.calendar-cell.adjacent .calendar-daynum { color: var(--warm-400); }
.calendar-cell.today .calendar-daynum {
  display: inline-flex;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-control);
  padding: 1px 8px;
}
.calendar-cell.selected { background: color-mix(in srgb, var(--brand) 16%, var(--paper)); box-shadow: inset 0 0 0 2px var(--brand); }
.calendar-daynum { display: inline-flex; font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.calendar-cell:nth-child(7n+1):not(.today) .calendar-daynum,
.calendar-cell:nth-child(7n):not(.today) .calendar-daynum { color: var(--warm-400); }
.calendar-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.calendar-items li {
  font-size: 11px;
  background: var(--paper-sunk);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
}
.calendar-items li span { overflow: hidden; text-overflow: ellipsis; }
.cal-item-actions { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.cal-gcal-link {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent, var(--accent-fallback));
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 3px;
}
.cal-gcal-link:hover { background: var(--paper-sunk); }
.cal-del {
  background: transparent;
  color: #a6442c;
  border: none;
  padding: 0 2px;
  font-size: 12px;
  flex-shrink: 0;
}
.cal-del:hover { background: transparent; color: #823322; filter: none; }

.kanban-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kanban-col { background: var(--paper-sunk); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 130px; }
.kanban-col h3 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 700;
}
.kanban-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
}
.kanban-card .kanban-card-title { font-weight: 600; }
.kanban-card .kanban-card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.kanban-card-actions { display: flex; gap: 4px; }
.kanban-card-actions button { font-size: 11px; padding: 2px 6px; }

.timer-display {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 600;
  text-align: center;
  margin: 14px 0;
  color: var(--accent, var(--accent-fallback));
  letter-spacing: 0.02em;
}

.paper-item-title a { font-weight: 600; }

.flight-price-row { display: flex; justify-content: space-between; align-items: center; }
.flight-price-row.lowest { color: #2e7d4f; font-weight: bold; }

.countdown-hero {
  background: var(--accent, var(--accent-fallback));
  color: #fffaf3;
  text-align: center;
  padding: 22px;
}
.countdown-hero .countdown-num { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; }
.countdown-hero .countdown-label { font-size: 13px; opacity: 0.9; margin-top: 6px; }

.weather-widget { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.weather-now { display: flex; align-items: center; gap: 10px; }
.weather-now .weather-icon { font-size: 30px; }
.weather-now .weather-temp { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.weather-days { display: flex; gap: 10px; }
.weather-day { text-align: center; font-size: 11px; color: var(--ink-soft); }
.weather-day .weather-icon { font-size: 18px; }

.share-panel { max-width: 800px; margin: 0 auto 18px; position: relative; z-index: 1; }
.share-panel .row { margin-bottom: 10px; }
.trip-code-display { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: 0.08em; color: var(--accent, var(--accent-fallback)); }

.travel-widget { padding: 0; overflow: hidden; }
.travel-widget-header {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}
.travel-widget-header:hover { background: var(--paper-sunk); filter: none; }
.travel-widget-content { padding: 4px 20px 18px; }

/* ---- Custom checkbox ---- */
input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  flex: none;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  margin: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
input[type="checkbox"]::before { content: "✓"; font-size: 12px; color: #fffaf3; transform: scale(0); transition: transform 0.12s ease; }
input[type="checkbox"]:checked { background: var(--accent, var(--accent-fallback)); border-color: var(--accent, var(--accent-fallback)); }
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, var(--accent-fallback)) 18%, transparent); }

/* ---- Select chevron ---- */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a8967e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

/* ---- Search input ---- */
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--paper);
  margin-bottom: 8px;
}
.search-input-icon { font-size: 13px; opacity: 0.6; }
.search-input input { flex: 1; border: none; background: transparent; padding: 9px 0; margin: 0; }
.search-input input:focus { outline: none; box-shadow: none; }
.search-input-clear { background: transparent; border: none; color: var(--ink-faint); font-size: 16px; cursor: pointer; padding: 0; }
.search-input-clear:hover { color: var(--ink); filter: none; }

/* ---- Progress bar ---- */
.progress-bar { margin-bottom: 16px; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; }
.progress-bar-track { background: var(--paper-sunk); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent, var(--accent-fallback)); border-radius: 999px; transition: width 0.2s ease; }
.progress-bar-fill.over-budget { background: #a6442c; }
.week-summary-stat .progress-bar-track { margin-top: 6px; height: 5px; }

/* ---- Avatar (kanban assignee) ---- */
.avatar-bubble {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, var(--accent-fallback)) 18%, var(--paper-sunk));
  color: var(--accent, var(--accent-fallback));
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- Tooltip (icon buttons) ---- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  animation: toast-in var(--duration-normal) var(--ease-out);
}
.toast--success { background: color-mix(in srgb, var(--success) 12%, var(--paper)); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--paper)); }
.toast--danger { background: color-mix(in srgb, var(--danger) 12%, var(--paper)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--paper)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast-out { opacity: 0; transition: opacity 200ms var(--ease-in); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 150;
}
.modal {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
  animation: card-enter var(--duration-normal) var(--ease-out);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-close { background: transparent; border: none; font-size: 18px; color: var(--ink-faint); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--ink); filter: none; }
.modal-body { padding: 16px 18px; font-size: 14px; color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
.modal-cancel { background: transparent; color: var(--ink-soft); border: 1px solid var(--border); }
.modal-cancel:hover { background: var(--paper-sunk); filter: none; }

html[data-theme="dark"] {
  --bg:        #1c1916;        /* 深棕黑·非純黑 */
  --paper:     #252018;        /* 卡片 */
  --ink:       #ede8e3;        /* 主文字 */
  --ink-soft:  #a8a098;        /* 次要文字 */
  --ink-faint: #7a716a;

  --warm-100:  #2c261f;
  --warm-200:  #3a3228;
  --warm-400:  #5a5147;
  --warm-600:  #847a6f;

  --brand:       #b5562c;      /* 強調色維持 */
  --brand-hover: #cc6633;      /* 暗色 hover */

  --shadow-card:       0 1px 3px rgba(0,0,0,0.40);
  --shadow-card-hover: 0 3px 8px rgba(0,0,0,0.50);
  --shadow-modal:      0 8px 32px rgba(0,0,0,0.60);

  /* Legacy aliases */
  --paper-sunk: var(--warm-100);
  --border:     var(--warm-200);
  --shadow-sm:  var(--shadow-card);
  --shadow-md:  var(--shadow-modal);
}
html[data-theme="dark"] body::before { opacity: 0.25; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { color: var(--ink); }
html[data-theme="dark"] .balance-positive { color: #6fce93; }
html[data-theme="dark"] .balance-negative { color: #e08a72; }
html[data-theme="dark"] .delete-btn { color: #e08a72; border-color: #5c372c; }
html[data-theme="dark"] .delete-btn:hover { background: #3a2820; }
html[data-theme="dark"] .checklist-item.overdue:not(.done) span,
html[data-theme="dark"] .calendar-items li.conflict { color: #e08a72; }
html[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238d8071'/%3E%3C/svg%3E");
}
html[data-theme="dark"] input[type="checkbox"]::before { color: #1c1712; }

@media print {
  .no-print, .nav-dock, .topbar-actions, #leaveBtn, .reminder-banner, .sub-nav { display: none !important; }
  .tab-panel, .sub-panel { display: block !important; page-break-inside: avoid; }
  body { background: #fff; }
  body::before { display: none; }
}
