:root {
  --brand: #0070f0;
  --brand-soft: #e6f1fe;
  --ink: #1d1c1f;
  --muted: #6b6a70;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --field: #ffffff;
  --line: #e3e5e9;
  --hover: #f0f2f5;
  --danger: #c0392b;
  --thanks: #e8f7ee;
  --problem: #fdecee;
  --idea: #e6f1fe;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 2px 8px rgba(20, 20, 30, 0.04);
  --pop-shadow: 0 8px 28px rgba(20, 20, 30, 0.16);
  --radius: 12px;
  --control: 36px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-soft: #0f2744;
    --ink: #ececf0;
    --muted: #9a99a2;
    --bg: #111114;
    --surface: #1b1b20;
    --field: #232329;
    --line: #2e2e36;
    --hover: #26262d;
    --danger: #ff8a7e;
    --thanks: #15271d;
    --problem: #2b191b;
    --idea: #122237;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --pop-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.emoji { margin-right: 6px; }

/* ---------- Controls ---------- */

.btn, .chip, .picker {
  font: inherit;
  font-size: 14px;
  height: var(--control);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover, .chip:hover, .picker:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.ghost.danger:hover { color: var(--danger); }
.btn.big { height: 44px; font-size: 16px; padding: 0 20px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.6;
  flex: none;
}

.picker { width: 100%; background: var(--field); padding: 0 12px 0 8px; }
.picker .placeholder { color: var(--muted); padding-left: 2px; }
.picker .chevron { margin-left: auto; }
.picker.compact { width: auto; height: 28px; padding: 0 8px 0 4px; font-size: 13px; background: none; border-color: transparent; color: var(--muted); }
.picker.compact:hover { background: var(--hover); color: var(--ink); }
.picker.compact:has(.avatar) { color: var(--ink); }

.icon-btn {
  font: inherit;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

input {
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: var(--control);
  padding: 0 10px;
  width: 100%;
}
input::placeholder { color: var(--muted); }
input:focus, .picker:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand-soft); outline-offset: 0; border-color: var(--brand); }

.field { position: relative; display: block; }
.field input { padding-right: 56px; }
.counter { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); pointer-events: none; }
.counter.full { color: var(--danger); }

/* ---------- Menu ---------- */

.menu {
  position: fixed;
  z-index: 40;
  max-height: min(360px, 70vh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--pop-shadow);
  padding: 4px;
  display: grid;
  gap: 1px;
}
.menu-item {
  font: inherit;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 4px 10px 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.on { background: var(--brand-soft); }
.menu-item.muted { color: var(--muted); padding-left: 10px; }
.menu-item:not(:has(.avatar)) { padding-left: 10px; }
.menu-title { font-size: 12px; color: var(--muted); padding: 8px 10px 4px; }
.menu-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 2px 10px 2px 6px; font-size: 14px; }
.presence-list { min-width: 240px; }
.presence-list .away .menu-row { color: var(--muted); }
.presence-list .away .avatar { opacity: 0.45; }
.menu-label { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Avatars and people ---------- */

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  overflow: hidden;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.small { width: 22px; height: 22px; font-size: 9px; }
.avatar.tiny { width: 20px; height: 20px; font-size: 8px; }
.avatar.large { width: 36px; height: 36px; font-size: 13px; }
.avatar.more { background: var(--muted); }
.person { display: inline-flex; align-items: center; gap: 6px; }
.person.strong { font-weight: 600; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.host-tools { display: flex; gap: 4px; flex: none; }
.host-tools .btn { height: 32px; padding: 0 8px 0 10px; gap: 6px; }
.people { display: flex; align-items: center; flex: none; }
.presence {
  display: flex;
  align-items: center;
  height: var(--control);
  padding: 0 0 0 6px;
  margin-right: -10px; /* the stack of others tucks under your own name button */
  border: 0;
  background: none;
  cursor: pointer;
}
.presence .avatar { margin-left: -8px; border: 2px solid var(--surface); box-sizing: content-box; }
.presence:hover .avatar { border-color: var(--hover); }
.chip { position: relative; }
.chip { border-radius: 999px; padding: 0 12px 0 6px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .brand { font-size: 14px; }
  .chip { padding: 0 6px; font-size: 0; gap: 0; }
}

/* ---------- Landing ---------- */

.landing { display: grid; place-items: center; padding: 64px 16px; }
.landing-card {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  justify-items: start;
}
.landing-card h1 { font-size: 26px; }

/* ---------- Board layout ---------- */

.board {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding: 20px;
  max-width: 1500px;
  margin: 0 auto;
}
.main { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 1000px) { .board { grid-template-columns: 1fr; padding: 16px; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }

/* Composer */
.composer { display: grid; gap: 8px; }
.composer > .tabs { margin-bottom: 8px; }
.composer > .btn { justify-self: start; margin-top: 8px; padding: 0 20px; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; background: var(--bg); padding: 3px; border-radius: 10px; }
.tab { font: inherit; font-size: 13px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 7px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.mine { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.mine:empty { display: none; }
.mine-head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.mine-card { position: relative; border-radius: 10px; padding: 8px 32px 8px 10px; font-size: 14px; }
.mine-card .icon-btn { position: absolute; top: 4px; right: 4px; }

/* Cards: shared content */
.kind-thanks .card, .mine-card.kind-thanks, .stack-card.kind-thanks { background: var(--thanks); }
.kind-problem .card, .mine-card.kind-problem, .stack-card.kind-problem { background: var(--problem); }
.kind-idea .card, .mine-card.kind-idea, .stack-card.kind-idea { background: var(--idea); }

.card-body { display: grid; gap: 4px; overflow-wrap: anywhere; }
.prep { color: var(--muted); font-weight: 400; }
.phrase { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.phrase-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; }
.phrase-row .field, .phrase-row .picker { min-width: 0; }
.solution { display: flex; gap: 6px; font-weight: 600; }
.arrow { color: var(--muted); font-weight: 400; }
.card-body.large { font-size: 18px; gap: 8px; }
.card-body.large .avatar.small { width: 26px; height: 26px; }

/* Stack */
.stack { display: grid; gap: 10px; }
.stack-head { display: flex; align-items: baseline; gap: 10px; padding: 0 2px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stack-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  gap: 14px;
  max-width: 720px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.stack-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.kind-label { font-weight: 600; color: var(--ink); }
.by { display: inline-flex; align-items: center; gap: 6px; }
.stack-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.edit-fields { display: grid; gap: 8px; }

/* Columns */
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } }
.column { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.column-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 0; }
.column-count { color: var(--muted); font-size: 13px; }
.cards { display: grid; gap: 8px; }
.empty { color: var(--muted); font-size: 13px; padding: 2px 4px 4px; }

.card { position: relative; border-radius: 10px; padding: 10px 12px 8px; display: grid; gap: 10px; }
.card-foot { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 13px; }
.reporters { display: inline-flex; gap: 2px; }
.owner { color: var(--ink); }

.card-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 2px;
}
@media (hover: hover) {
  .card-actions { opacity: 0; transition: opacity 0.12s; }
  .card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
}

.plus {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  height: 26px;
  min-width: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
button.plus:hover { border-color: var(--brand); color: var(--brand); }
.plus.on, button.plus.on:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.plus.mine { cursor: default; opacity: 0.8; }

/* ---------- Picker dialog ---------- */

.overlay { position: fixed; inset: 0; background: rgba(10, 10, 15, 0.5); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  gap: 12px;
  box-shadow: var(--pop-shadow);
}
.dialog h2 { font-size: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head .icon-btn { font-size: 20px; width: 32px; height: 32px; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.picker-list .btn { height: auto; min-height: 48px; padding: 6px 10px 6px 6px; gap: 10px; }
.picker-list .btn.me { border-color: var(--brand); background: var(--brand-soft); }
.picker-list .pick-name { flex: 1; min-width: 0; text-align: left; white-space: normal; }
.picker-list .btn:disabled { opacity: 0.55; cursor: default; }
.picker-list .btn:disabled:hover { background: var(--surface); }
.picker-list .taken { display: block; font-size: 11px; color: var(--muted); }

/* ---------- Messages ---------- */

.banner, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  z-index: 30;
  max-width: calc(100% - 32px);
}
.banner { top: 68px; padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.toast { bottom: 20px; padding: 10px 16px; border-radius: 10px; }
