:root {
  --bg: #fefefe;
  --ink: #1e1e1e;
  --ink-2: #5c5c5c;
  --muted: #9a9a9a;
  --line: #e7e7e7;
  --line-2: #d7d7d7;
  --accent: #09aea1;
  --pink: #f386a1;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Fragment Mono", var(--mono);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131313;
    --ink: #f1f1f1;
    --ink-2: #b4b4b4;
    --muted: #7d7d7d;
    --line: #262626;
    --line-2: #333333;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app {
  max-width: 740px;
  margin: 0 auto;
  height: 100dvh;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
}

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.brand:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 6px;
}

.logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.wordmark {
  font-weight: 500;
}

.tag {
  color: var(--muted);
}

.how-trigger,
.how-close {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.how-trigger:hover,
.how-close:hover {
  color: var(--ink);
}

.how-trigger:focus-visible,
.how-close:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 5px;
}

/* how it works */
.how {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 0;
  overflow-y: auto;
}

.how[open] {
  animation: how-in 0.14s steps(3, end);
}

.how::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

@keyframes how-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.how-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.how-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.how-steps {
  margin: 0;
  padding: 0 20px;
  list-style: none;
}

.how-steps li {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.step-label {
  display: block;
  margin-bottom: 11px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.how p {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
}

.how pre {
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink);
}

.how .picked {
  color: var(--accent);
}

.how .stop {
  color: var(--pink);
}

.how .aside {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.how-after {
  padding: 20px;
}

.how-after code {
  font-family: var(--mono);
  color: var(--pink);
}

.how-end {
  margin: 0 !important;
  padding: 18px 20px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px !important;
  color: var(--muted) !important;
}

@media (prefers-reduced-motion: reduce) {
  .how[open] {
    animation: none;
  }
}

/* transcript */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  scrollbar-width: thin;
}

.turn {
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .turn {
    animation: none;
  }
}

.role {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.turn.assistant .role {
  color: var(--accent);
}

.turn.user .text {
  color: var(--ink-2);
}

.text {
  margin: 0;
  word-break: break-word;
}

.text .w {
  margin-left: 0.32em;
}

.text .w:first-child {
  margin-left: 0;
}

.text .w.punct {
  margin-left: 0;
}

.show-p .w {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-decoration-color: rgba(9, 174, 161, var(--p, 0));
}

.caret {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  margin-left: 0.14em;
  vertical-align: -0.16em;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

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

.turnmeta {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.turnmeta .over {
  color: var(--pink);
}

/* empty state */
.empty {
  margin: auto 0;
}

.lead {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}

/* composer */
.composer {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 16px 0 24px;
}

.input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font: inherit;
  color: var(--ink);
}

.input::placeholder {
  color: var(--muted);
}

.send {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 6px 16px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.send:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.send:disabled {
  opacity: 0.4;
  cursor: default;
}

.composer.busy .send {
  background: none;
  color: var(--muted);
  border-color: var(--line);
}

/* suggestions */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  transition: border-color 0.15s, color 0.15s;
}

.chip:hover {
  color: var(--ink);
  border-color: var(--line-2);
}

/* word alternatives popover */
.tip {
  position: fixed;
  z-index: 20;
  min-width: 152px;
  padding: 8px 10px 9px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink);
  pointer-events: none;
}

.tip .tip-head {
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.tip .row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 1px 0;
}

.tip .row.chosen {
  color: var(--accent);
  font-weight: 500;
}

.tip .bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  min-width: 34px;
}

.tip .bar i {
  display: block;
  height: 100%;
  background: var(--muted);
}

.tip .row.chosen .bar i {
  background: var(--accent);
}

.tip .p {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tip .row.chosen .p {
  color: var(--accent);
}
