:root {
  --paper: oklch(0.975 0.008 70);
  --paper-2: oklch(0.96 0.01 70);
  --paper-3: oklch(0.95 0.012 70);
  --ink: oklch(0.22 0.02 50);
  --ink-2: oklch(0.3 0.02 50);
  --ink-caption: oklch(0.25 0.02 50);
  --ink-soft: oklch(0.35 0.02 50);
  --ink-muted: oklch(0.45 0.02 50);
  --ink-faint: oklch(0.55 0.02 50);
  --ink-faint-2: oklch(0.6 0.02 50);
  --ink-ghost: oklch(0.7 0.02 50);
  --accent: oklch(0.52 0.11 25);
  --accent-hover: oklch(0.45 0.11 25);
  --line: oklch(0.88 0.015 60);
  --line-2: oklch(0.85 0.02 60);
  --line-3: oklch(0.86 0.015 60);
  --line-4: oklch(0.93 0.01 60);
  --line-5: oklch(0.6 0.02 60);
  --line-dashed: oklch(0.8 0.02 60);
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: ui-monospace, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Karla, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }

@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
@keyframes pulse { 0%, 100% { opacity: .35 } 50% { opacity: 1 } }

.shell {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
}
.col { width: 100%; display: flex; flex-direction: column; animation: fadeUp .4s ease; }
.col-gen { max-width: 640px; gap: 28px; }
.col-play { max-width: 720px; gap: 20px; }

/* Buttons */
.btn-primary {
  border: 0; background: var(--accent); color: #fff; font-weight: 600;
}
@media (hover: hover) { .btn-primary:hover { background: var(--accent-hover); } }
.btn-ghost {
  border: 1px solid var(--line-2); background: #fff; color: inherit; font-weight: 600;
}
@media (hover: hover) { .btn-ghost:hover { background: var(--paper-2); } }
.btn-sm { border-radius: 8px; padding: 0 14px; min-height: 40px; font-size: 14px; }
.btn-md { border-radius: 9px; padding: 0 16px; min-height: 42px; font-size: 14px; }

/* Generator */
.hero { display: flex; flex-direction: column; gap: 12px; text-align: center; margin-top: 48px; }
.hero h1 {
  margin: 0; font-family: var(--serif); font-weight: 600;
  font-size: clamp(34px, 6vw, 52px); line-height: 1.05; letter-spacing: -0.01em;
  text-wrap: balance;
}
.hero em, .wordmark em { font-style: italic; font-weight: 400; color: var(--accent); }
.hero p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink-muted); text-wrap: pretty; }

.input-row {
  display: flex; gap: 10px; align-items: stretch;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 8px 8px 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.input-row input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 17px; color: inherit; padding: 10px 0;
}
.input-row input::placeholder { color: var(--ink-ghost); }
.btn-get { border-radius: 9px; padding: 0 18px; font-size: 15px; min-height: 44px; flex: none; }

.result { display: flex; flex-direction: column; gap: 10px; animation: fadeUp .3s ease; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.link-row {
  display: flex; gap: 10px; align-items: center;
  background: var(--paper-2); border: 1px dashed var(--line-dashed); border-radius: 12px;
  padding: 10px 10px 10px 16px;
}
.link-row code {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-row button { flex: none; }
.footer { margin: 24px 0 0; text-align: center; font-size: 13px; color: var(--ink-faint-2); text-wrap: balance; }

/* Playback */
.wordmark { text-align: center; font-family: var(--serif); font-size: 16px; color: var(--ink-2); }
.steps { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }
.pills { display: flex; gap: 6px; }
.pills span { width: 14px; height: 6px; border-radius: 3px; background: var(--line-3); transition: all .3s; }
.pills span.on { background: var(--accent); }
.pills span.cur { width: 28px; }
.caption {
  font-family: var(--serif); font-size: clamp(22px, 4vw, 30px); line-height: 1.2;
  color: var(--ink-caption); text-align: center; min-height: 36px; text-wrap: pretty;
}
.caption .num { color: var(--accent); font-style: italic; }
.skip {
  border: 0; background: transparent; color: var(--ink-faint); font-size: 13px; font-weight: 500;
  min-height: 40px; padding: 0 12px; margin-top: -6px;
}
@media (hover: hover) { .skip:hover { color: var(--ink); } }
.chat { cursor: default; }

.chat {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .05); overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 440px;
  min-height: clamp(320px, calc(100svh - 200px), 440px);
}
.chat-head {
  display: flex; align-items: center; gap: 2px 10px; flex-wrap: wrap; padding: 14px 18px;
  border-bottom: 1px solid var(--line-4);
}
.avatar {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--serif); font-weight: 600; font-size: 15px;
}
.avatar-sm { font-size: 14px; }
.chat-name { font-weight: 600; font-size: 15px; }
.chat-tag { font-size: 12px; color: var(--ink-faint-2); }

.chat-body { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 22px 20px; }
.empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 22px; color: var(--ink-ghost); font-style: italic;
}
.bubble {
  align-self: flex-end; max-width: 80%; background: var(--paper-3);
  border-radius: 16px 16px 4px 16px; padding: 10px 14px; font-size: 15px; line-height: 1.5;
  overflow-wrap: anywhere; white-space: pre-wrap; animation: fadeUp .25s ease;
}
.thinking { display: flex; gap: 6px; align-items: center; padding: 6px 4px; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }

.bot { display: flex; gap: 12px; align-items: flex-start; animation: fadeUp .25s ease; }
.bot-col { display: flex; flex-direction: column; gap: 12px; padding-top: 2px; min-width: 0; }
.bot-text { font-size: 15px; line-height: 1.6; text-wrap: pretty; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff;
  text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600;
}
@media (hover: hover) { .pill:hover { border-color: var(--accent); color: var(--accent); } }
.pill-dashed { border: 1px dashed var(--line-dashed); background: transparent; color: var(--ink-muted); }
@media (hover: hover) { .pill-dashed:hover { color: var(--ink); border-color: var(--line-5); } }
.helper { font-size: 13px; color: var(--ink-faint); }
.pill .paste { font-weight: 500; color: var(--ink-faint); margin-left: 4px; }

.composer { padding: 14px 18px 18px; }
.composer-row {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 8px 12px 16px; transition: border-color .2s;
}
.composer-row.typing { border-color: var(--accent); }
.typed {
  flex: 1; min-width: 0; font-size: 15px; line-height: 22px; min-height: 22px;
  color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 88px; overflow: hidden; /* 4 lines; render() pins the typing edge in view */
}
.caret {
  display: inline-block; width: 2px; height: 18px; background: var(--ink-2);
  margin-left: 1px; vertical-align: -4px; animation: blink 1s step-end infinite;
}
.send {
  flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; line-height: 1;
  transition: transform .15s, background .2s;
}
.send.ready { background: var(--accent); }
.send.press { transform: scale(0.85); }

.outro {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; padding: 14px 0; animation: fadeUp .4s ease;
}
.outro p { margin: 0; font-family: var(--serif); font-size: 24px; line-height: 1.3; color: var(--ink-2); text-wrap: pretty; }
.outro-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 480px) {
  .shell { padding-top: 28px; }
  .hero { margin-top: 24px; }
  .link-row { flex-wrap: wrap; padding: 12px; }
  .link-row code { flex-basis: 100%; padding: 2px 4px 4px; }
  .link-row button { flex: 1; }
  .chat-body { padding: 18px 16px; }
  .composer { padding: 12px 14px 14px; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input-row:focus-within { border-color: var(--line-5); }

@media (prefers-reduced-motion: reduce) {
  .col, .result, .bubble, .bot, .outro { animation: none; }
  .pills span, .send, .composer-row { transition: none; }
}
