/* ─── Design tokens (Linear light mode) ─────────────────── */
:root {
  --bg:          #E2E3E8;
  --sidebar-bg:  #DDDDE3;
  --surface:     #FFFFFF;
  --surface-2:   #F4F5F7;
  --surface-3:   #ECEDF0;
  --panel-bg:    #F7F8FA;

  --text-1:      #141313;
  --text-2:      #606984;
  --text-3:      #9499AA;

  --border:      #E4E5E7;
  --border-2:    #D0D1D6;

  --accent:      #5E6AD2;
  --accent-h:    #4F5AB8;
  --accent-soft: #EEEFFE;

  /* Now-lane amber marker (kept from original) */
  --now:         #B8895A;
  --now-soft:    #FBF3EA;

  /* Priority */
  --p-urgent: #E5484D;
  --p-high:   #E07B35;
  --p-medium: #F0C040;
  --p-low:    #5E6AD2;
  --p-none:   #9499AA;

  --radius:    6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --sidebar-w: 216px;
  --col-width: 272px;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.06);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-modal: 0 12px 48px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.10);

  --col-grad-top:  #FAFBFC;
  --col-grad-bot:  #EBEBEF;
  --card-grad-top: #FFFFFF;
  --card-grad-bot: #F3F4F7;

  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); font-size: 14px; }

/* ─── App shell ──────────────────────────────────────────── */
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: 160px;
  max-width: 400px;
  flex-shrink: 0;
  position: relative;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg) 100%);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

/* Resize handle on sidebar right edge */
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.4;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 0;
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.sidebar-name {
  font-size: 25px;
  font-weight: 700;
  color: var(--text-1);
}

.sidebar-section {
  padding: 10px 8px 4px;
}

.sidebar-section-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 6px 6px;
  display: block;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  text-decoration: none;
  /* reset button defaults */
  border: none;
  background: none;
  appearance: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-item:hover { background: var(--surface-3); color: var(--text-1); }
.sidebar-item.active { background: rgba(94,106,210,0.1); color: var(--accent); font-weight: 500; }

.sidebar-item svg { opacity: 0.7; flex-shrink: 0; }
.sidebar-item.active svg { opacity: 1; }
.sidebar-item--muted { color: var(--text-3); font-size: 13px; }

/* Category dot in sidebar */
.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* Category item wrapper + hover pencil */
.sidebar-cat-item-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-cat-item-wrap .sidebar-item { flex: 1; }

.cat-hover-btns {
  position: absolute;
  right: 4px;
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.1s;
}
.sidebar-cat-item-wrap:hover .cat-hover-btns { opacity: 1; }

.cat-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 3px 4px;
  border-radius: var(--radius);
  transition: color 0.1s, background 0.1s;
  line-height: 1;
  flex-shrink: 0;
}
.cat-icon-btn:hover { color: var(--text-1); background: var(--surface-3); }
.cat-icon-btn--danger:hover { color: #e05252; background: rgba(224,82,82,0.1); }

#category-list .htmx-swapping { opacity: 0; transition: opacity 0.15s; }

.sidebar-cat-edit-form { padding: 4px 8px 4px; }

/* Sidebar inline "New category" form */
.sidebar-new-cat { padding: 2px 0; }

.sidebar-cat-form {
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-cat-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
}
.sidebar-cat-input:focus { border-color: var(--accent); }

.sidebar-cat-form-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-colour-pick {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius);
  padding: 2px;
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px;
}

.sidebar-footer-divider {
  margin: 8px 4px;
  border-top: 1px solid var(--border);
}

.sidebar-logout {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-3);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sidebar-logout:hover {
  color: var(--text-2);
  background: var(--surface-3);
  border-color: var(--border);
}

/* ─── Main column ────────────────────────────────────────── */
.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
  padding: 8px 10px 10px 6px;
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--panel-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

/* ─── Toolbar ────────────────────────────────────────────── */
.toolbar {
  height: 48px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.toolbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin-right: 4px;
}

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-2);
  flex-shrink: 0;
}

/* ─── Search ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 0 0 200px;
}

.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px 5px 28px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.12s, background 0.12s;
  font-size: 13.5px;
}

.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--accent); background: var(--surface); }

.search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  z-index: 200;
  overflow: hidden;
  min-width: 280px;
}

.search-list { list-style: none; }

.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-2); }
.search-item-title { font-size: 13.5px; font-weight: 500; }
.search-item-col { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.search-empty { padding: 10px 12px; font-size: 13px; color: var(--text-3); }

/* ─── Board ──────────────────────────────────────────────── */
.board {
  flex: 1;
  overflow: hidden;
  display: flex;
}

.columns {
  display: flex;
  padding: 16px 20px 40px;
  overflow-x: auto;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

/* ─── Column ─────────────────────────────────────────────── */
.column {
  flex: 1 1 var(--col-width);
  max-width: 480px;
  min-width: var(--col-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 10px;
}

.column-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--col-grad-top) 0%, var(--col-grad-bot) 100%);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 8px 10px 14px;
}

.column-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  flex: 1;
}

.column-count {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 10px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

.column-count.over-wip { background: #FEE9E9; color: var(--p-urgent); }


/* ─── Card list ──────────────────────────────────────────── */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 32px;
  padding: 2px 0;
}

/* ─── Card ───────────────────────────────────────────────── */
.card {
  background: linear-gradient(150deg, var(--card-grad-top) 0%, var(--card-grad-bot) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 15px;
  min-height: 125px;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.12s;
  position: relative;
}

.card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.06); }

.card.sortable-ghost  { opacity: 0.3; }
.card.sortable-chosen { box-shadow: 0 4px 16px rgba(0,0,0,0.14); }

/* Top row: priority icon + title */
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* Priority icon — small coloured circle */
.priority-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.priority-dot-0 { border: 1.5px solid var(--p-none); background: transparent; }
.priority-dot-1 { background: var(--p-low);    opacity: 0.7; }
.priority-dot-2 { background: var(--p-medium); opacity: 0.8; }
.priority-dot-3 { background: var(--p-high); }
.priority-dot-4 { background: var(--p-urgent); }

/* Urgent inner exclamation */
.priority-dot-4::after {
  content: '!';
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

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

/* Category chip on card */
.card-cat-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  align-self: flex-start;
  letter-spacing: 0.02em;
}

/* Bottom row: labels + task badge */
.card-bottom {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 20px;
  margin-top: auto;
}

.card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}

.label-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}

.card-date {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.7;
}

.card-task-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  min-height: 7px;
}

.card-task-dots.hidden { visibility: hidden; }

.task-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-2);
  flex-shrink: 0;
  transition: background 0.15s;
}

.task-dot--done          { background: var(--accent); }
.all-done .task-dot      { background: #3DB56A; }

.task-dot-overflow {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1;
}

/* ─── Category banner ────────────────────────────────────── */
.category-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-left: 3px solid transparent;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  flex-shrink: 0;
}

.category-banner-name { color: var(--text-1); font-weight: 600; }

.category-banner-clear {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
}
.category-banner-clear:hover { color: var(--accent); }

/* ─── Archive view ───────────────────────────────────────── */
.archive-view {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.archive-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.archive-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.archive-count {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 10px;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: linear-gradient(150deg, var(--card-grad-top) 0%, var(--card-grad-bot) 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: opacity 0.2s ease;
}

.archive-item.htmx-swapping { opacity: 0; }

.archive-item-info {
  flex: 1;
  min-width: 0;
}

.archive-item-title {
  font-size: 14px;
  font-weight: 450;
  color: var(--text-2);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-item-meta {
  font-size: 12px;
  color: var(--text-3);
  display: block;
  margin-top: 2px;
}

.archive-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ─── Column header composer ─────────────────────────────── */
.column-header-composer { padding-bottom: 6px; }

.add-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  padding: 5px 4px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 0.1s, background 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.add-btn:hover { color: var(--text-2); background: rgba(0,0,0,0.04); }

.composer-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 9px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.12s;
  box-shadow: var(--shadow-sm);
}

.composer-input:focus { border-color: var(--accent); }

.composer-actions {
  display: flex;
  gap: 5px;
  margin-top: 5px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 13px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.12s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary.btn-sm { padding: 4px 10px; font-size: 13px; }

.btn-ghost {
  background: none;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color 0.12s, color 0.12s;
}
.btn-ghost:hover { border-color: var(--border-2); color: var(--text-1); }
.btn-ghost.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-ghost--danger { color: #EA580C; border-color: #FB923C; }
.btn-ghost--danger:hover { color: #C2410C; border-color: #C2410C; background: #FFF7ED; }

.btn-danger {
  background: none;
  color: var(--p-urgent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s, border-color 0.12s;
}
.btn-danger:hover { background: #FEF0F0; border-color: #FECACA; }

/* ─── Modal backdrop ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.45);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 80vw;
  max-width: 1100px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

/* Alpine transitions */
.modal-backdrop-enter        { transition: opacity 0.15s ease; }
.modal-backdrop-enter-start  { opacity: 0; }
.modal-backdrop-enter-end    { opacity: 1; }
.modal-backdrop-leave        { transition: opacity 0.1s ease; }
.modal-backdrop-leave-start  { opacity: 1; }
.modal-backdrop-leave-end    { opacity: 0; }

.modal-inner-enter       { transition: opacity 0.15s ease, transform 0.15s ease; }
.modal-inner-enter-start { opacity: 0; transform: scale(0.97) translateY(6px); }
.modal-inner-enter-end   { opacity: 1; transform: scale(1) translateY(0); }
.modal-inner-leave       { transition: opacity 0.1s ease, transform 0.1s ease; }
.modal-inner-leave-start { opacity: 1; transform: scale(1); }
.modal-inner-leave-end   { opacity: 0; transform: scale(0.97); }

.modal-header {
  display: flex;
  align-items: center;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.modal-breadcrumb {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--surface-3); color: var(--text-1); }

/* ─── Modal body layout ──────────────────────────────────── */
.modal-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.modal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 20px;
  gap: 16px;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.modal-meta {
  width: 230px;
  flex-shrink: 0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

/* ─── Modal form fields ──────────────────────────────────── */
.modal-title-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  outline: none;
  padding: 0;
  line-height: 1.35;
}

.modal-title-input::placeholder { color: var(--text-3); }

.body-field {
  margin-top: 14px;
  display: grid;
  grid-template: 'body' / 1fr;
}
.body-field > .body-view,
.body-field > .body-edit-wrap {
  grid-area: body;
  min-width: 0;
}

.body-view { position: relative; }

.body-edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.body-edit-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border-2);
}

/* Grid overlay: textarea and Done button share the same cell */
.body-edit-wrap {
  display: grid;
}
.body-edit-wrap > .modal-body-input,
.body-edit-wrap > .body-done-btn {
  grid-area: 1 / 1;
}

.body-done-btn {
  align-self: end;
  justify-self: end;
  margin: 0 9px 9px 0;
  z-index: 1;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.body-done-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border-2);
}

.modal-body-input {
  width: 100%;
  min-height: 120px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  padding: 10px 12px 40px 12px;
  transition: border-color 0.12s;
  field-sizing: content;
}

.modal-body-input:focus {
  border-color: var(--border-2);
}

.modal-body-input::placeholder { color: var(--text-3); }

.body-rendered {
  min-height: 80px;
  padding: 10px 40px 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
  cursor: default;
  transition: border-color 0.12s;
}
.body-rendered:hover {
  border-color: var(--border-2);
}
/* Markdown element styles inside rendered body */
.body-rendered p                       { margin-bottom: 0.6em; }
.body-rendered p:last-child            { margin-bottom: 0; }
.body-rendered h1,.body-rendered h2,
.body-rendered h3,.body-rendered h4    { font-weight: 600; margin: 0.8em 0 0.3em; color: var(--text-1); }
.body-rendered h1                      { font-size: 1.2em; }
.body-rendered h2                      { font-size: 1.1em; }
.body-rendered h3,.body-rendered h4    { font-size: 1em; }
.body-rendered ul,.body-rendered ol    { padding-left: 1.4em; margin-bottom: 0.6em; }
.body-rendered li                      { margin-bottom: 0.2em; }
.body-rendered code                    { font-family: monospace; font-size: 0.88em; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.body-rendered pre                     { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 0.6em; }
.body-rendered pre code                { background: none; padding: 0; }
.body-rendered strong                  { font-weight: 600; color: var(--text-1); }
.body-rendered em                      { font-style: italic; }
.body-rendered hr                      { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }
.body-rendered blockquote              { border-left: 3px solid var(--border-2); padding-left: 10px; color: var(--text-3); margin: 0.4em 0; }
.body-rendered a                       { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.body-rendered a:hover                 { color: var(--accent-h); }

/* ─── Meta sidebar items ─────────────────────────────────── */
.meta-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.meta-group + .meta-group { margin-top: 8px; }
.meta-group .meta-row {
  border-radius: 0;
  padding-right: 14px;
}
.meta-group .meta-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.meta-group .meta-row:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
.meta-group .meta-row:only-child  { border-radius: var(--radius); }
.meta-group .meta-row + .meta-row { border-top: 1px solid var(--border); }
.meta-group .meta-row:hover { background: var(--surface-3); }
.meta-group--dates .meta-row:hover { background: none; cursor: default; }

.meta-row {
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--radius);
  gap: 10px;
  cursor: default;
  transition: background 0.1s;
}

.meta-row:hover { background: var(--surface-2); }

.meta-label {
  font-size: 12.5px;
  color: var(--text-3);
  width: 72px;
  flex-shrink: 0;
}

.meta-value {
  font-size: 13.5px;
  color: var(--text-1);
  font-weight: 500;
  margin-left: auto;
}

.meta-select-wrap {
  margin-left: auto;
  position: relative;
  padding-right: 14px;
}

.meta-select-wrap::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}

.meta-select {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
  color: var(--text-1);
  font-size: 13.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
  display: block;
}

.meta-row--dates { padding: 5px 10px; }
.meta-row--dates:hover { background: none; }
.meta-value--date {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 400;
}

.meta-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.meta-archive-btn {
  margin: 6px 0 0;
}

.meta-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
}

.btn-block { width: 100%; justify-content: center; }

/* ─── Tasks section ──────────────────────────────────────── */
.tasks-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tasks-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.tasks-header-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.tasks-header-count {
  font-size: 12px;
  color: var(--text-3);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ─── Task item ──────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: var(--radius);
  group: task;
  transition: background 0.1s;
}

.task-item:hover { background: var(--surface-2); }

.task-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-2);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.1s, background 0.1s;
  padding: 0;
}

.task-check:hover { border-color: var(--accent); }
.task-check.is-done { background: var(--accent); border-color: var(--accent); }

.task-check.is-done::after {
  content: '';
  display: block;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.task-title {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-1);
  line-height: 1.4;
  min-width: 0;
}

.task-title.is-done {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--text-3);
}

.task-delete {
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s;
  padding: 0;
  flex-shrink: 0;
}

.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { background: var(--surface-3); color: var(--p-urgent); }

/* ─── Task composer ──────────────────────────────────────── */
.task-composer {
  padding-top: 4px;
}

.task-composer-input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  padding: 5px 4px;
  color: var(--text-1);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.12s;
}

.task-composer-input::placeholder { color: var(--text-3); }
.task-composer-input:focus { border-color: var(--border-2); }

/* ─── Breadcrumb back button ─────────────────────────────── */
.breadcrumb-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb-back:hover { color: var(--text-1); background: var(--surface-3); }
.breadcrumb-back svg { flex-shrink: 0; }

/* ─── Task detail body ───────────────────────────────────── */
.task-detail-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px 24px 24px;
  gap: 16px;
  overflow-y: auto;
}

.task-detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-check--lg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.task-check--lg.is-done::after {
  width: 10px;
  height: 6px;
  border-left-width: 2px;
  border-bottom-width: 2px;
}

.task-detail-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: color 0.15s;
}
.task-detail-status.is-done { color: #3DB56A; }

.task-detail-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.task-body-textarea {
  min-height: 200px;
  flex: 1;
}

.task-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Make task title look clickable */
.task-title[role="button"] {
  cursor: pointer;
}
.task-title[role="button"]:hover:not(.is-done) {
  color: var(--accent);
}

/* ─── Sidebar board rename input ─────────────────────────── */
.sidebar-rename-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  outline: none;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════
   THEMES
   Set via data-theme on <html>. Each theme overrides :root
   custom properties. color-scheme tells the browser which
   native UI variant to use for scrollbars, inputs, etc.
   ═══════════════════════════════════════════════════════════ */

/* ─── Dark ───────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;

  --bg:          #090D12;
  --sidebar-bg:  #0D1117;
  --surface:     #1C2128;
  --surface-2:   #22272E;
  --surface-3:   #2D333B;
  --panel-bg:    #111820;

  --text-1:      #E6EDF3;
  --text-2:      #8B949E;
  --text-3:      #57606A;

  --border:      #30363D;
  --border-2:    #3D444D;

  --accent:      #58A6FF;
  --accent-h:    #79B8FF;
  --accent-soft: #0D2440;

  --now:         #F0A050;
  --now-soft:    #2B1E0A;

  --p-urgent: #FF7B72;
  --p-high:   #FFA657;
  --p-medium: #E3B341;
  --p-low:    #58A6FF;
  --p-none:   #57606A;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.4);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-modal: 0 16px 56px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4);

  --col-grad-top:  #1E2530;
  --col-grad-bot:  #161C24;
  --card-grad-top: #22272E;
  --card-grad-bot: #1A1F26;
}

/* ─── Monokai ────────────────────────────────────────────── */
[data-theme="monokai"] {
  color-scheme: dark;

  --bg:          #1A1B16;
  --sidebar-bg:  #1E1F1A;
  --surface:     #2F3029;
  --surface-2:   #383830;
  --surface-3:   #3E3D32;
  --panel-bg:    #232420;

  --text-1:      #F8F8F2;
  --text-2:      #CFCFC2;
  --text-3:      #75715E;

  --border:      #3E3D32;
  --border-2:    #49483E;

  --accent:      #A6E22E;   /* Monokai green */
  --accent-h:    #88C21E;
  --accent-soft: #273318;

  --now:         #FD971F;   /* Monokai orange */
  --now-soft:    #332210;

  --p-urgent: #F92672;      /* Monokai red/pink */
  --p-high:   #FD971F;      /* orange */
  --p-medium: #E6DB74;      /* yellow */
  --p-low:    #66D9E8;      /* cyan */
  --p-none:   #75715E;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.5);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-modal: 0 16px 56px rgba(0,0,0,0.7), 0 4px 16px rgba(0,0,0,0.5);

  --col-grad-top:  #323328;
  --col-grad-bot:  #272820;
  --card-grad-top: #38382F;
  --card-grad-bot: #2E2E25;
}

/* ─── Ocean (deep blue-grey dark) ───────────────────────── */
[data-theme="ocean"] {
  color-scheme: dark;

  --bg:          #080E17;
  --sidebar-bg:  #0A1219;
  --surface:     #162130;
  --surface-2:   #1D2B3A;
  --surface-3:   #243546;
  --panel-bg:    #0D1824;

  --text-1:      #E2EAF0;
  --text-2:      #7FA3BC;
  --text-3:      #4A6578;

  --border:      #1E3044;
  --border-2:    #2A3F54;

  --accent:      #38BDF8;   /* sky blue */
  --accent-h:    #0EA5E9;
  --accent-soft: #0C2A40;

  --now:         #FB923C;   /* warm orange */
  --now-soft:    #2A1808;

  --p-urgent: #F87171;      /* soft red */
  --p-high:   #FB923C;      /* orange */
  --p-medium: #FCD34D;      /* yellow */
  --p-low:    #38BDF8;      /* sky */
  --p-none:   #4A6578;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.5);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-modal: 0 16px 56px rgba(0,0,0,0.65), 0 4px 16px rgba(0,0,0,0.4);

  --col-grad-top:  #182334;
  --col-grad-bot:  #0E1720;
  --card-grad-top: #1D2B3A;
  --card-grad-bot: #141F2B;
}

/* ─── Theme switcher ─────────────────────────────────────── */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.theme-switcher-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  flex-shrink: 0;
}

.theme-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s;
  outline: none;
  flex-shrink: 0;
}

.theme-swatch:hover { transform: scale(1.2); }
.theme-swatch.active {
  border-color: var(--accent);
  transform: scale(1.25);
}

.theme-swatch--light  { background: #F7F8FA; box-shadow: inset 0 0 0 1px #C8C9CC; }
.theme-swatch--grey   { background: #868E96; }
.theme-swatch--dark   { background: #0D1117; }
.theme-swatch--monokai { background: #272822; }
.theme-swatch--ocean  { background: #0F1923; }
.theme-swatch--black  { background: #000000; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }

/* ─── Black theme ────────────────────────────────────────── */
[data-theme="black"] {
  color-scheme: dark;

  --bg:          #000000;
  --sidebar-bg:  #080808;
  --surface:     #111111;
  --surface-2:   #181818;
  --surface-3:   #202020;
  --panel-bg:    #0A0A0A;

  --text-1:      #F0F0F0;
  --text-2:      #888888;
  --text-3:      #4A4A4A;

  --border:      #1E1E1E;
  --border-2:    #2C2C2C;

  --accent:      #A78BFA;   /* soft violet */
  --accent-h:    #8B6FE8;
  --accent-soft: #1A1528;

  --now:         #F59E0B;
  --now-soft:    #1A1200;

  --p-urgent: #F87171;
  --p-high:   #FB923C;
  --p-medium: #FBBF24;
  --p-low:    #60A5FA;
  --p-none:   #4A4A4A;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.9);
  --shadow-card:  0 1px 4px rgba(0,0,0,0.9), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-modal: 0 16px 56px rgba(0,0,0,0.95), 0 4px 16px rgba(0,0,0,0.8);

  --col-grad-top:  #161616;
  --col-grad-bot:  #0D0D0D;
  --card-grad-top: #1C1C1C;
  --card-grad-bot: #141414;
}

/* ─── Grey ───────────────────────────────────────────────── */
[data-theme="grey"] {
  color-scheme: light;

  --bg:          #9EA7B0;
  --sidebar-bg:  #B8BFC8;      /* lighter so category chips stay legible */
  --surface:     #F2F3F5;      /* near-white cards/modals */
  --surface-2:   #E6E9EC;
  --surface-3:   #D8DCE0;
  --panel-bg:    #ECEEF1;

  --text-1:      #1A1D20;
  --text-2:      #3A4048;
  --text-3:      #5A636C;

  --border:      #C4CAD0;
  --border-2:    #B4BBC2;

  --accent:      #3B6EA5;
  --accent-h:    #2D5A8E;
  --accent-soft: #D0DCE8;

  --now:         #C45000;
  --now-soft:    #F5E8D8;

  --p-urgent: #E5484D;         /* same vibrant palette as Light */
  --p-high:   #E07B35;
  --p-medium: #D4A017;
  --p-low:    #3B6EA5;
  --p-none:   #8A939C;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.15);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.06);
  --shadow-modal: 0 16px 56px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.12);

  --col-grad-top:  #A8B0B8;
  --col-grad-bot:  #9CA4AC;
  --card-grad-top: #F4F5F7;    /* light cards pop against the grey columns */
  --card-grad-bot: #ECEEF1;
}
