* {
  box-sizing: border-box;
}

:root {
  --paper: #080a0d;
  --ink: #f5f7fa;
  --quiet: rgb(245 247 250 / 68%);
  --rule: rgb(245 247 250 / 25%);
  --coral: #d4527e;
  --primary: #92b0c9;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  color-scheme: dark;
  font: 20px/1.35 "Times New Roman", Georgia, serif;
}

body.day {
  --paper: #f5f7fa;
  --ink: #080a0d;
  --quiet: rgb(8 10 13 / 68%);
  --rule: rgb(8 10 13 / 27%);
  --coral: #b63a64;
  --primary: #1e4f73;
  color-scheme: light;
}

#stage {
  width: min(100%, 38rem);
  min-height: 100svh;
  margin-inline: auto;
  padding-inline: max(clamp(20px, 7vw, 48px), env(safe-area-inset-left))
    max(clamp(20px, 7vw, 48px), env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
}

main {
  padding-block: max(clamp(28px, 6svh, 76px), env(safe-area-inset-top)) 42px;
  overflow-wrap: anywhere;
}

p, h1, figure {
  margin: 0;
}

h1 {
  font-weight: normal;
}

button, textarea, a {
  font: inherit;
  color: inherit;
}

button, a {
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  text-underline-offset: 0.19em;
}

button {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 5px 0;
  text-align: start;
  white-space: normal;
}

a {
  display: inline-flex;
  align-items: center;
}

button:hover, a:hover {
  text-decoration: underline;
}

:where(button, a):focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

textarea:focus,
input:focus {
  outline: none;
  border-bottom-color: var(--coral);
}

textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  font-size: 20px;
  margin: 0;
  padding: 7px 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  resize: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--rule);
}

textarea::placeholder {
  color: var(--quiet);
  opacity: 1;
}

.quiet, .quiet a, .quiet button {
  color: var(--quiet);
  font-size: 17px;
}

.letter .said, .letter .truth, .struck-edit {
  display: block;
  font-size: 26px;
  line-height: 1.18;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.letter .truth {
  margin-top: 10px;
}
.letter .truth:first-child {
  margin-top: 0;
}

.coral-strike {
  font-style: italic;
  text-decoration: none;
}

.coral-strike span {
  color: var(--quiet);
  background: linear-gradient(var(--coral), var(--coral)) left 57% / 100% 2px no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.coral-strike.fresh span {
  animation: ink-strike 420ms ease-out both;
}

@keyframes ink-strike {
  from { background-size: 0 2px; }
}

hr {
  width: 44px;
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 16px 0 8px;
}

.music {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  color: var(--quiet);
  font-size: 17px;
}

.time, .time:focus-visible {
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}

.playback, .actions, .footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 17px;
}

.playback {
  font-size: 17px;
}

.letter .said.edit, .letter .truth.edit {
  padding-block: 0;
}

.letter .music :is(span, button) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.letter .music button { max-width: 100%; }

.letter .music > span[aria-hidden] {
  min-height: auto;
}

.letter .music .time {
  padding-inline: 5px;
}

.cover .letter {
  margin: 22px 0 17px;
}

.cover .letter .truth {
  font-size: 22px;
}

.cover .music > span {
  min-height: auto;
  padding-inline: 0;
}

.cover .invitation {
  margin-bottom: 5px;
}

.spark, .write {
  display: block;
  width: 100%;
  min-height: 48px;
  font-size: 25px;
  line-height: 1.15;
  font-style: italic;
}

.spark:hover {
  text-decoration-color: var(--rule);
}

.primary {
  min-height: 48px;
  color: var(--primary);
  font-size: 24px;
  line-height: 1.15;
}

.write {
  min-height: 52px;
  border-bottom: 1px solid var(--rule);
  font-style: normal;
}

.caret {
  margin-left: 0.3em;
  color: var(--coral);
  animation: caret 1.2s steps(2, start) 4;
}

@keyframes caret {
  50% { opacity: 0; }
}

.composition {
  position: relative;
}

.entry {
  line-height: 1.2;
}

.line-entry, .truth-entry {
  font-size: 28px;
}

.line-entry {
  font-style: italic;
}

.song-entry {
  font-size: 22px;
}

.struck-edit, .compact .said, .compact .truth, blockquote .said {
  font-size: 22px;
}

blockquote .truth {
  font-size: 20px;
}

.line-hint {
  font-size: 14px;
  margin-bottom: 21px;
}

.prompt {
  margin: 2px 0 7px;
}

.forward {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 18px;
}

.keyboard-open main:has(.forward) {
  padding-bottom: calc(var(--keyboard-inset) + 108px);
}

.keyboard-open .forward {
  position: fixed;
  z-index: 1;
  bottom: var(--keyboard-inset, 0px);
  inset-inline: max(0px, (100% - 38rem) / 2);
  padding: 3px max(20px, 7vw);
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.keyboard-open .forward .primary {
  white-space: normal;
}

.song-title, .clock-row, .song-cue, .share, .received-actions {
  margin-top: 14px;
}

.clock-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 14px;
}

.clock {
  width: min(9ch, 100%);
  font-size: 24px;
}

.clock::placeholder {
  color: var(--coral);
  opacity: 0.75;
}

.time-error {
  flex-basis: 100%;
}

.song-cue:empty {
  display: none;
}

.share > p {
  margin-bottom: 4px;
}

.share-actions {
  font-size: 17px;
}

.copy-field {
  margin-block: 7px;
  font-size: 16px;
}

.composition > .letter:has(.edit) {
  margin-block: 15px;
}

.edit:hover {
  text-decoration: none;
}

.received-actions > * {
  display: block;
}

blockquote {
  margin: 0 0 30px;
  padding-left: 14px;
  border-left: 1px solid var(--rule);
  color: var(--quiet);
}

.received + .composition {
  margin-top: 22px;
}

footer {
  margin-top: auto;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

footer, footer button {
  font-size: 15px;
  color: var(--quiet);
}

footer a {
  text-decoration: none;
}

.footer-row {
  column-gap: 7px;
}

.languages a {
  justify-content: center;
}

.languages [aria-current] {
  text-decoration: underline;
}

.gallery figure {
  margin-block: 22px;
}

.gallery img {
  display: block;
  max-width: 100%;
  height: auto;
}

.gallery figcaption {
  margin-top: 7px;
}

.story-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  overflow: auto;
}

.story-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 69svh;
  object-fit: contain;
  margin-inline: auto;
}

.story-dialog .actions {
  justify-content: center;
}

.story-dialog p {
  max-width: 32ch;
  margin: 3px auto 0;
}

body:has(.story-dialog[open]) {
  overflow: hidden;
}

.origin {
  max-width: 34rem;
  margin: 0 auto;
  padding-inline: max(22px, 7vw);
}

.origin h1 {
  font-size: 27px;
  margin-block: 25px 20px;
}

.origin p {
  margin-bottom: 1em;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .coral-strike.fresh span, .caret {
    animation: none;
  }
}
