:root {
  --green: #19975D;
  --green-dark: #147a4c;
  --green-soft: #e8f3ee;
  --pink: #F4C3CB;
  --pink-soft: #fcebee;
  --grey: #95a5a6;
  --bg: #ecf0f1;
  --ink: #2c3e50;
  --white: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: 32px 16px 80px;
  line-height: 1.5;
}

.app {
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
header {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.logo .kat {
  color: var(--pink);
  background: var(--ink);
  padding: 2px 10px 4px;
  border-radius: 10px 0 0 10px;
}

.logo .gpt {
  color: var(--white);
  background: var(--green);
  padding: 2px 10px 4px;
  border-radius: 0 10px 10px 0;
}

.tagline {
  color: var(--grey);
  margin: 12px 0 0;
  font-size: 0.95rem;
}

/* ---------- Explainer ---------- */
.explainer {
  background: var(--white);
  padding: 16px 20px;
  border-radius: 12px;
  border-left: 4px solid var(--pink);
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.explainer p { margin: 0; }

/* ---------- Steps ---------- */
.step { display: none; }
.step.active { display: block; }

.step-title {
  margin: 0 0 14px;
  font-size: 1.1rem;
  color: var(--ink);
}

/* ---------- Question grid ---------- */
.questions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.question {
  background: var(--white);
  border: 2px solid transparent;
  padding: 16px 18px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 0.98rem;
  color: var(--ink);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.question:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(25, 151, 93, 0.15);
}

.question:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

/* ---------- Chat ---------- */
.chat {
  background: var(--white);
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.msg + .msg { margin-top: 14px; }

.msg-user { text-align: right; }
.msg-bot  { text-align: left; }

.who {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--grey);
  margin-bottom: 4px;
}

.bubble {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 16px;
  max-width: 85%;
  word-wrap: break-word;
  line-height: 1.55;
  text-align: left;
}

.bubble-user {
  background: var(--pink);
  color: var(--ink);
  border-radius: 16px 16px 4px 16px;
}

.bubble-bot {
  background: var(--green);
  color: var(--white);
  border-radius: 16px 16px 16px 4px;
  min-height: 1.7em;
}

.tok {
  display: inline;
}

.tok.pop {
  animation: popIn 0.22s ease-out;
  display: inline-block;
}

@keyframes popIn {
  from { transform: translateY(-6px) scale(0.85); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--white);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}

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

/* ---------- Picker ---------- */
.picker {
  background: var(--white);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.picker-head { margin-bottom: 14px; }

.hint {
  color: var(--grey);
  font-size: 0.88rem;
  margin: 0;
}

.tokens {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.token {
  position: relative;
  background: var(--bg);
  border: 2px solid transparent;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.token:hover {
  border-color: var(--green);
}

.token:active {
  transform: scale(0.99);
}

.token:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

.token .bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--green-soft);
  border-right: 2px solid rgba(25, 151, 93, 0.35);
  z-index: 0;
  transition: width 0.2s;
}

.token.top .bar {
  background: rgba(25, 151, 93, 0.18);
  border-right-color: var(--green);
}

.token .txt,
.token .prob {
  position: relative;
  z-index: 1;
}

.token .txt {
  font-weight: 600;
  font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.98rem;
}

.token .prob {
  color: var(--grey);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.token.top .prob { color: var(--green-dark); font-weight: 700; }

/* ---------- Done ---------- */
.done {
  background: var(--white);
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.done-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.done-stats {
  color: var(--grey);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.btn {
  background: var(--green);
  color: var(--white);
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: var(--green-dark); }
.btn:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

/* ---------- Footer ---------- */
footer {
  margin-top: 36px;
  text-align: center;
}

.foot {
  color: var(--grey);
  font-size: 0.82rem;
  margin: 0;
}

/* ---------- Small screens ---------- */
@media (max-width: 500px) {
  body { padding: 20px 12px 60px; }
  .logo { font-size: 2.2rem; }
  .questions { grid-template-columns: 1fr; }
}
