:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #475569;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --hover-overlay: rgba(255,255,255,0.05);
  --drop-label-bg: rgba(15, 23, 42, 0.94);
  --drop-label-text: #e2e8f0;
}

[data-theme="light"] {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface2: #dce4ee;
  --text: #1e1a14;
  --text-muted: #5a4e40;
  --accent: #2b5a8a;
  --accent-hover: #1e4066;
  --success: #2d6a4a;
  --warning: #a05a28;
  --danger: #a03828;
  --border: #b8aea0;
  --shadow: 0 2px 6px rgb(30 26 20 / 0.08);
  --hover-overlay: rgba(43, 90, 138, 0.1);
  --drop-label-bg: rgba(255, 255, 255, 0.97);
  --drop-label-text: #1e1a14;
}
[data-theme="light"] .sidebar {
  background: #e4eaf2;
  border-right-color: #b8c4d4;
}
[data-theme="light"] .main {
  background: #f7f4ef;
}
[data-theme="light"] .task-item,
[data-theme="light"] .modal,
[data-theme="light"] .wb-bulk-form,
[data-theme="light"] .png-thumbnail-container {
  background: #ffffff;
  border-color: #b8aea0;
  box-shadow: 0 1px 3px rgb(30 26 20 / 0.08);
}
[data-theme="light"] .task-item:hover {
  border-color: #8a9bb0;
  box-shadow: 0 2px 6px rgb(43 90 138 / 0.12);
}
[data-theme="light"] .project-item:hover,
[data-theme="light"] .project-item.active {
  background: #d4e0ee;
}
[data-theme="light"] .view-toggle {
  background: #d0d8e4;
}
[data-theme="light"] .btn-secondary {
  background: #e0e8f2;
  color: #1e1a14;
  border: 1px solid #b8c4d4;
}
[data-theme="light"] .btn-secondary:hover {
  background: #c8d4e6;
}
[data-theme="light"] .sidebar-dropzone,
[data-theme="light"] .import-dropzone {
  border-color: #a8b4c4;
  background: #f4f7fb;
}
[data-theme="light"] .sidebar-dropzone:hover,
[data-theme="light"] .import-dropzone:hover {
  border-color: var(--accent);
  background: #e8f0f8;
}
/* Higher-contrast switches in light mode */
[data-theme="light"] .slider {
  background-color: #b0b8c4;
  border: 1px solid #8a94a4;
}
[data-theme="light"] .slider:before {
  background-color: #ffffff;
  border: 1px solid #6a7484;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}
[data-theme="light"] .switch input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent-hover);
}
[data-theme="light"] .switch input:checked + .slider:before {
  border-color: #1e4066;
}
[data-theme="light"] .links-panel,
[data-theme="light"] .project-header {
  border-color: #c4b8a8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  --sidebar-width: 280px;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  flex-shrink: 0;
  position: relative;
}
.sidebar.resizing {
  transition: none;
}
.sidebar.collapsed {
  width: 52px !important;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .help-btn,
.sidebar.collapsed .view-toggle,
.sidebar.collapsed #add-project-btn,
.sidebar.collapsed .project-list,
.sidebar.collapsed .sidebar-footer .compress-toggle,
.sidebar.collapsed .sidebar-dropzone,
.sidebar.collapsed .add-project-wrap,
.sidebar.collapsed .sync-status #sync-indicator,
.sidebar.collapsed .sync-status-title,
.sidebar.collapsed .sync-status #logout-btn,
.sidebar.collapsed .sync-status #save-local-btn,
.sidebar.collapsed .sync-status #import-local-btn,
.sidebar.collapsed .sync-status #admin-btn,
.sidebar.collapsed .profile-name,
.sidebar.collapsed .profile-mode,
.sidebar.collapsed .profile-actions {
  display: none;
}
.sidebar.collapsed .profile-bar {
  justify-content: center;
  margin-top: 0.5rem;
  padding: 0.25rem 0;
}
.sidebar.collapsed .profile-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.7rem;
}
.sidebar.collapsed .sync-status {
  flex-direction: column;
  padding: 0.4rem 0.2rem;
  gap: 0.25rem;
  border-bottom: none;
}
.sidebar.collapsed .sync-status #sync-btn {
  padding: 0.35rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar.collapsed .sidebar-header {
  padding: 0.75rem 0.4rem;
}
.sidebar.collapsed .sidebar-header > div {
  justify-content: center;
}
.sidebar.collapsed #sidebar-collapse-btn svg {
  transform: rotate(180deg);
}
.app-title-collapsed {
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  line-height: 1;
}
.sidebar.collapsed ~ .main .app-title-collapsed {
  display: block;
  padding-left: 0.25rem;
}

.sidebar-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.help-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.profile-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
  border-radius: 6px;
}
.profile-meta { flex: 1; min-width: 0; }
.profile-name, .profile-mode {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}
.sync-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
  margin-left: auto;
}
.profile-bar:hover { background: var(--surface2); }
.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 0.9rem; font-weight: 600; }
.profile-mode { font-size: 0.75rem; color: var(--text-muted); }
.project-picker label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  cursor: pointer;
}

.project-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.project-item {
  padding: 0.6rem 1rem 0.6rem 0.5rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}
.project-grip {
  color: var(--text-muted);
  opacity: 0.5;
  cursor: grab;
  display: flex;
  padding: 0.25rem;
  border-radius: 4px;
}
.project-grip:hover { opacity: 1; }
.project-grip:active { cursor: grabbing; }
.project-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.8;
  margin-left: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
}
.sidebar-resizer:hover,
.sidebar.resizing .sidebar-resizer {
  background: var(--accent);
  opacity: 0.4;
}
.sidebar.collapsed .sidebar-resizer { display: none; }
.project-ellipsis {
  opacity: 0;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.2rem;
}
.project-item:hover .project-ellipsis,
.project-item.active .project-ellipsis {
  opacity: 1;
}

.project-item.archived { opacity: 0.6; }
.add-project-wrap {
  display: flex;
  justify-content: center;
  padding: 0.75rem 1rem 1rem;
}
.add-project-wrap #add-project-btn {
  width: 100%;
  max-width: 220px;
}
.view-toggle {
  display: flex;
  margin: 0.75rem 0 0.5rem;
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.view-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.view-btn.active {
  background: var(--accent);
  color: white;
}
.view-btn:hover:not(.active) {
  background: var(--hover-overlay);
  color: var(--text);
}

.whiteboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.whiteboard-header h2 {
  font-size: 1.35rem;
  margin: 0;
  font-weight: 600;
}
.whiteboard-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.whiteboard-controls .compress-toggle {
  gap: 0.6rem;
  min-height: 20px;
}
.whiteboard-board {
  column-count: 2;
  column-gap: 2rem;
}
.wb-project-block {
  break-inside: avoid;
  margin-bottom: 1.5rem;
}
.wb-project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  cursor: pointer;
}
.wb-project-header h3 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
  text-decoration: underline;
  min-width: 0;
}
.wb-grip {
  color: var(--text-muted);
  opacity: 0;
  cursor: grab;
  display: flex;
  align-items: center;
  padding: 0.15rem 0.25rem;
  margin-right: 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.wb-project-header:hover .wb-grip,
.wb-project-block li:hover .wb-grip {
  opacity: 1;
}
.wb-grip:active { cursor: grabbing; }
.wb-grip { user-select: none; -webkit-user-select: none; }
.wb-grip svg { pointer-events: none; }
.wb-project-block.dragging,
.wb-project-block li.dragging {
  opacity: 0.5;
}
.wb-project-block.drop-before,
.wb-project-block.drop-after,
.wb-project-block li.drop-before,
.wb-project-block li.drop-after {
  position: relative;
}
.wb-project-block.drop-before::before,
.wb-project-block li.drop-before::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--accent, #e2e8f0);
  z-index: 2;
}
.wb-project-block.drop-after::after,
.wb-project-block li.drop-after::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent, #e2e8f0);
  z-index: 2;
}
.wb-project-block.invalid-drop,
.wb-project-block li.invalid-drop {
  outline: 1px dashed #ef4444;
}
.wb-collapse-btn {
  flex-shrink: 0;
  padding: 0.15rem 0.25rem;
  margin-left: 0.1rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.wb-project-header:hover .wb-collapse-btn {
  opacity: 1;
}
.wb-project-header:hover h3 { color: #cbd5e1; }
.wb-project-actions {
  display: flex;
  gap: 0.15rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
  margin-left: auto;
}
.wb-project-header:hover .wb-project-actions {
  opacity: 1;
}
.wb-project-block ul {
  margin: 0;
  padding-left: 0.2rem;
  list-style: none;
}
.wb-project-block ul.numbered {
  padding-left: 0;
}
.wb-project-block ul:not(.numbered) .wb-task-line::before {
  content: "•";
  margin-right: 0.45rem;
  flex-shrink: 0;
  color: var(--text);
}
.wb-project-block li {
  position: relative;
  margin-bottom: 0.15rem;
  cursor: pointer;
  display: block;
}
.wb-task-line {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding-right: 3.25rem;
}
.wb-task-title-wrap {
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.2rem;
}
.wb-project-block li:hover {
  background: var(--hover-overlay);
  border-radius: 3px;
}
.wb-task-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.wb-desc-toggle {
  flex-shrink: 0;
  opacity: 1;
  padding: 0.1rem;
}
.wb-task-desc {
  margin: 0.15rem 0 0.25rem 1.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  cursor: default;
}
.wb-task-actions {
  display: flex;
  gap: 0.15rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  position: absolute;
  top: 0;
  right: 0;
  background: var(--surface);
  border-radius: 4px;
  z-index: 1;
}
.wb-project-block li:hover .wb-task-actions {
  opacity: 1;
}
.wb-project-block .done {
  text-decoration: line-through;
  color: var(--text-muted);
}
.wb-project-block .empty {
  color: var(--text-muted);
  font-style: italic;
}
.wb-bulk-form {
  margin: 0.5rem 0 0.75rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.wb-bulk-form textarea {
  width: 100%;
  min-height: 80px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  box-sizing: border-box;
}
.wb-bulk-form .buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  justify-content: flex-end;
}
.wb-bulk-form button {
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}
.wb-bulk-form button.add {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.wb-bulk-form button:hover { opacity: 0.9; }

@media (max-width: 700px) {
  .whiteboard-board { column-count: 1; }
}
.wb-print-btn {
  margin-top: 0.35rem;
  align-self: flex-end;
}

@page {
  size: letter;
  margin: 0.6in;
}

@media print {
  html, body, .app, .main, #whiteboard-view {
    background: #fff !important;
    color: #111 !important;
    height: auto !important;
    overflow: visible !important;
  }
  .sidebar,
  .mobile-bar,
  .sidebar-backdrop,
  .view-toggle,
  .whiteboard-controls,
  .wb-print-btn,
  .local-mode-banner,
  .api-error-banner,
  .modal-overlay,
  .wb-collapse-btn,
  .wb-desc-toggle,
  .wb-task-actions,
  .wb-project-actions,
  .wb-grip,
  .wb-bulk-form {
    display: none !important;
  }
  .app { display: block; }
  .main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }
  body.printing-whiteboard #whiteboard-view { display: block !important; }
  body.printing-whiteboard #tasks-view { display: none !important; }
  .whiteboard-header {
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
    padding-top: 0.7rem;
    padding-bottom: 0.45rem;
  }
  .whiteboard-header h2,
  .app-title-collapsed {
    color: #111 !important;
  }
  .whiteboard-header .app-title-collapsed {
    display: block !important;
    margin-bottom: 0.35rem;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
  }
  .whiteboard-header h2 {
    font-size: 1.35rem;
    line-height: 1.2;
    margin: 0;
  }
  .whiteboard-board {
    column-count: 1;
    column-gap: 0;
    font-size: 10.5pt;
    line-height: 1.25;
  }
  .wb-project-block {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 0.7rem;
  }
  .wb-project-block ul {
    margin: 0;
    padding: 0;
  }
  .wb-project-header {
    cursor: default;
    margin-bottom: 0.2rem;
  }
  .wb-project-header h3 {
    color: #111 !important;
    text-decoration: none;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.1rem;
    font-size: 12pt;
    line-height: 1.2;
  }
  .wb-project-block li {
    cursor: default;
    margin: 0 0 0.08rem;
    padding: 0;
    line-height: 1.25;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .wb-project-block li:hover { background: none; }
  .wb-task-line {
    padding-right: 0;
    gap: 0.2rem;
    align-items: baseline;
  }
  .wb-task-text,
  .wb-project-block ul:not(.numbered) .wb-task-line::before {
    color: #111 !important;
    font-size: 10.5pt;
    line-height: 1.25;
  }
  .wb-task-desc {
    color: #333 !important;
    margin: 0.05rem 0 0.1rem 1rem;
    font-size: 9.5pt;
    line-height: 1.25;
  }
  .wb-project-block .done {
    color: #555 !important;
    text-decoration: line-through;
  }
  .wb-project-block .empty { color: #666 !important; }
}
.project-item.drop-above::before,
.project-item.drop-below::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #e2e8f0;
  z-index: 2;
}
.project-item.drop-above::before { top: 0; }
.project-item.drop-below::after { bottom: 0; }

.project-item:hover { background: var(--surface2); }
.project-item.active {
  background: var(--surface2);
  border-left-color: var(--accent);
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.project-header h2 {
  font-size: 1.75rem;
  outline: none;
}

.project-details {
  color: var(--text-muted);
  outline: none;
  min-height: 1.5em;
}

.project-actions { display: flex; gap: 0.5rem; }

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  cursor: grab;
  transition: transform 0.1s, box-shadow 0.1s;
}

.task-item.compressed {
  padding: 0.5rem 0.75rem;
}
.task-item.compressed .task-title { margin-bottom: 0; }
.task-title-row {
  flex-wrap: wrap;
  align-items: center;
}
.task-title-row .task-title {
  flex: 0 1 auto;
  min-width: 0;
}
.task-title-row .badge {
  flex: 0 0 auto;
}

.compress-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.compress-toggle .toggle-label { line-height: 1; }

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface2);
  border-radius: 20px;
  transition: 0.2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background-color: var(--accent);
}
.switch input:checked + .slider:before {
  transform: translateX(16px);
}
.task-item.drop-before,
.task-item.drop-after,
.task-item.drop-dep-source,
.task-item.drop-dep-dest,
.task-item.invalid-drop {
  position: relative;
}
.drop-zone-rect {
  position: absolute;
  pointer-events: none;
  border: 2px dashed #cbd5e1;
  border-radius: 4px;
  z-index: 4;
}
.drop-zone-rect.invalid {
  border-color: #ef4444;
}
.drop-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--drop-label-bg);
  color: var(--drop-label-text);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
  border: 1px solid #cbd5e1;
  max-width: 90%;
  text-align: center;
}
.drop-label.invalid {
  border-color: #ef4444;
  color: #fecaca;
}
.drop-label strong {
  font-weight: 700;
  text-decoration: underline;
}

.task-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 4.5rem;
}
.task-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.last-modified {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
  text-align: right;
}
.last-modified-modal {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.8;
}
.task-item.compressed .last-modified { font-size: 0.65rem; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.icon-btn-subtle:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

.task-order {
  font-weight: 700;
  color: var(--text-muted);
  min-width: 1.5rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.task-content { flex: 1; }

.task-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 2rem;
}

.status-slider {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 300px;
  max-width: 420px;
  width: 100%;
  font-size: 0.7rem;
  flex: 1 1 300px;
}
.status-slider input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 0.35rem 0 0;
  accent-color: var(--accent, #3b82f6);
  cursor: pointer;
}
.status-slider-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.15rem;
  color: var(--text-muted);
  line-height: 1.15;
}
.status-slider-label {
  flex: 1 1 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s, font-weight 0.15s;
}
.status-slider-label.active {
  color: var(--text);
  font-weight: 600;
}
.status-slider-label[data-idx="0"].active { color: #94a3b8; }
.status-slider-label[data-idx="1"].active { color: #3b82f6; }
.status-slider-label[data-idx="2"].active { color: #f59e0b; }
.status-slider-label[data-idx="3"].active { color: #10b981; }
.status-slider-label[data-idx="4"].active { color: #a78bfa; }

.archived-header {
  margin: 2rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.archived-header h4 {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.task-item.archived {
  opacity: 0.75;
}
.task-item.archived .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-item.compressed .status-slider-label { font-size: 0.55rem; }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.type-enhancement { background: #1e40af; color: #dbeafe; }
.type-newidea { background: #6b21a8; color: #f3e8ff; }
.type-bug { background: #9f1239; color: #ffe4e6; }
.type-research { background: #065f46; color: #d1fae5; }

.type-badge-btn {
  cursor: pointer;
  border: 1px solid transparent;
  font: inherit;
  letter-spacing: inherit;
}
.type-badge-btn:hover {
  filter: brightness(1.15);
  border-color: rgba(255,255,255,0.25);
}

.type-selector {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  padding: 0.6rem;
  min-width: 180px;
}
.type-selector-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.type-selector-options .badge {
  cursor: pointer;
  border: 1px solid transparent;
  font: inherit;
  letter-spacing: inherit;
}
.type-selector-options .badge:hover {
  filter: brightness(1.15);
}
.type-selector-options .badge.current {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 1px;
}
.type-selector-cancel {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.type-selector-cancel:hover {
  background: var(--surface2);
  color: var(--text);
}

.status-todo { background: var(--surface2); color: var(--text-muted); }
.status-inprogress { background: #1e40af; color: #dbeafe; }
.status-testing { background: #92400e; color: #fef3c7; }
.status-done { background: #065f46; color: #d1fae5; }
.status-wontdo { background: #5b21b6; color: #ede9fe; }

.deps {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.links-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.link-item:last-child { border-bottom: none; }

.links-panel a {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 500;
}
.links-panel a:hover {
  color: #bfdbfe;
  text-decoration: underline;
}

.btn-primary, .btn-secondary, .btn-danger {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-muted {
  background: var(--surface2);
  color: var(--text-muted);
}
.btn-muted:hover {
  background: #475569;
  color: var(--text);
}

.sidebar-dropzone {
  margin: 0.75rem;
  padding: 0.75rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.sidebar-dropzone:hover {
  border-color: var(--accent);
  color: var(--text);
}
.sidebar-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
}

.import-row {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  margin-top: 0.5rem;
}
.import-dropzone {
  flex: 0 0 50%;
  max-width: 50%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 100px;
  cursor: pointer;
}
.import-dropzone:hover {
  border-color: var(--accent);
  color: var(--text);
}
.import-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  color: var(--text);
}
.dropzone-hint {
  font-size: 0.8rem;
  opacity: 0.8;
}
.png-thumbnail-container {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s;
  min-height: 100px;
}
.png-thumbnail-container:hover {
  border-color: var(--accent);
}
.png-thumbnail-container img {
  max-width: 100%;
  max-height: 100px;
  object-fit: contain;
  border-radius: 4px;
}
.png-thumbnail-container .thumb-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-align: center;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 90%;
  max-width: 720px;
  max-height: 80vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.close-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; color: var(--text-muted); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.form-group input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}

.form-group textarea { min-height: 80px; resize: vertical; }

.checkbox-list { max-height: 150px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem; }
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-item input[type="checkbox"] {
  margin: 0;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.checkbox-item span { line-height: 1.3; }

.sync-status {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  padding: 0.55rem 0.75rem 0.45rem;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sync-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.5rem;
}
.sync-status-title {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}
.sync-status #sync-indicator {
  display: block;
  opacity: 0.95;
  line-height: 1.2;
}
.sync-status.dirty #sync-indicator { color: #e67e22; }
.auth-footer {
  padding: 0;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.auth-footer-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.auth-password-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
  gap: 0.5rem;
}
.auth-password-label-row > label[for="auth-password"] {
  margin-bottom: 0;
  display: block;
}
.auth-show-wrap {
  display: flex !important;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.auth-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover {
  color: var(--text);
}
.sync-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}
.sync-toast.ok { border-color: #27ae60; }
.sync-toast.warn { border-color: #e67e22; }
.api-error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #7f1d1d;
  color: #fee2e2;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  text-align: center;
}

/* Local Mode banner (shown when not signed in) */
.local-mode-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.4rem 1rem;
  background: #dc2626;
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: center;
  border-bottom: 1px solid #b91c1c;
}
.local-mode-banner.muted {
  background: #3d3428;
  color: #f5e6c8;
  border-bottom-color: #5a4a38;
}
[data-theme="light"] .local-mode-banner.muted {
  background: #f3e6d4;
  color: #5a4a38;
  border-bottom-color: #e0cbb0;
}
.local-mode-banner strong {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.local-banner-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 600;
}
.local-banner-link:hover {
  opacity: 0.85;
}
.local-banner-mute {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.95;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.local-banner-mute input {
  margin: 0;
  cursor: pointer;
}
body.has-local-banner {
  padding-top: 48px;
}
body.has-local-banner .app {
  height: calc(100vh - 48px);
}
@media (max-width: 768px) {
  body.has-local-banner .app {
    height: calc(100dvh - 48px);
  }
  body.has-local-banner .mobile-bar {
    top: 48px;
  }
}

.hidden { display: none !important; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th { color: var(--text-muted); font-weight: 600; }

.mobile-bar, .sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .app {
    flex-direction: column;
    height: 100dvh;
  }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .mobile-title { font-weight: 600; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 320px) !important;
    max-height: none;
    height: 100dvh;
    z-index: 80;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar-resizer { display: none; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed,
  .sidebar.collapsed.mobile-open {
    width: min(92vw, 360px);
  }
  .sidebar.collapsed { transform: translateX(-105%); }
  .sidebar.collapsed.mobile-open { transform: translateX(0); }

  /* Phone drawer is always the full expanded layout */
  .sidebar.collapsed .sidebar-header h1,
  .sidebar.collapsed .help-btn,
  .sidebar.collapsed .view-toggle,
  .sidebar.collapsed #add-project-btn,
  .sidebar.collapsed .project-list,
  .sidebar.collapsed .sidebar-footer,
  .sidebar.collapsed .sidebar-footer .compress-toggle,
  .sidebar.collapsed .sidebar-dropzone,
  .sidebar.collapsed .profile-bar,
  .sidebar.collapsed .add-project-wrap {
    display: revert;
  }
  .sidebar.collapsed .project-list { display: block; overflow-x: hidden; }
  .sidebar.collapsed .sync-status {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
    align-items: center;
  }
  .sidebar.collapsed .sync-status #sync-indicator,
  .sidebar.collapsed .sync-status #sync-btn,
  .sidebar.collapsed .sync-status #logout-btn,
  .sidebar.collapsed .profile-name,
  .sidebar.collapsed .profile-mode {
    display: revert;
    font-size: inherit;
    width: auto;
    height: auto;
  }
  .sidebar.collapsed .sync-status #sync-btn::before { content: none; }
  .sidebar.collapsed .sidebar-header { padding: 1.25rem 1.5rem 1rem; }
  #sidebar-collapse-btn { display: none !important; }

  .sidebar { overflow-x: hidden; overflow-y: auto; }
  .project-item { min-width: 0; }
  .project-name { min-width: 0; }
  .project-grip { display: none; }
  .sync-status {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sync-status #sync-indicator {
    flex: 1;
    min-width: 0;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 70;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  .main {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .project-header, .tasks-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .project-header h2 { font-size: 1.35rem; }
  .project-actions, .tasks-header > div {
    flex-wrap: wrap;
  }
  .task-item {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.35rem 0.65rem;
  }
  .task-order {
    flex: 0 0 1.25rem;
    height: 2rem;
  }
  .task-content { flex: 1 1 12rem; min-width: 0; }
  .task-right {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
  }
  .status-slider { max-width: 100%; }
  .project-ellipsis { opacity: 1; }
  .modal {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
  .modal-body { padding: 1rem; }
  .auth-footer { flex-wrap: wrap; }
  .sync-status button { min-height: 36px; }
  .whiteboard-board { column-count: 1; }
}

.status-badge-btn {
  cursor: pointer;
  border: 1px solid transparent;
  font: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-badge-btn:hover {
  filter: brightness(1.15);
  border-color: rgba(255,255,255,0.25);
}

.task-details {
  margin: 0.25rem 0 0.15rem;
}
.task-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.15rem 0;
}
.task-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
