/* ——— one page, two pens ——— */

:root {
  --paper: #ecedf1;
  --dots: #c8cbd4;
  --ink: #20222e;
  --ink-soft: #6a6e80;
  --card: #ffffff;
  --line: #d8dae2;
  --red: #e0303b;
  --blue: #2b50d9;
  --shadow: 0 2px 6px rgba(32, 34, 46, 0.12), 0 8px 24px rgba(32, 34, 46, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
}

/* ——— the board ——— */

#viewport {
  position: fixed;
  inset: 0;
  overflow: auto;
  background: var(--paper);
}

#board {
  position: relative;
  width: 2400px;
  height: 1600px;
  background-image: radial-gradient(var(--dots) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  touch-action: none;
}

#hint {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: 34px;
  line-height: 1.3;
  color: var(--ink-soft);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s;
}
#hint.gone { opacity: 0; }
#hint.gone #hint-upload { pointer-events: none; }
#hint-upload {
  display: block;
  pointer-events: auto; /* the hint itself lets clicks/drops fall through to the board */
  margin: 16px auto 0;
  padding: 6px 22px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 24px;
  color: var(--ink);
  cursor: pointer;
}
#hint-upload:hover { background: var(--ink); color: var(--card); }

/* ——— stickers ——— */

.item {
  position: absolute;
  cursor: grab;
  transform: rotate(var(--rot, 0deg));
  user-select: none;
  -webkit-user-select: none;
}
.item.dragging { cursor: grabbing; }
.item.settle { animation: settle 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes settle {
  from { transform: rotate(var(--rot, 0deg)) scale(0.6); opacity: 0; }
  to   { transform: rotate(var(--rot, 0deg)) scale(1); opacity: 1; }
}

.item.image, .item.text, .item.video, .item.menu {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* menu sticker: handwritten title, typed rows with dotted leaders */
.item.menu { padding: 14px 16px; }
.menu-card { display: flex; flex-direction: column; }
.menu-title {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: "Caveat", cursive;
  font-size: 26px;
  font-weight: 600;
  color: var(--author, var(--ink));
  outline: none;
}
input.menu-title::placeholder { color: var(--ink-soft); }
.menu-row { display: flex; align-items: baseline; gap: 7px; margin-top: 6px; }
.menu-row .m-name, .menu-row .m-price {
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}
.menu-row .m-name { min-width: 0; }
.menu-row.edit .m-name { flex: 1; }
.menu-row .m-price {
  flex-shrink: 0;
  width: 56px;
  text-align: right;
  font-family: "Space Mono", monospace;
  font-size: 12.5px;
}
.menu-row input::placeholder { color: var(--ink-soft); }
.m-leader {
  border-bottom: 2px dotted var(--dots);
  transform: translateY(-3px);
}
.menu-row.edit .m-leader { flex: 0 0 16px; }
.menu-row:not(.edit) .m-leader { flex: 1; min-width: 14px; }
.menu-add {
  align-self: flex-start;
  margin-top: 9px;
  padding: 0;
  border: none;
  background: transparent;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  cursor: pointer;
}
.menu-add:hover { color: var(--ink); }

.item.image { padding: 8px 8px 12px; }
.item.image img {
  display: block;
  width: 100%;
  pointer-events: none;
}

.item.video { padding: 8px 8px 12px; }
.item.video video {
  display: block;
  width: 100%;
}
.vid-wrap { position: relative; }
.vid-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0 0 0 4px; /* optical centering for the ▶ */
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.vid-play:hover { transform: translate(-50%, -50%) scale(1.08); }
.vid-wrap.playing .vid-play { opacity: 0; pointer-events: none; }
.vid-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px; /* generous tap target; the visible line is thinner */
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.vid-wrap:hover .vid-bar, .vid-wrap.playing .vid-bar { opacity: 1; }
.vid-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  height: 3px;
  background: rgba(255, 255, 255, 0.45);
}
.vid-bar-fill {
  position: absolute;
  left: 0;
  bottom: 5px;
  height: 3px;
  width: 0;
  background: var(--author, var(--red));
}
.vid-ctrls {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 14px; /* clear of the scrub line */
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.vid-wrap:hover .vid-ctrls, .vid-wrap.playing .vid-ctrls { opacity: 1; pointer-events: auto; }
.vid-ctrls-left { display: flex; align-items: center; gap: 6px; }
.vid-ctrls button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.vid-ctrls button:hover { border-color: var(--ink); }
.vid-vol {
  width: 60px;
  accent-color: var(--ink);
  cursor: pointer;
}

.item.text {
  padding: 14px 18px 12px;
  min-height: 56px;
}
.item.text .note {
  font-family: "Caveat", cursive;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--author, var(--ink));
  outline: none;
  word-wrap: break-word;
  white-space: pre-wrap;
  cursor: text;
}
.item.text:not(.editing) .note { cursor: inherit; }

/* font picker: scrollable list, each name set in its own face */
#font-picker {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  width: 212px;
  max-height: 256px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}
#font-picker button {
  flex-shrink: 0;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
#font-picker button:hover { background: var(--paper); }
#font-picker button.active { background: var(--ink); color: var(--card); }

.item.emoji {
  font-size: var(--size, 72px);
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(32, 34, 46, 0.18));
}

/* authorship tape on cards */
.tape {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 70px;
  height: 22px;
  transform: translateX(-50%) rotate(-2.5deg);
  background: var(--author);
  opacity: 0.68;
  border-radius: 1px;
  pointer-events: none;
}
#board.no-pins .tape { display: none; } /* board setting: pins off */
#board.no-dots { background-image: none; } /* a tinted background covers the dot grid too */
#board .tape { background: var(--pin-color, var(--author)); } /* board setting: one pin color for everyone */

/* selection */
.item.selected { outline: 2px solid var(--author, var(--ink)); outline-offset: 3px; }
.item.emoji.selected { outline-style: dashed; }

.item .ctrl {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  border: none;
  font-size: 12px;
  font-family: "Space Mono", monospace;
  padding: 0;
  cursor: pointer;
}
.item.selected .ctrl { display: flex; }
.item .ctrl.del { top: -12px; right: -12px; }
.item .ctrl.resize { bottom: -12px; right: -12px; cursor: nwse-resize; }

/* ——— live cursors ——— */

#cursors { position: absolute; inset: 0; pointer-events: none; }

.cursor {
  position: absolute;
  transition: transform 90ms linear;
  will-change: transform;
}
.cursor .nib {
  width: 12px;
  height: 12px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--c);
  border: 2px solid var(--card);
  box-shadow: 0 1px 3px rgba(32, 34, 46, 0.3);
}
.cursor .tag {
  margin: 4px 0 0 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--c);
  color: var(--card);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  width: fit-content;
}

/* ——— chrome ——— */

#topbar {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 100;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 20px;
  font-family: "Space Mono", monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}
.wordmark .dot { width: 9px; height: 9px; border-radius: 50%; }
.wordmark .dot:first-of-type { margin-left: 4px; }
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }

.topbar-right { display: flex; align-items: flex-start; gap: 8px; }
.peer-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--c, var(--ink));
}
.share-chip.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.share-chip.danger:hover { filter: brightness(0.88); }
#presence { display: flex; gap: 8px; }
.peer {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
}
.peer .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.peer .you { color: var(--ink-soft); font-size: 12px; }

#toolbar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 100;
}

#toolbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
  padding: 9px 14px 8px;
  border: none;
  border-radius: 11px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
#toolbar[hidden] { display: none; }
#toolbar button:hover { background: var(--paper); }
#toolbar .glyph { font-size: 20px; line-height: 1; font-weight: 600; }

/* custom elements modal */
.modal-title {
  margin: 0 0 12px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
#custom-list { display: flex; flex-direction: column; gap: 4px; }
.custom-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.custom-row:hover { background: var(--paper); }
.custom-row .c-glyph { font-size: 17px; line-height: 1; }
.custom-row .c-text { display: flex; flex-direction: column; gap: 1px; }
.custom-row .c-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.custom-row .c-desc { font-size: 11.5px; color: var(--ink-soft); }

/* public view: one card — reactions, then comment input, then the expand arrow */
#social-bar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  padding: 10px 10px 4px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 100;
}
#social-bar[hidden] { display: none; }
#comments-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 6px 4px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.4;
}
#comments-panel[hidden] { display: none; }
.comment { overflow-wrap: anywhere; }
.comment-author { font-weight: 600; margin-right: 7px; }
/* one dense strip: ~25px cells, counts float as corner badges so cells stay tight */
#reaction-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(24px, 1fr)); gap: 0; }
.react-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
}
.react-btn:hover { background: var(--paper); }
.react-btn.mine { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
.react-btn .count {
  position: absolute;
  top: -5px;
  right: -2px;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  font-family: "Space Mono", monospace;
  font-size: 9px;
  line-height: 1.4;
  color: var(--ink-soft);
  pointer-events: none;
}
#comment-form { display: flex; gap: 6px; }
#comment-form[hidden] { display: none; }
#comment-input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 11px;
  background: var(--paper);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
#comment-input::placeholder { color: var(--ink-soft); }
#comment-form button {
  width: 38px;
  flex-shrink: 0;
  padding: 8px 0;
  border: none;
  border-radius: 11px;
  background: var(--ink);
  color: var(--card);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}
#comment-form button:hover { opacity: 0.85; }
#comments-toggle {
  padding: 2px 0 5px;
  border: none;
  background: transparent;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
}
#comments-toggle:hover { color: var(--ink); }
#comments-toggle[hidden] { display: none; }
#corner-comment-wrap {
  position: fixed;
  bottom: 22px;
  right: 16px;
  z-index: 100;
}
#corner-comment-wrap[hidden] { display: none; }
#corner-comment {
  width: 210px;
  padding: 8px 34px 8px 12px;
  background: var(--card);
  border: none;
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
#corner-comment::placeholder { color: var(--ink-soft); }
.corner-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--ink-soft);
  pointer-events: none;
}

#emoji-pop[hidden] { display: none; }
#emoji-pop {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  width: 356px;
  max-width: calc(100vw - 32px);
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
#emoji-pop button {
  min-width: 0;
  padding: 6px 0;
  font-size: 24px;
  flex-direction: row;
}

/* ——— auth screen ——— */

#auth {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  background-image: radial-gradient(var(--dots) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  z-index: 200;
}
#auth[hidden] { display: none; }

#auth-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 340px;
  max-width: calc(100vw - 40px);
  padding: 36px 32px 28px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
#auth-card .wordmark.big {
  margin: 0 auto;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 34px;
  font-weight: 400;
}
#auth-card .big .dot { width: 13px; height: 13px; }
#auth-card .tagline {
  margin: -6px 0 10px;
  font-family: "Caveat", cursive;
  font-size: 24px;
  color: var(--ink-soft);
}
#auth-card input {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  text-align: center;
}
#auth-card input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
#auth-card button[type="submit"] {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: var(--card);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
#auth-card button[type="submit"]:hover { background: #343748; }

.form-error {
  margin: 0;
  font-size: 13px;
  color: var(--red);
}
.auth-switch {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.auth-switch a { color: var(--blue); }

/* ——— home: your boards ——— */

#home {
  position: fixed;
  inset: 0;
  overflow: auto;
  background: var(--card);
}
#home[hidden] { display: none; }

/* unsplash-style chrome: full-width sticky header + tab row */
.home-chrome {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.home-top {
  display: flex;
  align-items: stretch;
  gap: 28px;
  min-height: 56px;
  padding: 0 20px;
}
.home-top .wordmark { align-self: center; }
/* the home pill holds the name and, underneath it, the tagline */
#home-wordmark {
  flex-direction: column;
  gap: 2px;
  padding: 7px 16px;
}
.wordmark-top { display: inline-flex; align-items: center; gap: 5px; }
.brand-tag {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1;
  color: var(--ink-soft);
  white-space: nowrap;
}
.home-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.home-tabs {
  display: flex;
  gap: 22px;
  overflow-x: auto;
}
.home-tabs a {
  display: flex;
  align-items: center;
  padding: 0 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.home-tabs a:hover { color: var(--ink); }
.home-tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.community-empty { color: var(--ink-soft); }
.view-only #hint { display: none; }
.view-only .item { cursor: pointer; } /* tapping opens the sticker's comments */

/* the fused photo bar: quick reactions · ＋ · comment launcher · send */
.item-bar {
  position: absolute;
  left: 50%;
  top: calc(100% - 12px); /* top flush with the photo's bottom edge */
  transform: translateX(-50%) rotate(calc(-1 * var(--rot, 0deg)));
  transform-origin: top center;
  display: none;
  align-items: center;
  width: 270px;
  max-width: none;
  padding: 4px;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.view-only .item.image:hover .item-bar { display: flex; }
.view-only .item.image:hover .item-comments { display: none; } /* the bar takes the caption's spot */
.ib-ems { display: flex; align-items: center; }
.ib-em {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 13.5px;
  line-height: 1;
  cursor: pointer;
}
.ib-em:hover { background: var(--paper); }
.ib-em.mine { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
.ib-em .count {
  position: absolute;
  top: -6px;
  right: -3px;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  font-family: "Space Mono", monospace;
  font-size: 9px;
  line-height: 1.4;
  color: var(--ink-soft);
  pointer-events: none;
}
.ib-more {
  padding: 5px 5px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}
.ib-more:hover { background: var(--paper); color: var(--ink); }
.ib-launch {
  flex: 1;
  min-width: 0;
  padding: 5px 10px;
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: text;
}
.ib-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 10px;
}

/* per-sticker caption: a compact pill — newest comment + 💬 count.
   same anchor as the hover bar, so hovering swaps one for the other */
.item-comments {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  max-width: 115%;
  transform: translateX(-50%) rotate(calc(-1 * var(--rot, 0deg)));
  transform-origin: top center;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 11.5px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  text-align: left;
}
.item.image .item-comments { top: calc(100% - 12px); }
.view-only .item-comments:not(:empty) { display: flex; }
.item-comments b { font-weight: 600; flex-shrink: 0; }
.item-comments .cb-t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.item-comments .cb-n {
  flex-shrink: 0;
  padding-left: 7px;
  border-left: 1px solid var(--line);
  font-family: "Space Mono", monospace;
  font-size: 10px;
  color: var(--ink-soft);
}
.item-comments:hover .cb-n { color: var(--ink); }

/* the full thread: one card — emoji grid deck, comments, the fused bar */
#item-thread {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  /* stay level even when the sticker is tilted */
  transform: translateX(-50%) rotate(calc(-1 * var(--rot, 0deg)));
  transform-origin: top center;
  width: 290px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  overflow: hidden;
  font-size: 13px;
  cursor: default;
  text-align: left;
  z-index: 50;
}
.item.image #item-thread { top: calc(100% - 12px); } /* same anchor as the bar */
#item-thread[hidden] { display: none; }
/* while the thread is open, its caption and hover bar step aside */
.item:has(#item-thread:not([hidden])) .item-comments,
.item:has(#item-thread:not([hidden])) .item-bar { display: none !important; }
#icm-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  padding: 8px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
#icm-grid[hidden] { display: none; }
#icm-grid button {
  padding: 3px 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
}
#icm-grid button:hover { background: var(--card); }
.icm-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
  padding: 11px 14px 9px;
  font-size: 12.5px;
  line-height: 1.4;
}
.icm-empty { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.icm-form {
  display: flex;
  align-items: center;
  padding: 4px;
  border-top: 1px solid var(--line);
}
.icm-form .ib-ems { padding-left: 2px; }
.icm-form input {
  flex: 1;
  min-width: 0;
  padding: 5px 10px;
  border: none;
  border-left: 1px solid var(--line);
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--ink);
  outline: none;
}
.icm-form input::placeholder { color: var(--ink-soft); }
.icm-form button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 10px;
  cursor: pointer;
}
.icm-form button[type="submit"]:hover { opacity: 0.85; }
#create-board {
  padding: 7px 14px;
  border: none;
  border-radius: 16px;
  background: var(--ink);
  color: var(--card);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
#create-board:hover { opacity: 0.85; }
#board-name.renaming {
  outline: none;
  border-bottom: 1.5px dashed var(--ink-soft);
  cursor: text;
  min-width: 40px;
}

/* ——— organisations ——— */

/* group cards: a postcard — freshest board photo left, info right */
.org-card {
  position: relative;
  display: flex;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.org-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(32, 34, 46, 0.16), 0 14px 32px rgba(32, 34, 46, 0.08);
}
.org-card-cover {
  position: relative;
  width: 180px;
  min-height: 108px;
  flex-shrink: 0;
  background: var(--paper);
  overflow: hidden;
}
.org-card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.org-card-cover.blank {
  background-image: radial-gradient(var(--dots) 1.1px, transparent 1.1px);
  background-size: 14px 14px;
}
.org-card-cover .tape { top: 10px; width: 58px; height: 18px; opacity: 0.62; z-index: 1; }
.org-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px 18px 13px;
  min-width: 0;
}
.org-card-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.org-card-meta {
  font-family: "Space Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.org-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}
.org-avatars { display: flex; }
.org-avatars b, .org-avatars img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--card);
  margin-left: -6px;
  object-fit: cover;
}
.org-avatars :first-child { margin-left: 0; }

.create-org { display: flex; gap: 8px; }
.create-org input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}
.create-org input:focus { border-color: var(--ink); }
.create-org button {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: var(--card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.org-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 18px; }
.org-head h2 { margin: 0; font-size: 24px; }
#org-join {
  padding: 6px 14px;
  border: none;
  border-radius: 14px;
  background: var(--ink);
  color: var(--card);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.org-chip-wrap { position: relative; pointer-events: auto; }
#org-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
}
#org-pop[hidden] { display: none; }
#org-pop button {
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
#org-pop button:hover { background: var(--paper); }
#org-pop button.active { background: var(--ink); color: var(--card); }
.org-pop-empty { padding: 8px 10px; font-size: 12.5px; color: var(--ink-soft); }

/* ——— friends ——— */
.people-col {
  width: min(600px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 10px;
}
.people-heading {
  margin: 0 0 10px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.person-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-soft);
}
.person-info { flex: 1; min-width: 0; }
.person-name { font-size: 15px; font-weight: 600; }
.person-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.person-actions { display: flex; gap: 8px; }
.person-actions button, .org-card-foot button {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.person-actions button:hover, .org-card-foot button:hover { border-color: var(--ink); }
.person-actions button.primary, .org-card-foot button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}
.person-actions button.primary:hover, .org-card-foot button.primary:hover { opacity: 0.85; }

.person.clickable { cursor: pointer; }
.person.clickable:hover { border-color: var(--ink-soft); }

/* ——— globe ——— */
#globe-section { display: flex; justify-content: center; }
#globe-section[hidden] { display: none; }
.globe-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 12px;
}
#globe-preview {
  position: absolute;
  width: 164px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 5;
}
#globe-preview img {
  width: 100%;
  border-radius: 6px;
  display: block;
}
#globe-preview-name { font-size: 13px; font-weight: 600; }
#globe-preview-meta {
  font-family: "Space Mono", monospace;
  font-size: 10.5px;
  color: var(--ink-soft);
}
#globe-canvas {
  width: min(88vw, 560px);
  height: min(88vw, 560px);
  cursor: grab;
  touch-action: none;
}
#globe-canvas:active { cursor: grabbing; }
.globe-caption {
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: 25px;
  color: var(--ink-soft);
  transform: rotate(-1.5deg);
}

/* ——— public profile page ——— */
.user-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0 30px;
  text-align: center;
}
.user-avatar-img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 600;
  color: var(--ink-soft);
}
.user-profile h2 { margin: 10px 0 0; font-size: 24px; }
#user-bio { margin: 6px 0 12px; max-width: 420px; color: var(--ink); }

/* ——— profile ——— */
#home-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}
#home-profile:hover #home-name { text-decoration: underline; }
#home-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
#profile-section { display: flex; justify-content: center; padding-top: 26px; }
#profile-section[hidden] { display: none; }
.profile-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.profile-avatar {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px dashed var(--dots);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}
.profile-avatar:hover { border-color: var(--ink-soft); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
#profile-avatar-empty { font-size: 32px; color: var(--ink-soft); }
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.profile-field input,
.profile-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  resize: vertical;
}
.profile-field input:focus,
.profile-field textarea:focus { border-color: var(--ink-soft); }
#profile-save {
  align-self: flex-start;
  padding: 9px 20px;
  border: none;
  border-radius: 16px;
  background: var(--ink);
  color: var(--card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
#profile-save:hover { opacity: 0.85; }
#sign-out {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
}
#sign-out:hover { color: var(--ink); border-color: var(--ink); }

.home-main {
  padding: 22px 20px 80px;
}

/* masonry, pinterest-style: CSS columns, cards keep natural height */
.board-grid {
  columns: 5 230px;
  column-gap: 18px;
}

.board-card {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: 18px;
  break-inside: avoid;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.board-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(32, 34, 46, 0.16), 0 14px 32px rgba(32, 34, 46, 0.08);
}
.board-card .tape {
  top: 10px;
  opacity: 0.6;
  z-index: 1;
}
.board-card-cover {
  display: block;
  width: 100%;
  background: var(--paper);
}
.board-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px 14px;
}
.board-card:not(.has-cover) .board-card-body {
  padding-top: 34px;
  min-height: 74px;
}
.board-card-name {
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.board-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Space Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.board-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.board-card-head .board-card-meta { flex-shrink: 0; }
.card-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 9px;
  margin-top: 2px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
}
.card-reaction { white-space: nowrap; }
.card-comments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.35;
}
.card-comment {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card-comment b { font-weight: 600; margin-right: 5px; }
.owner-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
}
.board-card-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.board-card:hover .board-card-del { opacity: 1; }
.board-card-del:hover { background: var(--paper); color: var(--red); }

.board-card.new-board {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 110px;
  padding: 18px;
  background: transparent;
  border: 2px dashed var(--dots);
  border-radius: 14px;
  box-shadow: none;
  overflow: visible;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-soft);
  text-align: center;
  cursor: pointer;
}
.board-card.new-board:hover { border-color: var(--ink-soft); color: var(--ink); transform: none; }

/* ——— board top bar extras ——— */

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
a.wordmark { color: var(--ink); text-decoration: none; pointer-events: auto; }
#topbar .wordmark, #topbar .board-name-chip, #topbar .share-chip, #presence, #view-toggle, .presence-wrap { pointer-events: auto; }

/* board options menu, anchored under your own name chip */
.presence-wrap { position: relative; }
.peer.me { cursor: pointer; }
.peer.me .caret { font-size: 10px; color: var(--ink-soft); }
#board-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
}
#board-menu[hidden] { display: none; }
#board-menu .share-chip {
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
}
#board-menu .share-chip:hover { background: var(--paper); color: var(--ink); }
#board-menu .share-chip.danger { background: transparent; color: var(--red); }
#board-menu .share-chip.danger:hover { background: var(--red); color: #fff; }
#board-menu .org-chip-wrap { display: block; }
#board-menu #org-pop {
  top: 0;
  left: auto;
  right: calc(100% + 12px);
}


.board-name-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 320px;
}
#board-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rename-board {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 2px;
}
#rename-board:hover { color: var(--ink); }

.share-chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.share-chip:hover { color: var(--ink); }

/* ——— confirm modal ——— */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(32, 34, 46, 0.35);
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(360px, calc(100vw - 48px));
  padding: 22px 24px 18px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal-card p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.45; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.modal-actions button:hover { border-color: var(--ink); }
.modal-actions button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.modal-actions button.danger:hover { filter: brightness(0.9); }

/* board settings rows inside the modal */
.settings-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  margin: 0 -10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.settings-row:hover { background: var(--paper); }
.settings-row input { accent-color: var(--ink); cursor: pointer; }
.settings-row.disabled { opacity: 0.45; pointer-events: none; }
.settings-colors { cursor: default; }
#pin-colors, #bg-colors { display: flex; gap: 7px; margin-left: auto; }
.swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
#pin-colors .swatch.auto {
  /* "auto": every author keeps their own color */
  background: conic-gradient(#e0303b, #2b50d9, #118b50, #8333b4, #d9730d, #0f8b8d, #e0303b);
}
#bg-colors .swatch.auto { background: var(--paper); } /* "auto": default paper */
.swatch:hover { border-color: var(--ink); }
.swatch.active { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ——— toast ——— */

#toast {
  position: fixed;
  bottom: 24px;
  left: 20px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--card);
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 300;
}

/* ——— quality floor ——— */

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

@media (prefers-reduced-motion: reduce) {
  .item.settle { animation: none; }
  .cursor { transition: none; }
  #hint { transition: none; }
}

@media (max-width: 560px) {
  #toolbar button { min-width: 56px; padding: 8px 10px; }
  #topbar { flex-wrap: wrap; gap: 8px; }
}
