:root {
  --paper: oklch(0.965 0.012 80);
  --paper-2: oklch(0.925 0.016 78);
  --ink: oklch(0.21 0.02 55);
  --mute: oklch(0.56 0.02 60);
  --line: oklch(0.84 0.015 75);
  --accent: oklch(0.52 0.19 28);
  --accent-ink: oklch(0.975 0.01 80);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
:root[data-kind="songwriters"] { --accent: oklch(0.46 0.13 258); }
:root[data-kind="bands"] { --accent: oklch(0.42 0.12 150); }
:root[data-kind="acoustic"] { --accent: oklch(0.55 0.14 70); }
@media (prefers-color-scheme: dark) {
  :root {
    --paper: oklch(0.2 0.012 60);
    --paper-2: oklch(0.26 0.014 60);
    --ink: oklch(0.94 0.012 80);
    --mute: oklch(0.62 0.02 70);
    --line: oklch(0.36 0.014 65);
    --accent: oklch(0.7 0.17 32);
    --accent-ink: oklch(0.16 0.02 40);
    color-scheme: dark;
  }
  :root[data-kind="songwriters"] { --accent: oklch(0.74 0.11 250); }
  :root[data-kind="bands"] { --accent: oklch(0.75 0.13 150); }
  :root[data-kind="acoustic"] { --accent: oklch(0.8 0.12 75); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.app {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1.25rem, 5vw, 2rem) 6rem;
}

/* ---- hero ------------------------------------------------------------ */
.hero { margin-bottom: clamp(2.5rem, 8vw, 4rem); }
.hero > * { animation: rise 0.9s var(--ease) both; }
.hero > :nth-child(2) { animation-delay: 0.08s; }
.hero > :nth-child(3) { animation-delay: 0.18s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .hero > * { animation: none; } }

.kind {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.55em;
}
.glyph {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-size: 1.5em;
  line-height: 1;
  letter-spacing: 0;
}

.when {
  margin: 0;
  display: flex;
  align-items: flex-end;
  gap: 0.15em;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  line-height: 1;
}
.day {
  font-size: clamp(6.5rem, 30vw, 11rem);
  font-weight: 800;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.05em;
  line-height: 0.82;
  margin-left: -0.04em;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  padding-bottom: 0.15em;
  font-size: clamp(1.4rem, 6vw, 2.1rem);
  font-style: italic;
  font-variation-settings: "opsz" 48, "SOFT" 60, "WONK" 1;
  letter-spacing: -0.01em;
  text-transform: lowercase;
}
.where {
  margin: 1rem 0 0;
  padding-top: 0.8rem;
  border-top: 1.5px solid var(--ink);
  display: flex;
  gap: 1.2em;
  font-size: 1rem;
  color: var(--mute);
}
.where span:first-child { color: var(--ink); font-weight: 600; }

/* ---- sections -------------------------------------------------------- */
.sec { margin-bottom: clamp(2.2rem, 7vw, 3.2rem); }
.sec + .sec { padding-top: 0; }
.lbl {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute);
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.5rem 0.95rem 0.5rem 0.75rem;
  font: 500 0.98rem/1 "Familjen Grotesk", sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.chip .glyph { font-size: 1.25em; opacity: 0.7; }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip[aria-pressed="true"] .glyph { opacity: 1; }
.chip.here { border-width: 2px; }
.chip.here[aria-pressed="false"] { border-color: var(--accent); color: var(--accent); }
.chip small { font-weight: 400; opacity: 0.7; font-size: 0.82em; }
.chip small::before { content: "·"; margin: 0 0.35em 0 0.1em; }

/* fields */
input, textarea {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 0.75rem 0;
  margin: 0;
  outline: none;
  transition: border-color 0.18s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--mute); opacity: 1; }
input:focus, textarea:focus { border-bottom-color: var(--ink); }
input.bad, textarea.bad { border-bottom-color: var(--accent); animation: shake 0.4s var(--ease); }
textarea { resize: none; line-height: 1.45; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 380px) { .row { grid-template-columns: 1fr; gap: 0; } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* code reveal */
.reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s var(--ease);
}
.reveal.open { grid-template-rows: 1fr; }
.reveal > div { overflow: hidden; min-height: 0; }
#code {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-size: 2rem;
  letter-spacing: 0.45em;
  padding: 0.6rem 0 0.4rem;
  border-bottom-color: var(--accent);
}
.hint {
  margin: 0.35rem 0 0.4rem;
  font-size: 0.78rem;
  color: var(--mute);
  letter-spacing: 0.04em;
}

/* tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 0.6rem;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  outline: 0 solid var(--accent);
  outline-offset: 2px;
  transition: outline-width 0.15s var(--ease), opacity 0.2s var(--ease), filter 0.2s var(--ease), transform 0.15s var(--ease);
}
.tile:active { transform: scale(0.97); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .glyph { font-size: 2.2rem; color: var(--mute); }
.tile.on { outline-width: 3px; }
.tile.off { opacity: 0.35; filter: grayscale(1); }
.tile.add {
  background: transparent;
  border: 1.5px dashed var(--line);
  color: var(--mute);
  font-family: "Fraunces", Georgia, serif;
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
}
.tile.add:hover { border-color: var(--ink); color: var(--ink); }
.tile.add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tile.busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: conic-gradient(transparent calc(var(--p, 0) * 1%), oklch(from var(--paper) l c h / 0.72) 0);
  transition: --p 0.2s linear;
}
.tile.fail { outline: 2px solid var(--accent); }
.tile.fail::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; color: var(--accent); background: oklch(from var(--paper) l c h / 0.7); }

/* send */
.send {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  padding: 1rem 1.2rem;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.7rem;
  font-weight: 500;
  font-variation-settings: "opsz" 72, "SOFT" 80, "WONK" 1;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
.send::after { content: "→"; font-style: normal; font-family: "Familjen Grotesk", sans-serif; font-size: 1.3rem; transition: transform 0.25s var(--ease); }
.send:hover { background: var(--accent); color: var(--accent-ink); }
.send:hover::after { transform: translateX(4px); }
.send:active { transform: scale(0.99); }
.send[disabled] { opacity: 0.55; cursor: progress; }
.send.busy span::after { content: "…"; }

/* done */
.done { animation: rise 0.7s var(--ease) both; }
.stamp {
  margin: 0 0 1.2rem;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(4rem, 22vw, 7rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  color: var(--accent);
}
.edit {
  appearance: none;
  border: 0;
  background: none;
  color: var(--mute);
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  padding: 0;
  margin-top: 2.2rem;
  cursor: pointer;
}
.edit:hover { color: var(--ink); }

/* night: the bill, then the carousel as it stands */
.night { margin-top: clamp(3rem, 10vw, 4.5rem); padding-top: 1.4rem; border-top: 1.5px solid var(--ink); }
.bill { list-style: none; margin: 0 0 1.6rem; padding: 0; }
.bill li {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.35rem;
  font-variation-settings: "opsz" 48, "SOFT" 60;
}
.bill li:first-child { border-top: 0; }
.bill .at { font-family: "Familjen Grotesk", sans-serif; font-size: 0.85rem; color: var(--mute); min-width: 3.2em; }
.bill .you { color: var(--accent); font-style: italic; }
.reel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * clamp(1.25rem, 5vw, 2rem));
  padding: 0 clamp(1.25rem, 5vw, 2rem) 0.75rem;
  scrollbar-width: thin;
}
.frame {
  flex: 0 0 78%;
  aspect-ratio: 4 / 5;
  scroll-snap-align: center;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: #17120f;
}
.frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1080px;
  height: 1350px;
  border: 0;
  transform-origin: 0 0;
  transform: scale(var(--s, 0.25));
  pointer-events: none;
}

/* toast + empty */
.err {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  animation: rise 0.35s var(--ease) both;
  max-width: calc(100vw - 2rem);
}
.gone {
  margin: 30vh 0 0;
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 4rem;
  color: var(--mute);
}

/* credit */
.credit {
  margin: 4rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--mute);
}
.credit a { color: inherit; text-decoration: none; }
.credit a:hover { text-decoration: underline; }
