*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { height: 100vh; height: 100dvh; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s, color 0.4s;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
kbd {
  font-family: var(--f-mono); font-size: 11px; padding: 1px 6px;
  border: 1.5px solid currentColor; border-radius: 4px; opacity: 0.6;
}
::selection { background: var(--acid); color: #0e0e10; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; white-space: nowrap;
  font-family: var(--f-mono); font-weight: 600; font-size: 13px; letter-spacing: 0.04em;
  border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-hard-sm);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn-acid { background: var(--acid); color: #0e0e10; border-color: #0e0e10; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ghost { box-shadow: none; border-color: transparent; background: transparent; }
.btn-ghost:hover { border-color: var(--line); }

.avatar {
  --c: var(--acid);
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--f-mono); font-weight: 600; font-size: 12px;
  background: var(--c); color: #0e0e10;
  border: var(--bw) solid var(--line);
  flex: none;
}
.avatar-sm { width: 22px; height: 22px; font-size: 9px; border-width: 1.5px; }

/* ===== Top bar ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: 28px;
  padding: env(safe-area-inset-top, 0px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  border-bottom: var(--bw) solid var(--line);
  transition: background 0.4s;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-mark { position: relative; width: 28px; height: 28px; }
.logo-mark i { position: absolute; width: 16px; height: 16px; background: var(--ink); }
.logo-mark i:first-child { left: 0; bottom: 0; }
.logo-mark i:last-child { right: 0; top: 0; background: var(--hot); border: 2px solid var(--ink); }
.logo-word { font-family: var(--f-display); font-style: italic; font-size: 34px; line-height: 1; letter-spacing: -0.02em; }
.logo-word em { color: var(--hot); font-style: normal; }
.logo-sticker {
  font-family: var(--f-marker); font-size: 12px; padding: 1px 8px;
  background: var(--cyan); color: #0e0e10; border: 1.5px solid #0e0e10;
  transform: rotate(-8deg) translateY(-8px); border-radius: 3px;
}

.tabs { display: flex; gap: 4px; }
.tab {
  font-family: var(--f-mono); font-size: 13px; font-weight: 500; letter-spacing: 0.06em;
  background: none; border: 0; padding: 6px 10px; border-radius: 4px; color: var(--ink-2); white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--paper-2); }
.tab.is-active { color: #0e0e10; background: var(--acid); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.presence { display: flex; }
.presence .avatar { margin-left: -8px; }
.avatar-me { --c: var(--hot); }

/* ===== Filter bar ===== */
.filterbar {
  position: fixed; top: var(--topbar-h); left: 0; right: 0; height: var(--filterbar-h); z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 0 max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1.5px dashed var(--line);
}
.seg { display: flex; height: 34px; border: var(--bw) solid var(--line); border-radius: var(--r-sm); overflow: hidden; flex: none; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--f-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
  padding: 0 12px; border: 0; background: var(--card);
}
.seg-btn:not(.is-active):hover { background: var(--paper-2); }
.seg-btn:focus-visible { outline: 2px solid var(--hot); outline-offset: -4px; }
.seg-btn + .seg-btn { border-left: var(--bw) solid var(--line); }
.seg-btn.is-active { background: var(--ink); color: var(--paper); }

/* chips scroll sideways: board.js wraps #chips in .chips-wrap and toggles can-l / can-r
   so the edges fade and little nudge arrows appear only where there's more to see */
.chips-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 5px 4px 6px; scroll-padding-inline: 40px; }
.chips::-webkit-scrollbar { display: none; }
.chips-wrap.can-r .chips { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent calc(100% - 6px)); mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent calc(100% - 6px)); }
.chips-wrap.can-l .chips { -webkit-mask-image: linear-gradient(to right, transparent 6px, #000 56px); mask-image: linear-gradient(to right, transparent 6px, #000 56px); }
.chips-wrap.can-l.can-r .chips { -webkit-mask-image: linear-gradient(to right, transparent 6px, #000 56px, #000 calc(100% - 56px), transparent calc(100% - 6px)); mask-image: linear-gradient(to right, transparent 6px, #000 56px, #000 calc(100% - 56px), transparent calc(100% - 6px)); }
.chips-nudge {
  position: absolute; top: 50%; z-index: 1;
  width: 22px; height: 22px; padding: 0; margin-top: -11px;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 15px; font-weight: 700; line-height: 1;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 50%;
  opacity: 0; pointer-events: none; transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s var(--ease-spring);
}
.chips-nudge-l { left: -2px; }
.chips-nudge-r { right: -2px; }
.chips-wrap.can-l .chips-nudge-l, .chips-wrap.can-r .chips-nudge-r { opacity: 0.85; pointer-events: auto; transform: none; }
.chips-nudge:hover { opacity: 1; background: var(--acid); color: #0e0e10; }
.chips-wrap.can-r .chips-nudge-r { animation: nudge-r 2.4s ease-in-out 1.2s 2; }
@keyframes nudge-r { 0%, 100% { translate: 0 0; } 50% { translate: 3px 0; } }
@media (hover: none) { .chips-nudge { display: none; } }
@media (prefers-reduced-motion: reduce) { .chips-wrap.can-r .chips-nudge-r { animation: none; } }
.chip {
  --c: var(--acid);
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 12px; font-weight: 500;
  padding: 5px 11px 5px 8px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line); background: var(--card);
  transition: transform 0.15s var(--ease-spring), background 0.2s;
}
.chip:hover { transform: translateY(-2px) rotate(-1deg); }
.chip:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 1.5px solid #0e0e10; }
.chip .n { opacity: 0.55; }
.chip.is-active { background: var(--c); color: #0e0e10; box-shadow: var(--shadow-hard-sm); }

.search {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; width: 220px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--card);
}
.search input { border: 0; outline: 0; background: none; width: 100%; font-family: var(--f-mono); font-size: 13px; }
.search:focus-within { box-shadow: var(--shadow-hard-sm); }

/* ===== Bottom toolbar ===== */
.toolbar {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); z-index: 45;
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: var(--card); border: var(--bw) solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-hard);
}
.tool {
  position: relative; width: 44px; height: 44px; border-radius: 10px; border: 0; background: none;
  display: grid; place-items: center; font-size: 18px;
}
.tool small { position: absolute; right: 4px; bottom: 2px; font-family: var(--f-mono); font-size: 9px; opacity: 0.5; }
.tool:hover { background: var(--paper-2); }
.tool.is-active { background: var(--ink); color: var(--paper); }
.tool-sep { width: 1.5px; height: 28px; background: var(--line); opacity: 0.25; margin: 0 4px; }
.tool-postit { width: 58px; }
.postit-icon {
  width: 26px; height: 26px; background: var(--pi-yellow); border: 1.5px solid #0e0e10;
  transform: rotate(-6deg); box-shadow: 2px 2px 0 #0e0e10;
  transition: transform 0.2s var(--ease-spring);
}
.tool-postit:hover .postit-icon { transform: rotate(4deg) scale(1.1); }
.tool-postit.is-active .postit-icon { box-shadow: 2px 2px 0 var(--acid); }
.tool-hint {
  font-family: var(--f-mono); font-size: 11px; padding: 0 10px 0 6px; max-width: 0; overflow: hidden;
  white-space: nowrap; opacity: 0; transition: max-width 0.3s var(--ease-out), opacity 0.3s;
}
.toolbar.show-hint .tool-hint { max-width: 260px; opacity: 1; }

/* ===== Zoom HUD ===== */
.zoom-hud {
  position: fixed; right: 20px; bottom: calc(var(--nav-h) + 20px); z-index: 45;
  display: flex; border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: var(--card); box-shadow: var(--shadow-hard-sm); overflow: hidden;
}
.zoom-hud button { border: 0; background: none; height: 34px; min-width: 34px; font-family: var(--f-mono); font-size: 13px; }
.zoom-hud button:hover { background: var(--acid); color: #0e0e10; }
#zoom-label { min-width: 58px; border-inline: 1.5px solid var(--line); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 96px); z-index: 500;
  max-width: calc(100vw - 32px); text-align: center;
  transform: translate(-50%, 20px) rotate(-1deg); opacity: 0; pointer-events: none;
  font-family: var(--f-mono); font-size: 13px; font-weight: 600;
  padding: 10px 16px; background: var(--ink); color: var(--paper);
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--hot);
  transition: transform 0.35s var(--ease-spring), opacity 0.25s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

/* "coming soon" tab view */
.soon {
  position: fixed; inset: calc(var(--topbar-h) + var(--filterbar-h)) 0 0 0; z-index: 30;
  display: grid; place-items: center; background: var(--paper); text-align: center;
}
.soon h2 { font-family: var(--f-display); font-style: italic; font-weight: 400; font-size: 72px; margin: 0; }
.soon p { font-family: var(--f-mono); }


/* ===== v2 controls ===== */
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: var(--bw) solid var(--line); background: var(--card);
  font-family: var(--f-mono); font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-hard-sm);
}
.icon-btn:hover { background: var(--acid); color: #0e0e10; }
.needs-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.03em;
  height: 34px; padding: 0 10px; border-radius: var(--r-sm); white-space: nowrap;
  border: 1.5px dashed var(--line); background: transparent;
}
.needs-btn .n { background: var(--ink); color: var(--paper); padding: 0 5px; border-radius: 3px; font-size: 10.5px; }
.needs-btn:hover { border-style: solid; }
.needs-btn.is-active { background: var(--hot); color: #0e0e10; border: 1.5px solid #0e0e10; box-shadow: var(--shadow-hard-sm); }
.needs-btn.is-active .n { background: #0e0e10; color: var(--hot); }
.search-n { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.search-n:empty { display: none; }
.kbd-btn {
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600; padding: 2px 6px;
  border: 1.5px solid var(--line); border-radius: 4px; background: var(--paper-2); flex: none;
}
.kbd-btn:hover { background: var(--acid); color: #0e0e10; }

/* list view hides canvas-only chrome */
body[data-view="list"] .toolbar,
body[data-view="list"] .zoom-hud,
body[data-view="list"] #minimap-slot { display: none !important; }


/* ===== "you" tag: your own ideas + stickies say you, loudly ===== */
.you-tag {
  display: inline-flex; align-items: center; gap: 3px; padding: 0 7px 0 6px; line-height: 1.5;
  font-family: var(--f-mono); font-size: 0.86em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: #0e0e10; background: var(--hot); border: 1.5px solid #0e0e10; border-radius: 4px;
  box-shadow: 2px 2px 0 #0e0e10; transform: rotate(-3deg); white-space: nowrap;
}
.you-tag::before { content: "★"; font-size: 0.85em; }
.name-tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =====================================================================
   v4 responsive shell
   phone <= 700 · tablet 701-1024 · desktop >= 1025 (see ARCHITECTURE.md)
   ===================================================================== */
.fb-scroll { display: contents; }
.m-only { display: none; }
.bnav { display: none; }

/* ----- narrower desktops: all four tabs stay, everything just gets tighter ----- */
@media (max-width: 1280px) {
  .topbar { gap: 18px; }
  .tabs { gap: 2px; }
  .tab { font-size: 12px; letter-spacing: 0.03em; padding: 6px 8px; }
  .topbar-right { gap: 10px; }
  .filterbar { gap: 10px; }
  .seg-btn { padding: 0 9px; font-size: 11.5px; letter-spacing: 0.03em; }
  .search { width: 184px; }
}
@media (max-width: 1180px) {
  .logo-sticker { display: none; }
  #presence { display: none; }
  .needs-btn { gap: 5px; padding: 0 9px; }
  .search { width: 160px; }
}

/* ----- phone + tablet: the bottom nav replaces the top tabs ----- */
@media (max-width: 1024px) {
  .tabs { display: none; }
  .topbar { gap: 14px; }
  .bnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
    height: var(--nav-h);
    padding: 0 max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px));
    display: grid; grid-template-columns: 1fr 1fr 68px 1fr 1fr; align-items: stretch;
    background: var(--paper);
    border-top: var(--bw) solid var(--line);
    box-shadow: 0 -6px 18px -12px rgba(14, 14, 16, 0.35);
  }
  .bnav-tab {
    position: relative; min-width: 0; min-height: 44px; padding: 6px 2px 4px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: 0; background: none; color: var(--ink-2);
    font-family: var(--f-mono); font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: uppercase;
  }
  .bnav-tab:hover, .bnav-tab.is-active { background: none; color: var(--ink); }
  .bnav-ic {
    width: 46px; height: 28px; padding: 3px 12px; flex: none; overflow: visible;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    border: 1.5px solid transparent; border-radius: var(--r-pill);
    transition: background 0.2s, transform 0.25s var(--ease-spring);
  }
  .bnav-tab.is-active .bnav-ic { background: var(--acid); color: #0e0e10; border-color: #0e0e10; box-shadow: 2px 2px 0 #0e0e10; transform: rotate(-3deg); }
  .bnav-tab:active .bnav-ic { transform: scale(0.92); }
  .bnav-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
  .bnav-tab:focus-visible { outline-offset: -4px !important; border-radius: 10px; }

  /* raised centre "+": a fresh post-it to pin an idea */
  .bnav-add {
    align-self: start; justify-self: center; margin-top: -18px;
    width: 58px; height: 58px; padding: 0; display: grid; place-items: center;
    background: var(--acid); color: #0e0e10;
    border: var(--bw) solid #0e0e10; border-radius: 6px;
    box-shadow: 4px 4px 0 #0e0e10; transform: rotate(-4deg);
    transition: transform 0.2s var(--ease-spring), box-shadow 0.15s;
  }
  .bnav-add-pi { font-family: var(--f-mono); font-size: 32px; font-weight: 600; line-height: 1; margin-top: -2px; }
  .bnav-add:hover { transform: rotate(2deg) translateY(-2px); }
  .bnav-add:active { transform: rotate(-4deg) translate(3px, 3px); box-shadow: 1px 1px 0 #0e0e10; }

  /* the board's floating chrome sits above the nav */
  .toolbar { bottom: calc(var(--nav-h) + 14px); }
  .zoom-hud { bottom: calc(var(--nav-h) + 14px); right: max(14px, env(safe-area-inset-right, 0px)); }
  .toast { bottom: calc(var(--nav-h) + 76px); }
  /* search lives behind ⌕ in the top bar (the jump-anywhere palette), so the chips get the room */
  .search { display: none; }
  .m-only { display: inline-grid; place-items: center; }
}
@media (max-width: 900px) and (min-width: 701px) {
  #presence { display: none; }
}

/* ----- phone ----- */
@media (max-width: 700px) {
  .topbar { gap: 8px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .logo { gap: 7px; }
  .logo-mark { width: 22px; height: 22px; }
  .logo-mark i { width: 13px; height: 13px; }
  .logo-word { font-size: 28px; }
  .topbar-right { gap: 10px; }
  #share-btn, #help-btn, #presence { display: none; }   /* the nav's "+" pins; shortcuts live in ⌘K */
  .topbar .icon-btn, .topbar .avatar { width: 40px; height: 40px; font-size: 16px; }
  .avatar-me { font-size: 13px; }

  /* filter bar: one row that scrolls sideways as a whole, with fading edges */
  .filterbar { padding: 0; gap: 0; }
  .fb-scroll {
    display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 100%;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
    padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
    scroll-padding-inline: 36px;
  }
  .fb-scroll::-webkit-scrollbar { display: none; }
  .fb-scroll.can-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent calc(100% - 4px)); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent calc(100% - 4px)); }
  .fb-scroll.can-l { -webkit-mask-image: linear-gradient(to right, transparent 4px, #000 40px); mask-image: linear-gradient(to right, transparent 4px, #000 40px); }
  .fb-scroll.can-l.can-r { -webkit-mask-image: linear-gradient(to right, transparent 4px, #000 40px, #000 calc(100% - 48px), transparent calc(100% - 4px)); mask-image: linear-gradient(to right, transparent 4px, #000 40px, #000 calc(100% - 48px), transparent calc(100% - 4px)); }
  .fb-scroll .chips-wrap { flex: none; }
  .fb-scroll .chips { flex: none; overflow: visible; padding: 0; -webkit-mask-image: none !important; mask-image: none !important; }
  .seg { height: 38px; }
  .seg-btn { padding: 0 8px; font-size: 11px; letter-spacing: 0; gap: 4px; }
  .needs-btn { height: 38px; padding: 0 8px; gap: 4px; font-size: 11px; letter-spacing: 0; }
  .chip { min-height: 38px; padding: 5px 12px 5px 9px; }
}

/* ----- touch: no tool palette; tap a card, then + Add advice ----- */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
  .toolbar { display: none; }
}
/* phones: a slim vertical zoom stack on the right edge, over the post-it fans rather than card text */
@media (max-width: 700px) {
  .zoom-hud { flex-direction: column-reverse; right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(var(--nav-h) + 12px); }
  .zoom-hud button { width: 44px; height: 44px; min-width: 0; padding: 0; font-size: 18px; }
  #zoom-label { min-width: 0; font-size: 10.5px; border-inline: 0; border-block: 1.5px solid var(--line); }
}
@media (hover: none) { .tool small { display: none; } }
@media (pointer: coarse) {
  .seg-btn, .needs-btn { min-height: 40px; }
}
