:root {
  --fondo: #f6f4ef;
  --carta: #fffefb;
  --inchiostro: #16161a;
  --grigio: #77757d;
  --grigio-chiaro: #b3b1b8;
  --linea: rgba(22, 22, 26, 0.09);
  --tinta: #ff5b1f;
  --tinta-rgb: 255, 91, 31;
  --bianco: #ffffff;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 28px) 16px;
}

/* the document card: one sheet of paper with a soft shadow */
.doc {
  position: relative;
  width: min(100%, 760px);
  background: var(--carta);
  border: 1px solid var(--linea);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 18px 40px -22px rgba(22, 22, 26, 0.28), 0 2px 6px -2px rgba(22, 22, 26, 0.08);
  padding: clamp(14px, 3.4vh, 30px) clamp(16px, 4vw, 36px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.6vh, 22px);
}

.doc__top, .doc__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--inchiostro);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.doc__file {
  font-size: 12px;
  color: var(--grigio);
  font-variation-settings: "wdth" 92;
  white-space: nowrap;
}

/* the tone switch: three words and one pill that slides under the chosen one */
.tones {
  position: relative;
  align-self: flex-start;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #efede7;
  box-shadow: inset 0 0 0 1px rgba(22, 22, 26, 0.05);
}

.tones__pill {
  position: absolute;
  left: 0;
  top: 3px;
  height: calc(100% - 6px);
  width: 60px;
  border-radius: 999px;
  background: var(--bianco);
  box-shadow: 0 1px 2px rgba(22, 22, 26, 0.12), 0 4px 10px -4px rgba(22, 22, 26, 0.18);
  pointer-events: none;
}

.tone {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 560;
  color: var(--grigio);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tone[aria-checked="true"] { color: var(--inchiostro); }

@media (hover: hover) {
  .tone:hover { color: var(--inchiostro); }
}

.tone:focus-visible, .accept:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }

/* the sheet holds the headline; its height is kept by script so the card does not jump */
.sheet {
  position: relative;
  min-height: 2.3em;
  font-size: clamp(25px, min(6.4vw, 8.4vh), 64px);
}

.line {
  --w: 560;
  --d: 100;
  font-size: 1em;
  line-height: 1.08;
  letter-spacing: -0.028em;
  font-weight: normal;
  font-variation-settings: "wght" var(--w), "wdth" var(--d);
}

.word {
  --wd: 0;
  display: inline-block;
  position: relative;
  margin-right: 0.24em;
  white-space: pre;
  vertical-align: top;
  font-variation-settings: "wght" var(--w), "wdth" calc(var(--d) + var(--wd));
}

.word .ch {
  display: inline-block;
  --lw: 0;
  --ld: 0;
  font-variation-settings: "wght" calc(var(--w) + var(--lw)), "wdth" calc(var(--d) + var(--wd) + var(--ld));
}

/* a word going out: grey, with a line drawn through it */
.word--del { color: var(--grigio-chiaro); }

.strike {
  position: absolute;
  left: -0.04em;
  right: -0.04em;
  top: 52%;
  height: max(2px, 0.055em);
  border-radius: 2px;
  background: var(--tinta);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

/* a word coming in: a soft wash of the accent behind it */
.word--add {
  --hl: 0.16;
  background: linear-gradient(transparent 9%, rgba(var(--tinta-rgb), var(--hl)) 9%, rgba(var(--tinta-rgb), var(--hl)) 93%, transparent 93%);
  border-radius: 0.12em;
  padding: 0 0.05em;
  margin-left: -0.05em;
  margin-right: 0.19em;
}

.caret {
  position: absolute;
  left: 0;
  top: 0;
  width: max(2px, 0.045em);
  height: 1em;
  border-radius: 2px;
  background: var(--tinta);
  opacity: 0;
  pointer-events: none;
}

.caret.is-idle { animation: blink 1.05s steps(1) infinite; }

@keyframes blink { 50% { visibility: hidden; } }

.doc__bottom { padding-top: clamp(8px, 1.8vh, 14px); border-top: 1px solid var(--linea); }

.meta {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  font-size: 12.5px;
  color: var(--grigio);
  white-space: nowrap;
}

.meta__diff { display: inline-flex; gap: 6px; align-items: baseline; }

.roll {
  display: inline-block;
  position: relative;
  overflow: hidden;
  vertical-align: bottom;
  height: 1.3em;
  line-height: 1.3em;
}

.roll > span { display: block; }

[data-plus] { color: #1f8a4c; font-weight: 600; }
.roll--minus { color: var(--tinta); font-weight: 600; }

.accept {
  position: relative;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--inchiostro);
  color: var(--bianco);
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.accept:disabled { background: #e9e7e1; color: var(--grigio-chiaro); cursor: default; }

.accept__face {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 8px 15px;
}

.accept__check {
  width: 0;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 10;
  fill: var(--inchiostro);
  stroke: var(--bianco);
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  opacity: 0;
}

@media (max-width: 420px) {
  .doc__file { display: none; }
  .meta { gap: 10px; }
  .meta__words { display: none; }
}
