/* =========================================================================
   Roger's Todo — sidebar layout, heavier hierarchy, no apologies
   ========================================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

:root {
  --font-sans: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: "Noto Serif TC", Georgia, serif;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --ease: cubic-bezier(.2,.7,.2,1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 320ms;
}

/* ===== Linear (default) ===== */
[data-style="linear"][data-theme="dark"] {
  --bg:           #0d0d10;
  --bg-elev:      #16161a;
  --bg-elev-2:    #1d1d22;
  --bg-hover:     #22222a;
  --sidebar-bg:   #0a0a0d;
  --border:       #26262e;
  --border-soft:  #1c1c22;
  --text:         #ededf0;
  --text-soft:    #a1a1aa;
  --text-mute:    #6e6e78;
  --accent:       #8b8cf7;
  --accent-soft:  rgba(139,140,247,.16);
  --accent-text:  #b6b7ff;
  --focus-ring:   rgba(139,140,247,.4);
  --c-priority:   #f87171;
  --c-normal:     #60a5fa;
  --c-done:       #34d399;
  --c-warn:       #fbbf24;
  --heading-font: var(--font-sans);
  --heading-weight: 600;
}
[data-style="linear"][data-theme="light"] {
  --bg:           #ffffff;
  --bg-elev:      #f7f7f9;
  --bg-elev-2:    #efeff2;
  --bg-hover:     #ebebee;
  --sidebar-bg:   #f4f4f7;
  --border:       #e2e2e6;
  --border-soft:  #ecedf0;
  --text:         #18181b;
  --text-soft:    #52525b;
  --text-mute:    #9595a0;
  --accent:       #5b5fef;
  --accent-soft:  rgba(91,95,239,.10);
  --accent-text:  #4f53d8;
  --focus-ring:   rgba(91,95,239,.32);
  --c-priority:   #dc2626;
  --c-normal:     #2563eb;
  --c-done:       #059669;
  --c-warn:       #d97706;
  --heading-font: var(--font-sans);
  --heading-weight: 600;
}

/* ===== Paper ===== */
[data-style="paper"][data-theme="dark"] {
  --bg:           #1a1612;
  --bg-elev:      #221c16;
  --bg-elev-2:    #2a231b;
  --bg-hover:     #312921;
  --sidebar-bg:   #15110d;
  --border:       #3a2f24;
  --border-soft:  #2c241c;
  --text:         #ece3d2;
  --text-soft:    #b6a98f;
  --text-mute:    #7a6f5c;
  --accent:       #d4a86a;
  --accent-soft:  rgba(212,168,106,.16);
  --accent-text:  #e6bf86;
  --focus-ring:   rgba(212,168,106,.4);
  --c-priority:   #e07a5f;
  --c-normal:     #81a4b8;
  --c-done:       #a3b18a;
  --c-warn:       #d4a86a;
  --heading-font: var(--font-serif);
  --heading-weight: 700;
}
[data-style="paper"][data-theme="light"] {
  --bg:           #f3ecdc;
  --bg-elev:      #faf3e1;
  --bg-elev-2:    #fdf8e8;
  --bg-hover:     #ede4cd;
  --sidebar-bg:   #ede4cd;
  --border:       #d6cab2;
  --border-soft:  #e2d8c0;
  --text:         #2a2218;
  --text-soft:    #6b5d45;
  --text-mute:    #9b8e72;
  --accent:       #8a6a2c;
  --accent-soft:  rgba(138,106,44,.12);
  --accent-text:  #6e5320;
  --focus-ring:   rgba(138,106,44,.4);
  --c-priority:   #b54232;
  --c-normal:     #345a73;
  --c-done:       #5b7a3e;
  --c-warn:       #a06b1e;
  --heading-font: var(--font-serif);
  --heading-weight: 700;
}

/* ===== GitHub Dark Pro ===== */
[data-style="gh"][data-theme="dark"] {
  --bg:           #0d1117;
  --bg-elev:      #161b22;
  --bg-elev-2:    #1c2128;
  --bg-hover:     #21262d;
  --sidebar-bg:   #010409;
  --border:       #30363d;
  --border-soft:  #21262d;
  --text:         #e6edf3;
  --text-soft:    #8b949e;
  --text-mute:    #6e7681;
  --accent:       #2f81f7;
  --accent-soft:  rgba(47,129,247,.16);
  --accent-text:  #58a6ff;
  --focus-ring:   rgba(47,129,247,.45);
  --c-priority:   #f85149;
  --c-normal:     #58a6ff;
  --c-done:       #3fb950;
  --c-warn:       #d29922;
  --heading-font: var(--font-sans);
  --heading-weight: 600;
}
[data-style="gh"][data-theme="light"] {
  --bg:           #ffffff;
  --bg-elev:      #f6f8fa;
  --bg-elev-2:    #ffffff;
  --bg-hover:     #eaeef2;
  --sidebar-bg:   #f6f8fa;
  --border:       #d0d7de;
  --border-soft:  #d8dee4;
  --text:         #1f2328;
  --text-soft:    #59636e;
  --text-mute:    #8c959f;
  --accent:       #0969da;
  --accent-soft:  rgba(9,105,218,.10);
  --accent-text:  #0860ca;
  --focus-ring:   rgba(9,105,218,.35);
  --c-priority:   #cf222e;
  --c-normal:     #0969da;
  --c-done:       #1a7f37;
  --c-warn:       #9a6700;
  --heading-font: var(--font-sans);
  --heading-weight: 600;
}

/* ===== Apple (SF / macOS / iOS 風格) ===== */
[data-style="apple"][data-theme="dark"] {
  --bg:           #1c1c1e;
  --bg-elev:      #2c2c2e;
  --bg-elev-2:    #3a3a3c;
  --bg-hover:     #3a3a3c;
  --sidebar-bg:   rgba(28, 28, 30, .82);
  --border:       rgba(255, 255, 255, .09);
  --border-soft:  rgba(255, 255, 255, .055);
  --text:         #f5f5f7;
  --text-soft:    #aeaeb2;
  --text-mute:    #6c6c70;
  --accent:       #0a84ff;
  --accent-soft:  rgba(10, 132, 255, .18);
  --accent-text:  #409cff;
  --focus-ring:   rgba(10, 132, 255, .45);
  --c-priority:   #ff453a;
  --c-normal:     #0a84ff;
  --c-done:       #30d158;
  --c-warn:       #ff9f0a;
  --heading-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang TC", "Heiti TC", sans-serif;
  --heading-weight: 600;
}
[data-style="apple"][data-theme="light"] {
  --bg:           #f5f5f7;
  --bg-elev:      #ffffff;
  --bg-elev-2:    #fafafa;
  --bg-hover:     #f0f0f2;
  --sidebar-bg:   rgba(245, 245, 247, .85);
  --border:       rgba(60, 60, 67, .12);
  --border-soft:  rgba(60, 60, 67, .07);
  --text:         #1d1d1f;
  --text-soft:    #6e6e73;
  --text-mute:    #a1a1a6;
  --accent:       #007aff;
  --accent-soft:  rgba(0, 122, 255, .12);
  --accent-text:  #0066d6;
  --focus-ring:   rgba(0, 122, 255, .35);
  --c-priority:   #ff3b30;
  --c-normal:     #007aff;
  --c-done:       #34c759;
  --c-warn:       #ff9500;
  --heading-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang TC", "Heiti TC", sans-serif;
  --heading-weight: 600;
}
[data-style="apple"] body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang TC", "Heiti TC", sans-serif;
  letter-spacing: -.005em;
}
/* Apple-specific: 圓角 + frosted sidebar + 細節 */
[data-style="apple"] .sidebar {
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
[data-style="apple"] .lane {
  border-radius: 12px;
}
[data-style="apple"] .item {
  border-radius: 8px;
}
[data-style="apple"] .agenda__col {
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.04),
    0 4px 16px rgba(0,0,0,.04);
}
[data-theme="dark"][data-style="apple"] .agenda__col {
  box-shadow:
    0 1px 0 rgba(255,255,255,.04),
    0 4px 16px rgba(0,0,0,.3);
}
[data-style="apple"] .btn-primary {
  background: var(--accent);
  border-radius: 8px;
  font-weight: 500;
  letter-spacing: -.01em;
}
[data-style="apple"] .agenda__item,
[data-style="apple"] .cal__agenda-list .item__inner {
  border-radius: 10px;
}
[data-style="apple"] .cal__day.is-today .cal__daynum,
[data-style="apple"] .cal__day.is-selected .cal__daynum {
  background: var(--c-priority);
  color: #fff;
}
[data-style="apple"] .header__title h1 {
  font-weight: 600;
  letter-spacing: -.025em;
}
[data-style="apple"] .view-header__title {
  font-weight: 600;
  letter-spacing: -.025em;
}
[data-style="apple"] .lane__title {
  letter-spacing: .02em;
  font-weight: 600;
  text-transform: none;
  font-size: 12px;
}
[data-style="apple"] .topbar,
[data-style="apple"] .header {
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
}
[data-style="apple"] .seg {
  border-radius: 8px;
  background: var(--bg-elev-2);
}
[data-style="apple"] .seg__btn.is-active {
  border-radius: 6px;
}
[data-style="apple"] .item__check {
  border-radius: 50%;
}
[data-style="apple"] .item__check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
[data-style="apple"] .item__id {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: 0;
}
[data-style="apple"] .brand-mark {
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, var(--c-priority)));
  color: #fff;
}

/* ============ Body ============ */
body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11","ss01";
}
::selection { background: var(--accent-soft); color: var(--text); }

/* ============ App layout ============ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
}

/* ============ Sidebar ============ */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  gap: 4px;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 50%, white));
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px color-mix(in oklab, var(--accent) 50%, transparent);
}
[data-style="paper"] .brand-mark { color: #1c1409; }
.brand-meta { display: flex; flex-direction: column; min-width: 0; }
.brand-meta__name {
  font-family: var(--heading-font);
  font-weight: var(--heading-weight);
  font-size: 14px;
  letter-spacing: -.01em;
  color: var(--text);
  line-height: 1.2;
}
.brand-meta__user {
  font: 500 11px var(--font-mono);
  color: var(--text-mute);
  letter-spacing: .01em;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 1px; padding: 0 0 8px; }

.sidebar__section { padding: 8px 0 4px; display: flex; flex-direction: column; gap: 1px; }
.sidebar__section-label {
  font: 600 10px var(--font-sans);
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 10px 6px;
}

.sidebar__item, .tab {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: 500 13px var(--font-sans);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-align: left;
  width: 100%;
  letter-spacing: -.005em;
}
.sidebar__item:hover, .tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.tab__icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-size: 10px;
  background: var(--bg-elev-2);
  color: var(--text-soft);
}
.tab.is-active .tab__icon {
  background: var(--accent);
  color: white;
}
[data-style="paper"] .tab.is-active .tab__icon { color: #1c1409; }
.tab__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab__count {
  font: 500 10.5px var(--font-mono);
  color: var(--text-mute);
  background: transparent;
  padding: 0;
  letter-spacing: 0;
}
.tab.is-active .tab__count { color: var(--accent-text); }

.sidebar__item kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
  color: var(--text-mute);
  line-height: 1.5;
}

.sidebar__divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 4px;
}

.sidebar__footer {
  margin-top: auto;
  padding: 8px 4px 0;
  border-top: 1px solid var(--border-soft);
}
.sidebar__theme {
  display: flex; align-items: center; gap: 6px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.seg--full { flex: 1; }
.seg--full .seg__btn { flex: 1; }
.seg__btn {
  border: 0; background: transparent;
  color: var(--text-soft);
  font: 500 10.5px var(--font-mono);
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  letter-spacing: .02em;
}
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active { background: var(--accent-soft); color: var(--accent-text); }
.seg--sm .seg__btn { font-family: var(--font-sans); font-size: 11px; letter-spacing: 0; font-weight: 500; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.iconbtn:hover { color: var(--text); background: var(--bg-hover); }
.iconbtn:active { transform: scale(.94); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

.iconbtn-ghost {
  border: 0; background: transparent;
  width: 22px; height: 22px;
  color: var(--text-mute);
  font-size: 16px; line-height: 1;
  cursor: pointer; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn-ghost:hover { background: var(--bg-hover); color: var(--text); }

/* ============ Main column ============ */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  flex-shrink: 0;
  gap: 24px;
}
.header__title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.header__title h1 {
  margin: 0;
  font: var(--heading-weight) 19px var(--heading-font);
  color: var(--text);
  letter-spacing: -.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-style="paper"] .header__title h1 { font-weight: 700; letter-spacing: 0; }
.header__sub {
  font: 400 12px var(--font-mono);
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 360px;
}

.header__progress {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  min-width: 220px;
}
.header__progress-num {
  display: flex; align-items: baseline; gap: 6px;
  font: 500 11.5px var(--font-mono);
  color: var(--text-soft);
  white-space: nowrap;
}
.header__progress-pct {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
}
.progress-track {
  width: 140px;
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-done), var(--accent));
  border-radius: 999px;
  transition: width var(--dur-slow) var(--ease);
}

/* ============ Cmdbar ============ */
.cmdbar {
  padding: 14px 24px 0;
  background: var(--bg);
  flex-shrink: 0;
}
.cmdbar__inner {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 5px 5px 11px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cmdbar__inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.cmdbar__icon { color: var(--text-mute); display: inline-flex; }
.cmdbar__input {
  flex: 1; border: 0; background: transparent;
  color: var(--text);
  font: 500 13.5px var(--font-sans);
  outline: 0; padding: 6px 0;
  min-width: 0;
  letter-spacing: -.005em;
}
.cmdbar__input::placeholder { color: var(--text-mute); font-weight: 400; }

.chip-select, .chip-date {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 5px;
  padding: 0 8px;
  height: 26px;
  font: 500 12px var(--font-sans);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip-select:hover, .chip-date:hover { background: var(--bg-hover); color: var(--text); }
.chip-date { font-family: var(--font-mono); font-size: 11px; color-scheme: dark; }
[data-theme="light"] .chip-date { color-scheme: light; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 5px;
  padding: 0 11px;
  height: 26px;
  font: 600 12px var(--font-sans);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
[data-style="paper"] .btn-primary { color: #1c1409; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.97); }
.btn-primary .kbd {
  background: rgba(255,255,255,.2);
  color: rgba(255,255,255,.92);
  font: 500 10px var(--font-mono);
  padding: 1px 5px;
  border-radius: 3px;
}
[data-style="paper"] .btn-primary .kbd { background: rgba(0,0,0,.16); color: rgba(0,0,0,.7); }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 6px 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: slideDown var(--dur) var(--ease);
}
.searchbar svg { color: var(--text-mute); flex-shrink: 0; }
.searchbar input {
  flex: 1; border: 0; background: transparent;
  color: var(--text); font: 500 12.5px var(--font-sans);
  outline: 0; padding: 3px 0;
}
.searchbar input::placeholder { color: var(--text-mute); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Board ============ */
.board {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  padding: 16px 24px 24px;
  overflow: auto;
  flex: 1;
  align-content: start;
}
.board.is-fading { opacity: 0; transform: translateY(3px); }
.board { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }

.lane {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease);
  align-self: start;
}
.lane.is-drop-target {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent-soft) 40%, var(--bg-elev));
}

.lane__head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev-2);
}
.lane__icon { font-size: 12px; line-height: 1; }
.lane__title {
  margin: 0;
  white-space: nowrap;
  font: 600 11.5px var(--heading-font);
  color: var(--text);
  letter-spacing: .04em;
  text-transform: uppercase;
}
[data-style="paper"] .lane__title { font-weight: 700; letter-spacing: .08em; }
.lane__count {
  margin-left: auto;
  font: 500 10.5px var(--font-mono);
  color: var(--text-soft);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 26px;
  text-align: center;
}

.lane__list {
  list-style: none; margin: 0; padding: 5px;
  display: flex; flex-direction: column;
  gap: 1px;
  min-height: 80px;
}
.lane__list:empty::after {
  content: "—";
  display: block;
  text-align: center;
  color: var(--text-mute);
  font: 500 13px var(--font-mono);
  padding: 32px 0;
  opacity: .4;
  letter-spacing: .2em;
}

/* ============ Item ============ */
.item {
  display: grid;
  grid-template-columns: 12px 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 5px;
  transition: background var(--dur-fast) var(--ease), opacity var(--dur) var(--ease);
  position: relative;
  min-height: 32px;
}
.item:hover { background: var(--bg-hover); }
.item.is-dragging { opacity: .35; }

.item__handle {
  color: var(--text-mute);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none;
  height: 16px;
}
.item:hover .item__handle, .item:focus-within .item__handle { opacity: .55; }
.item__handle:hover { opacity: 1 !important; color: var(--text-soft); }
.item__handle:active { cursor: grabbing; }

.item__check {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--text-mute);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.item__check:hover { border-color: var(--text-soft); background: var(--bg-elev-2); }
.item__check:checked {
  background: var(--c-done);
  border-color: var(--c-done);
  animation: pop var(--dur) var(--ease);
}
.item__check:checked::after {
  content: "";
  position: absolute;
  left: 3px; top: 0;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
[data-style="paper"] .item__check:checked::after { border-color: #1c1409; }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

.item__body { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item__title {
  flex: 1; min-width: 0;
  font-size: 13.2px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 3px;
  outline: 0;
  letter-spacing: -.005em;
}
.item__title:focus, .item__title[contenteditable="true"] {
  background: var(--bg);
  outline: 1.5px solid var(--accent);
  white-space: normal;
  overflow: visible;
}
.item.is-done .item__title {
  color: var(--text-mute);
  text-decoration: line-through;
  text-decoration-color: var(--text-mute);
}

.item__meta {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.item__date {
  font: 500 11px var(--font-mono);
  color: var(--text-soft);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.item__date.is-due-soon { color: var(--c-warn); }
.item__date.is-overdue {
  color: var(--c-priority);
  font-weight: 600;
}
.item__date.is-overdue::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--c-priority);
  display: inline-block;
}

.item__id {
  font: 500 10.5px var(--font-mono);
  color: var(--text-mute);
  letter-spacing: .02em;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.item:hover .item__id { opacity: .65; }

.item__delete {
  border: 0; background: transparent;
  color: var(--text-mute);
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease);
}
.item:hover .item__delete, .item:focus-within .item__delete { opacity: .7; }
.item__delete:hover {
  background: color-mix(in oklab, var(--c-priority) 18%, transparent);
  color: var(--c-priority);
  opacity: 1 !important;
}

.item.is-entering { animation: itemEnter var(--dur) var(--ease); }
.item.is-leaving {
  animation: itemLeave var(--dur-slow) var(--ease) forwards;
  pointer-events: none;
}
@keyframes itemEnter { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes itemLeave { to { opacity: 0; transform: translateX(-10px); height: 0; padding: 0; margin: 0; } }

.drag-placeholder {
  height: 30px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 5px;
  margin: 1px 0;
}

/* ============ Stats ============ */
.stats-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklab, var(--bg) 50%, black 50%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn var(--dur) var(--ease);
  padding: 24px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.stats-panel {
  width: min(540px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 56px -12px rgba(0,0,0,.6);
  animation: panelIn var(--dur) var(--ease);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.stats-panel__head { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--border-soft); }
.stats-panel__head h3 { margin: 0; flex: 1; font: 600 13px var(--heading-font); }
.stats-panel__body { padding: 16px 14px 18px; }
.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.stats-summary__cell { background: var(--bg-elev-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 9px 11px; }
.stats-summary__num { display: block; font: 600 20px var(--font-mono); color: var(--text); letter-spacing: -.02em; line-height: 1.1; }
.stats-summary__lbl { font-size: 10.5px; color: var(--text-soft); }
.stats-chart {
  display: flex; align-items: end; gap: 3px;
  height: 96px; padding: 6px 4px 22px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.stats-bar { flex: 1; min-width: 4px; background: var(--bg-hover); border-radius: 3px 3px 0 0; position: relative; transition: background var(--dur-fast) var(--ease); }
.stats-bar.has-data { background: var(--accent); }
.stats-bar:hover { background: var(--accent-text); }
.stats-bar__label { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font: 500 9px var(--font-mono); color: var(--text-mute); white-space: nowrap; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font: 500 12px var(--font-sans);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.4);
  z-index: 50;
  animation: toastIn var(--dur) var(--ease);
  display: flex; align-items: center; gap: 10px;
}
.toast button {
  border: 0; background: transparent;
  color: var(--accent-text);
  font: 600 12px var(--font-sans);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.toast button:hover { background: var(--accent-soft); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ RWD ============ */
@media (max-width: 1100px) {
  .board { grid-template-columns: 1fr 1fr; }
  .lane[data-zone="done"] { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: hidden;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    height: auto;
  }
  .sidebar__brand { padding: 0 8px 0 0; border-bottom: 0; margin-bottom: 0; border-right: 1px solid var(--border-soft); margin-right: 4px; }
  .sidebar__nav { flex-direction: row; padding: 0; }
  .sidebar__divider, .sidebar__section, .sidebar__footer { display: none; }
  .main { height: calc(100vh - 60px); }
  .board { grid-template-columns: 1fr; padding: 12px 14px 24px; }
  .lane[data-zone="done"] { grid-column: auto; }
  .header { padding: 14px 16px 12px; }
  .header__sub { display: none; }
  .cmdbar { padding: 10px 14px 0; }
  .cmdbar__inner { flex-wrap: wrap; }
  .item__id { display: none; }
}

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

/* ============ Sidebar view-switch active ============ */
.sidebar__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.sidebar__item.is-active svg { color: var(--accent-text); }
.sidebar__item > span:not(.tab__icon):not(.tab__count) {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar__item kbd { flex-shrink: 0; margin-left: auto; }
.sidebar__item { gap: 9px; }

/* ============ View switch visibility ============ */
.main[data-view="agenda"] .board,
.main[data-view="agenda"] .cmdbar,
.main[data-view="calendar"] .board,
.main[data-view="calendar"] .cmdbar { display: none; }
.main[data-view="board"] .agenda,
.main[data-view="board"] .calendar-view,
.main[data-view="board"] #agendaHeader,
.main[data-view="board"] #calendarHeader { display: none !important; }
.main[data-view="agenda"] .calendar-view,
.main[data-view="agenda"] #calendarHeader { display: none !important; }
.main[data-view="calendar"] .agenda,
.main[data-view="calendar"] #agendaHeader { display: none !important; }
.main[data-view="agenda"] #agendaHeader { display: flex !important; }
.main[data-view="calendar"] #calendarHeader { display: flex !important; }
.main[data-view="agenda"] .header__progress { visibility: hidden; }
.main[data-view="calendar"] .header__progress { visibility: hidden; }

/* ============ Agenda (七日) — 仿 TickTick / Things ============ */
.agenda {
  display: grid;
  grid-template-columns: repeat(7, minmax(260px, 1fr));
  gap: 14px;
  padding: 12px 24px 28px;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  align-content: start;
  min-height: 0;
}
.agenda__col {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: hidden;
  align-self: start;
  min-height: 240px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
}
[data-theme="dark"] .agenda__col {
  box-shadow: 0 1px 0 rgba(255,255,255,.02);
}
.agenda__col.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 1px 3px rgba(0,0,0,.06);
}
.agenda__head {
  padding: 16px 16px 10px;
  display: flex; align-items: baseline; gap: 10px;
  background: transparent;
  border-bottom: 0;
}
.agenda__day {
  font: 700 18px var(--heading-font);
  color: var(--text);
  letter-spacing: -.02em;
}
.agenda__col.is-today .agenda__day { color: var(--accent-text); }
.agenda__date {
  font: 500 13px var(--font-sans);
  color: var(--text-soft);
}
.agenda__col.is-overdue .agenda__day { color: var(--c-priority); }
.agenda__list {
  list-style: none; margin: 0;
  padding: 4px 10px 10px;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1;
}
.agenda__empty {
  display: block;
  color: var(--text-mute); font: 500 12.5px var(--font-sans);
  padding: 8px 6px;
  opacity: .6;
}
.agenda__add {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 10px 12px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-mute);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-align: left;
}
.agenda__add:hover { background: var(--bg-hover); color: var(--text); }
.agenda__add::before { content: "+"; font-size: 16px; line-height: 1; color: var(--text-mute); }

/* 卡片化的 agenda item */
.agenda__item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.agenda__item:hover { background: var(--bg-hover); border-color: var(--border); }
.agenda__item.is-done { opacity: .55; }
.agenda__item.is-done .item__title { text-decoration: line-through; color: var(--text-mute); }
.agenda__item .item__check {
  margin-top: 2px; flex-shrink: 0;
}
.agenda__item .item__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.agenda__source {
  font: 500 10.5px var(--font-sans);
  color: var(--text-mute);
  display: flex; align-items: center; gap: 4px;
  letter-spacing: .01em;
}
.agenda__source svg { flex-shrink: 0; opacity: .7; }
.agenda__item .item__title {
  font: 500 13.5px var(--font-sans);
  color: var(--text);
  white-space: normal;
  line-height: 1.4;
  letter-spacing: -.005em;
}
.agenda__item.is-priority { border-left: 3px solid var(--c-priority); }

/* ============ Calendar — 仿圖 2 mobile-first ============ */
.calendar-view {
  display: flex; flex-direction: column;
  padding: 12px 24px 24px;
  overflow: auto;
  flex: 1;
  gap: 16px;
  min-height: 0;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.cal__head { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.cal__title {
  margin: 0;
  font: 600 19px var(--heading-font);
  color: var(--text);
  letter-spacing: -.015em;
  flex: 1;
  text-align: center;
}
.iconbtn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 20px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.iconbtn:hover { background: var(--bg-hover); color: var(--text); }
.cal__today {
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font: 600 13px var(--font-sans);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.cal__today:hover { background: var(--accent-soft); }
.cal__weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 0;
  font: 500 11.5px var(--font-sans);
  color: var(--text-mute);
  text-transform: none;
  letter-spacing: .02em;
  text-align: center;
  padding: 0 4px;
}
.cal__weekdays span { padding: 4px 0; }
.cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(48px, auto);
  gap: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0 4px;
}
.cal__day {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  padding: 6px 0 8px;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  min-width: 0;
  position: relative;
  text-align: center;
  border: 0;
  font: inherit;
  color: inherit;
}
.cal__day:hover { background: var(--bg-hover); border-radius: 6px; }
.cal__day.is-other-month .cal__daynum { color: var(--text-mute); opacity: .5; }
.cal__daynum {
  font: 500 15px var(--font-sans);
  color: var(--text);
  width: 32px; height: 32px;
  line-height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  letter-spacing: 0;
}
.cal__day.is-today .cal__daynum {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
[data-style="paper"] .cal__day.is-today .cal__daynum { color: #1c1409; }
.cal__day.is-selected .cal__daynum {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.cal__day.is-today.is-selected .cal__daynum {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
/* 日期下方紅點(有事項) */
.cal__dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--c-priority);
  display: block;
  margin-top: -2px;
}
.cal__dot.is-normal { background: var(--accent); }
.cal__dot.is-mixed { background: var(--c-priority); box-shadow: 0 0 0 1px var(--bg), 4px 0 0 var(--accent); }
.cal__dot.is-done-only { background: var(--c-done); opacity: .6; }
.cal__day.is-other-month .cal__dot { opacity: .35; }

/* hide chip rendering inside cells (we use dots now) */
.cal__chips { display: none; }
.cal__more { display: none; }

.cal__divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
}

.cal__agenda {
  display: flex; flex-direction: column;
  padding: 0;
  gap: 0;
}
.cal__agenda-group {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.cal__agenda-group:last-child { border-bottom: 0; }
.cal__agenda-head {
  padding: 6px 4px 8px;
  background: transparent;
  border-bottom: 0;
  display: flex; align-items: baseline; gap: 8px;
}
.cal__agenda-day {
  font: 500 12.5px var(--font-sans);
  color: var(--text-soft);
  letter-spacing: 0;
}
.cal__agenda-group.is-overdue .cal__agenda-day { color: var(--c-priority); font-weight: 600; }
.cal__agenda-date { display: none; }
.cal__agenda-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 1px;
}

/* 列表項目:左側時間/標籤垂直線 + 右側 checkbox + 標題 */
.cal__agenda-list .item {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  border-radius: 6px;
  position: relative;
}
.cal__agenda-list .item:hover { background: var(--bg-hover); }
.cal__agenda-list .item__time {
  font: 500 12px var(--font-sans);
  color: var(--text-mute);
  text-align: right;
  line-height: 1.3;
}
.cal__agenda-list .item__time small {
  display: block;
  font-size: 10.5px;
  margin-top: 1px;
  letter-spacing: .02em;
}
.cal__agenda-list .item__inner {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 0;
}
.cal__agenda-list .item__inner .item__title {
  font: 500 13.5px var(--font-sans);
  color: var(--text);
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal__agenda-list .item.is-done .item__title { text-decoration: line-through; color: var(--text-mute); }
.cal__agenda-list .item.is-priority .item__time { color: var(--c-priority); font-weight: 600; }
.cal__agenda-list .item.is-priority::before {
  content: "";
  position: absolute;
  left: 70px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--c-priority);
  border-radius: 1px;
}
.cal__agenda-list .item__source {
  font: 500 10.5px var(--font-sans);
  color: var(--text-mute);
  flex-shrink: 0;
  background: var(--bg-elev-2);
  padding: 2px 7px;
  border-radius: 4px;
}

/* 逾期 banner row(完整一行的紅色強調) */
.cal__agenda-overdue-banner {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 10px 4px;
  align-items: center;
  border-bottom: 1px solid color-mix(in oklch, var(--c-priority) 25%, var(--border-soft));
  position: relative;
}
.cal__agenda-overdue-banner__label {
  font: 600 11.5px var(--font-sans);
  color: var(--c-priority);
  text-align: right;
  line-height: 1.25;
}
.cal__agenda-overdue-banner__label small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  margin-top: 1px;
  color: var(--c-priority);
  opacity: .85;
}
.cal__agenda-overdue-banner__body {
  font: 500 13.5px var(--font-sans);
  color: var(--text);
}
.cal__agenda-overdue-banner::before {
  content: "";
  position: absolute;
  left: 70px;
  bottom: -1px;
  width: 60px;
  height: 2px;
  background: var(--c-priority);
}

@media (max-width: 720px) {
  .agenda { grid-template-columns: 1fr; padding: 12px 14px 24px; }
  .calendar-view { padding: 12px 14px 24px; }
  .cal__grid { grid-auto-rows: minmax(54px, 1fr); }
  .cal__chip { font-size: 9.5px; padding: 1px 3px; }
}

/* main fade between views */
.main { transition: opacity var(--dur) var(--ease); }
.main.is-fading { opacity: 0; }

/* hide tab title on agenda/calendar — these are cross-tab views */
.main[data-view="agenda"] .header,
.main[data-view="calendar"] .header { display: none; }

.view-header {
  padding: 18px 24px 0;
  display: flex; align-items: baseline; gap: 12px;
}
.view-header__title {
  margin: 0;
  font: 600 21px var(--heading-font);
  color: var(--text);
  letter-spacing: -.018em;
  white-space: nowrap;
}
.view-header__sub {
  font: 500 13px var(--font-sans);
  color: var(--text-soft);
  white-space: nowrap;
}

/* agenda priority pill */
.item__zone-pill {
  font: 600 9.5px var(--font-sans);
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-soft);
  border: 1px solid var(--border-soft);
  text-transform: uppercase;
}
.item__zone-pill.is-priority {
  color: var(--c-priority);
  border-color: color-mix(in oklch, var(--c-priority) 35%, var(--border));
  background: color-mix(in oklch, var(--c-priority) 10%, transparent);
}

/* agenda items inherit board item styling but override padding */
.agenda__item, .cal__agenda-list .item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.agenda__item:hover, .cal__agenda-list .item:hover { background: var(--bg-hover); }
.agenda__item.is-done .item__title, .cal__agenda-list .item.is-done .item__title {
  text-decoration: line-through;
  color: var(--text-mute);
}
.agenda__item .item__body, .cal__agenda-list .item .item__body { flex: 1; min-width: 0; }
.agenda__item .item__title, .cal__agenda-list .item .item__title {
  font: 500 12.5px var(--font-sans);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.agenda__item .item__meta, .cal__agenda-list .item .item__meta {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
