.desk--cork { padding-top: 1.5rem; }

/* Cards keep one width whatever their headings say, at most four across, and overlap
   their neighbors a little like cards pinned up by hand. Rows start at the top, so a board
   with few cards doesn't stretch them to fill its height. */
.corkboard {
  --card-width: 19rem;
  --card-overlap: 1.25rem;
  --zoomed-width: 36rem; /* ZOOMED_WIDTH in corkboard_controller.js */

  display: grid;
  grid-template-columns: repeat(auto-fill, min(var(--card-width), 100%));
  justify-content: center;
  align-content: start;
  gap: 2rem 0;
  max-width: calc(4 * var(--card-width) + 2 * (1.75rem + 14px) + 2 * var(--card-overlap));
  min-height: 60vh;
  margin: 0 auto;
  padding: 2.25rem 1.75rem;
  /* A mitred wooden frame, lit from above, around natural cork: two layers of noise rather than a
     repeating dot pattern. Each tile is drawn once and then repeated, so scrolling repaints nothing. */
  border: 14px solid;
  border-color: #6f4b2c #5a3b22 #4a2f19 #5a3b22;
  border-radius: 3px;
  list-style: none;
  background-color: #b98550;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360'%3E%3Cfilter id='d' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.42' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .27 0 0 0 0 .15 0 0 0 0 .05 0 0 0 2.6 -1.28'/%3E%3C/filter%3E%3Cfilter id='l' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .93 0 0 0 0 .77 0 0 0 0 .55 0 0 0 1.7 -1.0'/%3E%3C/filter%3E%3Crect width='360' height='360' filter='url(%23d)'/%3E%3Crect width='360' height='360' filter='url(%23l)'/%3E%3C/svg%3E");
  background-size: 360px 360px;
  box-shadow: inset 0 2px 5px rgb(0 0 0 / 0.45), inset 0 0 28px rgb(50 25 5 / 0.3), 0 16px 36px rgb(0 0 0 / 0.45);
}

@container (max-width: 40rem) {
  .corkboard { --card-overlap: 0rem; gap: 2rem 1rem; padding: 1.5rem 0.75rem; border-width: 8px; }
}

/* A card is measured in --u, a rem on the board, which a zoomed card scales up. Scaling the
   card's own lengths rather than using CSS zoom keeps it laid out the same in every browser.
   --card-line is the height of a line of beats and notes, one rule apart. */
.card {
  --u: 1rem;
  --card: #fdfdf8;
  --card-rule: #b9d3ea;
  --card-line: calc(1.5 * var(--u));
  min-width: 0;
  margin-inline: calc(var(--card-overlap) / -2);
  font-size: var(--u);
  perspective: 1400px;
  transform: rotate(-1deg);
}

.card:nth-child(3n + 2) { transform: rotate(0.8deg); }
.card:nth-child(4n + 3) { transform: rotate(-0.3deg); }
.card:nth-child(5n) { transform: rotate(1.4deg); }

.card--yellow { --card: #fff4b5; }
.card--blue { --card: #d8ebff; }
.card--pink { --card: #ffd9e5; }
.card--green { --card: #ddf3d3; }

.card--ghost { opacity: 0.35; }
.card--chosen .card__face { box-shadow: 0 18px 30px rgb(0 0 0 / 0.45); }

/* Shaped like a 3×5 index card however much is written on it; both faces scroll inside. */
.card__inner {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  aspect-ratio: 5 / 3;
  transform-style: preserve-3d;
  transition: transform 450ms ease-in-out;
}

.card--flipped .card__inner { transform: rotateY(180deg); }

.card__face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: calc(0.25 * var(--u));
  margin: 0;
  /* The next card overlaps this one's right edge, so nothing written goes under it. */
  padding: calc(1.1 * var(--u)) calc(var(--u) + var(--card-overlap, 0rem)) calc(0.6 * var(--u)) var(--u);
  backface-visibility: hidden;
  background-color: var(--card);
  /* Only the red heading rule; the blue rules are drawn in the script and the beats and notes.
     Rules are solid strips placed with background size and position, never lengths inside the
     gradient, which Safari can draw as thick bands. */
  background-image: linear-gradient(#e58a8a, #e58a8a);
  background-size: 100% 1.5px;
  background-position: 0 calc(2.6 * var(--u));
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-hand);
  box-shadow: 0 1px 2px rgb(40 20 0 / 0.3), 0 6px 12px rgb(40 20 0 / 0.22);
  cursor: grab;
}

.card__back { transform: rotateY(180deg); }

/* The face turned away still sits behind the other, and Chrome sends the wheel to its scrolling
   beats or script, so it lets the mouse through. */
.card:not(.card--flipped) .card__back, .card--flipped .card__front { pointer-events: none; }

/* The beats and notes scroll when they outgrow the card, with rules that scroll along and fall
   where the handwriting sits, so the words rest on them, with no scrollbar. It reaches out over the face's
   padding to keep the beats' + and − margin inside it. */
.card__body {
  flex: 1 1 0;
  min-height: 0;
  margin-inline: calc(-1 * var(--u));
  padding-inline: var(--u);
  overflow-y: auto;
  scrollbar-width: none;
  background-image: linear-gradient(to top, var(--card-rule) 1px, transparent 1px);
  background-size: 100% var(--card-line);
  background-position: 0 calc(-0.1 * var(--u));
  background-attachment: local;
}

.card__pin {
  position: absolute;
  top: calc(-0.45 * var(--u));
  left: 50%;
  width: calc(1.1 * var(--u));
  height: calc(1.1 * var(--u));
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a80, #c62828 60%, #7f1515);
  box-shadow: 1px 3px 4px rgb(0 0 0 / 0.45);
  transform: translateX(-50%);
}

/* An ink splat in the top left corner of both faces when two beats in a row share a charge.
   It sits at the face's content start, so it's moved out to the corner from there. */
.card__splat {
  --splat-size: calc(2 * var(--u));
  display: none;
  position: absolute;
  width: var(--splat-size);
  height: var(--splat-size);
  color: #111;
  translate: calc(calc(-0.55 * var(--u)) - var(--splat-size) / 2) calc(calc(-0.65 * var(--u)) - var(--splat-size) / 2);
  pointer-events: none;
}

.card__splat--2 { --splat-size: calc(1.6 * var(--u)); }
.card__splat--3 { --splat-size: calc(2.5 * var(--u)); }

.card--splatted .card__splat { display: block; }

.card input, .card textarea {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  resize: none;
  field-sizing: content;
  scrollbar-width: none; /* a sliver of rounding can make a fitted textarea scroll a pixel */
  outline: none;
  cursor: text;
}

.card input:focus-visible, .card textarea:focus-visible { background: rgb(255 255 255 / 0.4); }

.card__heading {
  field-sizing: fixed !important;
  height: calc(1.7 * var(--u));
  text-overflow: ellipsis;
  font-weight: 700 !important;
  font-size: calc(1.05 * var(--u)) !important;
  text-transform: uppercase;
}

/* Beats on .card to outrank the font: inherit above, which would set the textareas' lines to the font's own height and off the rules. */
.card .card__beats, .card .card__notes { line-height: var(--card-line); }
.card__beats { display: block; min-height: calc(3 * var(--card-line)); }

.card__beat-list { position: relative; margin-top: calc(0.4 * var(--u)); }

.card__beats--mirror {
  position: absolute;
  inset: 0 0 auto;
  visibility: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* The margin left of the beats, where each beat can take a + or −. */
.card__charges { position: absolute; inset: 0 100% 0 auto; width: var(--u); margin: 0; padding: 0; list-style: none; }

.card__charge {
  position: absolute;
  right: calc(0.1 * var(--u));
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: var(--card-line);
}

.card__charge-choice {
  width: calc(0.8 * var(--u));
  height: calc(0.7 * var(--u));
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--pencil);
  font: 700 calc(0.75 * var(--u))/calc(0.7 * var(--u)) var(--font-typed);
  opacity: 0;
  cursor: pointer;
}

.card__charge:hover .card__charge-choice, .card__charge-choice:focus-visible { opacity: 0.8; }
.card__charge-choice:hover { background: rgb(0 0 0 / 0.08); }
.card__charge-choice--plus[aria-pressed="true"] { color: #2e7d32; }
.card__charge-choice--minus[aria-pressed="true"] { color: #c62828; }

/* A beat with a charge shows just that one, full height, until the margin is hovered. */
.card__charge[data-charge] .card__charge-choice[aria-pressed="true"] { height: var(--card-line); font-size: var(--u); line-height: var(--card-line); opacity: 1; }
.card__charge[data-charge] .card__charge-choice[aria-pressed="false"] { display: none; }
.card__charge[data-charge]:hover .card__charge-choice { display: block; height: calc(0.7 * var(--u)); font-size: calc(0.75 * var(--u)); line-height: calc(0.7 * var(--u)); }
.card__notes { min-height: calc(3 * var(--u)); color: var(--pencil); font-size: calc(0.9 * var(--u)) !important; font-style: italic; }

.card__footer {
  display: flex;
  align-items: center;
  gap: calc(0.5 * var(--u));
  margin-top: auto;
  padding-top: calc(0.4 * var(--u));
  font: calc(0.8 * var(--u)) var(--font-typed);
}

.card__colors { display: flex; gap: calc(0.3 * var(--u)); margin: 0; padding: 0; border: 0; }

.card__color {
  appearance: none;
  width: calc(0.9 * var(--u)) !important;
  height: calc(0.9 * var(--u));
  margin: 0;
  border: 1px solid rgb(0 0 0 / 0.3) !important;
  border-radius: 50%;
  cursor: pointer !important;
}

.card__color:checked { outline: 2px solid var(--ink) !important; outline-offset: 1px; }
.card__color--white { background: #fdfdf8 !important; }
.card__color--yellow { background: #fff4b5 !important; }
.card__color--blue { background: #d8ebff !important; }
.card__color--pink { background: #ffd9e5 !important; }
.card__color--green { background: #ddf3d3 !important; }

/* The scene's mood (mood_wheel_controller.js): its own corner at the top of the card's back, apart from the
   paper colors, opening a color wheel. */
.card__mood { position: absolute; top: calc(0.55 * var(--u)); right: calc(0.7 * var(--u)); }
.card__back .card__heading { padding-right: calc(4 * var(--u)) !important; }
.card__mood-swatch {
  display: flex; align-items: center; gap: calc(0.3 * var(--u)); padding: 0; border: 0; background: none;
  color: var(--pencil); font: calc(0.75 * var(--u)) var(--font-hand); cursor: pointer;
}
.card__mood-swatch::after {
  content: ""; width: calc(0.9 * var(--u)); height: calc(0.9 * var(--u));
  border: 1px solid rgb(0 0 0 / 0.3); border-radius: 50%; background: var(--mood);
}
.card__mood-swatch--none::after { background: conic-gradient(#e66, #ec6, #6c6, #6ce, #66e, #c6c, #e66); opacity: 0.55; }
.card__mood-swatch:hover::after { opacity: 1; }

.mood-wheel {
  position: fixed; inset: auto; margin: 0; width: 196px; padding: 0.7rem;
  border: 0; border-radius: 3px; background: #fffdf6; color: #2b2620;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 8px 24px rgb(0 0 0 / 0.22); font: 0.8rem var(--font-ui);
}
.mood-wheel:popover-open { display: grid; gap: 0.55rem; justify-items: center; }
.mood-wheel__label { margin: 0; color: #6b6255; }
.mood-wheel__wheel {
  position: relative; width: 156px; aspect-ratio: 1; border-radius: 50%; cursor: crosshair; touch-action: none;
  background: radial-gradient(closest-side, #fff, rgb(255 255 255 / 0)), conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15);
}
.mood-wheel__wheel:focus-visible { outline: 2px solid var(--ink, #2b2620); outline-offset: 3px; }
.mood-wheel__dot {
  position: absolute; width: 16px; height: 16px; translate: -50% -50%; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.3); pointer-events: none;
}
.mood-wheel__none { padding: 0.2rem 0.5rem; border: 0; background: none; color: #6b6255; font: inherit; text-decoration: underline; cursor: pointer; }

.card__saved { color: var(--pencil); }

.card__flip {
  padding: calc(0.05 * var(--u)) calc(0.35 * var(--u));
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--pencil);
  font-size: var(--u);
  cursor: pointer;
}

.card__done {
  display: none;
  margin-left: auto;
  padding: calc(0.15 * var(--u)) calc(0.6 * var(--u));
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--card);
  font: inherit;
  cursor: pointer;
}

/* A clicked card comes off the board and floats over a dimmed desk for editing, shaped like
   an index card and scaled to fill most of the screen. The script sets --zoom to fit, which
   scales --u, the heights in pixels, and line heights that come out on whole screen pixels,
   since Safari rounds each rule's stripe down to them and the rules would otherwise drift off
   the writing. The card is exactly as tall as a card, and what's written on it scrolls inside. */
.card:popover-open {
  --u: calc(1rem * var(--zoom, 1));
  /* Room around the card for its pin and shadow, since a very tall card scrolls. */
  width: calc(var(--zoomed-width) * var(--zoom, 1));
  max-height: var(--zoomed-max-height);
  margin: auto;
  --card-top: calc(0.6 * var(--u));
  padding: var(--card-top) calc(1.5 * var(--u)) calc(1.5 * var(--u));
  border: 0;
  overflow-y: auto;
  background: transparent;
  color: var(--ink);
  transform: none;
  --card-overlap: 0rem;
}

.card:popover-open .card__inner { aspect-ratio: auto; height: var(--zoomed-face-height); }
.card:popover-open .card__face { cursor: auto; box-shadow: 0 6px 10px rgb(0 0 0 / 0.3), 0 24px 48px rgb(0 0 0 / 0.45); }
.card:popover-open .card__done { display: block; }

.card:popover-open::backdrop {
  background: rgb(20 12 6 / 0.6);
  animation: card-backdrop-in 300ms ease-out;
}

@keyframes card-backdrop-in { from { opacity: 0; } }

/* The board stays put under a zoomed card until it's put back. */
html:has(.card:popover-open) { overflow: hidden; scrollbar-gutter: stable; }

.card-slot { min-height: 11rem; list-style: none; }

.card__script-header { display: flex; justify-content: space-between; gap: calc(0.5 * var(--u)); min-height: calc(1.7 * var(--u)); }
.card__script-heading { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
/* The heading is written on the back; on the front it's a button that turns the card over to it, pencilled in until there is one. */
.card__script-heading:has(.card__heading-text) { display: flex; align-items: baseline; min-width: 0; }
.card__heading-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; text-align: start; cursor: text; }
.card__heading-text:empty::before { content: attr(data-placeholder); color: var(--pencil); font-weight: 400; }
.card__number { flex: none; margin-right: 0.35em; color: var(--pencil); font-weight: 400; }
.card__length { flex: none; color: var(--pencil); font: calc(0.8 * var(--u)) var(--font-typed); }

/* Sun and moon: a small sun or moon stamped beside the length, read from DAY or NIGHT in the heading. */
.card__sky { flex: none; width: calc(1.05 * var(--u)); height: calc(1.05 * var(--u)); margin: calc(0.1 * var(--u)) 0 0 auto; background: center / contain no-repeat; opacity: 0.85; }
.card__sky + .card__length { margin-left: calc(-0.2 * var(--u)); }
.card__sky--day { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c98a1b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4.2' fill='%23f2c14e'/%3E%3Cpath d='M12 2.5v2.6M12 18.9v2.6M2.5 12h2.6M18.9 12h2.6M5.3 5.3l1.8 1.8M16.9 16.9l1.8 1.8M5.3 18.7l1.8-1.8M16.9 7.1l1.8-1.8'/%3E%3C/svg%3E"); }
.card__sky--night { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.5 14.6A8 8 0 0 1 9.4 4.5a8 8 0 1 0 10.1 10.1z' fill='%237d8bb0' stroke='%23515e82' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* The scene's whole script fills the card, which keeps the notes side's height however long
   the script runs, and scrolls with the wheel or a finger, with no scrollbar. It fades out at
   the bottom, and the padding lets the last lines scroll clear of the fade. Every line and gap
   is one --line tall, and the rules are drawn one per line and scroll with the text, so each
   line of script stays on its rule. */
.card__excerpt {
  --line: var(--script-line, 1.25em);
  --rule-drop: 0.22em; /* from the bottom of a line to just under the typed baseline */
  flex: 1 1 0;
  min-height: 0;
  margin-top: calc(0.5 * var(--u));
  contain: size;
  padding-bottom: calc(2 * var(--u));
  overflow-y: auto;
  scrollbar-width: none;
  outline: none;
  font: calc(0.68 * var(--u))/var(--line) var(--font-typed);
  background-image: linear-gradient(to top, var(--card-rule) 1px, transparent 1px);
  background-size: 100% var(--line);
  background-position: 0 calc(var(--rule-drop) * -1);
  background-attachment: local;
  mask-image: linear-gradient(to bottom, #000 calc(100% - calc(2.5 * var(--u))), transparent);
}

.card__excerpt::-webkit-scrollbar, .card__body::-webkit-scrollbar, .card textarea::-webkit-scrollbar { display: none; }
.card__excerpt .element:first-child { margin-top: 0; }
.card__excerpt:empty { padding-bottom: 0; mask-image: none; }
.card__excerpt > .element:only-child:empty::before { content: "Start writing…"; color: var(--pencil); opacity: 0.6; }

/* Zoomed, the script can be edited too. */
.card:popover-open .card__excerpt { overscroll-behavior: contain; cursor: text; }

.card__flip:hover { background: rgb(0 0 0 / 0.07); color: var(--ink); }
.card__open { color: var(--pencil); text-decoration: none; }
.card__open:hover { color: var(--ink); text-decoration: underline; }

/* A spot over the pin. Resting on it for 0.6s brings up the button that throws the card away,
   and the button stays while the mouse is on it. */
.card__unpin {
  position: absolute;
  z-index: 1;
  top: calc(-0.75 * var(--u));
  left: calc(50% - calc(0.85 * var(--u)));
  width: calc(1.7 * var(--u));
  height: calc(1.7 * var(--u));
}

/* A zoomed card sits inside its padding, and overflow above it is cut off. */
.card:popover-open .card__unpin { top: calc(var(--card-top) - calc(0.75 * var(--u))); }

/* Beside the pin and out of the spot's box, so only the pin itself brings it up. */
.card__unpin form {
  position: absolute;
  top: 50%;
  left: calc(100% + calc(0.2 * var(--u)));
  translate: 0 -50%;
}

.card__discard {
  padding: calc(0.15 * var(--u)) calc(0.5 * var(--u));
  border: 0;
  border-radius: 3px;
  background: var(--danger);
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.3);
  color: #fff;
  font: calc(0.85 * var(--u)) var(--font-hand);
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms, visibility 0s 120ms;
}

.card__unpin:hover .card__discard {
  opacity: 1;
  visibility: visible;
  transition: opacity 120ms 600ms, visibility 0s 600ms;
}

/* A small New card button in each card's footer, there while the mouse (or focus) is on the card, and
   always on a touch screen, where there's no hover. */
.card__add {
  padding: 0 calc(0.4 * var(--u));
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--pencil);
  font: inherit;
  cursor: pointer;
  opacity: 0;
}

.card:hover .card__add, .card:focus-within .card__add, .card:popover-open .card__add, .card__add:focus-visible { opacity: 1; }
.card__add:hover { background: rgb(0 0 0 / 0.07); color: var(--ink); }
@media (hover: none) { .card__add { opacity: 1; } }
.card__add-form { display: contents; }

/* The script's FADE IN:, a typed slip pinned to the cork above whichever card is first. */
.board-fade-in { grid-column: 1 / -1; justify-self: start; margin: 0 0 -0.4rem 0.8rem; position: relative; z-index: 2; }
.board-fade-in__slip {
  display: block; padding: 0.15em 0.7em; font-family: var(--font-typed); font-size: 1.05rem; color: #2b2b2b;
  text-decoration: none; background: #fdfbf4; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transform: rotate(-1.5deg);
}
.board-fade-in__slip:hover, .board-fade-in__slip:focus-visible { box-shadow: 0 2px 6px rgb(0 0 0 / 0.3); }

/* Only on a board with no cards. */
.board__first-card { display: none; padding: 2rem; text-align: center; }
.board-sheet:not(:has(.card)) .board__first-card { display: block; }

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

@media (prefers-reduced-motion: reduce) {
  .card__inner { transition: none; }
  .card:popover-open::backdrop { animation: none; }
  .card.card--floating { animation: none; }
}

.corkboard[hidden] { display: none; }

/* On the back of the board, the buttons for arranging the front have nothing to do. */
.board-turned :is(.board__first-card, .yarn-menu, .structure-menu, [data-corkboard-target="flipAll"]) { display: none; }

/* The plain hardboard backing, inside the same frame. */
.corkboard--back {
  display: block;
  background-color: #5f4a35;
  background-image: repeating-linear-gradient(92deg, rgb(255 235 205 / 0.035) 0 2px, transparent 2px 7px), linear-gradient(rgb(0 0 0 / 0.12), transparent 18rem);
  background-size: auto;
  color: #f3e6d2;
}

.discards__title { margin: 0 0 1.75rem; font: 1.6rem var(--font-hand); text-align: center; }
.discards__empty { margin: 3rem 0; font: 1.25rem var(--font-hand); text-align: center; opacity: 0.8; }
.discards__empty:has(+ .discards > li) { display: none; }

.discards {
  display: grid;
  grid-template-columns: repeat(auto-fill, min(var(--card-width), 100%));
  justify-content: center;
  gap: 2.5rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A card thrown away: greyed, creased from being crumpled and smoothed out, and taped up, not pinned. */
.card--discarded { position: relative; filter: saturate(0.55) brightness(0.93); }

.card--discarded::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(104deg, transparent 31%, rgb(70 50 30 / 0.08) 31.5%, rgb(255 255 255 / 0.3) 31.9%, transparent 33%),
    linear-gradient(149deg, transparent 66%, rgb(70 50 30 / 0.07) 66.4%, rgb(255 255 255 / 0.25) 66.8%, transparent 68%),
    linear-gradient(174deg, transparent 52%, rgb(70 50 30 / 0.06) 52.4%, rgb(255 255 255 / 0.25) 52.8%, transparent 54%);
}

.card--discarded .card__face { cursor: default; }

.card__tape {
  position: absolute;
  top: calc(-0.6 * var(--u));
  left: 50%;
  z-index: 2;
  width: calc(5 * var(--u));
  height: calc(1.3 * var(--u));
  background: rgb(232 216 170 / 0.8);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transform: translateX(-50%) rotate(-2deg);
}

.card__actions { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: calc(0.4 * var(--u)); position: relative; z-index: 2; }
.card__actions:has(.sure) .card__put-back { display: none; }
.card__when { font-size: calc(0.8 * var(--u)); opacity: 0.7; white-space: nowrap; }

.card__put-back,
.card__erase {
  padding: 0 calc(0.5 * var(--u));
  border: 1px solid currentColor;
  border-radius: 3px;
  background: none;
  color: inherit;
  font: calc(0.9 * var(--u)) var(--font-hand);
  white-space: nowrap;
  cursor: pointer;
}

.card__put-back { border-color: var(--ink); background: var(--ink); color: var(--card); }
.card__erase { color: var(--danger); }

/* A card put back, held up off the board until it's dragged or pinned. */
.card.card--floating {
  z-index: 4;
  translate: 0 -0.7rem;
  scale: 1.06;
  animation: card-lift 380ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card--floating .card__face { box-shadow: 0 2px 4px rgb(40 20 0 / 0.3), 0 26px 38px rgb(30 15 0 / 0.55); }
.card--floating .card__pin { visibility: hidden; }

@keyframes card-lift { from { translate: 0 0; scale: 1; } }

.card__float {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.2rem 0.3rem 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 0.95rem var(--font-hand);
  white-space: nowrap;
  transform: translateX(-50%);
}

.card__float button { padding: 0 0.6rem; border: 0; border-radius: 999px; background: #fff; color: var(--ink); font: inherit; cursor: pointer; }

.card--dragging { opacity: 0.9 !important; transform: rotate(3deg); }

/* A phone's bar is one line, so Flip all says less there, leaving room for Undo and Redo. */
.flip-all__short { display: none; }

@media (max-width: 40rem) {
  .flip-all__long { display: none; }
  .flip-all__short { display: inline; }
}

/* A card added offline has no scene yet to weave into a plotline. */
.card[id^="card_pending_"] .plotlines { visibility: hidden; }

/* A new card drops onto the board, a little skewed, and its pin goes in after it lands. Once. */
.card--dropping { animation: card-drop 340ms cubic-bezier(0.3, 1.35, 0.55, 1) both; }
.card--dropping .card__pin { animation: pin-in 180ms 320ms ease-in both; }
@keyframes card-drop {
  from { translate: 0 -3rem; rotate: -5deg; opacity: 0; }
  60% { opacity: 1; }
}
@keyframes pin-in {
  from { scale: 1.9; opacity: 0; box-shadow: 5px 12px 10px rgb(0 0 0 / 0.3); }
}
@media (prefers-reduced-motion: reduce) {
  .card--dropping, .card--dropping .card__pin { animation: none; }
}
