:root {
  --ink: #172b4d;
  --muted: #44546f;
  --faint: #626f86;
  --line: rgba(9, 30, 66, 0.13);
  --list: #f1f2f4;
  --card: #fff;
  --bar: #1d2125;
  --blue: #0c66e4;
  --blue-dark: #0055cc;
  --danger: #ae2e24;
  --shadow: 0 1px 1px rgba(9, 30, 66, 0.25), 0 0 1px rgba(9, 30, 66, 0.31);
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --board: #0079bf;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #f1f2f4;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

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

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 16px;
  background: var(--bar);
  color: #fff;
}
.topbar-spacer, .board-bar-spacer { flex: 1; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 18px;
}
.brand.dark { color: var(--ink); }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--blue);
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 6px 5px;
  align-items: end;
}
.brand-mark span { display: block; background: #fff; border-radius: 1px; height: 100%; }
.brand-mark span:nth-child(2) { height: 70%; }
.brand-mark span:nth-child(3) { height: 45%; }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px 4px 4px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255, 255, 255, 0.08); }
.user-name { font-size: 14px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-card {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(9, 30, 66, 0.28);
  padding: 14px;
  z-index: 30;
  display: grid;
  gap: 8px;
}
.menu-card strong { font-size: 14px; }
.menu-email { color: var(--faint); font-size: 12px; word-break: break-all; }
.role-pill {
  justify-self: start;
  background: #e9f2ff;
  color: #0c66e4;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: hsl(var(--hue), 52%, 38%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  object-fit: cover;
  border: 2px solid #1d2125;
  flex: 0 0 auto;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; border-width: 0; }
.member-stack { display: flex; align-items: center; }
.member-stack .avatar { margin-left: -6px; }
.member-stack .avatar:first-child { margin-left: 0; }

.btn {
  height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}
.btn:hover { background: var(--blue-dark); }
.btn.secondary { background: rgba(9, 30, 66, 0.06); color: var(--ink); }
.btn.secondary:hover { background: rgba(9, 30, 66, 0.12); }
.btn.danger { background: #ffebe6; color: var(--danger); }
.btn.danger:hover { background: #ffd5d2; }
.btn.wide { width: 100%; }
.btn.small { height: 32px; padding: 0 10px; font-size: 14px; }

.icon-btn, .quiet-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
}
.icon-btn:hover, .quiet-btn:hover { background: rgba(255, 255, 255, 0.18); }
.icon-btn.on-light { color: var(--muted); font-size: 24px; }
.icon-btn.on-light:hover { background: rgba(9, 30, 66, 0.08); }
.quiet-btn { color: #fff; font-weight: 800; letter-spacing: 0.08em; }

.alert {
  background: #ffebe6;
  color: #ae2e24;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.75fr);
  background: #fff;
}
.login-stage {
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(255, 255, 255, 0.2), transparent 55%),
    #0079bf;
  color: #fff;
  padding: 48px 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
}
.stage-kicker {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}
.stage-copy h2 {
  margin: 0;
  max-width: 520px;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}
.stage-board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 0;
}
.login-stage .list { width: 240px; flex-basis: 240px; }
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 40px;
}
.login-panel h1 { margin: 22px 0 8px; font-size: 32px; letter-spacing: -0.04em; }
.lede { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.stack-form, .modal label, .create-modal label { display: grid; gap: 6px; }
.stack-form { gap: 14px; }
.stack-form span, .modal label span, .field-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
input[type="email"], input[type="password"], input[type="text"], input[type="search"], input[type="date"], textarea, select {
  width: 100%;
  border: 2px solid #dfe1e6;
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
.plain-title, .plain-area, .modal textarea { resize: none; }

.home { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.home-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.home-head p, .empty-copy { margin: 4px 0 0; color: var(--muted); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 16px; }
.board-tile, .create-tile {
  height: 120px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  text-align: left;
}
.board-tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 14px;
  text-decoration: none;
  color: #fff;
  background: var(--bg);
  box-shadow: var(--shadow);
}
.board-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 20%, rgba(0, 0, 0, 0.38));
}
.board-tile span, .board-tile small { position: relative; z-index: 1; }
.board-tile span {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.board-tile small { font-size: 12px; font-weight: 700; opacity: 0.9; }
.board-tile:hover { transform: translateY(-2px); }
.create-tile {
  border: none;
  background: #e4e6ea;
  color: var(--ink);
  font-weight: 800;
  padding: 14px;
}
.create-tile:hover { background: #d5d9e0; }
.empty-copy { margin-top: 18px; }

.board-page {
  height: 100vh;
  display: grid;
  grid-template-rows: 48px auto minmax(0, 1fr);
  background: var(--board);
  overflow: hidden;
}
.board-page .topbar { box-shadow: inset 0 -1px rgba(255, 255, 255, 0.06); }
.board-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 12px;
  color: #fff;
  flex-wrap: wrap;
}
input.board-name {
  width: min(280px, 32vw);
  flex: 0 1 280px;
  background: transparent;
  border: 2px solid transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  border-radius: 8px;
  padding: 6px 8px;
}
input.board-name:hover, input.board-name:focus { background: rgba(255, 255, 255, 0.18); border-color: transparent; }
.private-pill, .invite-btn, .board-search {
  height: 32px;
  border-radius: 6px;
  border: none;
}
.private-pill {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 13px;
  font-weight: 800;
}
.invite-btn {
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
.invite-btn:hover { background: #e9f2ff; }
input.board-search {
  width: 200px;
  flex: 0 0 200px;
  height: 32px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  padding: 0 10px;
  border: 2px solid transparent;
}
input.board-search::placeholder { color: rgba(255, 255, 255, 0.82); }
input.board-search:focus { background: #fff; color: var(--ink); border-color: #fff; }
.board-canvas {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 16px 16px;
  height: 100%;
}
.list {
  width: 272px;
  flex: 0 0 272px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--list);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list.skeleton { height: 220px; background: rgba(255, 255, 255, 0.28); box-shadow: none; }
.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 12px;
  background: var(--status);
  color: #fff;
  cursor: grab;
}
.list-head h2, .list-head h3 { color: #fff; }
.list-head h2, .list-head h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.22);
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.list-cards {
  overflow: auto;
  padding: 8px 8px 0;
  min-height: 8px;
}
.list-compose { padding: 8px; }
.add-card, .add-list {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px;
}
.add-card:hover { background: rgba(9, 30, 66, 0.08); color: var(--ink); }
.add-list-wrap { flex: 0 0 272px; width: 272px; }
.add-list {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
  min-height: 48px;
  padding: 12px 14px;
}
.add-list:hover { background: rgba(255, 255, 255, 0.34); }
.composer {
  background: var(--list);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 8px;
}
.list .composer { background: transparent; padding: 0; }
.composer textarea { min-height: 64px; background: #fff; }
.composer-actions { display: flex; gap: 8px; align-items: center; }
.text-btn { border: none; background: transparent; color: var(--muted); font-weight: 700; height: 32px; }

.card {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 8px 10px 8px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid transparent;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(9, 30, 66, 0.18);
  text-align: left;
  cursor: pointer;
}
.card:hover { border-color: var(--blue); }
.card-title, .card h4.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.label-pill {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--c);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.meta-avatars { margin-left: auto; display: flex; }
.meta-avatars .avatar { margin-left: -6px; border-color: #fff; }
.meta-avatars .avatar:first-child { margin-left: 0; }
.due, .meta-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  background: #e4e6ea;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.due.soon { background: #f8e6a0; color: #7f5f01; }
.due.overdue { background: #ffd5d2; color: #ae2e24; }
.due.done { background: #dcfff1; color: #216e4e; }
.card.is-placeholder { opacity: 0.45; }
.card.is-chosen { box-shadow: 0 12px 28px rgba(9, 30, 66, 0.28); }
.list.is-chosen { opacity: 0.85; }

.overlay { display: none; }
.overlay.is-open {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 32, 0.64);
  place-items: start center;
  padding: 48px 16px;
  overflow: auto;
}
.modal {
  width: min(860px, 100%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  padding: 18px 18px 24px;
}
.create-modal { width: min(440px, 100%); display: grid; gap: 14px; }
.modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2, .modal h2 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 18px; margin-top: 8px; }
.modal-kicker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--status);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.plain-title, .plain-area {
  width: 100%;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
}
.plain-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; min-height: 44px; }
.plain-area { background: #f7f8f9; min-height: 96px; }
.plain-title:focus, .plain-area:focus { border-color: var(--blue); background: #fff; }
.side-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: #f1f2f4;
  border-radius: 8px;
  min-height: 36px;
  padding: 8px 10px;
  font-weight: 700;
  margin-bottom: 8px;
}
.side-btn:hover { background: #e4e6ea; }
.section-label { margin: 18px 0 8px; font-size: 14px; }
.comment { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.comment p, .activity-line {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}
.comment p {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  white-space: pre-wrap;
}
.activity-line { color: var(--muted); padding-top: 6px; }
.comment-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--faint); font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.linkish { border: none; background: none; color: var(--danger); font-weight: 700; padding: 0; }

.popover {
  position: fixed;
  z-index: 60;
  width: 280px;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(9, 30, 66, 0.28);
  padding: 12px;
}
.popover h3 { margin: 0 0 8px; font-size: 14px; }
.popover .swatches { margin: 8px 0; }
.menu-row, .person-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px;
  text-align: left;
}
.menu-row:hover, .person-row:hover { background: #f1f2f4; }
.person-row small { display: block; color: var(--faint); font-weight: 600; }
.person-row span { display: block; font-weight: 700; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-weight: 700; font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 36px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--c);
  padding: 0;
}
.swatch.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.member-block { display: grid; gap: 6px; margin-top: 8px; }
.search-results { display: grid; gap: 4px; max-height: 240px; overflow: auto; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(12px);
  background: var(--bar);
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 70;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.toast.is-on { display: flex; }
.toast button { border: none; background: #fff; color: var(--ink); border-radius: 6px; height: 28px; padding: 0 8px; font-weight: 800; }

.error-page { width: min(640px, calc(100% - 32px)); margin: 64px auto; }
.error-page h1 { margin-bottom: 8px; }
.error-page p { color: var(--muted); }

.board-canvas::-webkit-scrollbar, .list-cards::-webkit-scrollbar { height: 12px; width: 10px; }
.board-canvas::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.45); border-radius: 99px; }
.list-cards::-webkit-scrollbar-thumb { background: rgba(9, 30, 66, 0.28); border-radius: 99px; }

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-stage { display: none; }
  .login-panel { min-height: 100vh; }
  .user-name { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
  input.board-name { width: min(180px, 42vw); flex-basis: 140px; }
  input.board-search { width: 120px; flex-basis: 120px; }
  .private-pill { display: none; }
  .home-head { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
