/* tasq prototype — CSS
 *
 * Mobile-first. All inputs are 16px to prevent iOS Safari zoom-on-focus.
 * Tap targets ≥ 44×44 on touch viewports.
 *
 * Color system intentionally minimal — pinned to system palette so the
 * prototype looks native on both light and dark mode without a toggle.
 */

:root {
  --bg:        #f7f7f8;
  --bg-card:   #ffffff;
  --bg-soft:   #eef0f3;
  --fg:        #1a1d23;
  --fg-soft:   #5b626d;
  --fg-muted:  #8b939f;
  --border:    #d8dde3;
  --border-soft:#e8ebef;
  --primary:   #2563eb;
  --primary-fg:#ffffff;
  --danger:    #dc2626;
  --warn:      #d97706;
  --good:      #16a34a;
  --selected:  #dbeafe;
  --shadow:    0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.06);
  --r:         8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1115;
    --bg-card:   #181b21;
    --bg-soft:   #1f232a;
    --fg:        #e6e8eb;
    --fg-soft:   #b3b9c2;
    --fg-muted:  #7a8290;
    --border:    #2c313a;
    --border-soft:#23272f;
    --primary:   #3b82f6;
    --selected:  #1e3a8a;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; cursor: pointer; }
input, select, textarea, button { font-size: 16px; } /* iOS no-zoom */

/* ─── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.brand { font-size: 1.125rem; }
.proto-tag {
  font-size: .7rem;
  background: var(--warn);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

select, input[type="text"], input[type="search"], input[type="date"], textarea {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .5rem .65rem;
  min-height: 38px;
}
input[type="search"] { min-width: 14rem; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  border-radius: var(--r);
  padding: .5rem .85rem;
  min-height: 38px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: transparent; }
.btn-danger  { background: var(--danger);  color: white;             border-color: transparent; }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--fg-soft); }
.btn:active { transform: translateY(1px); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r);
  /* No overflow:hidden — it would clip the [data-kbd] hint badges that
     float above the Table/Kanban buttons. Round the end-caps directly
     on the first/last seg-btn instead. */
}
.seg-btn:first-child { border-top-left-radius: calc(var(--r) - 1px); border-bottom-left-radius: calc(var(--r) - 1px); }
.seg-btn:last-child  { border-top-right-radius: calc(var(--r) - 1px); border-bottom-right-radius: calc(var(--r) - 1px); }
.seg-btn {
  background: var(--bg-card);
  color: var(--fg-soft);
  border: 0;
  padding: .5rem .9rem;
  min-height: 38px;
}
.seg-btn[aria-selected="true"] { background: var(--primary); color: var(--primary-fg); }

/* ─── Menu ───────────────────────────────────────────────────────────── */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: .25rem;
  z-index: 20;
}
.menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: .55rem .65rem;
  border-radius: 4px;
  color: var(--fg);
}
.menu-panel button:hover { background: var(--bg-soft); }
.menu-panel button.danger { color: var(--danger); }
.menu-panel hr { border: 0; border-top: 1px solid var(--border-soft); margin: .25rem 0; }

/* ─── Filterbar ──────────────────────────────────────────────────────── */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.filter-group { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.filter-label { color: var(--fg-muted); font-size: .85rem; }
.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-soft);
  border-radius: 999px;
  padding: .25rem .65rem;
  font-size: .85rem;
  white-space: nowrap;
  line-height: 1.2;
}
.chip[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
}
.chip-label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.chip-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--label-color, var(--fg-muted));
  display: inline-block;
}

/* ─── Main ───────────────────────────────────────────────────────────── */
#main {
  flex: 1 1 auto;
  padding: .75rem;
  overflow-x: auto;
}
.view { display: none; }
.view.view-active { display: block; }

/* ─── Table ──────────────────────────────────────────────────────────── */
.tasks-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  font-size: .95rem;
}
.tasks-table th, .tasks-table td {
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}
.tasks-table thead th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: .85rem;
  color: var(--fg-soft);
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}
.tasks-table thead th.sort-asc::after  { content: " ▲"; color: var(--primary); }
.tasks-table thead th.sort-desc::after { content: " ▼"; color: var(--primary); }
.tasks-table tbody tr {
  cursor: pointer;
  transition: background-color .08s;
}
.tasks-table tbody tr:hover { background: var(--bg-soft); }
.tasks-table tbody tr.selected { background: var(--selected); }
.tasks-table tbody tr.status-done td:nth-child(2) { text-decoration: line-through; color: var(--fg-muted); }
.tasks-table tbody tr.status-archived { opacity: .55; }

.col-actions { width: 1px; white-space: nowrap; }
.row-action {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--fg-soft);
  font-size: 1rem;
  min-width: 32px;
  min-height: 32px;
}
.row-action:hover { background: var(--bg-soft); }

.empty {
  padding: 3rem;
  text-align: center;
  color: var(--fg-muted);
}
kbd {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .85em;
}

/* ─── Kanban ─────────────────────────────────────────────────────────── */
.kanban-cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: .75rem;
}
.kanban-col {
  background: var(--bg-soft);
  border-radius: var(--r);
  padding: .5rem;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.kanban-col-head {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-soft);
  padding: .25rem .35rem;
  display: flex;
  justify-content: space-between;
}
.kanban-col-body {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 80px;
}
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .65rem;
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
}
.kanban-card.selected { outline: 2px solid var(--primary); }
.kanban-card-title { font-weight: 500; }
.kanban-card-meta {
  display: flex;
  gap: .35rem;
  margin-top: .35rem;
  flex-wrap: wrap;
  font-size: .75rem;
  color: var(--fg-muted);
}
.sortable-ghost { opacity: .4; }
.sortable-chosen { cursor: grabbing; }

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--border);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border-soft);
}
.modal-foot-split { justify-content: space-between; }
.modal-foot-left  { display: flex; gap: .5rem; }
#task-form { padding: 1rem; }
#task-form > label { display: block; margin-bottom: .85rem; }
#task-form > label input, #task-form > label textarea, #task-form > label select {
  display: block; width: 100%; margin-top: .3rem;
}
#task-form .row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
}
#task-form .row label { margin: 0; }
.labels-fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: .5rem .75rem; }
.label-pickers { display: flex; flex-wrap: wrap; gap: .35rem; }
.label-pickers .chip { cursor: pointer; }

.modal-spotlight { align-items: flex-start; padding-top: 12vh; }
.spotlight-card { padding: .5rem; }
#list-spotlight-input { width: 100%; }
.spotlight-results {
  list-style: none; padding: 0; margin: .5rem 0 0;
  max-height: 50vh; overflow: auto;
}
.spotlight-results li {
  padding: .55rem .65rem;
  border-radius: 4px;
  cursor: pointer;
}
.spotlight-results li.active { background: var(--selected); }
.spotlight-results li:hover { background: var(--bg-soft); }

.kbd-table { width: 100%; border-collapse: collapse; padding: .5rem; }
.kbd-table td { padding: .35rem .75rem; border-bottom: 1px solid var(--border-soft); }
.kbd-table tr:last-child td { border-bottom: 0; }

.labels-list { list-style: none; padding: 0; margin: 0; }
.labels-list li {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.labels-list li:last-child { border-bottom: 0; }
.labels-list li input[type="text"] { flex: 1; }
.label-form { display: flex; gap: .5rem; padding: 1rem; align-items: stretch; }
.label-form input[type="text"] { flex: 1; }

/* ─── Toasts ─────────────────────────────────────────────────────────── */
#toast-host {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: .25rem;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--fg);
  color: var(--bg-card);
  padding: .5rem .85rem;
  border-radius: var(--r);
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Bottom nav (mobile only) ───────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: .25rem;
  padding-bottom: calc(.25rem + env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
}
.bnav-btn {
  background: transparent;
  border: 0;
  font-size: 1rem;
  color: var(--fg-soft);
  flex: 1;
  min-height: 48px;
  border-radius: var(--r);
}
.bnav-btn.active { color: var(--primary); }

/* ─── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

  .topbar { padding: .5rem; }
  .topbar-right .btn:not(.btn-primary):not(#btn-help) { display: none; }
  input[type="search"] { min-width: 0; flex: 1; }
  .seg { display: none; } /* replaced by bottom-nav */

  .filterbar { padding: .35rem .5rem; gap: .5rem; }
  .filter-label { display: none; }

  #main { padding: .5rem; }

  /* Kanban becomes horizontal-paged on mobile */
  .kanban-cols {
    grid-template-columns: 1fr;
    grid-auto-flow: column;
    grid-auto-columns: 88vw;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .kanban-col { scroll-snap-align: start; }

  /* Hide some table columns on small screens */
  .tasks-table thead th:nth-child(5),  /* Labels */
  .tasks-table thead th:nth-child(6),  /* Updated */
  .tasks-table tbody td:nth-child(5),
  .tasks-table tbody td:nth-child(6) { display: none; }

  .bottom-nav { display: flex; }
}

/* Hide bottom nav on desktop even if media query doesn't catch it */
@media (min-width: 641px) {
  .bottom-nav { display: none !important; }
}

/* Cursor-style keyboard hint badges. Hidden by default; revealed when the
   body gets .show-kbd-hints (set while a modifier key is held, or while a
   leader-key sequence like `g …` is pending). */
[data-kbd] { position: relative; }
[data-kbd]::after {
  content: attr(data-kbd);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: #111827;
  color: #f9fafb;
  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #374151;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 90ms ease-out, transform 90ms ease-out, visibility 0s linear 90ms;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.show-kbd-hints [data-kbd]::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}
/* Wrapper for elements that can't render ::after themselves (input, select).
   Keep it inline so it doesn't disturb topbar layout. */
.kbd-wrap { display: inline-block; }
.kbd-wrap > * { display: inline-block; vertical-align: middle; }

/* Topbar is flush with the viewport top — flip badges to render BELOW the
   control so they don't clip off the top of the browser window. */
.topbar [data-kbd]::after {
  bottom: auto;
  top: calc(100% + 4px);
  transform: translateX(-50%) translateY(-2px);
}
.show-kbd-hints .topbar [data-kbd]::after {
  transform: translateX(-50%) translateY(0);
}
/* Search wrapper: badge below + right-anchored so it doesn't clip off the
   right edge of the topbar. */
.show-kbd-hints .kbd-wrap:has(#search)[data-kbd]::after { left: auto; right: 6px; transform: translateY(0); }

/* While the `g` leader is pending: highlight the G-prefixed badges and
   dim the rest, so it's obvious what the next key options are. */
.kbd-leader-g [data-kbd^="G "]::after {
  background: #be185d;
  border-color: #f472b6;
  box-shadow: 0 0 0 2px rgba(244, 114, 182, .35), 0 2px 8px rgba(0,0,0,.25);
}
.kbd-leader-g [data-kbd]:not([data-kbd^="G "])::after { opacity: .25; }
/* ─── Login / pre-auth pages ────────────────────────────────────────── */
.auth-card {
  max-width: 420px;
  margin: 4rem auto 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.auth-card h1 {
  margin: 0 0 .5rem;
  font-size: 1.5rem;
}
.auth-card p { margin: 0 0 1.25rem; color: var(--muted); }
.auth-card .notice {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: .75rem;
  border-radius: var(--r);
  margin-bottom: 1rem;
}
.auth-card form { margin: 0; }
.auth-card form > label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}
.auth-card form > label > input[type="text"],
.auth-card form > label > input[type="email"] {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .55rem .65rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-sizing: border-box;
}
.auth-card form > label > input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}
.auth-card label.remember {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: normal;
  margin-bottom: 1.25rem;
  color: var(--muted);
  cursor: pointer;
}
.auth-card label.remember > input { margin: 0; }
.auth-card button[type="submit"] {
  display: block;
  width: 100%;
  padding: .65rem;
  font-size: 1rem;
  background: var(--primary);
  color: var(--primary-fg);
  border: 1px solid var(--primary);
  border-radius: var(--r);
  cursor: pointer;
}
.auth-card button[type="submit"]:hover { background: #111827; }
.auth-card .muted { font-size: .85rem; }

/* ─── Mobile (< 640px) ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .kanban-cols { grid-template-columns: 1fr; }
  .tasks-table th:nth-child(4), .tasks-table td:nth-child(4),
  .tasks-table th:nth-child(5), .tasks-table td:nth-child(5),
  .tasks-table th:nth-child(6), .tasks-table td:nth-child(6) { display: none; }
}

/* ─── Top navigation (Phase 5+) ─────────────────────────────────────── */
.brand-link { text-decoration: none; color: inherit; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topnav-link {
  display: inline-flex;
  align-items: center;
  padding: .35rem .6rem;
  color: var(--fg-soft);
  text-decoration: none;
  border-radius: var(--r);
  min-height: 32px;
}
.topnav-link:hover    { background: var(--bg-soft); color: var(--fg); }
.topnav-link.is-active { background: var(--selected); color: var(--fg); font-weight: 600; }

/* Menu items as <a>, same look as <button>. */
.menu-panel a {
  display: block;
  padding: .55rem .65rem;
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
}
.menu-panel a:hover { background: var(--bg-soft); }

/* ─── Page bar (per-list controls) ────────────────────────────────── */
.page-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
}
.page-bar-left, .page-bar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.list-switcher { min-width: 12rem; }

/* Seg buttons: works for <a> and <button> alike. Remove underline so
   anchor-style routing matches button-style toggling visually. */
.seg-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  padding: .5rem .9rem;
  background: var(--bg-card);
  color: var(--fg-soft);
  border: 0;
  cursor: pointer;
  font-size: 1rem;
  min-height: 38px;
}
.seg-btn.is-active,
.seg-btn[aria-selected="true"] {
  background: var(--primary);
  color: var(--primary-fg);
}
.seg-btn:hover:not(.is-active):not([aria-selected="true"]) {
  background: var(--bg-soft);
  color: var(--fg);
}

/* "+ New task" should look primary on the page-bar. */
.page-bar-right .btn:first-child:not(.btn-ghost):not(.btn-danger) {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
}

/* ⋯ menu summary: bigger tap target, no list-marker. */
details.menu summary.btn {
  padding: .35rem .65rem;
  font-size: 1.25rem;
  line-height: 1;
  user-select: none;
}

/* Filter chips: respect .is-active (server-side state). */
.chip.is-active,
button.chip.is-active {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
}
.chip:hover:not(.is-active) {
  background: var(--bg-soft);
}
button.chip {
  font: inherit;
  cursor: pointer;
}

/* Status pill (table view). */
.status-pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--fg-soft);
}
.status-pill.status-doing { background: #fef3c7; color: #92400e; }
.status-pill.status-done  { background: #d1fae5; color: #065f46; }
.status-pill.status-archived { background: #fee2e2; color: #991b1b; }

/* Title cell button: looks like a link, not a button. */
.link-button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline;
  font: inherit;
  text-align: left;
}
.link-button:hover { color: var(--fg); }

/* Empty state under a table. */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--fg-muted);
}
.empty-state kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: .85em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* ─── Inner pages: 2-column where there's a list + a create form ──── */
.contacts-page,
.labels-page,
.settings-devices,
.checklist-prefs {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
}
.contacts-page > p.muted,
.labels-page > p.muted,
.settings-devices > p.muted,
.checklist-prefs > p.muted {
  grid-column: 1 / -1;
  margin: 0 0 .25rem;
}
@media (max-width: 880px) {
  .contacts-page, .labels-page, .settings-devices, .checklist-prefs {
    grid-template-columns: 1fr;
  }
}

/* Forms / single-flow pages stay centred + readable */
.checklist-new,
.checklist-preview {
  max-width: 760px;
  margin: 1.25rem auto;
  padding: 0 .75rem;
}
.checklist-new > p.muted {
  margin: 0 0 1.25rem;
}
.checklist-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.checklist-form > label,
.checklist-form > details > label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
  color: var(--fg);
}
.checklist-form > label > input,
.checklist-form > label > textarea,
.checklist-form > label > select,
.checklist-form > details > label > input {
  display: block;
  width: 100%;
  margin-top: .35rem;
  font-weight: normal;
}
.checklist-form > label > textarea {
  resize: vertical;
  min-height: 4.5em;
}
.checklist-form > details {
  background: var(--bg-soft);
  border-radius: var(--r);
  padding: .65rem 1rem;
  margin-bottom: 1rem;
}
.checklist-form > details > summary {
  cursor: pointer;
  color: var(--fg-soft);
  font-weight: 500;
  list-style: revert;
  padding: .25rem 0;
}
.checklist-form > details[open] > summary {
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: .5rem;
}
.checklist-form > details > label {
  display: block;
  margin-bottom: .75rem;
  font-weight: 500;
}
.checklist-form button[type="submit"] {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
  padding: .65rem 1.25rem;
  font-weight: 600;
  margin-top: .5rem;
}

/* Preview screen polish */
.checklist-preview > h2 { margin: 0 0 .25rem; font-size: 1.5rem; }
.checklist-preview > p.muted { margin: 0 0 1.5rem; }
.checklist-category,
.checklist-advisories,
.checklist-sources {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.checklist-category > h3,
.checklist-advisories > h3,
.checklist-sources > h3 {
  margin: 0 0 .65rem;
  font-size: 1.05rem;
  color: var(--fg);
}
.checklist-category ul,
.checklist-advisories ul,
.checklist-sources ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.checklist-category li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.checklist-category li:last-child { border-bottom: 0; }
.checklist-category li.priority-high {
  border-left: 3px solid var(--primary);
  padding-left: .65rem;
  margin-left: -.65rem;
}
.checklist-category li > strong { font-weight: 600; }
.checklist-category li .badge {
  display: inline-block;
  background: var(--primary);
  color: var(--primary-fg);
  padding: 1px 6px;
  font-size: .7rem;
  border-radius: 3px;
  margin-left: .35rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.checklist-category li > p {
  margin: .25rem 0 0;
  font-size: .9rem;
}
.checklist-category li .sources a {
  color: var(--primary);
  text-decoration: none;
  font-size: .85rem;
  margin-right: .5rem;
}
.checklist-confirm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
}
.checklist-confirm > label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}
.checklist-confirm > label > input {
  display: block;
  width: 100%;
  margin-top: .35rem;
}

/* ─── Preference columns + contacts/labels page polish ────────────── */
.prefs-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.prefs-columns > article,
.prefs-context {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
}
.prefs-columns > article > h2,
.prefs-context > h2 {
  margin: 0 0 .65rem;
  font-size: 1.05rem;
}
.prefs-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.prefs-list > li {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.prefs-list > li:last-child { border-bottom: 0; }
.prefs-list > li.empty {
  display: block;
  padding: .5rem 0;
  font-style: italic;
}
.row-inline {
  display: flex;
  gap: .35rem;
  align-items: center;
  flex: 1;
}
.row-inline input[type="text"] { flex: 1; min-width: 0; }
.prefs-add {
  display: flex;
  gap: .5rem;
  margin-top: .5rem;
  flex-wrap: wrap;
}
.prefs-add input[type="text"] { flex: 1; min-width: 8rem; }

/* Contacts table — page-bar contains h1, then the table sits below. */
.contacts-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin: 1rem 0;
}
.contacts-table th, .contacts-table td {
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}
.contacts-table tr:last-child td { border-bottom: 0; }
.contacts-table thead th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: .85rem;
  color: var(--fg-soft);
}
.contact-create-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}
.contact-create-form > label {
  display: block;
  margin-bottom: .65rem;
}
.contact-create-form > label > input,
.contact-create-form > label > textarea {
  display: block;
  width: 100%;
  margin-top: .25rem;
}
.contact-create-form button[type="submit"] {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
  margin-top: .5rem;
}

/* Settings/devices table */
.devices-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.devices-table th, .devices-table td {
  padding: .55rem .65rem;
  border-bottom: 1px solid var(--border-soft);
}
.devices-table tr:last-child td { border-bottom: 0; }
.devices-table thead th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: .85rem;
  color: var(--fg-soft);
  text-align: left;
}
.devices-table .badge {
  display: inline-block;
  background: var(--primary);
  color: var(--primary-fg);
  padding: 1px 6px;
  font-size: .7rem;
  border-radius: 3px;
  margin-left: .35rem;
}

/* Page-bar h1 spacing on inner pages */
.page-bar-left h1 { margin: 0; font-size: 1.25rem; }

/* Contacts page: list spans the wide column, create form sits in the
   narrow one. The h2 inside the right column is the "Add contact"
   heading. */
.contacts-list { min-width: 0; overflow-x: auto; }
.contacts-list .contacts-table { min-width: 720px; margin: 0; }
.contacts-create-col h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
.contacts-create-col .contact-create-form { margin: 0; }

/* ─── Task modal label-picker pills ────────────────────────────────── */
.labels-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .5rem .75rem .65rem;
  margin-bottom: .85rem;
}
.labels-fieldset > legend {
  padding: 0 .35rem;
  color: var(--fg-soft);
  font-size: .85rem;
}
.label-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

/* Override the bare .chip rules for a proper pill that holds a
   checkbox + a coloured dot + the label name on one line. */
.chip-label-picker {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .65rem .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--fg);
  font-size: .85rem;
  cursor: pointer;
  transition: background .08s, border-color .08s;
  user-select: none;
  white-space: nowrap;
  line-height: 1.2;
}
.chip-label-picker > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--label-color, var(--border));
  border-radius: 3px;
  background: transparent;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.chip-label-picker > input[type="checkbox"]:checked {
  background: var(--label-color, var(--primary));
  border-color: var(--label-color, var(--primary));
}
.chip-label-picker > input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: -2px;
  left: 1px;
  font-size: 11px;
  color: white;
  line-height: 1;
}
.chip-label-picker:hover {
  border-color: var(--label-color, var(--fg-muted));
  background: var(--bg-soft);
}
.chip-label-picker:has(input:checked) {
  background: color-mix(in oklab, var(--label-color, var(--primary)) 15%, var(--bg-card));
  border-color: var(--label-color, var(--primary));
  color: var(--fg);
}

/* Colour dot already exists in the prototype CSS as .chip-dot — used
   in non-picker chip displays. The picker uses the input box itself
   as the colour signifier (less visual noise). */

/* ─── Home / welcome dashboard ──────────────────────────────────────
   Post-login landing (public/index.php). Greeting + list launcher. */
.welcome { max-width: 640px; padding: 1rem; }
.welcome h1 { margin: 0 0 .35rem; }
.welcome > p.muted { color: var(--fg-muted); margin: 0 0 1rem; }
.welcome-lists {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.welcome-lists a {
  display: block;
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--fg);
  text-decoration: none;
}
.welcome-lists a:hover { border-color: var(--primary); }
