/* Little Tokyo Story Wall: shared components.
   Visual language: washi grounds, sumi ink, one vermilion accent, thin vermilion rules,
   tanzaku paper notes hung on a string, generous space, quiet motion.

   Index
     .visually-hidden
     .brand  (.brand__mark .brand__text .brand__name .brand__jp .brand__sub, --large, --stacked)
     .question  (--center, --plain)
     .btn  (--primary --ghost --quiet --block --small; [aria-busy] [aria-disabled])
     .fab-add  (.fab-add__mark .fab-add__label; [aria-disabled] paused look)
     .pill  (.pill__dot, --connection, --live) · .pill-anchor
     .chip  (--accent --quiet --solid --small)
     .field .field__label .field__hint .field__error .field__foot · .input · .textarea · .counter
     .note  (--kinari --sakura --ai --yamabuki --matcha, --own, --enter, --leave, --highlight,
             --short --long --clamp, .note__body .note__name .note__question .note__own)
     .sheet  (.sheet__backdrop .sheet__panel .sheet__grip .sheet__head .sheet__title
              .sheet__question .sheet__notice .sheet__textarea .sheet__feedback
              .sheet__status .sheet__wait .sheet__actions)
     .reading-card  (.reading-card__backdrop __panel __pin __close __title __body __name
                     __meta __question __label __question-text)
     .toast-region .toast  (--neutral --success --warn)
*/

/* ── Accessibility ─────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Brand ─────────────────────────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--c-ink);
  text-decoration: none;
  font-family: var(--font-display);
  line-height: 1.15;
}

a.brand:hover {
  color: var(--c-ink);
}

.brand__mark,
.brand > img:first-child,
.brand > svg:first-child {
  width: auto;
  height: 2.25rem;
  flex: none;
}

.brand__text,
.brand__wordmark {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.brand__name {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.brand__jp {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  line-height: 1.2;
  color: var(--c-vermilion-ink);
}

.brand__sub {
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--c-ink-2);
}

.brand--large {
  gap: var(--sp-4);
}

.brand--large .brand__mark,
.brand--large > img:first-child,
.brand--large > svg:first-child {
  height: 3.5rem;
}

.brand--large .brand__name {
  font-size: 1.5rem;
}

.brand--large .brand__jp {
  font-size: 0.875rem;
}

.brand--stacked {
  flex-direction: column;
  text-align: center;
}

.brand--stacked .brand__text,
.brand--stacked .brand__wordmark {
  align-items: center;
}

/* ── Question ──────────────────────────────────────────────────────────── */
.question {
  font-family: var(--font-display);
  font-size: var(--fs-question);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.005em;
  color: var(--c-ink);
  text-wrap: balance;
}

.question::before {
  content: "";
  display: block;
  width: var(--rule-len);
  height: var(--rule-w);
  margin: 0 0 clamp(12px, 0.45em, 24px);
  background: var(--c-vermilion);
}

.question--center,
.question[data-align="center"] {
  text-align: center;
}

.question--center::before,
.question[data-align="center"]::before,
:where(.text-center, .center, .is-centered, [style*="text-align: center"], [style*="text-align:center"]) > .question::before {
  margin-inline: auto;
}

.question--plain::before {
  content: none;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--c-ink);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-s);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:hover {
  color: var(--btn-fg);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--c-vermilion-ink);
  outline-offset: 3px;
}

.btn > svg {
  width: 1.1em;
  height: 1.1em;
}

.btn--primary {
  --btn-bg: var(--c-vermilion);
  --btn-fg: var(--c-on-vermilion);
  --btn-border: var(--c-vermilion);
  box-shadow: inset 0 1px 0 rgba(255, 248, 240, 0.16), 0 10px 20px -14px rgba(140, 44, 26, 0.8);
}

.btn--primary:hover {
  --btn-bg: var(--c-vermilion-ink);
  --btn-border: var(--c-vermilion-ink);
}

.btn--ghost {
  --btn-fg: var(--c-ink);
  --btn-border: var(--c-ink);
}

.btn--ghost:hover {
  --btn-bg: rgba(43, 42, 40, 0.05);
}

.btn--quiet {
  --btn-fg: var(--c-ink-2);
  padding-inline: 14px;
}

.btn--quiet:hover {
  --btn-fg: var(--c-ink);
  --btn-bg: rgba(43, 42, 40, 0.05);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: var(--fs-small);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn--primary[disabled],
.btn--primary[aria-disabled="true"] {
  --btn-bg: var(--c-line);
  --btn-fg: var(--c-ink-2);
  --btn-border: var(--c-line);
}

.btn--ghost[disabled],
.btn--ghost[aria-disabled="true"],
.btn--quiet[disabled],
.btn--quiet[aria-disabled="true"] {
  --btn-bg: transparent;
  --btn-fg: var(--c-ink-2);
  --btn-border: var(--c-line);
}

.btn--quiet[disabled],
.btn--quiet[aria-disabled="true"] {
  --btn-border: transparent;
}

/* Sending: stays vermilion, a thin brush-stroke travels along the bottom edge. */
.btn--primary[aria-busy="true"] {
  --btn-bg: var(--c-vermilion-ink);
  --btn-fg: var(--c-on-vermilion);
  --btn-border: var(--c-vermilion-ink);
  cursor: progress;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 38%;
  height: 2px;
  background: currentColor;
  opacity: 0.7;
  animation: ltsw-busy 1.15s var(--ease-in-out) infinite;
}

/* ── Add button (persistent bottom pill) ───────────────────────────────── */
.fab-add {
  position: fixed;
  z-index: var(--z-fab);
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: max(var(--sp-4), calc(var(--safe-bottom) + var(--sp-2)));
  width: max-content;
  max-width: calc(100% - 2 * var(--sp-4) - var(--safe-left) - var(--safe-right));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: 0 28px 0 22px;
  border: 1px solid var(--c-vermilion);
  border-radius: var(--radius-pill);
  background: var(--c-vermilion);
  color: var(--c-on-vermilion);
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.05em;
  white-space: nowrap;
  box-shadow: var(--shadow-fab);
  cursor: pointer;
  touch-action: manipulation;
  animation: ltsw-rise-in var(--dur-slow) var(--ease-out) 150ms backwards;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.fab-add:hover {
  background: var(--c-vermilion-ink);
  border-color: var(--c-vermilion-ink);
}

.fab-add:active {
  transform: scale(0.97);
}

.fab-add:focus-visible {
  outline: 2px solid var(--c-ink);
  outline-offset: 4px;
}

.fab-add__mark {
  display: inline-flex;
  width: 15px;
  height: 20px;
}

.fab-add__mark svg {
  width: 100%;
  height: 100%;
}

.fab-add__label {
  overflow: hidden;
  text-overflow: ellipsis;
  /* As a flex item the label clips at its own line box; with the button's
     line-height: 1 that cut the descenders of "Add your story". */
  line-height: 1.4;
}

.fab-add[disabled],
.fab-add[aria-disabled="true"] {
  background: var(--c-paper);
  border-color: var(--c-line-strong);
  color: var(--c-ink-2);
  box-shadow: var(--shadow-float);
  cursor: not-allowed;
  transform: none;
}

/* ── Pill ──────────────────────────────────────────────────────────────── */
.pill-anchor {
  position: fixed;
  z-index: var(--z-pill);
  top: calc(var(--safe-top) + var(--sp-3));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 32px;
  padding: 6px 14px 6px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-pill);
  background: var(--c-paper);
  color: var(--c-ink);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: var(--tracking-ui);
  white-space: nowrap;
}

.pill__dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-vermilion);
}

.pill--connection {
  pointer-events: auto;
  box-shadow: var(--shadow-float);
  animation: ltsw-drop-in var(--dur) var(--ease-out) backwards;
}

.pill--connection .pill__dot {
  animation: ltsw-breathe 1.4s var(--ease-in-out) infinite;
}

.pill--connection.is-leaving {
  animation: ltsw-rise-out var(--dur-fast) var(--ease-in) forwards;
}

.pill--live .pill__dot {
  box-shadow: 0 0 0 3px var(--c-vermilion-wash);
}

/* ── Chip ──────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 32px;
  padding: 5px 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-pill);
  background: rgba(251, 248, 242, 0.94);
  color: var(--c-ink);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

a.chip,
button.chip {
  min-height: 44px;
  cursor: pointer;
  box-shadow: var(--shadow-float);
}

a.chip:hover,
button.chip:hover {
  color: var(--c-ink);
  border-color: var(--c-ink-2);
  background: var(--c-paper);
}

.chip--accent {
  color: var(--c-vermilion-ink);
  border-color: rgba(192, 70, 47, 0.45);
}

.chip--quiet {
  background: transparent;
  color: var(--c-ink-2);
  box-shadow: none;
}

.chip--solid {
  background: var(--c-ink);
  border-color: var(--c-ink);
  color: var(--c-cream);
}

a.chip--solid:hover,
button.chip--solid:hover {
  background: #403E3A;
  border-color: #403E3A;
  color: var(--c-cream);
}

.chip--small {
  min-height: 24px;
  padding: 2px 10px;
  font-size: var(--fs-label);
  letter-spacing: 0.04em;
}

/* ── Form fields ───────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.field__label {
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--c-ink);
}

.field__hint {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--c-ink-2);
}

.field__error {
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.45;
  color: var(--c-vermilion-ink);
}

.field__foot {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--sp-3);
  min-height: 1.25rem;
}

.input,
.textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-s);
  background-color: #FFFDF8;
  color: var(--c-ink);
  font-family: var(--font-ui);
  font-size: max(16px, 1.0625rem); /* ≥ 16px: stops iOS zooming on focus */
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.textarea {
  min-height: 7.5rem;
  line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--c-ink-2);
  opacity: 1;
}

.input:hover,
.textarea:hover {
  border-color: var(--c-ink-2);
}

.input:focus,
.textarea:focus,
.input:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--c-ink);
  box-shadow: 0 0 0 3px rgba(192, 70, 47, 0.24);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--c-vermilion-ink);
}

.input[readonly],
.textarea[readonly] {
  color: var(--c-ink-2);
}

.input:disabled,
.textarea:disabled {
  background-color: var(--c-wash);
  color: var(--c-ink-2);
  cursor: not-allowed;
}

.counter {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--c-ink-2);
  transition: color var(--dur-fast) var(--ease-out);
}

.counter[data-state="near"] {
  color: var(--c-ink);
}

.counter[data-state="limit"] {
  color: var(--c-vermilion-ink);
}

/* ── Note (tanzaku paper) ──────────────────────────────────────────────── */
/* Sizes are in em: set font-size on .note (or a parent) to scale the whole note,
   e.g. the projector board sets a larger font-size. */
.note {
  --note-paper: var(--note-kinari);
  --note-ink: var(--c-ink);
  --note-rot: 0rad;
  position: relative;
  display: block;
  padding: 1.75em 1.15em 1.1em;
  border-radius: 2px;
  background-color: var(--note-paper);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 38%),
    var(--paper-texture);
  background-size: 100% 100%, var(--paper-tile) var(--paper-tile);
  color: var(--note-ink);
  box-shadow: var(--shadow-note);
  transform: rotate(var(--note-rot));
  transform-origin: 50% 0;
  text-align: left;
  overflow-wrap: anywhere;
  line-break: strict;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  isolation: isolate;
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

/* The string the note hangs from. */
.note::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: -0.8em;
  left: 50%;
  width: 1px;
  height: 1.45em;
  background: rgba(43, 42, 40, 0.55);
  transform: translateX(-50%);
  pointer-events: none;
}

/* The vermilion eyelet / pin. */
.note::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0.6em;
  left: 50%;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--c-vermilion);
  box-shadow: 0 0 0 0.16em var(--note-paper), 0 1px 1px 0.16em rgba(43, 42, 40, 0.12);
  transform: translateX(-50%);
  pointer-events: none;
}

.note--kinari { --note-paper: var(--note-kinari); --note-ink: var(--c-ink); }
.note--sakura { --note-paper: var(--note-sakura); --note-ink: var(--c-ink); }
.note--ai { --note-paper: var(--note-ai); --note-ink: var(--note-ink-ai); }
.note--yamabuki { --note-paper: var(--note-yamabuki); --note-ink: var(--c-ink); }
.note--matcha { --note-paper: var(--note-matcha); --note-ink: var(--note-ink-matcha); }

.note__body {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.0625em;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.005em;
  color: var(--note-ink);
  text-wrap: pretty;
}

.note--short .note__body {
  font-size: 1.375em;
  line-height: 1.4;
}

.note--long .note__body {
  font-size: 0.9375em;
  line-height: 1.55;
}

.note__name {
  margin: 0.95em 0 0;
  font-family: var(--font-ui);
  font-size: 0.8125em;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: var(--c-ink-2);
}

.note__name::before {
  content: "— ";
  content: "— " / "";
}

.note__question {
  margin: 0.85em 0 0;
  padding-top: 0.7em;
  border-top: 1px solid rgba(43, 42, 40, 0.14);
  font-family: var(--font-ui);
  font-size: 0.75em;
  line-height: 1.45;
  color: var(--c-ink-2);
}

.note__question-label {
  margin-right: 0.35em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.92em;
  color: var(--c-vermilion-ink);
}

/* Your own note: a small seal, a vermilion base rule. */
.note--own {
  box-shadow: var(--shadow-note), inset 0 -2px 0 var(--c-vermilion);
}

.note__own {
  display: flex;
  align-items: center;
  gap: 0.55em;
  margin: 0 0 0.7em;
  font-family: var(--font-ui);
  font-size: 0.6875em;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-vermilion-ink);
}

.note__own::before {
  content: "";
  flex: none;
  width: 0.95em;
  height: 0.95em;
  border-radius: 1.5px;
  background: var(--c-vermilion);
  box-shadow: inset 0 0 0 0.18em var(--c-vermilion), inset 0 0 0 0.26em rgba(255, 248, 240, 0.7);
  transform: rotate(-6deg);
}

/* Interactive notes (role="button"). */
.note[role="button"] {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .note[role="button"]:hover {
    transform: rotate(var(--note-rot)) translateY(-3px);
    box-shadow: var(--shadow-note-lift);
  }

  .note--own[role="button"]:hover {
    box-shadow: var(--shadow-note-lift), inset 0 -2px 0 var(--c-vermilion);
  }
}

.note[role="button"]:active {
  transform: rotate(var(--note-rot)) scale(0.985);
}

.note:focus-visible {
  outline: 2px solid var(--c-vermilion-ink);
  outline-offset: 4px;
  border-radius: 3px;
}

/* Fixed-size boards (projector): clamp long text inside the paper. */
.note--clamp .note__body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--note-lines, 6);
  overflow: hidden;
}

/* Entrance: hangs in from the string and settles with a damped sway. */
.note--enter {
  animation: ltsw-note-in var(--dur-slow) var(--ease-out) backwards;
}

.note--own.note--enter,
.note--highlight {
  animation:
    ltsw-note-in var(--dur-slow) var(--ease-out) backwards,
    ltsw-own-pulse 1.6s var(--ease-out) 450ms 1 backwards;
}

.note--highlight:not(.note--enter) {
  animation: ltsw-own-pulse 1.6s var(--ease-out) 1;
}

/* Leave: fades and drops slightly (300 ms). Remove the element on animationend. */
.note--leave {
  animation: ltsw-note-out 300ms var(--ease-in) forwards;
  pointer-events: none;
}

/* ── Submit sheet ──────────────────────────────────────────────────────── */
.sheet {
  position: fixed;
  z-index: var(--z-sheet);
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

.sheet.is-open {
  pointer-events: auto;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: var(--c-scrim);
  opacity: 0;
  touch-action: none;
  transition: opacity var(--dur) var(--ease-out);
}

.sheet.is-open .sheet__backdrop {
  opacity: 1;
}

.sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  width: 100%;
  max-width: 34rem;
  max-height: calc(100% - max(var(--sp-4), var(--safe-top)));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding:
    0
    calc(var(--sp-5) + var(--safe-right))
    calc(var(--sp-5) + var(--safe-bottom))
    calc(var(--sp-5) + var(--safe-left));
  border-radius: 18px 18px 0 0;
  background-color: var(--c-paper);
  background-image: var(--paper-texture);
  background-size: var(--paper-tile) var(--paper-tile);
  color: var(--c-ink);
  box-shadow: var(--shadow-sheet);
  transform: translateY(105%);
  transition: transform var(--dur) var(--ease-out);
}

.sheet.is-open .sheet__panel {
  transform: translateY(0);
}

.sheet__panel.is-dragging {
  transition: none;
}

.sheet.has-keyboard .sheet__panel {
  padding-bottom: var(--sp-4);
}

.sheet__grip {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: none;
  height: 22px;
  margin: 0 calc(-1 * var(--sp-5)) calc(-1 * var(--sp-2));
  padding-top: 10px;
  cursor: grab;
  touch-action: none;
}

.sheet__grip-bar {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--c-line);
}

.sheet__head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.sheet__title {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: var(--lh-tight);
  color: var(--c-ink);
}

.sheet__title::after {
  content: "";
  display: block;
  width: var(--rule-len);
  height: var(--rule-w);
  margin-top: var(--sp-3);
  background: var(--c-vermilion);
}

.sheet__question {
  padding-left: var(--sp-3);
  border-left: 1px solid var(--c-line-strong);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--c-ink-2);
}

.sheet__notice {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: var(--c-wash);
  color: var(--c-ink);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.4;
}

.sheet__notice::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-vermilion);
}

/* role="status": stays in the accessibility tree while empty (never display:none or
   [hidden]) so VoiceOver announces "Submissions are paused" when the text is inserted.
   Empty, it collapses to nothing and cancels its own flex gap in .sheet__panel. */
.sheet__notice:empty {
  padding: 0;
  margin-bottom: calc(-1 * var(--sp-4));
  background: none;
}

.sheet__notice:empty::before {
  content: none;
}

/* The writing surface: Mincho on faint ruled lines, like a blank tanzaku. */
.sheet__textarea {
  --line: 1.65em;
  min-height: calc(var(--line) * 4 + 28px);
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: var(--line);
  resize: none;
  background-image: linear-gradient(
    to bottom,
    transparent calc(var(--line) - 1px),
    rgba(43, 42, 40, 0.09) calc(var(--line) - 1px),
    rgba(43, 42, 40, 0.09) var(--line),
    transparent var(--line)
  );
  background-size: 100% var(--line);
  background-position: 0 14px;
  background-repeat: repeat-y;
  background-attachment: local;
}

.sheet__textarea::placeholder {
  font-family: var(--font-display);
}

.sheet__name {
  font-size: 1.0625rem;
}

.sheet__feedback {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 1.4em;
  margin-top: calc(-1 * var(--sp-2));
}

.sheet__status {
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.4;
  color: var(--c-vermilion-ink);
}

/* aria-live: kept in the accessibility tree while empty (no display:none) so
   "Couldn't send" / "Give it a moment" are announced when inserted; empty, it has no height. */
.sheet__status:empty {
  margin: 0;
  padding: 0;
}

.sheet__status[data-tone="info"] {
  color: var(--c-ink);
}

.sheet__wait {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--c-ink-2);
  font-variant-numeric: tabular-nums;
}

.sheet__actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  align-items: center;
}

.sheet__submit {
  width: 100%;
}

@media (min-width: 640px) {
  .sheet__panel {
    margin-bottom: max(var(--sp-5), var(--safe-bottom));
    padding-bottom: var(--sp-5);
    border-radius: 18px;
  }

  .sheet.has-keyboard .sheet__panel {
    margin-bottom: var(--sp-3);
  }
}

/* ── Reading card ──────────────────────────────────────────────────────── */
.reading-card {
  position: fixed;
  z-index: var(--z-modal);
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(var(--sp-7), calc(var(--safe-top) + var(--sp-6)))
    max(var(--sp-4), var(--safe-right))
    max(var(--sp-5), calc(var(--safe-bottom) + var(--sp-4)))
    max(var(--sp-4), var(--safe-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.reading-card__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 42, 40, 0.55);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

.reading-card.is-open .reading-card__backdrop {
  opacity: 1;
}

.reading-card__panel {
  position: relative;
  width: min(100%, 34rem);
  /* A 160-char unbroken word or 24-char name must wrap, not widen the card
     (which would push the Close button off-screen). */
  min-width: 0;
  overflow-wrap: anywhere;
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  border-radius: 3px;
  background-color: var(--note-paper, var(--c-paper));
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 30%),
    var(--paper-texture);
  background-size: 100% 100%, var(--paper-tile) var(--paper-tile);
  color: var(--note-ink, var(--c-ink));
  box-shadow: var(--shadow-modal);
  opacity: 0;
  transform: translateY(28px) rotate(-0.9deg);
  transform-origin: 50% 0;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.reading-card.is-open .reading-card__panel {
  opacity: 1;
  transform: none;
}

.reading-card.is-closing .reading-card__panel {
  opacity: 0;
  transform: translateY(14px);
  transition-duration: 260ms;
  transition-timing-function: var(--ease-in);
}

.reading-card__panel:focus-visible {
  outline: none;
}

/* Hung on a pale string that disappears into the dark backdrop. */
.reading-card__pin {
  position: absolute;
  top: 20px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-vermilion);
  box-shadow: 0 0 0 3px var(--note-paper, var(--c-paper)), 0 1px 2px 3px rgba(43, 42, 40, 0.12);
  transform: translateX(-50%);
}

.reading-card__pin::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 1px;
  height: 60px;
  background: linear-gradient(
    to top,
    rgba(43, 42, 40, 0.55) 0,
    rgba(43, 42, 40, 0.55) 24px,
    rgba(251, 248, 242, 0.6) 26px,
    rgba(251, 248, 242, 0) 100%
  );
  transform: translateX(-50%);
}

.reading-card__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--c-ink-2);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.reading-card__close:hover {
  background: rgba(43, 42, 40, 0.07);
  color: var(--c-ink);
}

.reading-card__close:focus-visible {
  outline: 2px solid var(--c-vermilion-ink);
  outline-offset: 0;
}

.reading-card__title {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--c-vermilion-ink);
}

.reading-card__panel.is-own .reading-card__title::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 1.5px;
  background: var(--c-vermilion);
  box-shadow: inset 0 0 0 2px var(--c-vermilion), inset 0 0 0 3px rgba(255, 248, 240, 0.7);
  transform: rotate(-6deg);
}

.reading-card__body {
  position: relative;
  margin-top: var(--sp-4);
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1.4vw, 1.875rem);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.005em;
  color: var(--note-ink, var(--c-ink));
  overflow-wrap: anywhere;
  line-break: strict;
  text-wrap: pretty;
}

.reading-card__name {
  margin-top: var(--sp-5);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--note-ink, var(--c-ink));
}

.reading-card__name::before {
  content: "— ";
  content: "— " / "";
  color: var(--c-ink-2);
}

.reading-card__meta {
  margin-top: 2px;
  font-size: var(--fs-small);
  color: var(--c-ink-2);
  font-variant-numeric: tabular-nums;
}

.reading-card__question {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid rgba(43, 42, 40, 0.15);
}

.reading-card__label {
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--c-ink-2);
}

.reading-card__question.is-earlier .reading-card__label {
  color: var(--c-vermilion-ink);
}

.reading-card__question-text {
  margin-top: var(--sp-1);
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.5;
  color: var(--note-ink, var(--c-ink));
}

@media (max-width: 380px) {
  .reading-card__panel {
    padding: var(--sp-7) var(--sp-5) var(--sp-5);
  }
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  left: 0;
  right: 0;
  bottom: calc(max(var(--sp-4), calc(var(--safe-bottom) + var(--sp-2))) + 56px + var(--sp-4));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--gutter);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(100%, 30rem);
  padding: 13px 20px 13px 16px;
  border-radius: var(--radius);
  background: var(--c-ink);
  color: var(--c-cream);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 4px rgba(43, 42, 40, 0.18), 0 16px 32px -14px rgba(43, 42, 40, 0.6);
  pointer-events: auto;
  cursor: default;
  animation: ltsw-rise-in var(--dur) var(--ease-out) backwards;
}

.toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(245, 239, 228, 0.55);
}

.toast--success::before {
  width: 10px;
  height: 10px;
  border-radius: 1.5px;
  background: var(--c-vermilion);
  box-shadow: 0 0 0 2px rgba(192, 70, 47, 0.25);
  transform: rotate(-6deg);
}

.toast--warn::before {
  background: var(--note-yamabuki);
}

.toast.is-leaving {
  animation: ltsw-sink-out var(--dur-fast) var(--ease-in) forwards;
}

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes ltsw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ltsw-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes ltsw-rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ltsw-sink-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

@keyframes ltsw-drop-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ltsw-rise-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

@keyframes ltsw-breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

@keyframes ltsw-busy {
  from { transform: translateX(-110%); }
  to { transform: translateX(280%); }
}

@keyframes ltsw-note-in {
  0% {
    opacity: 0;
    transform: translateY(-0.9em) rotate(calc(var(--note-rot, 0rad) - 2.6deg));
  }
  40% {
    opacity: 1;
    transform: translateY(0.12em) rotate(calc(var(--note-rot, 0rad) + 1.4deg));
  }
  66% {
    transform: translateY(-0.03em) rotate(calc(var(--note-rot, 0rad) - 0.6deg));
  }
  84% {
    transform: translateY(0) rotate(calc(var(--note-rot, 0rad) + 0.2deg));
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--note-rot, 0rad));
  }
}

@keyframes ltsw-note-out {
  from {
    opacity: 1;
    transform: rotate(var(--note-rot, 0rad));
  }
  to {
    opacity: 0;
    transform: translateY(0.7em) rotate(calc(var(--note-rot, 0rad) + 1.6deg)) scale(0.97);
  }
}

@keyframes ltsw-own-pulse {
  0% {
    box-shadow: var(--shadow-note), inset 0 -2px 0 var(--c-vermilion), 0 0 0 0 rgba(192, 70, 47, 0.5);
  }
  100% {
    box-shadow: var(--shadow-note), inset 0 -2px 0 var(--c-vermilion), 0 0 0 16px rgba(192, 70, 47, 0);
  }
}

/* ── Reduced motion: opacity only, no travel, no loops ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .fab-add,
  .note {
    transition-property: background-color, border-color, color, box-shadow, opacity;
  }

  .btn:active,
  .fab-add:active {
    transform: none;
  }

  .btn[aria-busy="true"]::after {
    animation: none;
    width: 100%;
    opacity: 0.35;
  }

  .fab-add {
    animation: ltsw-fade-in var(--dur) linear backwards;
  }

  .pill--connection {
    animation: ltsw-fade-in var(--dur-fast) linear backwards;
  }

  .pill--connection.is-leaving {
    animation: ltsw-fade-out var(--dur-fast) linear forwards;
  }

  .pill--connection .pill__dot {
    animation: none;
  }

  .note[role="button"]:hover,
  .note[role="button"]:active {
    transform: rotate(var(--note-rot));
  }

  .note--enter,
  .note--own.note--enter,
  .note--highlight,
  .note--highlight:not(.note--enter) {
    animation: ltsw-fade-in var(--dur) linear backwards;
  }

  .note--leave {
    animation: ltsw-fade-out var(--dur-fast) linear forwards;
  }

  .sheet__panel,
  .sheet.is-open .sheet__panel {
    transform: none;
  }

  .sheet__panel {
    opacity: 0;
    transition: opacity var(--dur-fast) linear;
  }

  .sheet.is-open .sheet__panel {
    opacity: 1;
  }

  .sheet__backdrop,
  .reading-card__backdrop {
    transition-duration: var(--dur-fast);
    transition-timing-function: linear;
  }

  .reading-card__panel,
  .reading-card.is-open .reading-card__panel,
  .reading-card.is-closing .reading-card__panel {
    transform: none;
    transition: opacity var(--dur-fast) linear;
  }

  .toast {
    animation: ltsw-fade-in var(--dur-fast) linear backwards;
  }

  .toast.is-leaving {
    animation: ltsw-fade-out var(--dur-fast) linear forwards;
  }
}
