:root {
  --bg: #e9eef5;
  --me: #dcf8c6;
  --them: #ffffff;
  --muted: #7b8794;
  --accent: #0b74de;
  --ok: #2e7d32;
  --warn: #8a5a00;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg), #f7fbff);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 70px 24px 24px;
}

.sample-watermark {
  position: fixed;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  background: rgba(255, 0, 0, 0.08);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 700;
  color: #a00;
  font-size: 12px;
  z-index: 9999;
  text-align: center;
  max-width: 90vw;
}

.resources-persistent-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 9999;
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.resources-persistent-link:hover { text-decoration: underline; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
}
.modal-box h1 { font-size: 20px; margin-top: 0; color: #1a2233; }
.modal-box p { color: #334155; line-height: 1.5; }
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

button.btn-primary, button.btn-secondary {
  flex: none;
  padding: 12px;
  border-radius: 10px;
  border: 0;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
button.btn-primary { background: var(--accent); color: #fff; }
button.btn-secondary { background: #eef2f7; color: #334155; }

/* Gauge */
.gauge-bar {
  width: 420px;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.gauge-track {
  flex: 1;
  min-width: 120px;
  height: 8px;
  background: #d7dee7;
  border-radius: 999px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease;
}
.gauge-label { font-size: 12px; color: #334155; white-space: nowrap; }
.skip-link { font-size: 12px; color: var(--muted); text-decoration: none; }
.skip-link:hover { text-decoration: underline; }

/* Chat frame */
.frame {
  width: 420px;
  max-width: 100%;
  background: #f2f6fb;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(20, 30, 50, 0.12);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #cfd8e3; display: inline-block; }
.title { font-weight: 600; }
.subtitle { font-size: 12px; color: var(--muted); }
.messages {
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.25;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  display: inline-block;
  white-space: pre-wrap;
}
.from-me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.from-them { align-self: flex-start; background: var(--them); border-bottom-left-radius: 4px; }
.meta { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.name-badge { font-weight: 600; color: #334155; font-size: 12px; margin-bottom: 4px; }
.time { font-size: 11px; color: var(--muted); }
.ticks { font-size: 12px; margin-left: 6px; opacity: 0.8; }
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.08); border-radius: 8px; }
.section {
  align-self: center;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  margin: 10px 0;
}

.freeread-card {
  align-self: center;
  background: #fff7e0;
  border: 1px solid #f0d98c;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #4a3c00;
  max-width: 92%;
}
.freeread-card strong { display: block; margin-bottom: 4px; }
.freeread-card p { margin: 0; line-height: 1.4; }

.controls {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  background: #fff;
}
button { flex: 1; padding: 8px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.small { font-size: 12px; padding: 6px; border-radius: 8px; }
.btn-export { background: #f3f4f6; color: #111; }

/* Question panel */
.question-panel {
  padding: 14px;
  background: #f8fafc;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.q-prompt { font-size: 14px; font-weight: 600; color: #1a2233; margin-bottom: 10px; line-height: 1.4; }
.q-input {
  width: 100%;
  min-height: 60px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.q-hint { margin-top: 8px; font-size: 12.5px; color: var(--warn); background: #fff3d6; border-radius: 8px; padding: 8px; }
.q-note { font-size: 13px; color: #334155; margin-bottom: 10px; }
.q-btn-row { margin-top: 10px; display: flex; }
.q-validate, .q-continue { background: var(--accent); color: #fff; }
.q-feedback { margin-top: 10px; padding: 10px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.q-feedback strong { display: block; margin-bottom: 4px; }
.q-feedback-ok { background: #e6f4ea; color: #1e4620; border: 1px solid #b7dfc0; }
.q-feedback-info { background: #eef2f7; color: #1a2233; border: 1px solid #d7dee7; }

.q-choices { display: flex; flex-direction: column; gap: 8px; }
.q-choice {
  flex: none;
  text-align: left;
  background: #fff;
  color: #1a2233;
  border: 1px solid #cbd5e1;
  font-weight: 400;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
}
.q-choice:hover:not(:disabled) { border-color: var(--accent); }
.q-choice:disabled { cursor: default; opacity: 0.85; }
.q-choice-correct { border-color: var(--ok); background: #e6f4ea; font-weight: 600; }
.q-choice-wrong { border-color: #c62828; background: #fbe9e7; }

/* Recap screen */
.recap-screen {
  width: 560px;
  max-width: 100%;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(20, 30, 50, 0.12);
  padding: 24px;
  margin-top: 20px;
}
.recap-screen h2 { margin-top: 0; color: #1a2233; }
.recap-intro { color: #334155; line-height: 1.5; }
.recap-timeline { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.recap-item {
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
}
.recap-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.recap-date { font-size: 12px; color: var(--muted); font-weight: 600; }
.recap-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-ok { background: #e6f4ea; color: #1e4620; }
.badge-miss { background: #fdecea; color: #7a1f1f; }
.badge-neutral { background: transparent; }
.recap-mechanism { font-weight: 600; color: #1a2233; margin-bottom: 4px; }
.recap-explanation { font-size: 13px; color: #334155; line-height: 1.45; }

.resources-block { margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.resources-block h3 { margin-top: 0; color: #1a2233; }
.resources-list { display: flex; flex-direction: column; gap: 10px; }
.resource-item { background: #f8fafc; border-radius: 8px; padding: 10px 12px; }
.resource-item a { color: var(--accent); text-decoration: none; font-size: 14px; }
.resource-item a:hover { text-decoration: underline; }
.resource-item p { margin: 4px 0 0; font-size: 12.5px; color: #334155; line-height: 1.4; }

.recap-actions { margin-top: 20px; display: flex; gap: 10px; }
.recap-actions button { flex: none; background: var(--accent); color: #fff; }
