/* Little Letters · In the Wild (Phase 05.4E): the stationery desk on the homepage.
   Promoted from the approved study (archive/wild-study/wild.css, Phases 05.4A–05.4D). Loaded after
   styles.css, which supplies the tokens, buttons and section rules. Every paper, tape strip,
   editor and caption below is the study's own; only the section header and the study-only
   parts (study tag, page intro, washi comparison) differ.
   Phase 05.1: C and D are now working studies (A Little Forecast, Tiny Controls) in wild-ui.css; the jar
   and menu they replaced stay in archive/wild-study/. */

:root {
  --cotton: #FFFDF8;
  --kraft: #EADCC4;
  --kraft-ink: #4A4336;
  --rule: rgba(132, 148, 123, 0.34);
  --washi: #D9B3AC;

  /* A faint paper tooth, drawn once and tiled. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .18 0 0 0 0 .15 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Paper sits on the desk; it does not float above it. */
  --lift: 0 1px 1px rgba(52, 52, 47, 0.05), 0 10px 24px -18px rgba(52, 52, 47, 0.22);
}

/* Section header: the same pattern as the Letter Drawer above it. ---- */

.wild-title {
  margin: 0;
  font-family: var(--letters);
  font-weight: 400;
  font-size: clamp(44px, 12vw, 72px);
  line-height: 1.1;
  text-wrap: balance;
}

.wild-lede {
  margin: 0.35em 0 0;
  font-family: var(--letters);
  font-size: clamp(22px, 5.4vw, 28px);
  line-height: 1.3;
  color: var(--graphite-soft);
}

/* Shared artifact parts ---------------------------------------------- */

.artifact {
  margin: 0;
  min-width: 0;
  transform: rotate(var(--tilt, 0deg));
}

.artifact p,
.artifact h3,
.artifact h4,
.artifact ul { margin: 0; }

.caption {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-left: 2px;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--graphite-soft);
  /* Captions read straight even when the paper is tilted. */
  transform: rotate(calc(var(--tilt, 0deg) * -1));
  transform-origin: left center;
}

.caption span {
  font-weight: 600;
  color: var(--terracotta-ink);
}

/* A. The note -------------------------------------------------------- */

.note {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 7 / 5;
  padding: clamp(28px, 7%, 44px) clamp(24px, 8%, 48px) clamp(22px, 6%, 34px);
  background: var(--grain), var(--cotton);
  border: 1px solid rgba(228, 221, 209, 0.9);
  border-radius: 2px;
  box-shadow: var(--lift);
  font-family: var(--letters);
  container-type: inline-size;
}

.note-to {
  font-size: clamp(17px, 5.2cqi, 22px);
  color: var(--graphite-soft);
}

.note-line {
  margin-top: auto !important;
  max-width: 11em;
  font-size: clamp(28px, 9.4cqi, 40px);
  line-height: 1.2;
  text-wrap: balance;
}

.note-sign {
  margin-top: auto !important;
  align-self: flex-end;
  font-size: clamp(16px, 4.8cqi, 20px);
  color: var(--graphite-soft);
  text-align: right;
}

.note-sign span { display: block; color: var(--graphite); }

/* B. The notebook page ----------------------------------------------- */

.notebook {
  --fs: 24px;
  --lh: 36px;
  /* With ascent 0.8 em and descent 0.2 em, the baseline sits lh/2 + 0.3 fs into each line.
     The pencil ink rests a touch below its baseline, so the rule drops 0.12 em to meet it. */
  --rule-at: calc(var(--lh) / 2 + 0.42 * var(--fs));

  position: relative;
  padding: calc(var(--lh) * 1) 28px calc(var(--lh) * 1.5) 64px;
  background-color: var(--cotton);
  background-image:
    var(--grain),
    linear-gradient(to right, transparent 46px, rgba(166, 109, 96, 0.3) 46px 47px, transparent 47px),
    repeating-linear-gradient(to bottom,
      transparent 0 calc(var(--rule-at) - 1px),
      var(--rule) calc(var(--rule-at) - 1px) var(--rule-at),
      transparent var(--rule-at) var(--lh));
  background-position: 0 0, 0 0, 0 calc(var(--lh) * 1);
  border: 1px solid rgba(228, 221, 209, 0.9);
  border-radius: 2px 6px 6px 2px;
  box-shadow: var(--lift);
  font-family: var(--letters);
  font-size: var(--fs);
  line-height: var(--lh);
}

/* Spiral holes along the top edge would be scrapbook; three small punched holes are enough. */
.notebook::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 22%;
  width: 11px;
  height: 56%;
  background: radial-gradient(circle at center, var(--ivory) 0 5px, rgba(228, 221, 209, 0.9) 5px 5.5px, transparent 6px) 0 0 / 11px calc(50% - 5px) repeat-y;
}

.nb-date {
  font-size: 18px;
  color: var(--graphite-soft);
  text-align: right;
}

.nb-title {
  font-weight: 400;
  font-size: 34px;
  line-height: var(--lh);
  /* Larger size, same rule: nudge its baseline down onto the line. */
  position: relative;
  top: calc(var(--rule-at) - (var(--lh) / 2 + 0.42 * 34px));
  text-wrap: balance;
  max-width: 11em;
}

.nb-list {
  margin-top: var(--lh) !important;
  padding: 0;
  list-style: none;
}

.nb-list li {
  position: relative;
  padding-left: 30px;
}

/* A pencil box, and a terracotta tick for the done ones. */
.nb-list li::before,
.nb-list li.is-done::after {
  content: "";
  position: absolute;
  left: 0;
  top: calc(var(--rule-at) - 15px);
  width: 15px;
  height: 15px;
  background: no-repeat center / contain;
}

.nb-list li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.2 2.6c3.8-.5 7.6-.4 11.4.1.4 3.6.3 7.2-.2 10.8-3.7.3-7.4.3-11 0-.4-3.6-.4-7.3-.2-10.9Z' fill='none' stroke='%2364635B' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.nb-list li.is-done::after {
  left: 2px;
  top: calc(var(--rule-at) - 21px);
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M2.8 10.2c1.4 1.2 2.6 2.6 3.6 4.2 2.2-4.8 5.2-8.8 9-12' fill='none' stroke='%23A66D60' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.nb-list li.is-done { color: var(--graphite-soft); }

.nb-aside {
  position: relative;
  width: fit-content;
  margin: calc(var(--lh) * 0.5) 4px 0 auto !important;
  font-size: 20px;
  line-height: var(--lh);
  color: var(--terracotta);
  transform: rotate(-4deg);
}

/* A quick pencil arrow back up to the list. */
.nb-arrow {
  position: absolute;
  right: calc(100% + 6px);
  bottom: 55%;
  width: 46px;
  height: 30px;
  overflow: visible;
  fill: none;
  stroke: var(--terracotta);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.nb-foot {
  position: absolute;
  right: 28px;
  bottom: 12px;
  font-size: 15px;
  line-height: 1;
  color: var(--graphite-soft);
}

/* The desk ----------------------------------------------------------- */

/* The study's lede-to-desk spacing (intro padding plus 16 px), on the homepage's section rhythm. */
.desk {
  display: grid;
  gap: 56px;
  margin-top: clamp(48px, 9vw, 72px);
}

/* Phones and small tablets: one column, papers nudged left and right so the stack feels set down by hand. */
.artifact--note     { --tilt: -1deg;   width: min(100%, 460px); }
.artifact--notebook { --tilt: 0.6deg;  width: min(100%, 480px); justify-self: end; }
.artifact--forecast { --tilt: -1.6deg; width: min(100%, 350px); justify-self: center; }
.artifact--controls { --tilt: 0.5deg;  width: min(100%, 460px); }

@media (max-width: 479px) {
  .notebook { --fs: 21px; --lh: 32px; padding-left: 52px; padding-right: 20px; }
  .notebook { background-image: var(--grain), linear-gradient(to right, transparent 38px, rgba(166, 109, 96, 0.3) 38px 39px, transparent 39px), repeating-linear-gradient(to bottom, transparent 0 calc(var(--rule-at) - 1px), var(--rule) calc(var(--rule-at) - 1px) var(--rule-at), transparent var(--rule-at) var(--lh)); }
  .notebook::before { left: 14px; }
  .nb-title { font-size: 28px; top: calc(var(--rule-at) - (var(--lh) / 2 + 0.42 * 28px)); }
  .nb-list li { padding-left: 26px; }
  .nb-aside { font-size: 18px; }
}

/* Tablets (Phase 05.4E): the desktop desk on a smaller table. Note and forecast on the left; the notebook
   and controls take the wider right-hand column, so every entry keeps its own line at full
   size. Below 960 px the notebook would start to wrap, so the single staggered column stays. */
@media (min-width: 960px) and (max-width: 1119px) {
  .desk {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    row-gap: 40px;
    align-items: start;
  }

  .artifact--note     { --tilt: -1.4deg; grid-column: 1 / span 5; grid-row: 1;     width: auto; margin-top: 56px; }
  .artifact--notebook { --tilt: 0.8deg;  grid-column: 6 / span 7; grid-row: 1 / 3; width: auto; justify-self: stretch; margin-left: 8px; }
  .artifact--forecast { --tilt: -2.4deg; grid-column: 1 / span 5; grid-row: 2 / 4; width: 100%; max-width: 350px; justify-self: center; margin-top: 24px; }
  .artifact--controls { --tilt: 1deg;    grid-column: 6 / span 7; grid-row: 3;     width: 100%; max-width: 480px; justify-self: center; margin-top: 8px; }
}

/* Desktop: a loose, asymmetric desk. Four columns of paper, never a tidy row of cards. */
@media (min-width: 1120px) {
  .desk {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: auto auto;
    column-gap: 24px;
    row-gap: 40px;
    align-items: start;
  }

  .desk { grid-template-rows: auto auto auto; }

  .artifact--note     { --tilt: -1.4deg; grid-column: 1 / span 5; grid-row: 1;     width: auto; margin-top: 56px; }
  .artifact--notebook { --tilt: 0.8deg;  grid-column: 7 / span 5; grid-row: 1 / 3; width: auto; justify-self: stretch; margin-left: 16px; }
  .artifact--forecast { --tilt: -2.4deg; grid-column: 2 / span 4; grid-row: 2 / 4; width: 100%; max-width: 350px; justify-self: center; margin-top: 24px; }
  .artifact--controls { --tilt: 1deg;    grid-column: 6 / span 6; grid-row: 3;     width: 100%; max-width: 480px; justify-self: center; margin-top: 8px; }
}


/* Washi tape ------------------------------------------------------- */

/* One strip: translucent, a little uneven at the torn ends, no shadow, no motion.
   The base is the approved dusty pink strip on the note; each paper below changes
   only its colour, length, angle and spot. Every strip sits on a paper edge, clear of text. */
.washi {
  --tape: var(--washi);
  --tape-alpha: 0.84;
  --tape-rot: -6deg;
  --tear: polygon(
    1.4% 4%, 99% 0%, 97.6% 16%, 99.6% 30%, 98% 46%, 100% 62%, 98.2% 78%, 99.4% 100%,
    0.6% 96%, 2.2% 82%, 0% 66%, 1.8% 50%, 0.2% 34%, 2% 18%);
  position: absolute;
  z-index: 1;
  top: -15px;
  left: 50%;
  width: clamp(104px, 30%, 132px);
  height: 30px;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 40%, rgba(166, 109, 96, 0.05)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 7px),
    var(--tape);
  opacity: var(--tape-alpha);
  mix-blend-mode: multiply;
  transform: translateX(-46%) rotate(var(--tape-rot));
  clip-path: var(--tear);
  pointer-events: none;
}

/* A second tear, so the strips are not cut from the same piece. */
.washi--forecast,
.washi--tiny,
.washi--notebook-right {
  --tear: polygon(
    0.4% 0%, 98.6% 5%, 100% 20%, 98.4% 36%, 99.8% 52%, 98% 70%, 100% 86%, 98.8% 100%,
    1.6% 97%, 0% 80%, 1.8% 64%, 0.2% 48%, 2% 30%, 0.6% 14%);
}

/* B. Oat, across the top left corner, outside the margin line and clear of the punched holes. */
.washi--notebook {
  --tape: #D8C5A5;
  --tape-alpha: 0.78;
  --tape-rot: -38deg;
  top: -4px;
  left: -25px;
  width: 66px;
  height: 24px;
  transform: rotate(var(--tape-rot));
}

/* Top-edge pairs: the papers look pinned to the desk along their top edge only.
   The second piece of each pair is a little shorter or longer, and tipped differently. */

/* B. Top right corner, tipped the other way from the top left piece, clear of the date. */
.washi--notebook-right {
  --tape: #D8C5A5;
  --tape-alpha: 0.78;
  --tape-rot: 33deg;
  top: -3px;
  left: auto;
  right: -22px;
  width: 60px;
  height: 23px;
  transform: rotate(var(--tape-rot));
}

/* On phones the notebook already meets the screen margin, so the corner pieces tuck in a little. */
@media (max-width: 719px) {
  .washi--notebook { left: -12px; }
  .washi--notebook-right { right: -12px; }
}


/* Phase 05.4B: make your own note ------------------------------------ */

/* The live note keeps the card's 7:5 shape. Only the message size changes, a few steps at most,
   so the composition holds. Past the soft limits the card is allowed to grow instead of clipping. */
.note--live { min-height: 0; }
.note--live.is-overfull { min-height: auto; }

.note--live .note-line {
  /* Never smaller than 18 px: past that, the card grows instead (see note.js). */
  font-size: max(18px, calc(clamp(28px, 9.4cqi, 40px) * var(--note-scale, 1)));
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note--live .note-to,
.note--live .note-sign { overflow-wrap: anywhere; }

.note--live .note-sign { max-width: 100%; }

/* Phase 05.4D: a full message no longer runs straight into "thank you, always.". Only once the
   message has stepped down (or the card has grown) does the closing keep this much room above it. */
.note--live.is-snug .note-sign { padding-top: 0.75em; }


/* An empty name leaves its line off the card but keeps its place, so nothing jumps. */
.note--live .note-to.is-empty,
.note--live [data-note="from"].is-empty { visibility: hidden; }

/* The font's own answer to a missing letter: a small empty box, drawn in pencil. */
.not-drawn {
  display: inline-block;
  width: 0.46em;
  height: 0.62em;
  margin: 0 0.05em;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.5;
  vertical-align: -0.02em;
}

.caption--note {
  flex-wrap: wrap;
  align-items: center;
  row-gap: 4px;
}

/* Quiet, like a pencilled note in the margin of the caption. */
.make-own {
  min-height: 32px;
  margin: -8px 0 -8px auto;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--terracotta-ink);
  font: 500 13px/1.2 var(--sans);
  letter-spacing: 0.01em;
}

.make-own:hover { border-color: var(--border); background: transparent; }
.make-own:active { background: var(--paper); }
.make-own[aria-expanded="true"] { color: var(--graphite-soft); }

/* The editor is a plain slip of paper set beside the card, straight on the desk. */
.note-editor {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 18px 18px 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  transform: rotate(calc(var(--tilt, 0deg) * -1));
  transform-origin: left top;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--graphite-soft);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--cotton);
  color: var(--graphite);
  caret-color: var(--terracotta);
  font: 400 16px/1.45 var(--sans);
}

.field textarea {
  min-height: 5.6em;
  resize: vertical;
}

.field input:hover,
.field textarea:hover { border-color: var(--sage); }

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 1px;
  border-color: transparent;
}

.field.is-long input,
.field.is-long textarea { border-color: var(--terracotta); }

/* A quiet pencilled aside, tucked just under the fields. */
.note-status {
  margin: -6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--graphite-soft);
}

.note-status:empty { margin-top: -14px; }  /* stays in the tree so it can still announce */

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.editor-actions button { min-height: 40px; }

@media (max-width: 719px) {
  .editor-actions button { min-height: 44px; }
}


/* Phase 05.4C: make your own notebook page ---------------------------- */

/* The page has no fixed shape: every line, wrapped or not, keeps the 36 px rule (32 px on phones),
   so long things simply add rules and the page grows taller. The type never shrinks. */
.notebook--live .nb-title,
.notebook--live .nb-list li {
  overflow-wrap: anywhere;
  min-height: var(--lh);  /* an empty line keeps its rule, so nothing below jumps */
}

/* The caption keeps its approved layout. The button sits at the end of its line when there is room
   (notebook.js measures). Where there isn't, it takes a row of its own under the words, laid out so the
   C and the caption wrap exactly as before; notebook.js then pulls the next paper up by that row and
   keeps the tilt pivots where they were, so nothing on the desk moves. */
.caption--notebook .make-own {
  flex: none;
  align-self: center;
  white-space: nowrap;
}

.caption--notebook.is-hanging {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  align-items: start;
}

.caption--notebook.is-hanging .make-own {
  grid-column: 2;
  justify-self: end;
  margin: 0 -10px 0 0;
}

/* One slip, one row per thing: the notebook's own pencil box, then the words. */
.nb-editor {
  --nb-box: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.2 2.6c3.8-.5 7.6-.4 11.4.1.4 3.6.3 7.2-.2 10.8-3.7.3-7.4.3-11 0-.4-3.6-.4-7.3-.2-10.9Z' fill='none' stroke='%2364635B' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
  --nb-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M2.8 10.2c1.4 1.2 2.6 2.6 3.6 4.2 2.2-4.8 5.2-8.8 9-12' fill='none' stroke='%23A66D60' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.nb-things {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  gap: 6px;
}

.nb-things legend {
  float: left;  /* lets the legend sit in the grid like the other labels */
  width: 100%;
  margin-bottom: -2px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--graphite-soft);
}

.nb-row {
  display: flex;
  align-items: center;
}

.nb-row input[type="text"] { flex: 1; min-width: 0; }

/* The whole 40 × 44 px square is the target; the pencil box inside is the same 15 px box as the page. */
.nb-check {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 44px;
  margin-left: -8px;
  cursor: pointer;
}

/* Scoped past .field input (the text-field look), so the box sits bare on the slip. */
.nb-things .nb-check input {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--nb-box) 4px 6px / 15px 15px no-repeat;
  cursor: pointer;
}

/* Same offset as the page: the tick overshoots the top of the box, as a quick pencil tick does. */
.nb-things .nb-check input:checked {
  background:
    var(--nb-tick) 6px 0 / 18px 18px no-repeat,
    var(--nb-box) 4px 6px / 15px 15px no-repeat;
}

.nb-things .nb-check input:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 1px;
}

.nb-things .nb-check:hover input { background-color: rgba(132, 148, 123, 0.12); }

@media (forced-colors: active) {
  .nb-things .nb-check input { -webkit-appearance: auto; appearance: auto; background: none; }
}

.nb-row.is-long input[type="text"] { border-color: var(--terracotta); }

/* The pencil boxes on the page are real checkboxes too. Each is an invisible 24 px square centred on
   its drawn box (15 px, from ::before above), so the drawing, the tick and the words stay as they were.
   While the editor is open these step aside, and the editor's boxes are the ones to use. */
.nb-paper-check {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  z-index: 1;  /* above the drawn tick (li::after), which would otherwise take the click */
  left: -4.5px;
  top: calc(var(--rule-at) - 19.5px);
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.nb-paper-check:focus-visible { outline-offset: 0; }
.nb-paper-check:disabled { pointer-events: none; }


/* Phase 05.4D: save the note as an image ---------------------------- */

/* "make your own" and "save as image" travel together at the end of the caption, on its line when
   both fit beside the words and on a row of their own below them otherwise (note-save.js decides,
   and gives that row back to the desk so nothing below moves). */
.note-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.note-actions:not(:has(> button:not([hidden]))) { display: none; }

.caption--note.is-hanging .note-actions {
  flex-basis: 100%;
  justify-content: flex-end;
}

/* Plain pencilled words at rest, like "make your own". A soft pill appears only on hover (mouse) and
   keyboard focus, drawn at the 32 px size "make your own" uses even where the touch target is
   taller, so the two read as a pair. */
.save-note {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 32px;
  margin: -8px 0;
  padding: 6px 11px;  /* 10 px plus the 1 px border the pill used to take, so the width holds */
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--terracotta-ink);
  font: 500 13px/1.2 var(--sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.save-note::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 32px;
  transform: translateY(-50%);
  border: 1px solid transparent;
  border-radius: 999px;
  pointer-events: none;
}

.save-note:hover { border-color: transparent; background: transparent; }
.save-note:active { background: transparent; }
.save-note:active::before { background: var(--paper); }

@media (hover: hover) {
  .save-note:hover::before { border-color: var(--border); }
}

/* Keyboard focus: the same pill, pencilled in terracotta, in place of the page's wider ring. */
.save-note:focus-visible { outline: none; }
.save-note:focus-visible::before { border-color: var(--terracotta); box-shadow: 0 0 0 0.5px var(--terracotta); }

@media (forced-colors: active) {
  .save-note:focus-visible { outline: 2px solid CanvasText; outline-offset: 2px; }
}

/* Every label shares one cell, so the button keeps the width of the longest and the caption never
   reflows while it says "saving…" or "saved". */
.save-note .save-label {
  position: relative;  /* above the pill */
  grid-area: 1 / 1;
  justify-self: center;
  font-weight: inherit;
  color: inherit;
  visibility: hidden;
}

.save-note[data-state="idle"] .save-label[data-state="idle"],
.save-note[data-state="busy"] .save-label[data-state="busy"],
.save-note[data-state="done"] .save-label[data-state="done"],
.save-note[data-state="error"] .save-label[data-state="error"] { visibility: visible; }

.save-note[data-state="busy"] { cursor: progress; color: var(--graphite-soft); }
.save-note[data-state="done"] { color: var(--graphite-soft); }

/* A full-size touch target on phones; the extra height hangs into the caption's margins. */
@media (max-width: 719px) {
  .save-note { min-height: 44px; margin: -14px 0; }
}
