/* Besley and Source Sans 3 (OFL). Files live in ./fonts/. */
@font-face {
  font-family: Besley;
  src: url("./fonts/besley-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Besley;
  src: url("./fonts/besley-latin-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("./fonts/source-sans-3-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3ebe3;
  --ink: #241c18;
  --muted: #4e3a31;
  --rose: #a61e45;
  --rose-deep: #8e1836;
  --rose-ink: #8e1a3a;
  --on-rose: #fff;
  --bamboo: #1b5a32;
  --bamboo-ink: #fff;
  --line: #e0d2c6;
  --card: #fffaf6;
  --shadow: 0 10px 28px rgba(70, 36, 24, 0.14);
  --focus: #1b5a32;
  --blob-rose: #f4c2d0;
  --display: Besley, "Iowan Old Style", Palatino, serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1c1614;
    --ink: #f6ece6;
    --muted: #e4d2c8;
    --rose: #c2415c;
    --rose-deep: #a61e45;
    --rose-ink: #ffc1d0;
    --on-rose: #fff;
    --bamboo: #b7e0bf;
    --bamboo-ink: #1c1614;
    --line: #56463e;
    --card: #2a221e;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    --focus: #b7e0bf;
    --blob-rose: #5a2a38;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: #c4a898 var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.55 var(--sans);
  padding-bottom: 120px;
  text-rendering: optimizeLegibility;
}
.wash {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
}
.wrap { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }
a { color: inherit; text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { background: #f3b8c6; color: #241c18; }
.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 30;
}
.skip:focus { top: 12px; }

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 2px solid var(--bamboo);
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  min-height: 68px;
  padding: 8px 0;
}
.brand {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  line-height: 1;
}
.brand span { color: var(--rose-ink); font-style: italic; font-weight: 500; }
nav { display: flex; gap: 18px; }
nav a {
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
nav a:hover { color: var(--rose-ink); text-decoration: underline; text-decoration-thickness: 1.5px; }

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 440px) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  min-height: calc(100dvh - 76px);
  padding: 36px 0 64px;
}
.hero-copy { max-width: 38rem; }
.panda-wrap {
  position: relative;
  z-index: 0;
  animation: arrive 0.9s var(--ease) both;
}
.panda-wrap::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 6%;
  top: 8%;
  width: 88%;
  height: 78%;
  background: radial-gradient(circle at 50% 46%, var(--blob-rose), transparent 68%);
}
svg.kim { width: 100%; height: auto; display: block; }
svg.boop { animation: boop 0.4s var(--ease); transform-origin: 140px 170px; }
@keyframes arrive {
  from { filter: blur(8px); transform: translateY(12px); }
  to { filter: blur(0); transform: none; }
}
@keyframes boop {
  40% { transform: scale(1.05) rotate(-3deg); }
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.4rem, 7vw, 6rem);
  font-weight: 560;
  font-optical-sizing: auto;
  letter-spacing: -0.03em;
  line-height: 0.9;
  text-wrap: balance;
}
h1 em {
  color: var(--rose-ink);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.lede {
  font-size: 1.3rem;
  line-height: 1.4;
  max-width: 28ch;
  margin: 18px 0 8px;
}
.featured {
  margin: 0 0 24px;
  max-width: 36ch;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.cta { display: flex; flex-wrap: wrap; gap: 10px; }

.btn, button, input, textarea { font: inherit; color: inherit; }
.btn, button[type="submit"], #copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.btn.primary, button[type="submit"] {
  background: var(--rose);
  border-color: var(--rose);
  color: var(--on-rose);
}
.btn.primary:hover, button[type="submit"]:hover,
.btn.primary:focus-visible, button[type="submit"]:focus-visible { background: var(--rose-deep); border-color: var(--rose-deep); }
.btn:not(.primary) { border-color: color-mix(in srgb, var(--ink) 32%, var(--line)); }
.btn:hover, #copy:hover:not(:disabled) { border-color: var(--ink); }
.btn:active, button[type="submit"]:active, #pat:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }

.band { padding: 8px 0 64px; }
h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(2rem, 3vw, 2.6rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}
.panel-head { margin-bottom: 4px; }
.panel-head p, .aside { color: var(--muted); margin: 0; max-width: 62ch; }
.reasons {
  list-style: none;
  margin: 20px 0 0;
  padding: 4px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 40px;
  border-top: 1px solid var(--line);
}
.reasons li { min-width: 0; padding-top: 18px; }
.reasons h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.02em;
}
.reasons li:first-child h3 { font-size: 1.7rem; }
.reasons p { margin: 0; color: var(--muted); }

.panel {
  padding: 32px;
  margin: 8px auto 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 22px; align-items: start; }
.split > * { min-width: 0; }
fieldset { border: 0; margin: 0; padding: 0; }
legend, label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
.tones, .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tones button, .chips button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
}
.tones button:hover, .chips button:hover { border-color: var(--ink); }
.tones button[aria-pressed="true"], .chips button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--rose) 14%, var(--card));
  border-color: var(--rose);
  color: var(--rose-ink);
}
textarea, input[type="text"], #prompt {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 12px 14px;
  margin-bottom: 14px;
  caret-color: var(--rose);
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
textarea { min-height: 120px; max-height: 220px; resize: vertical; }

.result-wrap { position: relative; min-width: 0; }
.result {
  min-height: 220px;
  padding: 22px 112px 22px 22px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 72%, var(--card));
  scroll-margin-top: 88px;
  scroll-margin-bottom: 112px;
}
.tone-label {
  margin: 0 0 8px;
  color: var(--bamboo);
  font-size: 0.8rem;
  font-weight: 600;
}
.note {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.35;
  letter-spacing: -0.02em;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.result.is-empty .note { color: var(--muted); }
#copy { position: absolute; top: 16px; right: 16px; min-height: 40px; min-width: 6.6rem; padding: 0 14px; }
#copy[data-state="copied"] {
  background: var(--bamboo);
  border-color: var(--bamboo);
  color: var(--bamboo-ink);
  opacity: 1;
}
#copy[data-state="pending"] { cursor: progress; }
.history { list-style: none; margin: 14px 0 0; padding: 0; display: grid; min-width: 0; }
.history:empty { display: none; }
.history li { min-width: 0; border-top: 1px solid var(--line); }
.history button {
  display: block;
  width: 100%;
  max-width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 2px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.history button:hover { color: var(--ink); }
.error {
  color: var(--rose-ink);
  background: color-mix(in srgb, var(--rose) 12%, var(--card));
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0 0;
  font-weight: 600;
}
.error:empty, .error[hidden] { display: none; }

.stage {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #fff, #f3e4d8);
}
.stage svg { width: min(92%, 440px); height: auto; }
.stage[data-scene="strawberry"] { background: radial-gradient(circle at 50% 40%, #ffe4ea, #f6d5c8); }
.stage[data-scene="tutu"] { background: radial-gradient(circle at 50% 40%, #ffe8f0, #f7d5e2); }
.stage[data-scene="cloud"] { background: radial-gradient(circle at 50% 40%, #f4f8fc, #d5e3ef); }
.stage[data-scene="code"] { background: radial-gradient(circle at 50% 40%, #f3fbf1, #d5ecd4); }
.stage[data-scene="boba"] { background: radial-gradient(circle at 50% 40%, #fff4e8, #f0dcc4); }
.stage[data-scene="bamboo"] { background: radial-gradient(circle at 50% 40%, #f4fbee, #d7ebc8); }
.caption {
  text-align: center;
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin: 14px 0 0;
  overflow-wrap: anywhere;
}
.aside { margin-top: 16px; }
footer { padding: 8px 0 12px; color: var(--muted); }

.dock {
  position: fixed;
  left: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow);
}
.dock.is-max { box-shadow: var(--shadow); outline: 2px solid #b8862d; outline-offset: 0; }
.meter { text-align: left; min-width: 0; }
section { scroll-margin-top: 84px; scroll-margin-bottom: 128px; }
.kicker { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.level {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--rose-ink);
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.pats { font-size: 0.85rem; color: var(--muted); }
#pat {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--rose);
  color: var(--on-rose);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  flex: none;
  transition: background-color 160ms ease;
}
#pat:hover { background: var(--rose-deep); }
.floater {
  position: absolute;
  bottom: 36px;
  color: var(--rose-ink);
  font-size: 1.1rem;
  animation: rise 0.7s var(--ease) forwards;
  pointer-events: none;
}
@keyframes rise {
  to { transform: translateY(-46px); opacity: 0; }
}

@media (prefers-color-scheme: dark) {
  ::selection { background: #6e3040; color: #fff; }
  html { scrollbar-color: #5c463c var(--bg); }
  .stage { background: radial-gradient(circle at 50% 42%, #3a2c28, #241c19); }
  .stage[data-scene="strawberry"] { background: radial-gradient(circle at 50% 40%, #4a2a32, #2a1c1e); }
  .stage[data-scene="tutu"] { background: radial-gradient(circle at 50% 40%, #4a2836, #261820); }
  .stage[data-scene="cloud"] { background: radial-gradient(circle at 50% 40%, #2a3642, #1b2228); }
  .stage[data-scene="code"] { background: radial-gradient(circle at 50% 40%, #24362a, #18221c); }
  .stage[data-scene="boba"] { background: radial-gradient(circle at 50% 40%, #3d2e24, #241c18); }
  .stage[data-scene="bamboo"] { background: radial-gradient(circle at 50% 40%, #243628, #182018); }
}

@media (max-width: 860px) {
  .wrap { width: min(1120px, calc(100% - 32px)); }
  .hero {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 3.25rem);
    text-align: center;
    padding: 12px 0 6rem;
    gap: 8px;
  }
  .dock {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    border-radius: 0;
    border-top: 1px solid var(--line);
    box-shadow: none;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom)) 18px;
    justify-content: space-between;
  }
  .dock.is-max { outline: none; border-top-color: #b8862d; }
  .hero-copy { margin-inline: auto; }
  .lede, .featured { margin-inline: auto; }
  .panda-wrap { max-width: 220px; margin: 0 auto; }
  .cta { justify-content: center; }
  .reasons, .split { grid-template-columns: 1fr; }
  .reasons { gap: 0; }
  .reasons li { padding: 16px 0; border-top: 1px solid var(--line); }
  .reasons li:first-child { border-top: 0; padding-top: 16px; }
  .reasons li:first-child h3 { font-size: 1.45rem; }
  h1 { font-size: clamp(3.25rem, 16vw, 4.4rem); }
  .panel { padding: 20px; }
  .band { padding-bottom: 36px; }
}
@media (max-width: 860px) and (max-height: 740px) {
  .panda-wrap { max-width: 140px; }
  h1 { font-size: 2.75rem; }
  .lede { margin-top: 8px; font-size: 1.12rem; }
  .featured { margin-bottom: 12px; }
}
@media (max-width: 860px) {
  .result { min-height: 9rem; }
}
@media (max-width: 600px) {
  body { padding-bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .panda-wrap, svg.boop, .floater { animation: none; }
  .btn, button, #pat, #copy { transition: none; }
}
