:root {
  --paper: #f5efe3;
  --paper-deep: #ebe2d0;
  --ink: #2a241d;
  --ink-soft: #6d6355;
  --line: #d8ccb6;
  --accent: #c2492b;
  --accent-deep: #9c3519;
  --green: #2a8a6e;
  --red: #b33a2a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, #fbf7ef 0%, var(--paper) 55%, var(--paper-deep) 100%) fixed;
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

a { color: var(--accent-deep); }

h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.15; }

.muted { color: var(--ink-soft); }

/* Masthead ---------------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font: 600 1.2rem var(--serif);
  text-decoration: none;
}


.masthead__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.masthead__nav a:not(.button) { color: var(--ink); text-decoration: none; }
.brand, .masthead__nav a, .masthead__nav button { white-space: nowrap; }

@media (max-width: 520px) {
  .masthead__nav { gap: 0.75rem; }
}

/* The three ways to look at your jars. */
.views {
  display: flex;
  gap: 0.25rem;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  max-width: 1200px;
  margin: 0 auto 1rem;
  overflow-x: auto;
}

.views__tab {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.views__tab:hover { color: var(--ink); background: rgb(255 255 255 / 0.5); }
.views__tab[aria-current="page"] { color: var(--paper); background: var(--ink); }

.page {
  padding: 0 clamp(1rem, 4vw, 2.5rem) 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.page__title { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0.5rem 0 1.5rem; }

.narrow { max-width: 32rem; margin: 1rem auto; }

.flash {
  max-width: 40rem;
  margin: 0 auto 1rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  background: #fffaf0;
  border: 1px solid var(--line);
  text-align: center;
}

.flash--alert { border-color: #e0a090; color: var(--accent-deep); }

/* Buttons and forms ------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 1rem var(--sans);
  text-decoration: none;
  cursor: pointer;
}

.button:hover { background: #000; }
.button--small { padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.button--quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.button--quiet:hover { background: #fffaf0; }

.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.link-button--danger { color: var(--accent-deep); margin-top: 2rem; }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.stacked-form { display: grid; gap: 1rem; }
.stacked-form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
.stacked-form__actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.sign-in { text-align: center; }
.sign-in .stacked-form { text-align: left; }

/* The jar ----------------------------------------------------------------- */

.jar { display: block; overflow: visible; }
.jar--large { width: 100%; height: min(56vh, 560px); }
.jar--medium { width: 100%; height: 240px; }
.jar--small { width: 100%; height: 150px; }
.jar--tiny { width: 66px; height: 86px; }

.jar__back { fill: rgb(255 255 255 / 0.45); }

.jar__glass {
  fill: none;
  stroke: rgb(120 140 150 / 0.55);
  stroke-width: 3;
  stroke-linejoin: round;
}

.jar__shine {
  fill: none;
  stroke: rgb(255 255 255 / 0.75);
  stroke-width: 9;
  stroke-linecap: round;
}

.jar__shine--thin { stroke-width: 4; stroke: rgb(255 255 255 / 0.55); }

.jar__rim {
  fill: rgb(255 255 255 / 0.6);
  stroke: rgb(120 140 150 / 0.55);
  stroke-width: 2.5;
}

.marble { filter: drop-shadow(0 1px 1px rgb(40 30 20 / 0.25)); }

/* The marble designs live in one hidden sprite; jars and icons <use> them.
   Not display: none, which would switch off their gradients. */
.marble-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.marble-icon { flex: none; display: inline-block; vertical-align: middle; overflow: visible; filter: drop-shadow(0 1px 1px rgb(40 30 20 / 0.25)); }
.marble-icon--tiny { width: 0.8rem; height: 0.8rem; }
.marble-icon--small { width: 1.1rem; height: 1.1rem; }
.marble-icon--brand { width: 1.4rem; height: 1.4rem; }
.marble-icon--avatar { width: 1.6rem; height: 1.6rem; margin-right: 0.4rem; }
.marble-icon--medium { width: 2rem; height: 2rem; }

/* New marbles fall in once and settle; nothing loops. */
.marble--dropping {
  animation: marble-drop 650ms cubic-bezier(0.3, 0, 0.6, 1) both;
}

@keyframes marble-drop {
  0%   { transform: translateY(calc(-1px * var(--drop))); }
  70%  { transform: translateY(0); }
  85%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .marble--dropping { animation: none; }
}

/* Contacts list ----------------------------------------------------------- */

.contact-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.25rem;
}

.contact-card {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 1rem 0.75rem;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: background 150ms;
}

.contact-card:hover { background: rgb(255 255 255 / 0.55); }
.contact-card__name { font: 600 1.1rem var(--serif); text-align: center; }
.contact-card__count { color: var(--ink-soft); font-size: 0.9rem; }

.empty { max-width: 28rem; margin: 2rem auto; text-align: center; }

/* The jars board: zooms on both sides, and turns over to the people at the back. */

.board__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.board__title { margin: 0.5rem 0 0; }
.board__tools { display: flex; align-items: center; gap: 0.75rem; }

.zoom {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.zoom__button, .zoom__level {
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 1rem var(--sans);
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.zoom__level { min-width: 4.2em; font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.zoom__button:hover:not(:disabled), .zoom__level:hover { background: #fffaf0; }
.zoom__button:disabled { color: var(--line); cursor: default; }

.board__sheet {
  padding: clamp(0.75rem, 2vw, 1.5rem);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 1px 1px, rgb(120 100 70 / 0.18) 1px, transparent 0) 0 0 / 22px 22px,
    rgb(255 253 248 / 0.6);
  box-shadow: inset 0 0 0 1px var(--line);
}

.board--turned .board__sheet {
  background:
    radial-gradient(circle at 1px 1px, rgb(60 40 20 / 0.2) 1px, transparent 0) 0 0 / 22px 22px,
    #e3d6bd;
}

/* CSS zoom lays the board out again, so more jars fit across when zoomed out. */
.board__side > :is(.contact-grid, .empty) { zoom: var(--board-zoom, 1); }
.board__side--back .lede { margin-top: 0; }

/* On the back, a jar becomes a little headstone: their name, and from when they were added to when they went back here. */
.tombstone {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.4rem;
  width: 112px;
  height: 140px;
  padding: 1.6rem 0.6rem 0.8rem;
  box-sizing: border-box;
  border-radius: 56px 56px 6px 6px;
  background: linear-gradient(160deg, #c9c4ba, #a39d92 70%, #8d877c);
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 0.18), inset 0 -10px 18px rgb(0 0 0 / 0.12), 0 6px 0 -2px #7d7064;
  color: #3d3a35;
  text-align: center;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.35);
}

.tombstone__name { font: 600 0.95rem/1.15 var(--serif); overflow-wrap: anywhere; }
.tombstone__dates { display: grid; font: 0.7rem/1.3 var(--sans); }
.contact-card--trashed .button { margin-top: 0.4rem; }

[hidden] { display: none !important; }

/* Photos ------------------------------------------------------------------ */

.avatar {
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: var(--paper-deep);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.8), 0 2px 8px rgb(0 0 0 / 0.12);
}
.avatar--large { flex: none; width: clamp(3rem, 8vw, 4.5rem); height: clamp(3rem, 8vw, 4.5rem); }
.avatar--small { display: inline-block; width: 1.6rem; height: 1.6rem; margin-right: 0.4rem; vertical-align: -0.35rem; }

.photo-form { display: flex; align-items: center; gap: 0.5rem; }
.photo-form label { cursor: pointer; }
.photo-form label:focus-within { outline: 2px solid var(--accent-deep); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One contact: their portrait beside the jar, the history below ---------- */

.contact {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 760px) {
  .contact { grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.2fr); align-items: start; column-gap: clamp(1.5rem, 4vw, 3rem); }
}

/* On a phone the portrait and the jar share the top row, and the details
   card follows the marble buttons. The two wrappers step aside so their
   pieces can sit in the page's grid. */
@media (max-width: 759px) {
  .contact {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "portrait jar"
      "portrait count"
      "header   header"
      "controls controls"
      "details  details"
      "history  history";
    gap: 0.75rem 1rem;
    align-items: center;
  }

  .contact > :is(.profile, .stage) { display: contents; }

  .contact .portrait-picker { grid-area: portrait; }
  .contact .profile__header { grid-area: header; margin: 0.5rem 0 0; }
  .contact .jar--large { grid-area: jar; height: 10rem; }
  .contact .stage__count { grid-area: count; justify-self: center; margin: 0; }
  .contact .marble-controls { grid-area: controls; justify-self: center; }
  .contact .contact__history { grid-area: history; margin-top: 1.25rem; }

  .contact .profile__details {
    grid-area: details;
    margin-top: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: rgb(255 253 248 / 0.8);
    box-shadow: 0 1px 0 var(--line), 0 10px 30px rgb(80 60 30 / 0.08);
  }

  .contact .portrait { width: min(9rem, 40vw); }
  .contact .portrait__initials { font-size: 3rem; }
}

.contact__history { grid-column: 1 / -1; }
.contact__history h2 { font-size: 1.4rem; margin: 0; }

.history-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.history-filter { display: flex; gap: 0.25rem; padding: 0.2rem; border-radius: 999px; background: var(--paper-deep); }
.history-filter__option { padding: 0.25rem 0.8rem; border-radius: 999px; color: var(--ink-soft); font-size: 0.9rem; text-decoration: none; }
.history-filter__option[aria-current="page"] { background: #fffdf8; color: var(--ink); box-shadow: 0 1px 2px rgb(60 40 20 / 0.15); }
.history__empty { color: var(--ink-soft); font-style: italic; }

.profile {
  padding: 1.5rem;
  border-radius: var(--radius);
  background: rgb(255 253 248 / 0.8);
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgb(80 60 30 / 0.08);
}

.profile__header { margin: 1rem 0 1.25rem; text-align: center; }
.profile__name { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; overflow-wrap: anywhere; }

/* The portrait: a photo ringed in the contact's group colours, or initials on them. */
.portrait {
  display: grid;
  place-items: center;
  width: clamp(9rem, 22vw, 12rem);
  aspect-ratio: 1;
  padding: 6px;
  border-radius: 50%;
  background: var(--portrait);
  box-shadow: 0 0 0 4px rgb(255 255 255 / 0.85), 0 6px 18px rgb(60 40 20 / 0.18);
}

.portrait__photo { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--paper-deep); }

.portrait__initials {
  color: #fff;
  font: 600 clamp(3rem, 8vw, 4.2rem)/1 var(--serif);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
}

.portrait-picker { display: grid; justify-items: center; gap: 0.35rem; }
.portrait-picker form { display: grid; justify-items: center; gap: 0.5rem; }
.portrait-picker__label { position: relative; display: block; border-radius: 50%; cursor: pointer; }
.portrait-picker__label:focus-within { outline: 3px solid var(--accent-deep); outline-offset: 6px; }

.portrait-picker__badge {
  position: absolute;
  bottom: 0.35rem;
  left: 50%;
  translate: -50% 0;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 150ms;
}

.portrait-picker__label:is(:hover, :focus-within) .portrait-picker__badge { opacity: 1; }
.portrait-picker__remove { font-size: 0.85rem; }

@media (hover: none) {
  .portrait-picker__badge { opacity: 0.85; }
}

.stage { display: grid; justify-items: center; text-align: center; }

.stage__count { margin: 0.25rem 0 1rem; color: var(--ink-soft); font-size: 1.1rem; }
.stage__count strong { display: block; color: var(--ink); font: 600 clamp(3rem, 8vw, 4.5rem)/1 var(--serif); }

.marble-controls { display: grid; gap: 0.75rem; width: min(100%, 26rem); }

.marble-controls__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* "+" comes first in the markup so Enter adds; "−" is shown on the left. */
.marble-button--remove { order: -1; }

.marble-controls .marble-controls__count { width: 5rem; flex: none; text-align: center; font-size: 1.2rem; }

.marble-button {
  flex: none;
  width: 4rem;
  height: 4rem;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font: 600 2rem/1 var(--sans);
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.2), 0 3px 8px rgb(60 40 20 / 0.2);
  transition: transform 100ms;
}

.marble-button:active { transform: translateY(2px); }
.marble-button--add { background: radial-gradient(circle at 35% 30%, #5cc4a5, var(--green)); width: 4.75rem; height: 4.75rem; }
.marble-button--remove { background: radial-gradient(circle at 35% 30%, #a99c8a, #776b5b); }
.marble-button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Contact details ---------------------------------------------------------- */

.detail-section + .detail-section { margin-top: 1.5rem; }
.detail-section h2 { font-size: 1.1rem; margin: 0 0 0.5rem; color: var(--ink-soft); }

.detail-list { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; gap: 0.35rem; }
.detail-list li { display: flex; align-items: center; gap: 0.5rem; }
.detail-list li > form, .detail-item__actions { margin-left: auto; }
.detail-item__actions { display: flex; align-items: center; gap: 0.15rem; }

.edit-button {
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
}

.edit-button:hover { color: var(--accent-deep); background: var(--paper); }

/* A phone number or email address, typed over in place. */
.detail-item__fields {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  align-items: baseline;
  justify-items: start;
  gap: 0.5rem;
  min-width: 0;
}

.remove-button {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.remove-button:hover { color: var(--accent-deep); background: var(--paper); }

.add-detail summary { cursor: pointer; color: var(--ink-soft); font-size: 0.9rem; }
.inline-form { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.inline-form .button { justify-self: start; }


.history {
  list-style: none;
  padding: 1rem 1.5rem;
  margin: 0;
  display: grid;
  gap: 0.6rem;
  font-size: 0.95rem;
  border-radius: var(--radius);
  background: rgb(255 253 248 / 0.8);
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgb(80 60 30 / 0.08);
}

.history__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  padding: 0.15rem 0 0.15rem 1rem;
  border-left: 3px solid var(--line);
  border-radius: 0 10px 10px 0;
}
.history__summary { display: grid; flex: 1; min-width: 0; }
.history__item--joined-group, .history__item--connected { border-color: var(--accent); }
.history__item--added-marbles { border-color: var(--green); color: var(--green); }
.history__item--removed-marbles { border-color: var(--red); color: var(--red); }
.history__change { font: 700 1.15rem/1 var(--sans); font-variant-numeric: tabular-nums; min-width: 2.2ch; }
.history__description { font-style: italic; }

/* A line with a note says why, so it stands out. */
.history__item--noted { padding-block: 0.5rem; background: rgb(255 255 255 / 0.55); }
.history__item--noted .history__description { font: italic 1.15rem/1.35 var(--serif); }
.history__item--noted .history__change { font-size: 1.45rem; }

.history__item--starred { background: #fbefc4; border-color: #d9a520; }

.history__item form { display: contents; }
.history__star {
  border: 0;
  background: none;
  padding: 0 0.2rem;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--line);
  cursor: pointer;
}
.history__star:hover, .history__star:focus-visible { color: #d9a520; }
.history__item--starred .history__star { color: #d9a520; }
.history time { color: var(--ink-soft); font-size: 0.8rem; }

/* Groups ------------------------------------------------------------------- */

.lede { font-size: 1.1rem; max-width: 36rem; }

.chips { list-style: none; padding: 0; margin: 0 0 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem 0.2rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--group, var(--line)) 16%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--group, var(--line)) 45%, transparent);
  font-size: 0.9rem;
}

.chip a { color: var(--ink); text-decoration: none; font-weight: 600; }
.chip .remove-button { font-size: 1rem; padding: 0 0.3rem; }

.chip--button { border: 0; padding-right: 0.7rem; color: var(--ink); font: 600 0.9rem var(--sans); cursor: pointer; }
.chip--button:hover { background: color-mix(in srgb, var(--group) 30%, white); }
.chip--button[aria-pressed="true"] { background: var(--group); color: white; }
.chips--add { margin-top: 0.6rem; }


.shelf { margin-bottom: 2.5rem; }
.shelf__header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.shelf__name { margin: 0; font-size: 1.5rem; }
.shelf__edit { margin-left: auto; }
.shelf__empty { padding: 1rem 0 1.25rem; border-bottom: 10px solid #b98e5c; }

/* Jars stand on a wooden plank in the group's colour-tinted light. */
.shelf__jars {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0.5rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  border-bottom: 12px solid #b98e5c;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(to top, color-mix(in srgb, var(--group, #b98e5c) 14%, transparent), transparent 70%);
  box-shadow: 0 10px 14px -8px rgb(80 50 20 / 0.45);
}

.shelf__jars li { flex: 0 0 9.5rem; }
.shelf__jars .contact-card { padding-bottom: 0.5rem; }
.shelf--loose .shelf__jars { border-bottom-color: var(--line); box-shadow: none; }

/* Dragging jars between shelves. The lifted jar stays behind as a faint
   placeholder while a copy follows the pointer. */
[data-shelves-target~="jar"] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
[data-shelves-target~="jar"] .contact-card { -webkit-user-drag: none; }
[data-shelves-target~="jar"].is-lifted { opacity: 0.3; }
.is-dragging, .is-dragging * { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.shelf[data-shelves-target~="shelf"] { border-radius: var(--radius); transition: background 150ms, box-shadow 150ms; }
.shelf.is-over { background: color-mix(in srgb, var(--group, #b98e5c) 12%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--group, #b98e5c) 60%, transparent); }

.shelf-ghost {
  position: fixed;
  z-index: 20;
  list-style: none;
  pointer-events: none;
  border-radius: var(--radius);
  background: rgb(255 253 248 / 0.95);
  box-shadow: 0 12px 28px rgb(60 40 20 / 0.25);
  rotate: -3deg;
}

/* A solid tray, fixed at the bottom while a jar is lifted off a group's shelf. */
.tray {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 10;
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.1rem 1rem;
  border: 2px dashed var(--accent-deep);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--accent-deep);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px rgb(60 40 20 / 0.2);
  transition: background 150ms, color 150ms;
}
.tray[hidden] { display: none; }
.tray.is-over { background: var(--accent-deep); color: var(--paper); }

.new-group {
  max-width: 30rem;
  margin-top: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  background: rgb(255 253 248 / 0.8);
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgb(80 60 30 / 0.08);
}

.new-group h2 { margin-top: 0; }

.color-picker, .member-picker { border: 0; padding: 0; margin: 0; }
.color-picker legend, .member-picker legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; }
.color-picker__marbles { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.color-picker__option {
  padding: 0.3rem;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 120ms;
}

.color-picker__option:hover { transform: translateY(-2px); }
.color-picker__option:has(:checked) { box-shadow: 0 0 0 3px var(--ink); }
.color-picker__option:has(:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

.member-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.35rem; }

.stacked-form .member-picker__option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  font-weight: 400;
  cursor: pointer;
}

.member-picker__option:has(:checked) { background: rgb(255 255 255 / 0.75); box-shadow: inset 0 0 0 1px var(--line); }
.member-picker__option .avatar { margin: 0; }

.acquaintance { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; font-weight: 600; }
.acquaintance:hover { text-decoration: underline; }

/* Who knows who -------------------------------------------------------------- */

.network__legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }

/* Without JavaScript the jars simply line up; the controller adds --ready and
   places each one. */
.network__board {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 1px 1px, rgb(120 100 70 / 0.18) 1px, transparent 0) 0 0 / 22px 22px,
    rgb(255 253 248 / 0.6);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.network__strings { display: none; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.network__board--ready .network__strings { display: block; }

.network__string {
  fill: none;
  stroke: var(--string, #a8875c);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 0;
  animation: string-tie 900ms ease-out both;
  transition: opacity 200ms, stroke-width 200ms;
}

.network__jar {
  display: grid;
  justify-items: center;
  width: 108px;
  padding: 0.35rem 0.25rem;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 200ms, background 150ms;
}

.network__board--ready .network__jar {
  position: absolute;
  translate: -50% -50%;
  cursor: grab;
  animation: jar-pop 450ms cubic-bezier(0.3, 1.4, 0.6, 1) both;
  animation-delay: calc(var(--i) * 25ms);
}

.network__jar:hover, .network__jar:focus-visible { background: rgb(255 255 255 / 0.7); z-index: 2; }
.network__jar--held { cursor: grabbing; z-index: 3; background: rgb(255 255 255 / 0.85); box-shadow: 0 8px 20px rgb(60 40 20 / 0.18); }
.network__jar--target { background: rgb(255 255 255 / 0.9); box-shadow: 0 0 0 3px var(--accent); }

.network__name { font: 600 0.9rem/1.2 var(--serif); text-align: center; }
.network__name .avatar--small { width: 1.2rem; height: 1.2rem; margin-right: 0.25rem; vertical-align: -0.25rem; }
.network__groups { display: flex; gap: 2px; margin-top: 2px; }

.network__board--tracing .network__jar:not(.is-traced),
.network__board--lit .network__jar:not(.is-lit) { opacity: 0.28; }
.network__board--tracing .network__string:not(.is-traced),
.network__board--lit .network__string:not(.is-lit) { opacity: 0.15; }
.network__string.is-traced, .network__string.is-lit { stroke-width: 4.5; }

.network__hint { text-align: center; margin-top: 0.75rem; }

/* Strings are tied once and jars pop into place once; nothing loops. */
@keyframes string-tie { from { stroke-dashoffset: 1200; } }
@keyframes jar-pop { from { scale: 0.4; opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .network__string, .network__board--ready .network__jar { animation: none; }
}
