:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: rgba(24, 22, 20, 0.09);
  --riga: rgba(24, 22, 20, 0.07);
  --testo: #1a1917;
  --testo-2: #6f6b66;
  --testo-3: #a8a39d;
  --menzione: #3b4fd8;        /* the pill text */
  --menzione-fondo: #ebeefd;  /* the pill ground: a soft tint of the same blue */
  --menzione-scelta: #3b4fd8; /* the pill armed by backspace */
  --scelta: #f3f3f1;          /* the active row of the list */
  --inchiostro: #1a1917;      /* the Comment button when it can post */
  --spento: #f1f0ee;          /* the Comment button with nothing to post */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 28px) 12px;
}
.wrap { position: relative; width: min(400px, 100%); isolation: isolate; }

/* ---- the card ---- */
.card {
  position: relative;
  z-index: 1;
  background: var(--carta);
  border-radius: 20px;
  padding: clamp(12px, 3vh, 18px) clamp(12px, 4vw, 18px) clamp(12px, 3vh, 16px);
  box-shadow:
    0 0 0 1px var(--bordo),
    0 1px 2px rgba(24, 22, 20, 0.04),
    0 12px 28px -10px rgba(24, 22, 20, 0.14),
    0 34px 60px -30px rgba(24, 22, 20, 0.16);
}
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(8px, 2vh, 14px); }
.doc { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.doc svg { width: 17px; height: 17px; fill: none; stroke: var(--testo); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.count { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--testo-2); }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: #f3f2f0; color: var(--testo); font-size: 11.5px; font-weight: 600;
  overflow: hidden; position: relative;
}
.badge__n { display: block; line-height: 20px; }

/* ---- the thread ---- */
.thread { position: relative; }
.item { overflow: hidden; }
.item__in { display: grid; grid-template-columns: 26px 1fr; column-gap: 10px; padding-bottom: clamp(9px, 2.2vh, 14px); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 650; letter-spacing: 0.02em; font-stretch: 105%;
  color: var(--av-t, #5b5650); background: var(--av-f, #efede9);
  box-shadow: inset 0 0 0 1px rgba(24, 22, 20, 0.05), 0 1px 1.5px rgba(24, 22, 20, 0.06);
  position: relative;
}
.avatar::after { /* a faint top light on the disc */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.item__head { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; line-height: 18px; }
.item__name { font-weight: 600; }
.item__time { color: var(--testo-3); font-size: 11.5px; }
.item__text { font-size: 13.5px; line-height: 1.42; color: #2c2a27; margin-top: 1px; overflow-wrap: anywhere; }

/* ---- the composer ---- */
.composer {
  position: relative;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--bordo), 0 1px 2px rgba(24, 22, 20, 0.03);
  transition: box-shadow .25s;
}
.composer.is-focus { box-shadow: 0 0 0 1px rgba(24, 22, 20, 0.22), 0 0 0 4px rgba(59, 79, 216, 0.08), 0 1px 2px rgba(24, 22, 20, 0.03); }
.editor {
  min-height: calc(2 * 1.45em + 18px);
  max-height: calc(4 * 1.45em + 18px);
  overflow-y: auto;
  padding: 9px 12px;
  font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
  outline: none;
  caret-color: var(--testo);
}
.editor.is-empty::before { content: attr(data-placeholder); color: var(--testo-3); pointer-events: none; }
.caret {
  position: absolute; left: 0; top: 0; width: 1.5px; height: 18px; border-radius: 1px;
  background: var(--testo); opacity: 0; pointer-events: none;
}
.caret.is-on { animation: batte 1.05s steps(1) infinite; }
@keyframes batte { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* the pill: never split, never edited, a soft ground with a hairline */
.mention {
  display: inline-block;
  padding: 0 6px 0 5px; margin: 0 1px;
  border-radius: 7px;
  line-height: 1.5;
  color: var(--menzione); background: var(--menzione-fondo);
  box-shadow: inset 0 0 0 1px rgba(59, 79, 216, 0.1);
  font-weight: 550;
  white-space: nowrap;
  transition: background-color .18s, color .18s, box-shadow .18s;
  user-select: all;
}
.mention__at { opacity: 0.55; margin-right: 1px; font-weight: 500; }
.mention.is-armed { background: var(--menzione-scelta); color: #fff; box-shadow: 0 2px 8px -2px rgba(59, 79, 216, 0.5); }
.mention.is-armed .mention__at { opacity: 0.75; }
.item__text .mention { padding: 0 5px 0 4px; line-height: 1.3; }

.tools { display: flex; align-items: center; gap: 2px; padding: 0 8px 8px 6px; }
.tool { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--testo-3); }
.tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* Comment: the elastic pill, grey until there is something to post */
.send {
  position: relative; isolation: isolate;
  margin-left: auto;
  height: 32px; padding: 0 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--testo-3);
}
.send__bg { position: absolute; inset: 0; border-radius: 999px; background: var(--spento); z-index: -1; }
.send__label { font-stretch: 100%; transition: font-stretch .45s cubic-bezier(.34,1.56,.64,1); }
.send__tick { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.send__tick path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.send:disabled { cursor: default; }
.send:focus-visible { outline: 2px solid var(--testo); outline-offset: 3px; border-radius: 999px; }
@media (hover: hover) { .send:not(:disabled):hover .send__label { font-stretch: 112%; } }

/* ---- the list of people: floats over the card, under the caret ---- */
.people {
  position: absolute; left: 0; top: 0; z-index: 30;
  width: min(258px, 100%);
  padding: 5px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow:
    0 0 0 1px rgba(24, 22, 20, 0.08),
    0 2px 4px rgba(24, 22, 20, 0.04),
    0 14px 30px -10px rgba(24, 22, 20, 0.22),
    0 30px 50px -28px rgba(24, 22, 20, 0.2);
  visibility: hidden; opacity: 0;
  overflow: hidden;
  transform-origin: 14px 0;
}
.people__rows { position: relative; }
.people__bar {
  position: absolute; left: 5px; right: 5px; top: 5px; height: 40px;
  border-radius: 9px; background: var(--scelta);
  box-shadow: inset 0 0 0 1px rgba(24, 22, 20, 0.05);
  z-index: 3; pointer-events: none;
  mix-blend-mode: multiply; /* the bar sits over the opaque rows and tints them, text stays dark */
  display: flex; align-items: center; justify-content: flex-end; padding-right: 10px;
}
.people__bar svg { width: 14px; height: 14px; fill: none; stroke: var(--testo-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.row {
  position: absolute; left: 0; right: 0; top: 0; height: 40px;
  display: grid; grid-template-columns: 26px 1fr; column-gap: 9px; align-items: center;
  padding: 0 30px 0 7px; border-radius: 9px;
  background: #ffffff;
  cursor: pointer; user-select: none;
}
.row__txt { display: flex; flex-direction: column; min-width: 0; }
.row__name { font-size: 13px; font-weight: 420; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__name b { font-weight: 680; }
.row__role { font-size: 11.5px; color: var(--testo-2); line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people__none { font-size: 12.5px; color: var(--testo-2); padding: 11px 9px; display: none; }

/* the name in flight, from the list to the text */
.fly { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; margin: 0; }
.fly--text { font-size: 13.5px; line-height: 1.42; color: #2c2a27; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .caret.is-on { animation: none; opacity: 1; }
  .send__label { transition: none; }
}
