:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --panel: #e9ebf1;
  --panel-line: #dadde5;
  --card: #ffffff;
  --card-line: #e1e4ea;
  --text: #171b26;
  --muted: #5d6476;
  --accent: #c98500;
  --accent-soft: rgba(240, 168, 40, 0.14);
  --focus: #2563eb;
  --todo: #64748b;
  --doing: #e8a317;
  --done: #22a06b;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.08);
  --lift: 0 18px 38px rgba(17, 24, 39, 0.22), 0 6px 12px rgba(17, 24, 39, 0.12);
  --radius: 10px;
  --gutter: clamp(14px, 3vw, 32px);
  --page: 1400px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13;
    --panel: #14171f;
    --panel-line: #232836;
    --card: #1c202b;
    --card-line: #2a3041;
    --text: #e8eaf0;
    --muted: #979eae;
    --accent: #f0a828;
    --accent-soft: rgba(240, 168, 40, 0.1);
    --focus: #7aa2ff;
    --todo: #8a96ad;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --lift: 0 20px 40px rgba(0, 0, 0, 0.55), 0 6px 14px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 72px; /* room to scroll past the corner badge */
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 22px var(--gutter) 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  flex: none;
  width: 34px;
  height: 34px;
  fill: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .logo {
    filter: drop-shadow(0 0 10px rgba(240, 168, 40, 0.4));
  }
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.session {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--doing);
  animation: pulse 1.2s ease-in-out infinite;
}

.status[data-state='live']::before {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  animation: none;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.people {
  display: flex;
  margin: 0;
  padding: 0 0 0 6px;
  list-style: none;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: -6px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--color, var(--muted));
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.avatar.more {
  background: var(--panel);
  color: var(--muted);
  text-shadow: none;
}

.me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  height: 34px;
  padding: 0 12px 0 3px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}

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

.me .avatar {
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 0;
  font-size: 10.5px;
}

.me-name {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Popover for changing your name and colour */

.me-panel {
  position: fixed;
  inset: auto;
  width: 260px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--lift);
}

.me-panel label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.me-panel input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--bg);
}

.me-panel input:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color);
  cursor: pointer;
}

.swatch[aria-checked='true'] {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--color);
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* Board */

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
}

.column[data-col='todo'] {
  --dot: var(--todo);
}
.column[data-col='doing'] {
  --dot: var(--doing);
}
.column[data-col='done'] {
  --dot: var(--done);
}

.column-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px 9px;
}

.column-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
}

.count {
  min-width: 24px;
  margin-left: auto;
  padding: 1px 8px;
  border: 1px solid var(--card-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.cards {
  position: relative; /* card offsets are measured against the list while dragging */
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 56px;
  margin: 0;
  padding: 2px 10px 10px;
  list-style: none;
}

.cards.empty::before,
.board[aria-busy='true'] .cards::before {
  content: 'No cards yet';
  display: grid;
  place-items: center;
  height: 56px;
  border: 1.5px dashed var(--panel-line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

.board[aria-busy='true'] .cards::before {
  content: 'Loading…';
}

.cards.empty:has(.placeholder)::before {
  display: none;
}

.card {
  position: relative;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  outline: none;
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.15s,
    box-shadow 0.15s;
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-line));
}

.card:focus-visible {
  box-shadow: 0 0 0 2px var(--focus), var(--shadow);
}

.text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.delete {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.12s,
    background-color 0.12s,
    color 0.12s;
}

.delete svg {
  width: 14px;
  height: 14px;
}

.card:hover .delete,
.card:focus-visible .delete,
.delete:focus-visible {
  opacity: 1;
}

.delete:hover {
  background: rgba(229, 72, 77, 0.12);
  color: #e5484d;
}

@media (hover: none) {
  .delete {
    opacity: 0.55;
  }
}

.card.editing {
  padding-right: 12px;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
  cursor: text;
}

.card.editing .text,
.card.editing .delete {
  display: none;
}

.editor {
  display: block;
  width: 100%;
  min-height: 21px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: none;
  line-height: inherit;
  outline: none;
  resize: none;
}

/* Someone else is moving or editing this card */
.card.busy {
  box-shadow: 0 0 0 2px var(--who), var(--shadow);
}

.who {
  position: absolute;
  top: -9px;
  right: 10px;
  display: none;
  max-width: calc(100% - 20px);
  overflow: hidden;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--who);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.card.busy .who {
  display: block;
}

/* Dragging */

.card.dragging {
  display: none;
}

.placeholder {
  flex: none;
  border: 2px dashed color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  margin: 0;
  list-style: none; /* it's an <li> outside its list */
  border-color: color-mix(in srgb, var(--accent) 60%, var(--card-line));
  box-shadow: var(--lift);
  pointer-events: none;
  transition: none;
  will-change: transform;
}

.ghost .delete {
  opacity: 0;
}

body.is-dragging,
body.is-dragging .card {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

@keyframes flash {
  from {
    box-shadow: 0 0 0 3px var(--flash), var(--shadow);
  }
}

.card.enter {
  animation: enter 0.22s ease-out;
}

.card.flash {
  animation: flash 1.4s ease-out;
}

.card.enter.flash {
  animation:
    enter 0.22s ease-out,
    flash 1.4s ease-out;
}

/* Adding cards */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0 10px 10px;
}

.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 8px 11px;
  overflow: hidden;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: var(--card);
  line-height: 1.4;
  resize: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer textarea:focus {
  border-color: transparent;
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.add {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #1a1100;
  font-weight: 650;
  cursor: pointer;
}

.add:hover {
  filter: brightness(1.07);
}

.help {
  max-width: var(--page);
  margin: 18px auto 0;
  padding: 0 var(--gutter);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--panel-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card);
  font: 600 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Toasts sit bottom-left, clear of the corner badge */

.toasts {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 2000;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #1b1f2a;
  color: #f1f2f6;
  box-shadow: var(--lift);
  font-size: 14px;
  animation: toast-in 0.2s ease-out;
}

.toast button {
  margin-left: auto;
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: rgba(240, 168, 40, 0.18);
  color: #f0a828;
  font-weight: 650;
  cursor: pointer;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.2s,
    transform 0.2s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

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

@media (max-width: 760px) {
  .board {
    grid-template-columns: minmax(0, 1fr);
  }

  .column {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .top {
    padding-top: 16px;
  }

  .tagline {
    font-size: 12.5px;
  }

  .toasts {
    bottom: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card.enter,
  .card.flash,
  .toast,
  .status::before {
    animation: none;
    transition: none;
  }
}
