:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --border: #d8dce2;
  --text: #16181d;
  --text-dim: #666e7a;
  --accent: #3b6cf0;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 20, 30, .08), 0 4px 12px rgba(16, 20, 30, .06);
  --radius: 10px;

  /* Cards are pink in light mode only; the dark palette below keeps them
     on the neutral surface colour. --card-dim is warmed to stay legible
     against pink rather than reusing the grey --text-dim. */
  --card-bg: #ffdfeb;
  --card-border: #f2b8d0;
  --card-dim: #6f4d5c;
  --card-chip: #ffc9dd;
}

/* Follow the system unless the toggle has pinned light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #14161a;
  --surface: #1e2126;
  --surface-2: #22262c;
  --border: #333941;
  --text: #e8eaed;
  --text-dim: #949ca8;
  --accent: #6b8dff;
  --accent-text: #0e1014;
  --danger: #e06a5c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);

  /* unchanged from before: cards sit on the plain surface colour */
  --card-bg: #1e2126;
  --card-border: #333941;
  --card-dim: #949ca8;
  --card-chip: #22262c;
  }
}

/* The toggle pinning dark has to win even on a light system, and a media
   query can't share a rule with a plain selector, so the palette repeats. */
:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1e2126;
  --surface-2: #22262c;
  --border: #333941;
  --text: #e8eaed;
  --text-dim: #949ca8;
  --accent: #6b8dff;
  --accent-text: #0e1014;
  --danger: #e06a5c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);

  /* unchanged from before: cards sit on the plain surface colour */
  --card-bg: #1e2126;
  --card-border: #333941;
  --card-dim: #949ca8;
  --card-chip: #22262c;
}

* { box-sizing: border-box; }

/* `display` rules below would otherwise beat the UA stylesheet's [hidden]. */
[hidden] { display: none !important; }


body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--text-dim);
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--text-dim); font-size: 13px; }
.presence { color: var(--text-dim); font-size: 13px; }

/* ---- filters ---- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-select {
  font: inherit;
  font-size: 13px;
  border-radius: 7px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.filter-dates {
  display: flex;
  gap: 2px;
}

.filter-dates button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  padding: 5px 10px;
  cursor: pointer;
}

.filter-dates button:first-child { border-radius: 7px 0 0 7px; }
.filter-dates button:last-child { border-radius: 0 7px 7px 0; }
.filter-dates button + button { border-left: none; }

.filter-dates button:hover { color: var(--text); }
.filter-dates button.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---- board ---- */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 16px;
  padding: 20px;
  align-items: start;
  overflow-x: auto;
  min-height: calc(100vh - 58px);
}

.column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
}

.count {
  font-weight: 500;
  background: var(--bg);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 12px;
  letter-spacing: 0;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 10px 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 40px;
}

.column.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
  display: block;
}

.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.dragging { opacity: .4; }
.card-title { font-weight: 500; overflow-wrap: anywhere; }
.card-notes {
  color: var(--card-dim);
  font-size: 13px;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-dates {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--card-dim);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--card-dim);
}

.assignee {
  background: var(--card-chip);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 1px 8px;
}

.nudge {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.nudge button {
  border: 1px solid var(--card-border);
  background: var(--surface);
  color: var(--card-dim);
  border-radius: 5px;
  width: 22px;
  height: 20px;
  line-height: 1;
  cursor: pointer;
  font-size: 12px;
}

.nudge button:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }
.nudge button:disabled { opacity: .3; cursor: default; }

.add {
  margin: 0 10px 10px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font: inherit;
}

.add:hover { color: var(--text); border-color: var(--text-dim); }

/* ---- buttons ---- */

.btn {
  font: inherit;
  border-radius: 7px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn-icon {
  padding: 6px 9px;
  line-height: 1;
  font-size: 14px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 500; }
.btn-quiet { background: none; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- auth ---- */

.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.muted { color: var(--text-dim); font-size: 14px; margin: 0 0 12px; }
.auth-msg { font-size: 13px; color: var(--text-dim); min-height: 1.2em; margin: 4px 0 0; }
.auth-msg.error { color: var(--danger); }

label { font-size: 13px; font-weight: 500; margin-top: 8px; }

input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  width: 100%;
  resize: vertical;
}

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---- editor dialog ---- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; }

.editor-actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.spacer { flex: 1; }

@media (max-width: 700px) {
  .board {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    min-height: 0;
  }
  .column { max-height: none; }
}
