/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #ffffff;
  --bg2: #f5f5f5;
  --bg3: #ebebeb;
  --border: #e0e0e0;
  --text: #111111;
  --text2: #3a3a3a;
  --text3: #6a6a6a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --topbar-bg: #1e1e1e;
  --topbar-text: #ffffff;
  --topbar-text2: #aaaaaa;
  --topbar-hover: rgba(255,255,255,0.12);
  --topbar-btn-bg: rgba(255,255,255,0.12);
  --topbar-btn-border: rgba(255,255,255,0.2);
  --topbar-btn-bg-hover: rgba(255,255,255,0.22);
  --topbar-btn-border-hover: rgba(255,255,255,0.35);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  --radius: 6px;
  --radius-lg: 10px;
  --transition: 0.15s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --topbar-height: 58px;
  --cl-red: #ef4444;
  --cl-blue: #3b82f6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --bg2: #1e1e1e; --bg3: #2a2a2a;
    --border: #383838; --text: #f5f5f5; --text2: #cccccc; --text3: #888888;
    --accent: #3b82f6; --accent-hover: #2563eb; --accent-light: #1e3a5f;
    --topbar-bg: #0a0a0a;
    --topbar-text: #ffffff;
    --topbar-text2: #aaaaaa;
    --topbar-hover: rgba(255,255,255,0.12);
    --topbar-btn-bg: rgba(255,255,255,0.12);
    --topbar-btn-border: rgba(255,255,255,0.2);
    --topbar-btn-bg-hover: rgba(255,255,255,0.22);
    --topbar-btn-border-hover: rgba(255,255,255,0.35);
  }
}
[data-theme="dark"] {
  --bg: #141414; --bg2: #1e1e1e; --bg3: #2a2a2a;
  --border: #383838; --text: #f5f5f5; --text2: #cccccc; --text3: #888888;
  --accent: #3b82f6; --accent-hover: #2563eb; --accent-light: #1e3a5f;
  --topbar-bg: #0a0a0a;
  --topbar-text: #ffffff;
  --topbar-text2: #aaaaaa;
  --topbar-hover: rgba(255,255,255,0.12);
  --topbar-btn-bg: rgba(255,255,255,0.12);
  --topbar-btn-border: rgba(255,255,255,0.2);
  --topbar-btn-bg-hover: rgba(255,255,255,0.22);
  --topbar-btn-border-hover: rgba(255,255,255,0.35);
}
[data-theme="light"] {
  --bg: #ffffff; --bg2: #f5f5f5; --bg3: #ebebeb;
  --border: #e0e0e0; --text: #111111; --text2: #3a3a3a; --text3: #6a6a6a;
  --topbar-bg: #ffffff;
  --topbar-text: #111111;
  --topbar-text2: #6a6a6a;
  --topbar-hover: rgba(0,0,0,0.06);
  --topbar-btn-bg: rgba(0,0,0,0.06);
  --topbar-btn-border: rgba(0,0,0,0.15);
  --topbar-btn-bg-hover: rgba(0,0,0,0.1);
  --topbar-btn-border-hover: rgba(0,0,0,0.25);
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; overflow: hidden; }
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--text); }
ul { list-style: none; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN
═══════════════════════════════════════════════════════════════ */
.auth-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 1000; }
.auth-card { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 40px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 360px; text-align: center; }
.auth-logo { color: var(--accent); }
.auth-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.auth-subtitle { color: var(--text2); font-size: 14px; }
.auth-note { color: var(--text3); font-size: 12px; }
.btn-google { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-weight: 500; color: var(--text); box-shadow: var(--shadow); transition: box-shadow var(--transition), background var(--transition); width: 100%; justify-content: center; }
.btn-google:hover { box-shadow: var(--shadow-md); background: var(--bg2); }

/* ═══════════════════════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════════════════════ */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height); background: var(--topbar-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 10px; gap: 6px; z-index: 100; user-select: none; }
.topbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar-center { display: flex; align-items: center; gap: 4px; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: flex-end; }
.app-name { color: var(--topbar-text); font-weight: 700; font-size: 19px; letter-spacing: -0.3px; flex-shrink: 0; }
.date-display { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; gap: 0; }
.date-text-btn { color: var(--topbar-text); font-size: 16px; font-weight: 600; padding: 2px 6px; border-radius: var(--radius); transition: background var(--transition); display: block; }
.date-text-btn:hover { background: var(--topbar-hover); }
.date-friendly { font-size: 12px; color: var(--topbar-text2); white-space: nowrap; padding-left: 6px; }
.nav-btn { color: var(--topbar-text2); padding: 4px 10px; border-radius: var(--radius); font-size: 22px; line-height: 1; transition: background var(--transition), color var(--transition); }
.nav-btn:hover { background: var(--topbar-hover); color: var(--topbar-text); }
.today-btn { font-size: 14px; padding: 5px 14px; font-weight: 600; color: var(--topbar-text); background: var(--topbar-btn-bg); border: 1px solid var(--topbar-btn-border); border-radius: var(--radius); min-width: 110px; text-align: center; }
.today-btn:hover { background: var(--topbar-btn-bg-hover); border-color: var(--topbar-btn-border-hover); }
.sync-status { display: flex; align-items: center; gap: 4px; color: var(--topbar-text2); font-size: 13px; }
.sync-icon { font-size: 11px; }
.sync-icon.synced { color: #22c55e; }
.sync-icon.syncing { color: var(--warning); animation: pulse 1s infinite; }
.sync-icon.offline { color: var(--text3); }
.sync-icon.error { color: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.icon-btn { color: var(--topbar-text); padding: 8px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: background var(--transition), color var(--transition); opacity: 0.85; }
.icon-btn:hover { background: var(--topbar-hover); opacity: 1; }
.icon-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.icon-btn:disabled:hover { background: none; }
.icon-btn svg { stroke: currentColor; width: 19px; height: 19px; }
.icon-btn.dark { color: var(--text2); opacity: 1; }
.icon-btn.dark:hover { background: var(--bg3); color: var(--text); }
.topbar-select-btn { font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: var(--radius); border: 1px solid var(--topbar-btn-border); }
.topbar-select-btn.active { background: var(--topbar-text); color: var(--topbar-bg); opacity: 1; border-color: var(--topbar-text); }

/* ═══════════════════════════════════════════════════════════════
   SELECT TOOLBAR
═══════════════════════════════════════════════════════════════ */
.select-toolbar {
  position: fixed; top: var(--topbar-height); left: 0; right: 0;
  background: var(--accent); color: white;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  z-index: 99;
  flex-wrap: wrap;
}
.select-count { font-size: 13px; font-weight: 600; margin-right: 4px; }
.select-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-select-action { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); padding: 4px 10px; border-radius: var(--radius); font-size: 12px; font-weight: 500; transition: background var(--transition); }
.btn-select-action:hover { background: rgba(255,255,255,0.35); }
.btn-select-action.danger { background: rgba(220,38,38,0.7); border-color: rgba(220,38,38,0.9); }
.btn-select-action.danger:hover { background: rgba(220,38,38,0.9); }

/* ═══════════════════════════════════════════════════════════════
   SCHEDULED CHECKLISTS
═══════════════════════════════════════════════════════════════ */
.checklists-area { margin-top: var(--topbar-height); padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg3); border-bottom: 1px solid var(--border); }
.checklists-area:empty { padding: 0; background: none; border-bottom: none; }
.checklist-banner { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); overflow: hidden; box-shadow: var(--shadow); }
.checklist-banner-header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; user-select: none; transition: background var(--transition); }
.checklist-banner-header:hover { background: var(--bg3); }
.cl-progress-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cl-progress-dot.incomplete { background: var(--cl-red); }
.cl-progress-dot.complete { background: var(--cl-blue); }
.cl-banner-name { font-weight: 600; font-size: 13px; flex: 1; }
.cl-banner-progress { font-size: 12px; color: var(--text2); white-space: nowrap; }
.cl-banner-schedule { font-size: 11px; color: var(--text3); white-space: nowrap; }
.cl-banner-chevron { color: var(--text3); font-size: 9px; transition: transform var(--transition); flex-shrink: 0; }
.checklist-banner.open .cl-banner-chevron { transform: rotate(90deg); }
.cl-banner-progress-bar { height: 3px; background: var(--border); }
.cl-banner-progress-fill { height: 100%; background: var(--cl-blue); transition: width 0.3s ease; }
.cl-banner-progress-fill.incomplete { background: var(--cl-red); }
.checklist-banner-body { display: none; padding: 6px 14px 10px; }
.checklist-banner.open .checklist-banner-body { display: block; }
.cl-carry-label { font-size: 11px; color: var(--text3); font-style: italic; padding: 2px 0 6px; }
.cl-item-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.cl-item-row:last-child { border-bottom: none; }
.cl-checkbox { width: 15px; height: 15px; margin-top: 2px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }
.cl-item-content { flex: 1; min-width: 0; }
.cl-item-text { font-size: 13px; }
.cl-item-text.done { text-decoration: line-through; color: var(--text3); }
.cl-item-link { font-size: 11px; color: var(--accent); cursor: pointer; margin-right: 4px; }
.cl-item-link:hover { text-decoration: underline; }
.cl-item-notes-text { font-size: 11px; color: var(--text2); font-style: italic; margin-top: 2px; }
.cl-check-all-btn { margin-top: 8px; width: 100%; padding: 5px; font-size: 12px; color: var(--text3); border: 1px dashed var(--border); border-radius: var(--radius); transition: all var(--transition); }
.cl-check-all-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ═══════════════════════════════════════════════════════════════
   CARRY BANNER
═══════════════════════════════════════════════════════════════ */
.carry-banner { background: var(--accent); color: white; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.carry-banner-actions { display: flex; gap: 8px; align-items: center; }
.btn-carry { background: white; color: var(--accent); padding: 4px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 600; }
.btn-carry:hover { opacity: 0.9; }
.btn-carry-dismiss { color: rgba(255,255,255,0.7); font-size: 12px; padding: 4px; }
.btn-carry-dismiss:hover { color: white; }

/* ═══════════════════════════════════════════════════════════════
   SWAP BAR
═══════════════════════════════════════════════════════════════ */
.swap-bar { background: var(--bg2); border-bottom: 2px solid var(--border); padding: 7px 16px; font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swap-bar-prefix { color: var(--text); font-size: 12px; font-weight: 500; }
.swap-panel-label { font-size: 13px; font-weight: 600; color: var(--text); padding: 3px 10px; border-radius: 12px; border: 1px solid var(--border); transition: all var(--transition); background: var(--bg3); }
.swap-panel-label.active { background: var(--bg3); color: var(--text); border-color: var(--border); }
.swap-bar-time { font-size: 12px; color: var(--text2); background: var(--bg3); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); }
.btn-swap-toggle { font-size: 17px; font-weight: 700; color: white; background: var(--accent); padding: 4px 12px; border-radius: var(--radius); border: none; transition: all var(--transition); box-shadow: var(--shadow); }
.btn-swap-toggle:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ═══════════════════════════════════════════════════════════════
   PANELS
═══════════════════════════════════════════════════════════════ */
#app { display: flex; flex-direction: column; height: 100vh; }
.panels-container { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.panels-container.flipped { flex-direction: row-reverse; }
.panel { display: flex; flex-direction: column; overflow: hidden; min-width: 0; flex: 1; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--border); gap: 8px; flex-shrink: 0; }
.panel-header-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: nowrap; }
.panel-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.focusing-badge { background: var(--accent); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; letter-spacing: 0.5px; white-space: nowrap; flex-shrink: 0; }
.panel-title { font-size: 16px; font-weight: 700; outline: none; border-radius: 3px; padding: 2px 4px; transition: background var(--transition); cursor: text; min-width: 20px; }
.panel-title:hover { background: var(--bg3); }
.panel-title:focus { background: var(--bg3); }
.panel-timestamp { font-size: 12px; color: var(--text3); white-space: nowrap; }
.btn-select-mode { font-size: 12px; color: var(--text2); border: 1px solid var(--border); padding: 3px 10px; border-radius: var(--radius); transition: all var(--transition); white-space: nowrap; }
.btn-select-mode:hover { border-color: var(--accent); color: var(--accent); }
.btn-select-mode.active { background: var(--accent); color: white; border-color: var(--accent); }
.add-form { display: flex; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.add-input { flex: 1; border: 1px solid var(--border); border-right: none; border-radius: var(--radius) 0 0 var(--radius); padding: 7px 12px; background: var(--bg2); font-size: 14px; transition: border-color var(--transition), background var(--transition); }
.add-input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.btn-add { width: 36px; background: var(--accent); color: white; border-radius: 0 var(--radius) var(--radius) 0; font-size: 22px; font-weight: 300; line-height: 1; flex-shrink: 0; transition: background var(--transition); }
.btn-add:hover { background: var(--accent-hover); }
.todo-list { padding: 4px 10px; }
.panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* ═══════════════════════════════════════════════════════════════
   TODO ITEMS
═══════════════════════════════════════════════════════════════ */
.todo-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--border); border-radius: 3px; transition: background var(--transition); position: relative; }
.todo-item:last-child { border-bottom: none; }
.todo-item:hover { background: var(--bg2); }
.todo-item.dragging { opacity: 0.35; background: var(--accent-light); border-radius: var(--radius); outline: 2px dashed var(--accent); outline-offset: -2px; }
.todo-item.drag-over { background: var(--accent-light); }
.todo-list.drag-over-panel { background: var(--accent-light); border-radius: var(--radius); }
.todo-item.select-mode { padding-left: 2px; }
.todo-item.selected { background: var(--accent-light); outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }

.todo-select-cb { width: 15px; height: 15px; margin-top: 3px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; display: none; }
.select-mode-active .todo-select-cb { display: block; }

.drag-handle { color: var(--text3); cursor: grab; padding: 2px 1px; font-size: 11px; flex-shrink: 0; opacity: 0; transition: opacity var(--transition); margin-top: 2px; }
.todo-item:hover .drag-handle { opacity: 1; }
.select-mode-active .drag-handle { display: none; }

/* Custom round checkbox to distinguish from square select checkbox */
.todo-checkbox { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; border: 2px solid var(--border); border-radius: 50%; cursor: pointer; flex-shrink: 0; margin-top: 2px; background: var(--bg); transition: all var(--transition); position: relative; }
.todo-checkbox:hover { border-color: var(--accent); }
.todo-checkbox:checked { background: var(--accent); border-color: var(--accent); display: flex; align-items: center; justify-content: center; }
.todo-checkbox:checked::after { content: ''; position: static; width: 5px; height: 9px; border: 2px solid white; border-top: none; border-left: none; transform: rotate(45deg) translate(-1px, -1px); }

.todo-content { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.todo-text { font-size: 14px; word-break: break-word; cursor: text; border-radius: 2px; padding: 1px 2px; outline: none; line-height: 1.4; min-width: 0; }
.todo-text:focus { background: transparent; }
.todo-text::selection { background: highlight; color: highlighttext; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text3); }
.todo-item.done.overdue .todo-text { color: var(--text3); }
.todo-item:not(.done).overdue .todo-text { color: var(--danger); font-weight: 500; }

.todo-meta { display: contents; }
.todo-badge { font-size: 10px; padding: 1px 5px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.badge-priority-low    { background: #fef9c3; color: #854d0e; }
.badge-priority-medium { background: #ffedd5; color: #9a3412; }
.badge-priority-high   { background: #fee2e2; color: #b91c1c; }
.badge-status-on-hold      { background: #fef9c3; color: #854d0e; }
.badge-status-not-started  { background: #f0f0f0; color: #555555; }
.badge-status-in-progress  { background: var(--accent-light); color: var(--accent); }
.badge-status-done         { background: #dcfce7; color: #166534; }
.badge-status-ongoing      { background: #f3e8ff; color: #7c3aed; }
.badge-due-overdue     { background: #fee2e2; color: var(--danger); font-weight: 700; }
.badge-due-soon        { background: #fef9c3; color: #854d0e; }
.badge-due-future      { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

[data-theme="dark"] .badge-priority-low    { background: #3b2f00; color: #fde68a; }
[data-theme="dark"] .badge-priority-medium { background: #3b1a00; color: #fdba74; }
[data-theme="dark"] .badge-priority-high   { background: #3b0000; color: #fca5a5; }
[data-theme="dark"] .badge-status-on-hold      { background: #3b2f00; color: #fde68a; }
[data-theme="dark"] .badge-status-not-started  { background: #2a2a2a; color: #aaaaaa; }
[data-theme="dark"] .badge-status-in-progress  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-status-done         { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-status-ongoing      { background: #2e1a47; color: #c4b5fd; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-priority-low    { background: #3b2f00; color: #fde68a; }
  :root:not([data-theme="light"]) .badge-priority-medium { background: #3b1a00; color: #fdba74; }
  :root:not([data-theme="light"]) .badge-priority-high   { background: #3b0000; color: #fca5a5; }
  :root:not([data-theme="light"]) .badge-status-on-hold     { background: #3b2f00; color: #fde68a; }
  :root:not([data-theme="light"]) .badge-status-not-started { background: #2a2a2a; color: #aaaaaa; }
  :root:not([data-theme="light"]) .badge-status-in-progress { background: #1e3a5f; color: #93c5fd; }
  :root:not([data-theme="light"]) .badge-status-done        { background: #14532d; color: #86efac; }
  :root:not([data-theme="light"]) .badge-status-ongoing     { background: #2e1a47; color: #c4b5fd; }
}

.todo-inline-links { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.todo-link-chip { font-size: 11px; color: var(--accent); cursor: pointer; padding: 0 2px; }
.todo-link-chip:hover { text-decoration: underline; }

.notes-icon { font-size: 12px; cursor: pointer; color: var(--text3); position: static; display: inline; }
.notes-icon:hover { color: var(--accent); }
.notes-tooltip { position: fixed; background: var(--topbar-bg); color: var(--topbar-text); font-size: 12px; padding: 7px 10px; border-radius: var(--radius); white-space: pre-wrap; max-width: 260px; z-index: 9999; pointer-events: none; box-shadow: var(--shadow-lg); line-height: 1.5; }

.todo-actions { display: flex; gap: 1px; opacity: 0; transition: opacity var(--transition); flex-shrink: 0; margin-top: 1px; }
.todo-item:hover .todo-actions { opacity: 1; }
.select-mode-active .todo-actions { display: none; }
.todo-btn { padding: 3px 5px; border-radius: 3px; color: var(--text3); font-size: 12px; transition: background var(--transition), color var(--transition); white-space: nowrap; }
.todo-btn:hover { background: var(--bg3); color: var(--text); }
.todo-btn.delete:hover { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   COMPLETED SECTION
═══════════════════════════════════════════════════════════════ */
.completed-section { border-top: 1px solid var(--border); }
.completed-toggle { width: 100%; text-align: left; padding: 6px 12px; font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 6px; transition: background var(--transition), color var(--transition); }
.completed-toggle:hover { background: var(--bg2); color: var(--text2); }
.completed-toggle-icon { font-size: 8px; transition: transform var(--transition); display: inline-block; }
.completed-section.open .completed-toggle-icon { transform: rotate(90deg); }
.completed-list { flex: none; max-height: 300px; overflow-y: auto; display: none; padding: 0 8px 6px; }
.completed-section.open .completed-list { display: block; }

/* ═══════════════════════════════════════════════════════════════
   PANEL DIVIDER (mobile only — hidden on desktop)
═══════════════════════════════════════════════════════════════ */
.panel-divider { display: none; }

/* ═══════════════════════════════════════════════════════════════
   RESIZE HANDLE (panels)
═══════════════════════════════════════════════════════════════ */
.resize-handle { width: 5px; background: var(--border); cursor: col-resize; flex-shrink: 0; transition: background var(--transition); align-self: stretch; }
.resize-handle:hover, .resize-handle.resizing { background: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   DRAWERS (Settings + Trash)
═══════════════════════════════════════════════════════════════ */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 200; backdrop-filter: blur(2px); }

.settings-drawer, .trash-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 340px; min-width: 240px; max-width: 600px;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 201;
  display: flex; overflow: hidden;
}

.settings-resize-handle, .trash-resize-handle {
  width: 4px; background: var(--border); cursor: col-resize;
  flex-shrink: 0; align-self: stretch; transition: background var(--transition);
}
.settings-resize-handle:hover, .trash-resize-handle:hover { background: var(--accent); }

.settings-content, .trash-content { flex: 1; overflow-y: auto; padding: 0 0 40px; min-width: 0; }

.settings-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.settings-header h2 { font-size: 16px; }

.settings-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.settings-section h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 10px; }
.settings-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.settings-row:last-child { margin-bottom: 0; }
.settings-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.settings-label { font-size: 13px; flex: 1; min-width: 80px; }
.settings-input { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 9px; background: var(--bg2); font-size: 13px; flex: 1; transition: border-color var(--transition); }
.settings-input:focus { outline: none; border-color: var(--accent); }
input[type="time"].settings-input,
input[type="date"].settings-input,
input[type="date"].modal-input { color-scheme: light; }
[data-theme="dark"] input[type="time"].settings-input,
[data-theme="dark"] input[type="date"].settings-input,
[data-theme="dark"] input[type="date"].modal-input { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="time"].settings-input,
  :root:not([data-theme="light"]) input[type="date"].settings-input,
  :root:not([data-theme="light"]) input[type="date"].modal-input { color-scheme: dark; }
}
.settings-select { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 9px; background: var(--bg2); font-size: 13px; flex: 1; cursor: pointer; }
.settings-select:focus { outline: none; border-color: var(--accent); }
.settings-textarea { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--bg2); font-size: 13px; resize: vertical; width: 100%; }
.settings-textarea:focus { outline: none; border-color: var(--accent); }

.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: background var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform var(--transition); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

#checklists-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.checklist-settings-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.checklist-settings-item:last-child { margin-bottom: 0; }
.checklist-settings-name { flex: 1; font-size: 13px; font-weight: 600; }
.checklist-settings-schedule { font-size: 11px; color: var(--text3); background: var(--bg3); padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }
.settings-close-section { background: var(--bg2); }

/* cl-item inline layout */
.cl-item-content { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.cl-item-text { font-size: 13px; }

/* Trash drawer */
.trash-toolbar { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.trash-list { padding: 8px 16px; display: flex; flex-direction: column; gap: 6px; }
.trash-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.trash-item-body { flex: 1; min-width: 0; }
.trash-item-text { font-size: 13px; word-break: break-word; }
.trash-item-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
.trash-item-actions { display: flex; gap: 4px; flex-shrink: 0; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════ */
.btn-primary { background: var(--accent); color: white; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; transition: background var(--transition); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); padding: 7px 14px; border-radius: var(--radius); font-size: 13px; transition: background var(--transition); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: white; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; transition: background var(--transition); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ═══════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300; backdrop-filter: blur(2px); }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 90%; max-width: 480px; z-index: 301; display: flex; flex-direction: column; max-height: 90vh; }
.cl-editor-modal { max-width: 540px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; gap: 8px; }
.modal-footer-right { display: flex; gap: 8px; }
.modal-input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--bg2); font-size: 14px; transition: border-color var(--transition); }
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-row { display: flex; align-items: center; gap: 10px; }
.modal-row label { font-size: 13px; color: var(--text2); min-width: 80px; flex-shrink: 0; }
.modal-row.col { flex-direction: column; align-items: stretch; gap: 4px; }
.modal-row.col label { min-width: unset; }

/* Notes modal */
.notes-display { font-size: 13px; white-space: pre-wrap; line-height: 1.6; color: var(--text); }

/* Link confirm modal */
.link-confirm-label { font-size: 12px; color: var(--text3); }
.link-confirm-url { font-size: 13px; word-break: break-all; color: var(--accent); padding: 6px 8px; background: var(--bg2); border-radius: var(--radius); border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════
   CHECKLIST EDITOR
═══════════════════════════════════════════════════════════════ */
.cl-items-list { display: flex; flex-direction: column; gap: 2px; }
.cl-item-edit-row { display: flex; align-items: center; gap: 6px; padding: 5px 2px; border-bottom: 1px solid var(--border); }
.cl-item-edit-row:last-child { border-bottom: none; }
.cl-item-drag-handle { color: var(--text3); cursor: grab; font-size: 12px; flex-shrink: 0; padding: 0 2px; }
.cl-item-edit-row.dragging { opacity: 0.4; }
.cl-item-edit-row.drag-over-cl { border-top: 2px solid var(--accent); }
.cl-item-edit-input { flex: 1; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 7px; background: transparent; font-size: 13px; transition: border-color var(--transition), background var(--transition); }
.cl-item-edit-input:focus { outline: none; border-color: var(--border); background: var(--bg2); }
.cl-item-edit-input.small { width: 130px; flex: none; font-size: 12px; color: var(--text2); }
.cl-schedule-options-inner { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.days-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.day-chip { padding: 3px 9px; border-radius: 12px; font-size: 12px; border: 1px solid var(--border); background: var(--bg2); cursor: pointer; transition: all var(--transition); }
.day-chip.selected { background: var(--accent); color: white; border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 999; pointer-events: none; }
.toast { background: var(--topbar-bg); color: var(--topbar-text); padding: 8px 16px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow-md); animation: toast-in 0.2s ease, toast-out 0.3s ease 2.5s forwards; max-width: 320px; text-align: center; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: white; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* ═══════════════════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* ── Page scroll: let body scroll, not internal containers ── */
  html, body { overflow: visible; height: auto; }
  #app { height: auto; min-height: 100vh; overflow: visible; }
  .panels-container {
    flex-direction: column;
    overflow: visible;
    flex: none;
  }
  .panels-container.flipped { flex-direction: column-reverse; }
  .panel { flex: none; min-height: 0; overflow: visible; }
  .panel-scroll { overflow-y: visible; flex: none; height: auto; }
  .completed-list { max-height: none; }

  /* ── Panel separator ── */
  .panel + .panel { border-top: none; margin-top: 0; }
  .panel-divider {
    display: block;
    height: 3px;
    background: var(--border);
    margin: 28px 20px;
    border-radius: 2px;
  }

  /* ── Topbar: taller, two rows ── */
  .topbar {
    height: auto;
    min-height: 60px;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 6px;
    position: sticky;
    top: 0;
  }
  .topbar-left { flex: 1 1 auto; min-width: 0; }
  .topbar-right { flex: 0 0 auto; gap: 6px; }
  .app-name { font-size: 16px; }
  .date-text-btn { font-size: 14px; }
  .date-friendly { font-size: 11px; }
  .icon-btn { padding: 7px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .topbar-select-btn { padding: 5px 11px; font-size: 13px; }
  /* Hide undo/redo and sync text on mobile */
  #btn-undo, #btn-redo { display: none; }
  .sync-label { display: none; }
  /* Hide nav arrows (topbar-center) — date tapping is primary nav */
  .topbar-center { display: none; }

  /* ── Checklists area ── */
  .checklists-area {
    padding: 8px 12px;
    margin-top: 0; /* topbar is sticky, not fixed */
  }
  /* Offset static sections that were offsetting for fixed topbar */
  .select-toolbar { position: sticky; top: 60px; }

  /* ── Swap bar: stack label pairs vertically ── */
  .swap-bar { padding: 10px 14px; gap: 8px; }

  /* ── Panel header ── */
  .panel-header { padding: 14px 16px; }
  .panel-header-left { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; }
  .focusing-badge { align-self: auto; }
  .panel-title { font-size: 18px; }
  .panel-timestamp { font-size: 12px; }

  /* ── Add form ── */
  .add-form { padding: 10px 14px; }
  .add-input { padding: 10px 14px; font-size: 15px; }
  .btn-add { width: 42px; font-size: 24px; }

  /* ── Todo items: more breathing room ── */
  .todo-list { padding: 4px 14px; }
  .todo-item { padding: 12px 6px; gap: 10px; }
  .todo-text { font-size: 15px; line-height: 1.5; }
  .todo-checkbox { width: 20px; height: 20px; margin-top: 2px; }
  .todo-actions { opacity: 1; }

  /* ── Completed section ── */
  .completed-toggle { padding: 10px 14px; font-size: 13px; }

  /* ── Drawers ── */
  .settings-drawer, .trash-drawer {
    width: 100% !important; max-width: 100%;
    border-left: none; border-top: 1px solid var(--border);
    top: auto; height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .settings-resize-handle, .trash-resize-handle { display: none; }
  .resize-handle { display: none; }
  .drag-handle { display: none; }

  /* ── Misc ── */
  .conflict-options { flex-direction: column; }
  .select-toolbar { flex-wrap: wrap; }
}
