:root {
  color-scheme: light dark;
  --bg: oklch(1 0 0);
  --lane: oklch(0.965 0.004 150);
  --surface: oklch(1 0 0);
  --line: oklch(0.9 0.006 150);
  --line-strong: oklch(0.8 0.008 150);
  --ink: oklch(0.22 0.012 150);
  --ink-2: oklch(0.42 0.012 150);
  --primary: oklch(0.47 0.11 148);
  --primary-hover: oklch(0.41 0.11 148);
  --primary-ink: oklch(1 0 0);
  --primary-soft: oklch(0.95 0.035 148);
  --danger: oklch(0.5 0.19 27);
  --danger-soft: oklch(0.955 0.03 27);
  --focus: oklch(0.58 0.15 148);
  --shadow-card: 0 1px 2px oklch(0.3 0.02 150 / 0.08);
  --shadow-lift: 0 12px 28px oklch(0.3 0.02 150 / 0.2), 0 2px 6px oklch(0.3 0.02 150 / 0.12);
  --p-jacob: oklch(0.5 0.13 255);
  --p-charles: oklch(0.5 0.11 60);
  --p-alyssa: oklch(0.5 0.15 345);
  --p-jay: oklch(0.5 0.09 200);
  --p-kaitlyn: oklch(0.5 0.14 300);
  --r-card: 10px;
  --r-ctl: 8px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --z-sticky: 10;
  --z-drag: 40;
  --z-toast: 60;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.16 0 0);
    --lane: oklch(0.2 0 0);
    --surface: oklch(0.255 0 0);
    --line: oklch(0.31 0 0);
    --line-strong: oklch(0.42 0 0);
    --ink: oklch(0.95 0 0);
    --ink-2: oklch(0.74 0 0);
    --primary: oklch(0.74 0.14 148);
    --primary-hover: oklch(0.8 0.14 148);
    --primary-ink: oklch(0.16 0 0);
    --primary-soft: oklch(0.3 0.05 148);
    --danger: oklch(0.72 0.16 27);
    --danger-soft: oklch(0.3 0.06 27);
    --focus: oklch(0.78 0.14 148);
    --shadow-card: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-lift: 0 14px 30px oklch(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink);
  font-weight: 550; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-danger { border-color: var(--danger); background: var(--danger); color: var(--bg); }
.btn svg { width: 16px; height: 16px; flex: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--lane); }
  .btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
  .btn-quiet:hover { color: var(--ink); }
  .btn-danger:hover { background: var(--danger); filter: brightness(0.94); }
}
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--ink-2);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--lane); color: var(--ink); } }

/* Fields */
.field { display: grid; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.input { height: 38px; }
.textarea { resize: none; min-height: 72px; line-height: 1.45; display: block; }
.input::placeholder, .textarea::placeholder { color: var(--ink-2); opacity: 1; }
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.error { color: var(--danger); font-size: 13.5px; font-weight: 500; min-height: 20px; }

/* Avatars: one color per person */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; color: oklch(1 0 0);
  background: var(--ink-2);
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar[data-p="Jacob"] { background: var(--p-jacob); }
.avatar[data-p="Charles"] { background: var(--p-charles); }
.avatar[data-p="Alyssa"] { background: var(--p-alyssa); }
.avatar[data-p="Jay"] { background: var(--p-jay); }
.avatar[data-p="Kaitlyn"] { background: var(--p-kaitlyn); }

/* Sign in */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--lane); }
.gate-box {
  width: min(380px, 100%); padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  display: grid; gap: 18px;
}
.gate-box h1 { font-size: 22px; letter-spacing: -0.01em; }
.gate-box p { color: var(--ink-2); }
.gate-mark { width: 36px; height: 36px; }
.code-input { height: 48px; font-size: 22px; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.gate .btn { height: 44px; }
.who-list { display: grid; gap: 8px; }
.who-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-card); background: var(--surface);
  text-align: left; font-weight: 600; font-size: 16px;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}
.who-btn:active { transform: scale(0.98); }
.who-btn small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) { .who-btn:hover { background: var(--lane); border-color: var(--ink-2); } }

/* App shell */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 28px; height: 28px; flex: none; }
.brand b { font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
/* Board switch: Sales and Marketing */
.boards { display: flex; gap: 2px; padding: 3px; margin-right: auto; background: var(--lane); border-radius: var(--r-ctl); }
.boards button {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, color 140ms ease;
}
.boards button:active { transform: scale(0.97); }
.boards button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.boards .n { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; opacity: 0.75; }
.boards.solo { padding: 0; background: transparent; }
.board-name { padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 600; font-size: 14px; }
@media (hover: hover) and (pointer: fine) { .boards button:not([aria-pressed="true"]):hover { color: var(--ink); } }
.me-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 550; }
.me-btn:active { transform: scale(0.97); }
.me-btn { transition: transform 140ms var(--ease-out), background-color 140ms ease; }
@media (hover: hover) and (pointer: fine) { .me-btn:hover { background: var(--lane); } }

.menu {
  position: fixed; inset: auto; top: 54px; right: 20px; margin: 0;
  min-width: 200px; padding: 6px;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lift);
  transform-origin: top right;
  opacity: 1; transform: scale(1);
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out), display 140ms allow-discrete, overlay 140ms allow-discrete;
}
.menu:not(:popover-open) { opacity: 0; transform: scale(0.96); }
@starting-style { .menu:popover-open { opacity: 0; transform: scale(0.96); } }
.menu p { padding: 6px 10px 8px; font-size: 13px; color: var(--ink-2); }
.menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
@media (hover: hover) and (pointer: fine) { .menu button:hover { background: var(--lane); } }

.filters { display: flex; gap: 6px; padding: 10px 20px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 550;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.chip:active { transform: scale(0.97); }
.chip .avatar { width: 20px; height: 20px; font-size: 9px; margin-left: -6px; }
.chip .n { font-variant-numeric: tabular-nums; font-weight: 600; opacity: 0.8; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
@media (hover: hover) and (pointer: fine) { .chip:not([aria-pressed="true"]):hover { color: var(--ink); border-color: var(--line-strong); } }

.tabs { display: none; }

/* Board */
.board {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 12px;
  padding: 16px 20px 20px; overflow-x: auto;
}
.col { display: flex; flex-direction: column; min-height: 0; background: var(--lane); border-radius: 12px; transition: box-shadow 140ms ease; }
.col.is-over { box-shadow: inset 0 0 0 2px var(--primary); }
.col-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 8px; }
.col-head h2 { font-size: 14px; font-weight: 650; }
.col-head .n { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.col-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.cards:not(:empty) + .empty { display: none; }
.empty { padding: 18px 10px; color: var(--ink-2); font-size: 14px; text-align: center; text-wrap: balance; }
.more { align-self: center; }

.card {
  display: grid; gap: 8px; padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: border-color 140ms ease, transform 160ms var(--ease-out);
}
.card:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .card:hover { border-color: var(--line-strong); } }
.card-title { font-size: 15px; font-weight: 550; line-height: 1.35; overflow-wrap: anywhere; }
.col[data-status="done"] .card-title { color: var(--ink-2); }
.card-meta { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.card-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
.card-who b { color: var(--ink); font-weight: 600; }
.card-bit { display: inline-flex; align-items: center; gap: 4px; flex: none; font-variant-numeric: tabular-nums; }
.card-bit svg { width: 14px; height: 14px; }
.card-bit.late { color: var(--danger); font-weight: 600; }
.tag-urgent {
  justify-self: start; padding: 1px 8px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); font-size: 12px; font-weight: 650;
}
.card-ghost { opacity: 0.35; box-shadow: none; }
.card-drag {
  position: fixed; left: 0; top: 0; margin: 0; z-index: var(--z-drag);
  pointer-events: none; box-shadow: var(--shadow-lift); border-color: var(--line-strong);
  transition: none; will-change: transform;
}
.card-landed { animation: land 200ms var(--ease-out); }
@keyframes land { from { transform: scale(1.03); } to { transform: scale(1); } }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* Composer */
.composer {
  display: grid; gap: 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--primary); border-radius: var(--r-card);
  box-shadow: 0 0 0 3px var(--primary-soft);
  animation: rise 180ms var(--ease-out);
}
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.composer .actions { display: flex; gap: 8px; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 4px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 550;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}
.pick button:active { transform: scale(0.97); }
.pick button[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 130px; }
.check { display: inline-flex; align-items: center; gap: 8px; height: 38px; font-weight: 550; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--danger); margin: 0; }

/* Ticket drawer */
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(460px, 100vw); height: 100dvh; max-height: none; max-width: none;
  padding: 0; border: 0; border-left: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
  transform: translateX(0);
  transition: transform 240ms var(--ease-drawer), display 240ms allow-discrete, overlay 240ms allow-discrete;
}
.drawer:not([open]) { transform: translateX(100%); transition-duration: 180ms; }
@starting-style { .drawer[open] { transform: translateX(100%); } }
.drawer::backdrop { background: oklch(0.2 0.01 150 / 0.28); transition: opacity 240ms ease, display 240ms allow-discrete, overlay 240ms allow-discrete; opacity: 1; }
.drawer:not([open])::backdrop { opacity: 0; }
@starting-style { .drawer[open]::backdrop { opacity: 0; } }
.dr { height: 100%; display: flex; flex-direction: column; }
.dr-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 0 20px; }
.dr-head span { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dr-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 20px; display: grid; gap: 18px; align-content: start; }
.dr-title {
  width: 100%; padding: 6px 8px; margin: 0 -8px; border: 1px solid transparent; border-radius: var(--r-ctl);
  background: transparent; resize: none; overflow: hidden;
  font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em;
  width: calc(100% + 16px);
}
.dr-title:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; gap: 2px; background: var(--lane); border-radius: var(--r-ctl); }
.seg button {
  height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms var(--ease-out);
}
.seg button:active { transform: scale(0.97); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.dr-opened { font-size: 13px; color: var(--ink-2); }
.talk { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.talk h3 { font-size: 14px; font-weight: 650; }
.talk ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.msg { display: grid; grid-template-columns: 24px 1fr; gap: 2px 10px; }
.msg .avatar { grid-row: span 2; margin-top: 1px; }
.msg-by { font-size: 13px; color: var(--ink-2); }
.msg-by b { color: var(--ink); font-weight: 600; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.evt { font-size: 13px; color: var(--ink-2); padding-left: 34px; }
.talk-none { font-size: 14px; color: var(--ink-2); }
.talk form { display: grid; gap: 8px; }
.talk form .btn { justify-self: end; }
.dr-foot { display: flex; align-items: center; gap: 8px; padding: 10px 20px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 14px; }
.dr-foot span { margin-right: auto; color: var(--ink-2); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 20px; z-index: var(--z-toast);
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: var(--r-ctl);
  background: var(--ink); color: var(--bg); font-weight: 550; font-size: 14px;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Phones: one column at a time, picked with tabs */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .me-btn span.me-name { display: none; }
  .me-btn { padding: 0 6px; }
  .brand b { display: none; }
  .brand:has(+ .boards:not(.solo)) { display: none; }
  .boards button { padding: 0 10px; }
  .boards .n { display: none; }
  .topbar .btn-primary { padding: 0 10px; }
  .menu { right: 14px; }
  .filters { padding: 8px 14px; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
  .tabs button {
    padding: 10px 2px 8px; border: 0; border-bottom: 2px solid transparent; background: transparent;
    color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap;
  }
  .tabs button .n { display: block; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
  .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
  .board { display: block; padding: 0; overflow: hidden; }
  .col { display: none; height: 100%; border-radius: 0; }
  .col-head { display: none; }
  .col-body { padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
  .board[data-active="todo"] .col[data-status="todo"],
  .board[data-active="doing"] .col[data-status="doing"],
  .board[data-active="waiting"] .col[data-status="waiting"],
  .board[data-active="done"] .col[data-status="done"] { display: flex; }
  .drawer { width: 100vw; border-left: 0; }
  .input, .textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .menu, #toast, .btn, .chip, .card, .icon-btn, .who-btn, .pick button, .seg button, .boards button { transition-duration: 1ms; }
  .btn:active, .chip:active, .card:active, .icon-btn:active, .who-btn:active, .pick button:active, .seg button:active, .me-btn:active, .boards button:active { transform: none; }
  .composer, .card-landed { animation: none; }
  .drawer:not([open]) { transform: none; opacity: 0; }
  @starting-style { .drawer[open] { transform: none; opacity: 0; } }
}
