/* =====================================================================
   Team Board — pm.withcolor.com
   ===================================================================== */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --text: #37352f;
  --text-soft: #787774;
  --text-faint: #9b9a97;
  --line: #e9e9e7;
  --line-soft: #f1f1ef;
  --hover: #f6f6f4;
  --accent: #2383e2;
  --code-bg: #f7f6f3;
  --code-ink: #eb5757;
  --danger-bg: #fbeceb;
  --danger-ink: #d44c47;
  --ok: #4dab6d;
  --warn: #d9a648;
  --shadow-card: 0 1px 2px rgba(15, 15, 15, .04), 0 0 0 1px rgba(15, 15, 15, .06);
  --shadow-card-hover: 0 2px 8px rgba(15, 15, 15, .10), 0 0 0 1px rgba(15, 15, 15, .08);
  --shadow-pop: 0 0 0 1px rgba(15, 15, 15, .05), 0 4px 12px rgba(15, 15, 15, .12), 0 12px 32px rgba(15, 15, 15, .10);
  --shadow-modal: 0 0 0 1px rgba(15, 15, 15, .05), 0 24px 60px rgba(15, 15, 15, .25);
  --overlay: rgba(15, 15, 15, .45);
  --radius: 8px;
  --name-col: 172px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171717; --surface: #202020; --card-bg: #2a2a2a;
    --text: #e6e5e2; --text-soft: #9b9a97; --text-faint: #6f6e69;
    --line: #343434; --line-soft: #2c2c2c; --hover: #2c2c2c;
    --accent: #4a9de8; --code-bg: #242424; --code-ink: #ef7470;
    --danger-bg: #3d2523; --danger-ink: #ef7470;
    --shadow-card: 0 1px 2px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.055);
    --shadow-card-hover: 0 2px 8px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.09);
    --shadow-pop: 0 0 0 1px rgba(255,255,255,.07), 0 4px 12px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
    --shadow-modal: 0 0 0 1px rgba(255,255,255,.07), 0 24px 60px rgba(0,0,0,.55);
    --overlay: rgba(0,0,0,.6);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[hidden] { display: none !important; }

/* ---------- Sign-in gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  z-index: 500;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}
.gate-logo { font-size: 34px; }
.gate-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.2px;
  margin: 10px 0 6px;
}
.gate-sub {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 22px;
}
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
}
.google-btn:hover { background: var(--hover); }
.google-btn:disabled { opacity: .6; cursor: default; }
.gate-error {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger-ink);
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 10px 12px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px 10px;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
  flex-shrink: 0;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.live-dot {
  font-size: 9px;
  color: var(--ok);
  transition: color .2s;
}
.live-dot.offline { color: var(--text-faint); }

.text-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-soft);
  padding: 4px 10px;
  cursor: pointer;
}
.text-btn:hover { background: var(--hover); color: var(--text); }

.save-status {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.save-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  transition: background .2s;
}
.save-status.saving .dot { background: var(--warn); }
.save-status.error .dot { background: var(--danger-ink); }

.user-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 99px;
  font: inherit;
  font-size: 12.5px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.user-chip:hover { background: var(--hover); color: var(--text); }

.text-btn:focus-visible, .user-chip:focus-visible, .google-btn:focus-visible,
.icon-btn:focus-visible, .card:focus-visible, .add-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Board ---------- */
.board-wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 32px 40px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;   /* own scroll container so headers below can stick */
}
.board { min-width: 1080px; }

.col-headers {
  display: grid;
  grid-template-columns: var(--name-col) repeat(4, minmax(210px, 1fr));
  gap: 12px;
  padding: 10px 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.col-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 2px;
}
.col-header .swatch { width: 8px; height: 8px; border-radius: 3px; }
.col-header .count { font-weight: 500; color: var(--text-faint); letter-spacing: 0; }

/* ---------- Pods ---------- */
.pod {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
  position: relative;
}
.pod::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--pod-color);
  opacity: .85;
}
.pod-label { display: flex; align-items: center; gap: 8px; padding: 10px 16px 0 20px; }
.pod-label .tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--pod-color);
  background: color-mix(in srgb, var(--pod-color) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--pod-color) 28%, var(--surface));
  padding: 2px 8px;
  border-radius: 99px;
}

.row {
  display: grid;
  grid-template-columns: var(--name-col) repeat(4, minmax(210px, 1fr));
  gap: 12px;
  padding: 10px 16px 10px 20px;
}
.row + .row { border-top: 1px solid var(--line-soft); }

.member { display: flex; align-items: center; gap: 10px; padding-top: 6px; align-self: start; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  background: var(--pod-color);
  flex-shrink: 0;
}
.member .name { font-size: 14px; font-weight: 600; text-transform: capitalize; }

/* ---------- Cells & cards ---------- */
.cell {
  border-radius: var(--radius);
  min-height: 64px;
  padding: 4px;
  transition: background .15s;
  display: flex;
  flex-direction: column;
}
.cell.drag-over { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.cards { display: flex; flex-direction: column; gap: 8px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: box-shadow .15s, transform .15s, opacity .15s;
}
.card:hover { box-shadow: var(--shadow-card-hover); }
.card.dragging { opacity: .45; transform: rotate(2deg); box-shadow: var(--shadow-pop); }
.card.just-changed { animation: flash 1.2s ease-out; }
@keyframes flash {
  from { box-shadow: 0 0 0 2px var(--accent); }
  to   { box-shadow: var(--shadow-card); }
}
.card-title { font-size: 13.5px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.card-title.untitled { color: var(--text-faint); }
.card-snippet {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card-snippet:empty { display: none; }

.add-card {
  margin-top: 6px;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-faint);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  padding: 5px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s;
}
.cell:hover .add-card, .cell.drag-over .add-card, .add-card:focus-visible { opacity: 1; }
.add-card:hover { background: var(--hover); color: var(--text-soft); }

@media (prefers-reduced-motion: reduce) {
  .card, .cell, .modal, .toast { transition: none; animation: none; }
}

/* ---------- Modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 72px 24px 40px;
  z-index: 100;
}
.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 780px;
  max-height: calc(100vh - 112px);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop {
  from { transform: translateY(10px) scale(.985); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-meta { display: flex; align-items: center; gap: 8px; }
.meta-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background-color: var(--surface);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  padding: 4px 24px 4px 10px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  text-transform: capitalize;
}
.meta-select:hover { background-color: var(--hover); }
.modal-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  border: none;
  background: none;
  border-radius: 6px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 15px;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger-ink); }
.icon-btn.armed, .icon-btn.armed:hover {
  width: auto;
  padding: 0 10px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 12.5px;
  font-weight: 600;
}

.remote-banner {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-size: 12.5px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.remote-banner button {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.modal-body { overflow-y: auto; padding: 34px 76px 80px; flex: 1; }

.doc-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.4px;
  line-height: 1.2;
  outline: none;
  margin-bottom: 6px;
}
.doc-title:empty::before { content: "Untitled"; color: var(--text-faint); opacity: .5; }
.doc-edited { font-size: 12px; color: var(--text-faint); margin-bottom: 18px; }

.editor {
  outline: none;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
  min-height: 220px;
  caret-color: var(--text);
}
.editor:empty::before,
.editor.show-hint::before {
  content: "Write something, or press '/' for commands…";
  color: var(--text-faint);
  opacity: .6;
  position: absolute;
  pointer-events: none;
}
.editor > * { margin-bottom: 2px; }
.editor p { min-height: 1.65em; }
.editor h1 { font-size: 26px; font-weight: 700; margin: 20px 0 4px; letter-spacing: -.3px; }
.editor h2 { font-size: 21px; font-weight: 700; margin: 16px 0 3px; letter-spacing: -.2px; }
.editor h3 { font-size: 17px; font-weight: 700; margin: 12px 0 2px; }
.editor ul, .editor ol { padding-left: 26px; }
.editor li { padding-left: 2px; }
.editor blockquote { border-left: 3px solid var(--text); padding: 2px 0 2px 14px; margin: 6px 0; }
.editor hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.editor pre {
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 8px 0;
}
.editor code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 85%;
  background: rgba(135, 131, 120, .15);
  color: var(--code-ink);
  border-radius: 4px;
  padding: 1.5px 5px;
}
.editor pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.editor a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-faint); cursor: pointer; }
.editor img { display: block; max-width: 100%; border-radius: 6px; margin: 6px 0; }
.editor img[data-pending] { opacity: .45; }
.editor.file-drag {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border-radius: 8px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---------- Floating format toolbar ---------- */
.fmt-bar {
  position: fixed;
  z-index: 300;
  display: none;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  padding: 3px;
  gap: 1px;
}
.fmt-bar.open { display: flex; }
.fmt-btn {
  border: none;
  background: none;
  border-radius: 5px;
  min-width: 28px; height: 28px;
  padding: 0 7px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fmt-btn:hover { background: var(--hover); }
.fmt-btn.active { color: var(--accent); }
.fmt-btn b { font-weight: 700; }
.fmt-btn i { font-style: italic; }
.fmt-btn u { text-decoration: underline; }
.fmt-btn s { text-decoration: line-through; }
.fmt-btn.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.fmt-sep { width: 1px; background: var(--line-soft); margin: 4px 3px; }

/* ---------- Slash menu ---------- */
.slash-menu {
  position: fixed;
  z-index: 300;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  width: 260px;
  max-height: 320px;
  overflow-y: auto;
}
.slash-menu.open { display: flex; }
.slash-menu .group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 6px 10px 4px;
}
.slash-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.slash-item.selected { background: var(--hover); }
.slash-item .glyph {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text);
  flex-shrink: 0;
  font-family: Georgia, serif;
}
.slash-item .label { font-size: 13.5px; font-weight: 500; }
.slash-item .desc { font-size: 11.5px; color: var(--text-faint); }
.slash-empty { padding: 10px; font-size: 13px; color: var(--text-faint); }

/* ---------- Link popover ---------- */
.link-pop {
  position: fixed;
  z-index: 310;
  display: none;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
}
.link-pop.open { display: block; }
.link-pop input {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  width: 240px;
  outline: none;
}
.link-pop input:focus { border-color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 400;
  max-width: min(90vw, 560px);
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast-action {
  margin-left: 12px;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

::selection { background: rgba(35, 131, 226, .25); }
