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

    :root {
      --bg-primary: #f8f9fc;
      --bg-secondary: #f0f2f7;
      --bg-card: #ffffff;
      --text-primary: #111827;
      --text-secondary: #4b5563;
      --text-muted: #9ca3af;
      --accent: #5B7FE8;
      --accent-hover: #4A6ED4;
      --border: #e2e5ec;
      --border-light: #edf0f5;
      --shadow: rgba(17, 24, 39, 0.04);
      --shadow-hover: rgba(17, 24, 39, 0.10);
    }

    /* ===== DARK THEME ===== */
    [data-theme='dark'] {
      --bg-primary:    #18181b;
      --bg-secondary:  #27272a;
      --bg-card:       #2d2d30;
      --text-primary:  #f4f4f5;
      --text-secondary:#a1a1aa;
      --text-muted:    #71717a;
      --border:        #3f3f46;
      --border-light:  #323235;
      --shadow:        rgba(0, 0, 0, 0.25);
      --shadow-hover:  rgba(0, 0, 0, 0.40);
      /* --accent and --accent-hover intentionally unchanged */
    }

    /* ===== SYSTEM THEME (follows OS preference) ===== */
    @media (prefers-color-scheme: dark) {
      [data-theme='system'] {
        --bg-primary:    #18181b;
        --bg-secondary:  #27272a;
        --bg-card:       #2d2d30;
        --text-primary:  #f4f4f5;
        --text-secondary:#a1a1aa;
        --text-muted:    #71717a;
        --border:        #3f3f46;
        --border-light:  #323235;
        --shadow:        rgba(0, 0, 0, 0.25);
        --shadow-hover:  rgba(0, 0, 0, 0.40);
      }
    }

    /* ===== DARK MODE TWEAKS ===== */
    [data-theme='dark'] .modal-overlay,
    [data-theme='system'] .modal-overlay {
      background: rgba(0, 0, 0, 0.65);
    }

    /* Smooth theme transitions */
    body, .task-card, .list-item, .column, .modal, .memory-card,
    .file-card, .stat, .section-picker, .search-box {
      transition: background-color 0.2s ease, border-color 0.15s ease, color 0.15s ease;
    }

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg-primary);
      color: var(--text-primary);
      height: 100vh;
      padding: 20px 24px;
      line-height: 1.5;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
      padding-bottom: 16px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    h1 {
      font-size: 1.5rem;
      font-weight: 600;
      letter-spacing: -0.02em;
    }

    h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }

    .header-left {
      display: flex;
      align-items: flex-start;
      gap: 0;
    }

    .view-toggle {
      display: flex;
      gap: 4px;
      background: var(--bg-secondary);
      padding: 4px;
      border-radius: 8px;
      margin-left: 16px;
    }

    .view-toggle button {
      background: transparent;
      border: none;
      padding: 6px 14px;
      font-size: 13px;
      color: var(--text-muted);
      border-radius: 6px;
    }

    .view-toggle button:hover {
      color: var(--text-primary);
      background: transparent;
    }

    .view-toggle button.active {
      background: var(--bg-card);
      color: var(--text-primary);
      box-shadow: 0 1px 3px var(--shadow);
    }

    .buttons { display: flex; gap: 12px; }

    button {
      background: var(--bg-card);
      color: var(--text-primary);
      border: 1px solid var(--border);
      padding: 10px 18px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 14px;
      font-weight: 500;
      font-family: inherit;
      transition: all 0.15s ease;
    }

    button:hover {
      background: var(--bg-secondary);
      border-color: var(--text-muted);
    }

    button.primary {
      background: var(--accent);
      color: white;
      border-color: var(--accent);
    }

    button.primary:hover {
      background: var(--accent-hover);
      border-color: var(--accent-hover);
    }

    button:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    /* ===== TASKS STYLES ===== */

    .board {
      display: flex;
      gap: 24px;
      overflow-x: auto;
      overflow-y: hidden;
      padding-bottom: 24px;
      flex: 1;
      min-height: 0;
    }

    .column {
      background: var(--bg-secondary);
      border-radius: 12px;
      min-width: 340px;
      max-width: 340px;
      display: flex;
      flex-direction: column;
      height: 100%;
      max-height: 100%;
    }

    .column-header {
      padding: 16px 18px;
      font-weight: 600;
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: grab;
    }

    .column-header:active {
      cursor: grabbing;
    }

    .column.dragging-column {
      opacity: 0.5;
    }

    .column-drop-indicator {
      width: 3px;
      background: var(--accent);
      border-radius: 2px;
      margin: 0 -2px;
      min-height: 100px;
    }

    .column-header .count {
      background: var(--bg-card);
      padding: 3px 10px;
      border-radius: 12px;
      font-size: 12px;
      font-weight: 500;
      color: var(--text-muted);
    }

    .cards {
      flex: 1;
      overflow-y: auto;
      padding: 0 12px 12px;
      min-height: 100px;
    }

    .cards.drag-over {
      background: rgba(91, 127, 232, 0.06);
      border-radius: 8px;
    }

    .task-card {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 14px 16px;
      margin-bottom: 10px;
      cursor: grab;
      transition: all 0.15s ease;
      box-shadow: 0 1px 3px var(--shadow);
      position: relative;
    }

    .task-card:hover {
      box-shadow: 0 4px 12px var(--shadow-hover);
      border-color: var(--border);
    }

    /* Child/subtask cards — indented with a left accent border */
    .task-card.subtask-card {
      margin-left: 18px;
      border-left: 3px solid var(--accent);
      border-radius: 6px;
      padding: 10px 14px;
      margin-bottom: 10px;
      opacity: 0.95;
    }

    /* Parent cards with child tasks — bottom accent border ties the group together */
    .task-card.has-child-tasks {
      border-bottom: 3px solid var(--accent);
      border-radius: 10px 10px 4px 4px;
      margin-bottom: 6px;
    }

    /* Drag-to-nest: highlight when hovering over a card's center while dragging */
    .task-card.attach-target {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
      background: rgba(91, 127, 232, 0.09);
    }
    .task-card.attach-target::after {
      content: '↳ nest here';
      position: absolute;
      right: 10px;
      bottom: 7px;
      font-size: 10px;
      font-weight: 600;
      color: var(--accent);
      opacity: 0.85;
      pointer-events: none;
      letter-spacing: 0.01em;
    }

    .task-card .add-on-hover {
      display: none;
    }

    .task-card:hover .add-on-hover {
      display: block;
    }

    /* Company tab bar */
    .company-bar {
      display: flex;
      gap: 4px;
      padding: 0 0 12px 0;
      border-bottom: 1px solid var(--border);
      margin-bottom: 16px;
      flex-shrink: 0;
    }
    .company-tab {
      background: transparent;
      border: 1px solid transparent;
      padding: 6px 18px;
      font-size: 13px;
      font-weight: 500;
      color: var(--text-muted);
      border-radius: 20px;
      cursor: pointer;
      transition: all 0.15s;
    }
    .company-tab:hover {
      color: var(--text-primary);
      background: var(--bg-secondary);
    }
    .company-tab.active {
      background: var(--accent);
      color: white;
      box-shadow: none;
    }

    /* Delete section button */
    .delete-section-btn {
      display: none;
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 2px 5px;
      font-size: 16px;
      line-height: 1;
      border-radius: 4px;
    }
    .column-header:hover .delete-section-btn {
      display: inline-block;
    }
    .delete-section-btn:hover {
      background: var(--bg-secondary);
      color: var(--accent);
    }

    .task-card .delete-btn {
      display: none;
      position: absolute;
      top: 8px;
      right: 8px;
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 4px 6px;
      font-size: 14px;
      line-height: 1;
      border-radius: 4px;
    }

    .task-card:hover .delete-btn {
      display: block;
    }

    .task-card .delete-btn:hover {
      background: var(--bg-secondary);
      color: var(--accent);
    }

    .task-card.dragging {
      opacity: 0.5;
      transform: rotate(2deg);
    }

    .star-btn {
      background: none;
      border: none;
      cursor: pointer;
      font-size: 15px;
      padding: 0 4px;
      line-height: 1;
      color: var(--text-muted);
      opacity: 0;
      transition: opacity 0.15s, color 0.15s;
      flex-shrink: 0;
      align-self: flex-start;
    }

    .board .star-btn {
      margin-right: 15px;
    }

    .task-card:hover .star-btn,
    .list-item:hover .star-btn { opacity: 0.5; }
    .star-btn.starred { opacity: 1; color: #f5a623; }
    .star-btn:hover { opacity: 1 !important; }

    .due-date-btn {
      background: none;
      border: none;
      cursor: pointer;
      font-size: 13px;
      padding: 0 4px;
      line-height: 1;
      color: var(--text-muted);
      opacity: 0;
      transition: opacity 0.15s, color 0.15s;
      flex-shrink: 0;
      align-self: flex-start;
    }
    .task-card:hover .due-date-btn,
    .list-item:hover .due-date-btn { opacity: 0.5; }
    .due-date-btn.has-due { opacity: 1; color: var(--accent); }
    .due-date-btn:hover { opacity: 1 !important; }

    .due-chip {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      font-size: 11px;
      color: var(--text-muted);
      background: var(--bg-secondary);
      padding: 2px 7px;
      border-radius: 4px;
      cursor: pointer;
      border: 1px solid transparent;
      margin-top: 5px;
    }
    .due-chip:hover { border-color: var(--border); color: var(--text-secondary); }
    .due-chip.overdue { color: #c53030; background: rgba(197,48,48,0.08); }
    .due-chip.soon    { color: #c05621; background: rgba(192,86,33,0.08); }

    .card-title {
      font-size: 14px;
      font-weight: 500;
      line-height: 1.5;
      color: var(--text-primary);
      flex: 1;
      min-width: 0;
    }

    .card-note {
      font-size: 13px;
      color: var(--text-muted);
      margin-top: 6px;
      line-height: 1.4;
      overflow-wrap: break-word;
      word-break: break-word;
      white-space: pre-wrap;
    }

    .card-subtasks {
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid var(--border-light);
      font-size: 13px;
      color: var(--text-secondary);
    }

    .subtask {
      padding: 3px 0;
      display: flex;
      align-items: flex-start;
      gap: 8px;
    }

    .checkbox {
      width: 18px;
      height: 18px;
      min-width: 18px;
      min-height: 18px;
      flex-shrink: 0;
      border: 2px solid var(--border);
      border-radius: 5px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      vertical-align: middle;
      cursor: pointer;
      transition: all 0.15s ease;
      background: var(--bg-card);
    }

    .checkbox:hover {
      border-color: var(--accent);
    }

    .checkbox.checked {
      background: var(--accent);
      border-color: var(--accent);
    }

    .checkbox.checked::after {
      content: '';
      width: 5px;
      height: 9px;
      border: solid white;
      border-width: 0 2px 2px 0;
      transform: rotate(45deg);
      margin-bottom: 2px;
    }

    .empty-state {
      text-align: center;
      padding: 80px 40px;
      color: var(--text-muted);
    }

    .empty-state button {
      font-size: 16px;
      padding: 14px 28px;
      background: var(--accent);
      border: none;
      color: white;
    }

    .empty-state button:hover {
      background: var(--accent-hover);
    }

    .status-bar {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      background: var(--text-primary);
      color: var(--bg-primary);
      padding: 12px 24px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 500;
      opacity: 0;
      transition: opacity 0.2s ease;
      box-shadow: 0 4px 20px rgba(20, 20, 19, 0.15);
      z-index: 200;
    }

    .status-bar.visible { opacity: 1; }

    .add-card {
      padding: 12px;
    }

    .add-card button {
      width: 100%;
      background: transparent;
      border: 2px dashed var(--border);
      color: var(--text-muted);
      font-weight: 500;
    }

    .add-card button:hover {
      border-color: var(--accent);
      color: var(--accent);
      background: transparent;
    }

    .new-task-input {
      width: 100%;
      background: var(--bg-card);
      border: 2px solid var(--accent);
      border-radius: 8px;
      padding: 12px;
      color: var(--text-primary);
      font-size: 14px;
      font-family: inherit;
      resize: none;
    }

    .new-task-input:focus {
      outline: none;
    }

    .new-task-input::placeholder {
      color: var(--text-muted);
    }

    /* Scrollbar styling */
    .cards::-webkit-scrollbar,
    .list-view::-webkit-scrollbar {
      width: 6px;
    }

    .cards::-webkit-scrollbar-track,
    .list-view::-webkit-scrollbar-track {
      background: transparent;
    }

    .cards::-webkit-scrollbar-thumb,
    .list-view::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .cards::-webkit-scrollbar-thumb:hover,
    .list-view::-webkit-scrollbar-thumb:hover {
      background: var(--text-muted);
    }

    /* ====== LIST VIEW STYLES ====== */

    .list-view {
      max-width: 800px;
      min-width: 350px;
      margin: 0 auto 40px auto;
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
      min-height: 0;
      padding: 0 20px 20px 20px;
    }

    .list-section {
      margin-bottom: 28px;
    }

    .list-section.drag-over {
      background: rgba(91, 127, 232, 0.06);
      border-radius: 8px;
      margin: 0 -12px 32px;
      padding: 0 12px;
    }

    .list-section-header {
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
      padding: 4px 0;
      margin-bottom: 6px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .list-section-header .section-title {
      cursor: pointer;
    }

    .list-section-header .section-title:hover {
      color: var(--text-primary);
    }

    .list-section-header .count {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 500;
    }

    .list-item {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      padding: 12px 14px;
      margin-bottom: 6px;
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      cursor: grab;
      position: relative;
      border-radius: 10px;
      transition: all 0.15s ease;
      box-shadow: 0 1px 3px var(--shadow);
    }

    .list-item:active {
      cursor: grabbing;
    }

    .list-item:hover {
      box-shadow: 0 4px 12px var(--shadow-hover);
      border-color: var(--border);
    }

    .list-item.dragging {
      opacity: 0.5;
      background: var(--bg-secondary);
    }

    .list-item .checkbox {
      margin-top: 2px;
      flex-shrink: 0;
    }

    .list-item-content {
      flex: 1;
      min-width: 0;
    }

    .list-item-title {
      font-size: 15px;
      color: var(--text-primary);
      line-height: 1.4;
    }

    .list-item-title.checked {
      color: var(--text-muted);
      text-decoration: line-through;
    }

    .list-item-note {
      font-size: 13px;
      color: var(--text-muted);
      margin-top: 4px;
      cursor: pointer;
    }

    .list-item-note:hover {
      color: var(--text-secondary);
    }

    .list-item-note.add-note {
      font-style: italic;
      display: none;
    }

    .list-item:hover .list-item-note.add-note {
      display: block;
    }

    .list-item-subtasks {
      margin-top: 8px;
      padding-left: 2px;
    }

    .list-item-subtask {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      padding: 3px 0;
      font-size: 13px;
      color: var(--text-secondary);
    }

    .list-item-subtask .checkbox {
      width: 16px;
      height: 16px;
      min-width: 16px;
      min-height: 16px;
      margin-top: 1px;
    }

    .list-item-subtask span {
      cursor: pointer;
    }

    .list-item-subtask span:hover {
      color: var(--text-primary);
    }

    .list-item-add-subtask {
      font-size: 13px;
      color: var(--text-muted);
      font-style: italic;
      cursor: pointer;
      padding: 3px 0;
      padding-left: 24px;
      display: none;
    }

    .list-item:hover .list-item-add-subtask {
      display: block;
    }

    .list-item-add-subtask:hover {
      color: var(--accent);
    }

    .list-item-section {
      font-size: 11px;
      color: var(--text-muted);
      background: var(--bg-secondary);
      padding: 2px 8px;
      border-radius: 4px;
      white-space: nowrap;
    }

    .list-item-actions {
      display: none;
      flex-shrink: 0;
      align-self: flex-start;
    }

    .list-item:hover .list-item-actions {
      display: flex;
      gap: 2px;
      align-items: center;
    }

    .list-item-actions button {
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 4px 6px;
      font-size: 14px;
      line-height: 1;
      border-radius: 4px;
    }

    .list-item-actions button:hover {
      background: var(--bg-card);
      color: var(--accent);
    }

    .list-drop-indicator {
      height: 3px;
      background: var(--accent);
      border-radius: 2px;
      margin: 2px -12px;
    }

    .list-section-drop-indicator {
      height: 3px;
      background: var(--accent);
      border-radius: 2px;
      margin: -14px 0;
      pointer-events: none;
    }

    .list-section.dragging-section {
      opacity: 0.4;
    }

    .list-section-header {
      cursor: grab;
    }

    .list-section-header:active {
      cursor: grabbing;
    }

    .list-add-section {
      margin-top: 16px;
      padding: 16px;
      border: 2px dashed var(--border);
      border-radius: 8px;
      text-align: center;
      cursor: pointer;
      color: var(--text-muted);
      font-size: 14px;
      font-weight: 500;
      transition: all 0.15s ease;
    }

    .list-add-section:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .quick-add {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 0;
    }

    .quick-add-input {
      flex: 1;
      background: transparent;
      border: none;
      font-size: 15px;
      color: var(--text-primary);
      font-family: inherit;
      outline: none;
    }

    .quick-add-input::placeholder {
      color: var(--text-muted);
    }

    .quick-add-section {
      font-size: 12px;
      color: var(--text-muted);
      background: var(--bg-secondary);
      padding: 4px 10px;
      border-radius: 6px;
      cursor: pointer;
      border: 1px solid var(--border);
    }

    .quick-add-section:hover {
      border-color: var(--accent);
    }

    .section-picker {
      position: absolute;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 4px 20px var(--shadow-hover);
      padding: 4px;
      z-index: 100;
    }

    .section-picker button {
      display: block;
      width: 100%;
      text-align: left;
      padding: 8px 12px;
      font-size: 13px;
      background: transparent;
      border: none;
      border-radius: 6px;
    }

    .section-picker button:hover {
      background: var(--bg-secondary);
    }

    .hide-delete-list { /* hide list delete button, Today|Tomorrow|Done */
      display: none !important;
    }

    /* ===== MEMORY STYLES ===== */

    .memory-tabs {
      display: flex;
      gap: 4px;
      margin-bottom: 12px;
      flex-wrap: wrap;
      background: var(--bg-secondary);
      padding: 4px;
      border-radius: 8px;
      flex-shrink: 0;
    }

    .memory-tab {
      background: transparent;
      color: var(--text-muted);
      padding: 8px 16px;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: all 0.15s ease;
      text-transform: capitalize;
    }

    .memory-tab:hover { color: var(--text-primary); }

    .memory-tab.active {
      color: var(--text-primary);
      background: var(--bg-card);
      box-shadow: 0 1px 3px var(--shadow);
    }

    .memory-tab .count {
      background: var(--bg-secondary);
      padding: 2px 8px;
      border-radius: 10px;
      font-size: 11px;
      margin-left: 6px;
      color: var(--text-muted);
    }

    .memory-tab.active .count {
      background: var(--border-light);
    }

    .memory-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 16px;
    }

    .memory-flat-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }

    .memory-flat-table th {
      text-align: left;
      padding: 10px 16px;
      font-weight: 500;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }

    .memory-flat-table td {
      padding: 9px 16px;
      border-bottom: 1px solid var(--border-light);
      color: var(--text-primary);
      line-height: 1.4;
    }

    .memory-flat-table td:first-child {
      color: var(--text-muted);
      font-weight: 500;
      white-space: nowrap;
      width: 120px;
    }

    .memory-flat-table tr:last-child td {
      border-bottom: none;
    }

    .memory-flat-table tr:hover td {
      background: var(--bg-secondary);
    }

    .memory-card {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 16px;
      cursor: pointer;
      transition: all 0.15s ease;
      box-shadow: 0 1px 3px var(--shadow);
    }

    .memory-card:hover {
      border-color: var(--accent);
      box-shadow: 0 4px 12px var(--shadow-hover);
    }

    .memory-card-title {
      font-size: 15px;
      font-weight: 600;
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-primary);
    }

    .memory-card-meta {
      font-size: 13px;
      color: var(--text-muted);
      margin-bottom: 8px;
    }

    .memory-card-preview {
      font-size: 13px;
      color: var(--text-secondary);
      line-height: 1.5;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
    }

    .memory-card-fields {
      margin-top: 10px;
      font-size: 12px;
    }

    .memory-card-field {
      display: flex;
      gap: 8px;
      margin-bottom: 4px;
    }

    .memory-card-field-label {
      color: var(--text-muted);
      min-width: 80px;
    }

    .memory-card-field-value {
      color: var(--text-secondary);
    }

    .file-card {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      margin-bottom: 16px;
      box-shadow: 0 1px 3px var(--shadow);
    }

    .file-card-header {
      padding: 16px;
      border-bottom: 1px solid var(--border-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
    }

    .file-card-header:hover {
      background: var(--bg-secondary);
    }

    .file-card-title {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-primary);
    }

    .file-card-content {
      padding: 16px;
      font-size: 13px;
      line-height: 1.6;
      white-space: pre-wrap;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      overflow-y: auto;
      display: none;
      color: var(--text-secondary);
    }

    .file-card-content.expanded {
      display: block;
    }

    .stats {
      display: flex;
      gap: 16px;
      margin-bottom: 24px;
      flex-wrap: wrap;
    }

    .stat {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 16px 24px;
      min-width: 100px;
      box-shadow: 0 1px 3px var(--shadow);
    }

    .stat-value {
      font-size: 28px;
      font-weight: 600;
      color: var(--accent);
    }

    .stat-label {
      font-size: 12px;
      color: var(--text-muted);
      text-transform: capitalize;
      margin-top: 4px;
    }

    .search-box {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 10px 16px;
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 20px;
    }

    .search-box input {
      flex: 1;
      background: transparent;
      border: none;
      color: var(--text-primary);
      font-size: 14px;
      font-family: inherit;
      outline: none;
    }

    .search-box input::placeholder {
      color: var(--text-muted);
    }

    .add-btn {
      background: transparent;
      border: 2px dashed var(--border);
      color: var(--text-muted);
      padding: 40px;
      border-radius: 10px;
      cursor: pointer;
      transition: all 0.15s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: 500;
    }

    .add-btn:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .markdown-content {
      line-height: 1.6;
      color: var(--text-secondary);
    }

    .markdown-content h1 { font-size: 1.4em; margin: 16px 0 8px; color: var(--text-primary); }
    .markdown-content h2 { font-size: 1.2em; margin: 14px 0 6px; color: var(--text-primary); }
    .markdown-content h3 { font-size: 1.1em; margin: 12px 0 4px; color: var(--text-secondary); }
    .markdown-content p { margin: 8px 0; }
    .markdown-content ul, .markdown-content ol { margin: 8px 0 8px 20px; }
    .markdown-content li { margin: 4px 0; }
    .markdown-content code {
      background: var(--bg-secondary);
      padding: 2px 6px;
      border-radius: 4px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      color: var(--text-primary);
    }
    .markdown-content pre {
      background: var(--bg-secondary);
      padding: 12px;
      border-radius: 8px;
      overflow-x: auto;
      margin: 8px 0;
      border: 1px solid var(--border-light);
    }
    .markdown-content table {
      width: 100%;
      border-collapse: collapse;
      margin: 8px 0;
      font-size: 13px;
    }
    .markdown-content th, .markdown-content td {
      padding: 12px 16px;
      text-align: left;
      border-bottom: 1px solid var(--border-light);
    }
    .markdown-content th {
      background: var(--bg-secondary);
      font-weight: 600;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
    }

    /* ====== MODAL ====== */

    .modal-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(20, 20, 19, 0.5);
      z-index: 100;
      align-items: center;
      justify-content: center;
    }

    .modal-overlay.visible {
      display: flex;
    }

    .modal {
      background: var(--bg-card);
      border-radius: 12px;
      width: 90%;
      max-width: 800px;
      max-height: 85vh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-shadow: 0 20px 60px rgba(20, 20, 19, 0.2);
    }

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

    .modal-header h3 {
      font-size: 18px;
      font-weight: 600;
      color: var(--text-primary);
    }

    .modal-close {
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 24px;
      cursor: pointer;
      padding: 0;
      line-height: 1;
    }

    .modal-close:hover { color: var(--text-primary); }

    .modal-body {
      padding: 20px;
      overflow-y: auto;
      flex: 1;
    }

    .modal-footer {
      padding: 16px 20px;
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    .form-group {
      margin-bottom: 16px;
    }

    .form-group label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 6px;
    }

    .form-group textarea {
      width: 100%;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px;
      color: var(--text-primary);
      font-size: 13px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      line-height: 1.5;
      min-height: 300px;
      resize: vertical;
    }

    .form-group textarea:focus {
      outline: none;
      border-color: var(--accent);
    }

    /* ====== TAB PANEL CONTAINERS ====== */

    .tab-panel {
      display: none;
      flex: 1;
      min-height: 0;
      flex-direction: column;
    }

    .tab-panel.active {
      display: flex;
    }

    /* ====== MEMORY PANEL SCROLLABLE AREA ====== */

    .memory-content-area {
      flex: 1;
      overflow-y: auto;
      min-height: 0;
    }

    .memory-content-area::-webkit-scrollbar {
      width: 6px;
    }

    .memory-content-area::-webkit-scrollbar-track {
      background: transparent;
    }

    .memory-content-area::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .memory-content-area::-webkit-scrollbar-thumb:hover {
      background: var(--text-muted);
    }

    .file-card-content::-webkit-scrollbar,
    .modal-body::-webkit-scrollbar {
      width: 6px;
    }

    .file-card-content::-webkit-scrollbar-track,
    .modal-body::-webkit-scrollbar-track {
      background: transparent;
    }

    .file-card-content::-webkit-scrollbar-thumb,
    .modal-body::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .file-card-content::-webkit-scrollbar-thumb:hover,
    .modal-body::-webkit-scrollbar-thumb:hover {
      background: var(--text-muted);
    }

    /* File path display */
    .file-path {
      font-size: 13px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    /* ====== SETTINGS PANEL ====== */
    #settingsPanel {
      overflow-y: auto;
    }

/* ====== SEARCH MODAL ====== */

#searchBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  box-sizing: border-box;
}

#searchBackdrop.open {
  display: flex;
}

#searchModal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchModalIn 0.15s ease-out;
}

@keyframes searchModalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#searchInputWrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#searchInputWrap svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

#searchInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text-primary);
  font-family: inherit;
  caret-color: var(--accent);
}

#searchInput::placeholder {
  color: var(--text-muted);
}

#searchKbdHint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

#searchResults {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
}

#searchResults::-webkit-scrollbar { width: 6px; }
#searchResults::-webkit-scrollbar-track { background: transparent; }
#searchResults::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.search-result-item:hover,
.search-result-item.focused {
  background: var(--bg-secondary);
}

.search-result-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.search-result-check:hover {
  border-color: var(--accent);
}

.search-result-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.search-result-check.checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.search-result-title.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.search-result-workspace {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.search-result-section {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.search-result-due {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.search-result-due.overdue {
  color: #dc2626;
}

.search-result-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}

.search-result-item:hover .search-result-actions,
.search-result-item.focused .search-result-actions {
  opacity: 1;
}

.search-result-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.1s, background 0.1s;
  line-height: 1;
}

.search-result-action-btn:hover {
  color: var(--accent);
  background: var(--bg-card);
}

.search-result-action-btn.star-active {
  color: #f59e0b;
}

.search-empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-empty-state .search-empty-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.search-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

/* Nav search button */
#searchNavBtn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

#searchNavBtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Highlight animation when scrolling to a task */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes taskHighlight {
  0%   { box-shadow: 0 0 0 3px var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-card)); }
  100% { box-shadow: none; background: var(--bg-card); }
}

.task-highlight-flash {
  animation: taskHighlight 1.2s ease-out forwards;
}

@media (max-width: 600px) {
  #searchBackdrop {
    padding-top: 20px;
    padding-left: 12px;
    padding-right: 12px;
    align-items: flex-start;
  }
  #searchModal {
    max-height: calc(100vh - 40px);
  }
  #searchKbdHint { display: none; }
}

/* ====== CARD COLOUR PICKER ====== */

.color-pick-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 3px;
  line-height: 1;
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
  align-self: flex-start;
}

.task-card:hover .color-pick-btn,
.list-item:hover .color-pick-btn {
  opacity: 0.5;
}

.color-pick-btn.has-color {
  opacity: 1;
}

.color-pick-btn:hover {
  opacity: 1 !important;
}

/* The popover palette */
#cardColorPopover {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.14);
  padding: 10px;
  z-index: 500;
  display: none;
}

#cardColorPopover.open {
  display: block;
}

.card-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 26px);
  gap: 5px;
}

.card-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}

.card-color-swatch:hover {
  transform: scale(1.15);
  border-color: rgba(17, 24, 39, 0.25);
}

.card-color-swatch.selected {
  border-color: var(--accent);
}

.card-color-swatch.none-swatch {
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1;
}

.card-color-swatch.none-swatch:hover {
  border-color: var(--text-muted);
}
