:root {
  --cream: #faf3e6;
  --paper: #fffdf8;
  --teal: #1f6e6e;
  --amber: #995019;
  --rust: #9c3d0b;
  --ink: #382f26;
  --muted: #665b4d;
  --line: #d9d2c4;
  --radius: 20px;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-size: 16px;
  line-height: 1.55;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100svh;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button,
.button {
  cursor: pointer;
  background: var(--teal);
  color: white;
  border: 2px solid var(--teal);
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: bold;
  min-height: 48px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover,
.button:hover {
  filter: brightness(0.93);
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
.quiet,
.secondary {
  color: var(--teal);
  background: transparent;
}
.quiet {
  border-color: transparent;
  padding: 8px 12px;
}
a {
  color: var(--teal);
  text-underline-offset: 3px;
}
h1,
h2,
h3 {
  color: var(--teal);
  line-height: 1.2;
}
h1 {
  font-size: clamp(2rem, 5vw, 2.7rem);
  margin: 12px 0 22px;
  letter-spacing: -0.035em;
}
h2 {
  font-size: 1.6rem;
}
h3 {
  font-size: 1.1rem;
}
p {
  margin: 12px 0;
}
small,
.muted {
  color: var(--muted);
}
label {
  display: block;
  font-weight: bold;
  margin: 12px 0 5px;
}
input,
select,
textarea {
  background: white;
  border: 1px solid #948a79;
  border-radius: 10px;
  padding: 11px;
  width: 100%;
  color: var(--ink);
}
input[type="checkbox"] {
  width: auto;
  min-width: 20px;
  min-height: 20px;
  vertical-align: middle;
  margin-right: 8px;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f1eee6;
  padding: 18px;
  border-radius: 12px;
}
code {
  font-size: 0.88rem;
}
:focus-visible {
  outline: 3px solid #9c3d0b;
  outline-offset: 4px;
}
button:focus-visible {
  outline-offset: 3px;
}
.skip-nav {
  position: fixed;
  top: -100px;
  left: 10px;
  background: #fff;
  padding: 10px;
  z-index: 10;
}
.skip-nav:focus {
  top: 10px;
}
.topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  font-size: 0.8rem;
  color: var(--teal);
  font-weight: bold;
  letter-spacing: 0.03em;
}
body:not(.studio) main {
  max-width: 560px;
  margin: auto;
  padding: 22px 22px 120px;
  min-height: calc(100svh - 80px);
}
.hero {
  text-align: center;
  padding-top: 4vh;
}
.hero img {
  width: 140px;
  height: 140px;
  object-fit: contain;
}
.hero .eyebrow {
  color: var(--amber);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: bold;
}
.hero p {
  font-size: 1.1rem;
}
.hero .button,
.hero button {
  margin-top: 20px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.consent h3 {
  color: var(--amber);
}
.warning {
  background: #fff3de;
  border: 1px solid #c5a161;
  padding: 14px;
  border-radius: 12px;
}
.danger {
  color: var(--rust);
  border-color: var(--rust);
  background: #fff2eb;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.actions > * {
  flex: 1;
}
.support {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  font-size: 0.83rem;
  z-index: 2;
}
.support button {
  font-size: 0.85rem;
}
.support span {
  max-width: 320px;
}
.support #save-state[data-error="true"] {
  color: var(--rust);
  font-weight: bold;
}
dialog {
  max-width: 490px;
  width: calc(100% - 32px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  background: var(--cream);
  color: var(--ink);
}
dialog::backdrop {
  background: #263b3ba6;
}
.question {
  font-size: 1.45rem;
  line-height: 1.4;
  margin-bottom: 24px;
  color: var(--ink);
}
.options {
  display: grid;
  gap: 10px;
}
.option {
  border: 2px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 14px;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 14px 16px;
  min-height: 56px;
  font-weight: normal;
  box-shadow: 0 4px 14px #3a2e2214;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.option:active { transform: scale(0.98); }
.option.selected { animation: tea-pop-in 0.25s ease; }
.option[aria-pressed="true"] {
  border-color: var(--teal);
  background: #e5f1ec;
  color: #174c4c;
  font-weight: bold;
}
.progress {
  width: 100%;
  accent-color: var(--teal);
  height: 12px;
  margin: 8px 0 20px;
}
.progress::-webkit-progress-bar { background: #3a2e221a; border-radius: 999px; }
.progress::-webkit-progress-value { background: linear-gradient(90deg, var(--teal), #d9a441); border-radius: 999px; }
.progress::-moz-progress-bar { background: linear-gradient(90deg, var(--teal), #d9a441); border-radius: 999px; }
.answer-hint { font-size: 0.85rem; margin-top: 20px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.hero img { animation: tea-float 3.2s ease-in-out; }
.pill {
  display: inline-block;
  font-size: 0.76rem;
  padding: 6px 12px;
  background: #e2eeea;
  border-radius: 999px;
  color: #174c4c;
}
.chapter-icon {
  font-size: 4rem;
  animation: tea-wiggle 0.6s ease;
}
.chapter-intro {
  text-align: center;
  padding: 8vh 0;
}
.result-card {
  /* Source tea gradients, shaded to keep their white copy readable. */
  background: linear-gradient(var(--tea-shade, #00000024), var(--tea-shade, #00000024)), linear-gradient(160deg, var(--tea-light, #2a9090), var(--tea-dark, #1f6e6e));
  color: white;
  text-align: center;
  padding: 30px 24px;
  border-radius: 28px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  animation: tea-card-pop 0.5s ease;
}
.result-card.no-result { animation: none; }
.result-card > :not(.tea-confetti) { position: relative; z-index: 1; }
.result-card h1 {
  color: white;
  margin: 6px 0 10px;
}
.result-emoji {
  font-size: 4.5rem;
  line-height: 1.2;
  animation: tea-wiggle 0.7s ease;
}
.tea-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -20px;
  left: var(--left);
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: #2a9090;
  animation: tea-confetti-fall var(--duration) linear var(--delay) both;
}
.confetti-piece:nth-child(6n + 2) { background: #d9a441; }
.confetti-piece:nth-child(6n + 3) { background: #b5470f; }
.confetti-piece:nth-child(6n + 4) { background: #1f6e6e; }
.confetti-piece:nth-child(6n + 5) { background: #5a3a1b; }
.confetti-piece:nth-child(6n) { background: #efd28c; }
@keyframes tea-pop-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes tea-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
@keyframes tea-wiggle {
  0% { transform: scale(0.5) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes tea-card-pop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes tea-confetti-fall {
  from { transform: translateY(-40px) rotate(0); opacity: 1; }
  to { transform: translateY(420px) rotate(360deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  body:not(.studio) main *, body:not(.studio) main *::before, body:not(.studio) main *::after {
    animation: none !important;
    transition: none !important;
  }
  .tea-confetti { display: none; }
}
.badges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.badge {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  padding: 16px 10px;
}
.badge h3 {
  font-size: 0.9rem;
  color: var(--amber);
  margin: 4px 0;
}
.badge p {
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 4px 0;
}
.badge .icon {
  font-size: 1.8rem;
}
.snapshot {
  margin: 24px 0;
}
.snapshot summary {
  font-weight: bold;
  color: var(--teal);
  cursor: pointer;
  padding: 12px 0;
}
.snapshot dl > div {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.snapshot dt {
  font-weight: bold;
}
.snapshot dd {
  margin: 4px 0;
}
.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 4vw;
  border-bottom: 1px solid var(--line);
}
.studio-header > a {
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
}
.studio main {
  max-width: 1260px;
  margin: auto;
  padding: 24px 4vw 80px;
}
.studio #notice {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--teal);
  color: white;
  padding: 0 4vw;
}
.studio #notice:not(:empty) {
  padding: 12px 4vw;
}
.studio #notice.error {
  background: var(--rust);
}
.studio-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
}
.quiz-list {
  display: grid;
  gap: 10px;
  align-content: start;
}
.quiz-list button {
  border-radius: 14px;
  justify-content: flex-start;
  text-align: left;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.tabs button {
  border-radius: 10px;
}
.tabs button[aria-pressed="false"] {
  background: transparent;
  color: var(--teal);
}
.editor-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.editor-toolbar button,
.editor-toolbar .button {
  font-size: 0.9rem;
  padding: 9px 16px;
}
.question-row {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
}
.question-row.disabled {
  opacity: 0.65;
}
.question-row summary {
  cursor: pointer;
  font-weight: bold;
  overflow-wrap: anywhere;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.row-actions button {
  padding: 6px 12px;
  font-size: 0.8rem;
  min-height: 40px;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  min-height: 280px;
}
.checks {
  font-size: 0.9rem;
}
.checks label {
  font-weight: normal;
}
.issues:empty {
  display: none;
}
.issues {
  margin-top: 20px;
}
.issues li {
  margin: 8px 0;
  overflow-wrap: anywhere;
}
.question-total {
  font-size: 0.9rem;
  color: var(--muted);
}
.version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}
.version .button {
  padding: 8px 12px;
  font-size: 0.8rem;
}
#prompt-output {
  min-height: 420px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.section-head h2 {
  margin-bottom: 4px;
}
.small-button {
  font-size: 0.8rem;
  min-height: 40px;
  padding: 5px 12px;
}
.source-tag {
  color: var(--amber);
  font-size: 0.8rem;
}
@media (max-width: 800px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .quiz-list {
    display: flex;
    flex-wrap: wrap;
  }
  .quiz-list button {
    flex: 1;
    min-width: 140px;
  }
  .studio-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .studio main {
    padding: 20px 16px 60px;
  }
  .editor-toolbar > * {
    flex: 1;
  }
  .badges {
    gap: 8px;
  }
  .support {
    padding: 6px 8px;
  }
  .topline {
    font-size: 0.7rem;
  }
  body:not(.studio) main {
    padding-top: 12px;
  }
}
:root [hidden] {
  display: none !important;
}
.auth-card,
.account-invite,
.account-card {
  background: var(--paper);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.auth-card form > button,
.account-invite > button {
  margin-top: 18px;
}
.account-invite {
  max-width: 680px;
}
.account-card h3 {
  overflow-wrap: anywhere;
}
