:root {
  color-scheme: light dark;
  --bg: #fbfbfc;
  --surface: #ffffff;
  --text: #1c1d21;
  --muted: #6b6f76;
  --border: #e4e5e9;
  --accent: #5e6ad2;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1011;
    --surface: #18191b;
    --text: #e6e6e8;
    --muted: #8a8f98;
    --border: #2a2b2f;
    --accent: #7c85e6;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

.muted { color: var(--muted); }

:root { --danger: #c93c37; }
@media (prefers-color-scheme: dark) { :root { --danger: #eb5757; } }

.topbar { justify-content: space-between; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-user form { margin: 0; }
.topbar-name { color: var(--muted); text-decoration: none; }
.topbar-name:hover { color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.button {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.button:disabled { opacity: 0.6; cursor: default; }
a.button { text-decoration: none; display: inline-block; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.ghost:hover { color: var(--text); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  margin: 48px auto;
}
.auth-form h1 { margin: 0; font-size: 20px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.form-error { margin: 0; color: var(--danger); }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; }

.breadcrumb { margin-bottom: 4px; color: var(--muted); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.section { margin-top: 32px; }

.list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.list:empty { display: none; }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; flex-wrap: wrap; }
.list li + li { border-top: 1px solid var(--border); }
.list li form { margin: 0 0 0 auto; }

.badge { margin-left: auto; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

.workspace-grid { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.workspace-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; color: var(--text); text-decoration: none; }
.workspace-card:hover { border-color: var(--accent); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; max-width: 480px; }
.inline-form input { flex: 1; min-width: 180px; }

.invite-link { margin-bottom: 12px; padding: 16px; }
.invite-link p { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Board */
.board-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.board-header form { margin: 0; }
.title-form { flex: 1; margin: 0; }

/* Board filter bar (board.js). Does nothing without JavaScript, so hidden then. */
.board-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; }
.board-filter input[type="search"] { flex: 0 1 220px; min-width: 140px; padding: 5px 8px; }
.board-filter select { max-width: 180px; font: inherit; padding: 5px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.board-filter select:has(option:checked:not([value=""])) { border-color: var(--accent); }
.board-filter-count { font-size: 13px; }
@media (scripting: none) { .board-filter { display: none; } }
.title-input, .column-name input {
  width: 100%;
  border-color: transparent;
  background: transparent;
  font-weight: 600;
}
.title-input { font-size: 22px; padding: 2px 6px; margin-left: -7px; }
.title-input:hover, .column-name input:hover { border-color: var(--border); }

.board-columns {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow-x: auto;
  /* Contain absolutely positioned children (e.g. .visually-hidden labels);
     otherwise they're laid out against the page at their scrolled-out
     position and widen it on phones. */
  position: relative;
  padding-bottom: 12px;
  /* Columns snap into place when swiping on a phone. */
  scroll-snap-type: x mandatory;
}
.column {
  flex: 0 0 272px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.column-header { display: flex; align-items: center; gap: 4px; }
.column-header form { margin: 0; }
.column-name { flex: 1; }
.column-name input { padding: 4px 6px; font-size: 14px; }
.column-cards { min-height: 40px; }

.add-column { display: flex; flex-direction: column; gap: 8px; background: transparent; border-style: dashed; }
.add-column .button { align-self: flex-start; }
.button.icon { padding: 2px 8px; font-size: 16px; line-height: 1; }

/* Cards */
.board-page { display: flex; gap: 16px; align-items: flex-start; }
.board-main { flex: 1; min-width: 0; }
.board-error { margin: 0 0 8px; }
.board-columns { flex-wrap: nowrap; }
.column-body { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.column-cards { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.card-tile {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.card-tile:hover { border-color: var(--accent); }
.card-tile-title { flex: 1; }
.card-tile-meta { color: var(--muted); font-size: 12px; }
.add-card input { width: 100%; border-style: dashed; background: transparent; }
.add-card input:focus { border-style: solid; background: var(--bg); }

/* Card panel: beside the board on wide screens, full screen on phones. */
.panel {
  flex: 0 0 420px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.panel[hidden] { display: none; }
@media (max-width: 800px) {
  .panel {
    position: fixed;
    inset: 0;
    max-height: none;
    border-radius: 0;
    border: none;
    z-index: 10;
  }
}
.panel-header { display: flex; justify-content: space-between; align-items: center; }
.card-title-form { margin: 0; }
.card-title-form .title-input { font-size: 18px; width: calc(100% + 7px); }
.section-label { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.card-description { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.card-description textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.form-actions { display: flex; gap: 8px; }
.panel-footer { margin: auto 0 0; padding-top: 8px; border-top: 1px solid var(--border); }
/* Line ghost buttons' text up with the panel's left edge. */
.panel-footer .button.ghost { margin-left: -12px; }
.button.danger { color: var(--danger); }

.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown ul:has(> li > input[type="checkbox"]) { list-style: none; padding-left: 4px; }
.markdown code { font-family: ui-monospace, monospace; font-size: 13px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.markdown pre { background: var(--bg); padding: 8px; border-radius: var(--radius); overflow-x: auto; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 4px 8px; }

/* Drag-and-drop (board.js) */
.column-cards { min-height: 8px; }
.card-tile { cursor: grab; touch-action: manipulation; }
.card-ghost { opacity: 0.4; border-style: dashed; }
.card-chosen { border-color: var(--accent); }
.card-dragging { cursor: grabbing; box-shadow: 0 6px 16px rgb(0 0 0 / 0.18); }
.card-column { display: flex; align-items: center; gap: 6px; margin: 0; }
.card-column select { font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.column-grip { cursor: grab; color: var(--muted); padding: 2px; margin-left: -4px; touch-action: none; user-select: none; }
.column-grip:hover { color: var(--text); }
.column-ghost { opacity: 0.4; }
.column-chosen { box-shadow: 0 6px 16px rgb(0 0 0 / 0.18); }

/* Keyboard (shortcuts.js) */
.card-tile:focus { outline: none; }
.card-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 12px/1.5 var(--font);
  text-align: center;
  color: var(--muted);
  background: var(--bg);
}
kbd + kbd { margin-left: 2px; }

/* Quick jump (Cmd-K) */
.jump { margin: 0; }
.jump-button { display: inline-flex; align-items: center; gap: 8px; }
dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.25);
}
dialog::backdrop { background: rgb(0 0 0 / 0.3); }
.jump-dialog { width: min(600px, calc(100vw - 32px)); margin-top: 12vh; }
.jump-dialog .jump-input {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  font-size: 16px;
}
.jump-dialog .jump-input:focus { outline: none; }
.jump-input::-webkit-search-cancel-button { display: none; }
.jump-results { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 55vh); overflow-y: auto; }
.jump-page-results { padding: 6px 0; max-height: none; }
.jump-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.jump-item.is-selected, .jump-page-results .jump-item:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.jump-kind { flex: 0 0 76px; font-size: 12px; color: var(--muted); }
.jump-title { overflow-wrap: anywhere; }
.jump-context { margin-left: auto; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
/* Why a card matched: a line under it, lined up with the title. */
.jump-snippet { flex: 1 0 100%; padding-left: 86px; font-size: 13px; overflow-wrap: anywhere; }
.jump-snippet mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; border-radius: 2px; }
.jump-empty { padding: 8px 10px; }
.jump-hint { margin: 0; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; }
@media (max-width: 640px) {
  .jump-button kbd, .jump-hint { display: none; }
  .jump-kind { flex-basis: auto; }
  .jump-snippet { padding-left: 0; }
}

.shortcuts-help { width: min(460px, calc(100vw - 32px)); }
.shortcuts-help-body { padding: 16px 20px; }
.shortcuts-help h2 { margin: 0 0 12px; font-size: 16px; }
.shortcuts-help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 12px; }
.shortcuts-help dt { white-space: nowrap; }
.shortcuts-help dd { margin: 0; }

/* Card details: tiles */
.card-tile { flex-wrap: wrap; }
.card-tile-title { flex: 1 1 auto; min-width: 0; }
.tile-labels { flex: 0 0 100%; display: flex; flex-wrap: wrap; gap: 4px; }
.tile-meta { flex: 0 0 100%; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tile-meta .avatar { margin-left: auto; }
.tile-due.overdue { color: var(--danger); font-weight: 600; }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
}

/* Labels. Tinted backgrounds that read in light and dark. */
.label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  color: var(--text);
  background: color-mix(in srgb, var(--label) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--label) 45%, transparent);
  white-space: nowrap;
}
.label-blue { --label: #3b82f6; }
.label-green { --label: #22a35a; }
.label-orange { --label: #f08c28; }
.label-purple { --label: #8b5cf6; }
.label-red { --label: #e5484d; }
.label-teal { --label: #14a3a3; }
.label-yellow { --label: #e0b100; }
.label-pink { --label: #e2549a; }
.label-gray { --label: #8a8f98; }
.label-remove { border: 0; background: none; padding: 0 0 0 2px; color: var(--muted); cursor: pointer; font: inherit; }
.label-remove:hover { color: var(--text); }

/* Card details: panel */
.card-properties { display: grid; gap: 6px; margin: 4px 0 16px; }
.property { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
.property-name { flex: 0 0 72px; color: var(--muted); font-size: 13px; }
.property select, .property input[type="date"] {
  font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}
.property-labels { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.label-chip, .label-add { margin: 0; }
.label-add input { width: 110px; padding: 1px 6px; font-size: 13px; border-style: dashed; background: transparent; }
.card-properties > .form-error { margin-left: 80px; }

.card-comments { margin: 16px 0; }
.comment { padding: 8px 0; border-top: 1px solid var(--border); }
.comment-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.comment-meta form { margin: 0 0 0 auto; }
.comment-form { display: grid; gap: 6px; justify-items: start; padding-top: 8px; border-top: 1px solid var(--border); }
.comment-form textarea {
  width: 100%; box-sizing: border-box; font: inherit; padding: 6px 8px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text);
}

/* Workspace page */
.label-list li { gap: 8px; }
.list li .label-edit { display: flex; align-items: center; gap: 8px; margin: 0; flex: 1; min-width: 0; }
.label-edit input { flex: 1; min-width: 0; }
.label-edit .label { flex: 0 0 auto; max-width: 30%; overflow: hidden; text-overflow: ellipsis; }
.label-edit select { font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.list li .badge + form { margin-left: 0; }
