:root {
  --bg: #fbeee0;
  --bg-soft: #fff6ec;
  --ink: #2b2730;
  --ink-soft: #6a5a64;
  --peach: #f6c1a8;
  --peach-deep: #e89e7e;
  --pink: #f7c1cf;
  --mint: #b9e4d2;
  --teal: #4ea99d;
  --coral: #e07a5f;
  --gold: #e7b864;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 8px 22px rgba(124, 58, 0, 0.08);
  --radius: 18px;
  --radius-lg: 26px;
  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, #fff2e6 0%, var(--bg) 60%, #f3dec7 100%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: var(--teal);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 246, 236, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.brand-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff url("janet.png") center/cover no-repeat;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: lowercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.karma {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}

.lang-switch {
  display: inline-flex;
  background: white;
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}

.lang-switch button {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  border-radius: 999px;
}

.lang-switch button.active {
  background: var(--peach);
  color: white;
}

.reset {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: white;
  box-shadow: var(--shadow);
  color: var(--ink-soft);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.reset:hover {
  color: var(--coral);
}

.view {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}

/* When the view holds a chat, drop the big bottom buffer so the
   fixed-height chat card fits the viewport cleanly. */
.view:has(.chat) {
  padding-bottom: 24px;
}

.hero {
  text-align: center;
  padding: 24px 8px 28px;
}

.hero-avatar {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #fff url("janet.png") center/cover no-repeat;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0;
  box-shadow: 0 14px 34px rgba(232, 158, 126, 0.45), 0 0 0 6px rgba(255, 255, 255, 0.6);
}

.hero h1 {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
}

.hero p {
  margin: 0 auto;
  max-width: 460px;
  color: var(--ink-soft);
}

.hero-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 14px;
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1.5px solid rgba(78, 169, 157, 0.4);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.hero-link:hover {
  color: #186a5e;
  border-color: #186a5e;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

/* About page */
.about {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px 32px 36px;
  box-shadow: var(--shadow);
}

.about-topbar {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.about-avatar {
  width: 132px;
  height: 132px;
  margin: 8px auto 22px;
  border-radius: 50%;
  background: #fff url("janet.png") center/cover no-repeat;
  box-shadow: 0 16px 38px rgba(232, 158, 126, 0.45), 0 0 0 7px rgba(255, 255, 255, 0.7);
}

.about h1 {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.4px;
  margin: 0 0 22px;
}

.about p {
  margin: 0 0 14px;
  line-height: 1.65;
  font-size: 16px;
  color: var(--ink);
}

.about p.about-footnote {
  margin-top: 24px;
  padding-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

@media (max-width: 540px) {
  .about {
    padding: 14px 18px 28px;
  }
  .about h1 {
    font-size: 24px;
  }
  .about p {
    font-size: 15px;
  }
}

.course-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 14px 30px rgba(124, 58, 0, 0.14);
}

.course-card[data-done="true"] {
  background: linear-gradient(180deg, #fff 0%, #f3fbf6 100%);
}

.course-card[data-done="true"]::after {
  content: "✓";
  position: absolute;
  top: 12px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--teal);
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.course-card .emoji {
  font-size: 26px;
  line-height: 1;
}

.course-card h3 {
  margin: 0;
  font-size: 16px;
  font-family: var(--font-display);
  font-weight: 700;
}

.course-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  flex: 1;
}

.course-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
}

.course-card .meta .pts {
  color: var(--coral);
  font-weight: 700;
}

/* Chat view */
.chat {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Fixed height anchored to the viewport, so .messages scrolls
     internally rather than the whole page growing. */
  height: calc(100vh - 112px);
  height: calc(100dvh - 112px);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(180deg, #fff8f0 0%, #fff 100%);
}

.back-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ink-soft);
}

.back-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.chat-title {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff url("janet.png") center/cover no-repeat;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.chat-name {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.15;
}

.chat-status {
  font-family: var(--font);
  font-weight: 500;
  font-size: 12px;
  color: var(--teal);
}

.chat-emoji {
  font-size: 18px;
}

.chat-spacer {
  flex: 1;
}

.messages {
  flex: 1;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.bubble-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: pop 0.22s ease;
}

.bubble-row.user {
  flex-direction: row-reverse;
}

.bubble-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.bubble-row.bot .bubble-avatar {
  background-image: url("janet.png");
}

.bubble-row.user .bubble-avatar {
  background-image: none;
  background-color: #cfe1f7;
  color: #14305a;
  font-size: 14px;
}

.bubble-row .bubble-avatar.hidden {
  visibility: hidden;
}

.bubble {
  max-width: min(78%, 520px);
  padding: 9px 13px;
  border-radius: 18px;
  background: #f4eee6;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble strong {
  font-weight: 700;
}

.bubble em {
  font-style: italic;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.92em;
}

.bubble-row.bot .bubble {
  background: #fdeee0;
  border-top-left-radius: 6px;
}

/* Bad Janet: dark, no portrait, slightly attitudey */
.bubble-row.bot.bad .bubble-avatar {
  background-image: none;
  background-color: #1f1c24;
  color: #ff7aa2;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.bubble-row.bot.bad .bubble {
  background: linear-gradient(135deg, #2d2935, #1a1820);
  color: #ffe6ec;
  border-top-left-radius: 6px;
}

.bubble-row.bot.bad .bubble strong {
  color: #ff7aa2;
}

.bubble-row.bot.bad .bubble code {
  background: rgba(255, 255, 255, 0.1);
  color: #ffd6df;
}

.bubble.typing.bad,
.bubble-row.bot.bad .bubble.typing {
  background: #1f1c24;
}

.bubble-row.bot.bad .bubble.typing span {
  background: #ff7aa2;
}

.bubble-row.user .bubble {
  background: linear-gradient(135deg, #cfe1f7, #b9d2f3);
  color: #14305a;
  border-top-right-radius: 6px;
}

.bubble-row.system .bubble {
  background: #eaf6f0;
  color: var(--teal);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  margin: 8px auto;
  border-radius: 14px;
  animation: summon 0.55s ease-out;
}

@keyframes summon {
  0% { opacity: 0; transform: scale(0.6); filter: blur(4px); }
  60% { opacity: 1; transform: scale(1.05); filter: blur(0); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

.bubble-row.system {
  justify-content: center;
}

.bubble-row.system .bubble-avatar {
  display: none;
}

.bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  background: #fdeee0;
  border-top-left-radius: 6px;
}

.bubble.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--peach-deep);
  opacity: 0.6;
  animation: typing 1.2s infinite ease-in-out;
}

.bubble.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.bubble.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.choices {
  padding: 12px 16px 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(180deg, #fff 0%, #fffaf3 100%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.choice {
  padding: 9px 14px;
  background: white;
  color: var(--teal);
  border: 1.5px solid var(--mint);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.choice:hover {
  background: var(--mint);
  color: #186a5e;
}

.choice:active {
  transform: scale(0.97);
}

.choice.primary {
  background: var(--peach);
  border-color: var(--peach);
  color: white;
}

.choice.primary:hover {
  background: var(--peach-deep);
  border-color: var(--peach-deep);
  color: white;
}

.bubble a {
  color: var(--teal);
  text-decoration: underline;
}

.end-banner {
  margin: 14px auto;
  padding: 16px 20px;
  background: linear-gradient(135deg, #fff3e6, #ffe5d0);
  border-radius: 18px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.end-banner h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
}

.end-banner p {
  margin: 0 0 8px;
  color: var(--ink-soft);
}

.end-banner .pts {
  font-weight: 700;
  color: var(--coral);
}

@media (max-width: 540px) {
  .view {
    padding: 16px 12px 80px;
  }
  .hero h1 {
    font-size: 24px;
  }
  .chat-header {
    padding: 12px;
  }
  .messages {
    padding: 14px;
  }
  .bubble {
    max-width: 82%;
  }
  .choices {
    padding: 12px;
  }
}
