/* ==========================================================================
   Roleplay · Aprendizaje Ilimitado — editorial / "Bosque editorial"
   --------------------------------------------------------------------------
   Tokens aligned with SM_Aprendizaje_Ilimitado_Plugin (paper #f5f3ef,
   slate ink, brand green #00804C, neutral rules, soft shadows).
   Editorial soul preserved: Fraunces serifs for display + chat, kicker ¶,
   Dramatis personae card, decimal-leading-zero objective numbering.
   Layout: drawer-style objectives panel (chat is full-width; objectives
   live in a floating panel that slides in from the right).
   ========================================================================== */

:root {
  /* --- Surfaces (paper) -------------------------------------------------- */
  --paper:        #f5f3ef;    /* main canvas — matches SM plugin */
  --paper-2:      #ece8e0;    /* sidebar / drawer */
  --surface:      #ffffff;    /* card / panel */
  --surface-alt:  #faf8f4;    /* hover / footer */
  --surface-dim:  #f0ede5;    /* progress track, subtle alt */

  /* --- Ink (slate) ------------------------------------------------------- */
  --ink:        #0f172a;
  --ink-2:      #1f2937;
  --ink-dim:    #475569;
  --ink-faint:  #94a3b8;

  /* --- Rules / borders --------------------------------------------------- */
  --rule:         #e5e7eb;
  --rule-soft:    #f3f4f6;
  --rule-strong:  #cbd5e1;

  /* --- Brand green (single source) -------------------------------------- */
  --accent:       #00804C;
  --accent-ink:   #006d40;
  --accent-soft:  #d1fae5;
  --accent-50:    #ecfdf5;
  --accent-glow:  rgba(0, 128, 76, 0.16);
  --accent-ring:  rgba(0, 128, 76, 0.18);

  /* --- Semantic ---------------------------------------------------------- */
  --ok:        #00804C;
  --ok-soft:   #d1fae5;
  --warn:      #f59e0b;
  --warn-soft: #fef3c7;
  --warn-ink:  #92400e;
  --danger:    #983628;

  /* --- Type -------------------------------------------------------------- */
  --serif: "Fraunces", "Cormorant Garamond", ui-serif, Georgia, serif;
  --sans:  "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* --- Radii ------------------------------------------------------------- */
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-pill: 999px;

  /* --- Shadows ----------------------------------------------------------- */
  --sh-xs:    0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-sm:    0 1px 3px rgba(15, 23, 42, 0.06);
  --sh-md:    0 4px 12px rgba(15, 23, 42, 0.06);
  --sh-lg:    0 8px 24px rgba(15, 23, 42, 0.10);
  --sh-xl:    0 20px 60px rgba(15, 23, 42, 0.15);
  --sh-drawer:-20px 0 40px rgba(15, 23, 42, 0.12);

  /* --- Motion ------------------------------------------------------------ */
  --t-fast:  150ms ease;
  --t-base:  220ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  background:
    radial-gradient(1100px 600px at 92% -10%, var(--surface) 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, var(--surface-dim) 0%, transparent 55%),
    var(--paper);
}

button { font: inherit; color: inherit; }
a { color: inherit; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
}

.hidden { display: none !important; }
.grain  { display: none !important; }      /* legacy paper-grain overlay — off in palette D */

input[type="checkbox"],
input[type="radio"],
input[type="range"] { accent-color: var(--accent); }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ==========================================================================
   Typographic primitives
   ========================================================================== */

.kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.kicker::before {
  content: "¶ ";
  color: var(--accent);
  letter-spacing: 0.04em;
}

.display {
  font-family: var(--serif);
  font-weight: 450;
  font-variation-settings: "opsz" 144, "SOFT" 40, "WONK" 0;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 8px 0 0;
}
.display em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  color: var(--accent);
}

.lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin: 10px 0 0;
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  min-height: 540px;
}

/* Discreet copyright footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 24px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-transform: uppercase;
  flex-wrap: wrap;
  row-gap: 2px;
}
.app-footer-sep { opacity: 0.5; }
.app-footer-product { color: var(--ink-dim); }
@media (max-width: 540px) {
  .app-footer { font-size: 10px; padding: 6px 14px; }
  .app-footer-sep, .app-footer-product { display: none; }
}

/* ---------- Masthead — slim header (no logo, no model picker) ------------ */

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 26px 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 5;
}

.masthead-scenario { min-width: 0; }

.masthead-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 6px;
}

.scenario-title {
  font-family: var(--serif);
  font-weight: 450;
  font-variation-settings: "opsz" 96, "SOFT" 50, "WONK" 0;
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.10;
  letter-spacing: -0.015em;
  margin: 6px 0 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scenario-title .caret {
  color: var(--accent);
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.scenario-description {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 6px 0 0;
  max-width: 76ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  border: 1px solid rgba(245, 158, 11, 0.22);
  margin: 0;
}
.variant-banner::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

/* Meta chips (Intento, Best, Difficulty) */
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--rule);
}
.meta-chip em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}
.meta-chip-button {
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.meta-chip-button:hover {
  background: var(--accent-50);
  border-color: var(--accent-soft);
  color: var(--accent-ink);
}
.meta-chip-button[data-level="easy"]   { color: var(--accent-ink); }
.meta-chip-button[data-level="normal"] { color: var(--ink-2); }
.meta-chip-button[data-level="hard"]   { color: var(--danger); }

/* Progress bar (inline, slim) */
.progress {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.progress-track {
  width: 220px;
  height: 4px;
  background: var(--surface-dim);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-bar[data-full="1"] {
  background: linear-gradient(90deg, var(--accent), var(--accent-ink));
}
.progress-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.progress-label em {
  font-style: normal;
  font-weight: 600;
  color: var(--ink-2);
}
.progress-word { color: var(--ink-faint); }

/* ---------- Actions ------------------------------------------------------ */

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Model picker is preserved hidden in DOM for app.js compatibility,
   but never visible to the alumno (model is preconfigured). */
.model-picker { display: none !important; }

/* ---------- Buttons ------------------------------------------------------ */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 9px 16px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast),
              border-color var(--t-fast), transform 80ms ease,
              box-shadow var(--t-base);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:not(:disabled):hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary .btn-arrow { transition: transform 0.2s ease; }
.btn-primary:not(:disabled):hover .btn-arrow { transform: translateX(3px); }

.btn-kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.3;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--rule);
}
.btn-ghost:not(:disabled):hover {
  background: var(--surface);
  border-color: var(--rule-strong);
  color: var(--ink);
}

.btn-primary.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-primary.btn-danger:not(:disabled):hover {
  background: #7e2a14;
  border-color: #7e2a14;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 14px;
}

/* ==========================================================================
   Main — chat + sidebar (objectives as stepper + focus card)
   ========================================================================== */

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 960px) {
  .main { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Chat
   ========================================================================== */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  position: relative;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px 0;
}
.chat-hint {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: var(--r-pill);
  border: 2px solid var(--surface);
}

/* Briefing card — student context shown before the conversation starts */
.briefing-card {
  align-self: stretch;
  padding: 18px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--sh-xs);
  margin-bottom: 4px;
}
.briefing-title {
  font-family: var(--serif);
  font-weight: 450;
  font-variation-settings: "opsz" 96, "SOFT" 40, "WONK" 0;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 6px 0 8px;
}
.briefing-intro {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 14px;
}
.briefing-okrs {
  list-style: none;
  counter-reset: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.briefing-okrs li {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--rule);
}
.briefing-okrs li:first-child { border-top: 0; padding-top: 2px; }
.briefing-okr-id {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.briefing-okr-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.briefing-okr-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.briefing-okr-sub {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-dim);
}
.briefing-aside {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 0;
  padding: 10px 12px;
  background: var(--accent-50);
  border-radius: var(--r-sm);
  border-left: 2px solid var(--accent);
}

/* Character card (shown before first turn) */
.character-card {
  align-self: stretch;
  padding: 18px 22px 0;
  border-left: 2px solid var(--accent);
  border-right: 1px dashed var(--rule);
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  background: var(--surface-alt);
  border-radius: 4px;
}
.character-card h3 {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 96, "SOFT" 100, "WONK" 1;
  font-size: 28px;
  font-weight: 450;
  margin: 6px 0 4px;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.character-card .character-role {
  font-size: 13.5px;
  color: var(--ink-dim);
  font-weight: 500;
  margin: 0 0 10px;
}
.character-card .character-personality {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 14px;
}
.character-card .character-divider {
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 12px 0;
  margin: 0 -22px;
  border-top: 1px solid var(--rule);
}

/* Message bubbles */
.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg.is-new {
  animation: msg-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg .role {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 450;
  font-size: 14px;
  font-variation-settings: "opsz" 48, "SOFT" 80, "WONK" 1;
  color: var(--accent);
}
.msg .role::after {
  content: " ——";
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  vertical-align: 2px;
}

/* Assistant: left rail in green */
.msg.assistant {
  align-self: flex-start;
  position: relative;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
}
.msg.assistant > .msg-body,
.msg.assistant > div:not(.role) {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* User: filled brand-green bubble on the right */
.msg.user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: 72%;
}
.msg.user .role {
  color: var(--ink-dim);
  font-size: 12px;
  font-style: normal;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.msg.user .role::after { content: ""; }
.msg.user > .msg-body,
.msg.user > div:not(.role) {
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-lg) var(--r-lg) 3px var(--r-lg);
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 128, 76, 0.16);
}
.msg.user code {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* Micro-feedback pill below user bubble */
.msg.user .turn-feedback {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-50);
  color: var(--accent-ink);
}
.msg.user .turn-feedback.warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.msg.user .turn-feedback.good {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.msg.user .turn-feedback .tf-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}
.msg.user .turn-feedback.warn .tf-icon { background: var(--warn); }

/* Speak button overlaid on assistant message */
.msg-speak {
  position: absolute;
  top: -4px;
  right: -36px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--surface-alt);
  color: var(--accent-ink);
  font-size: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--t-fast), transform var(--t-fast),
              background var(--t-fast);
}
.msg.assistant:hover .msg-speak { opacity: 1; transform: scale(1); }
.msg-speak:hover { background: var(--accent-50); }
.msg-speak.is-playing {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  opacity: 1;
  transform: scale(1);
}

/* Typing indicator */
.msg.typing {
  align-self: flex-start;
  padding: 6px 0 6px 16px;
  border-left: 2px dashed var(--accent);
  color: var(--ink-dim);
  font-style: italic;
  font-family: var(--serif);
  font-size: 14.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.msg.typing::after {
  content: "";
  display: inline-flex;
  width: 24px;
  height: 8px;
  background-image:
    radial-gradient(circle, var(--accent) 2.5px, transparent 3px),
    radial-gradient(circle, var(--accent) 2.5px, transparent 3px),
    radial-gradient(circle, var(--accent) 2.5px, transparent 3px);
  background-size: 8px 100%;
  background-repeat: no-repeat;
  background-position: 0 50%, 8px 50%, 16px 50%;
  animation: dots 1.1s infinite ease-in-out;
}
@keyframes dots {
  0%, 100% { opacity: 0.5; }
  33%      { opacity: 1; }
  66%      { opacity: 0.8; }
}

/* Flash highlight when scrolling to evidence */
.msg.flash > .msg-body,
.msg.flash > div:not(.role) {
  animation: flash 1.6s ease-out;
}
@keyframes flash {
  0%   { box-shadow: 0 0 0 0 rgba(0, 128, 76, 0.6); }
  30%  { box-shadow: 0 0 0 8px rgba(0, 128, 76, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(0, 128, 76, 0); }
}

/* ==========================================================================
   Composer
   ========================================================================== */

/* ----- composer (sidebar in grid, so no need to constrain max-width) ---- */
.composer {
  padding: 14px 26px 20px;
  background: linear-gradient(180deg, transparent 0, var(--surface) 30%);
  border-top: 1px solid var(--rule);
}
.composer-frame {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.composer-frame:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  max-height: 200px;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  outline: none;
}
.composer textarea::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--serif);
  font-weight: 350;
  font-size: 15.5px;
}
.composer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.draft-saved, .notes-saved {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-right: auto;
}
.draft-saved.is-saved, .notes-saved.is-saved { color: var(--accent-ink); }
.draft-saved.is-saved::before, .notes-saved.is-saved::before {
  content: "● ";
  color: var(--accent);
}

/* Mic button */
.btn-mic { gap: 6px; }
.mic-icon {
  width: 12px; height: 12px;
  border-radius: 4px 4px 4px 4px / 50% 50% 30% 30%;
  background: currentColor;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}
.mic-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  width: 2px;
  height: 4px;
  background: currentColor;
}
.btn-mic .mic-timer { font-family: var(--mono); font-size: 11px; }
.btn-mic.is-recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-mic.is-recording:hover { background: #7e2a14; }
.btn-mic.is-recording .mic-icon::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  animation: mic-pulse 1.2s infinite ease-out;
}
@keyframes mic-pulse {
  0%   { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}
.btn-mic.is-transcribing { opacity: 0.7; cursor: progress; }

/* ==========================================================================
   Quests sidebar (stepper + focus card)
   ========================================================================== */

.quests {
  background: var(--paper);
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.quests-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
}
.quests-title {
  font-family: var(--serif);
  font-weight: 450;
  font-variation-settings: "opsz" 48, "SOFT" 60, "WONK" 0;
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 6px 0 0;
  line-height: 1.1;
  color: var(--ink);
}
.quests-title em {
  font-style: italic;
  font-variation-settings: "opsz" 48, "SOFT" 100, "WONK" 1;
  color: var(--accent);
}
.quests-close { display: none; }   /* not needed in stepper layout */

/* The raw <ul id="objectives"> stays in the DOM for app.js to write to;
   we mirror it into the stepper + focus card and hide the original. */
#objectives { display: none; }

/* Stepper — fila de 6 pasos compactos */
.quest-stepper {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}
.quest-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast),
              box-shadow var(--t-fast);
}
.quest-step:hover { border-color: var(--rule-strong); }
.quest-step:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.quest-step.is-active {
  border-color: var(--accent);
  background: var(--accent-50);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.quest-step__num {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 48, "SOFT" 100, "WONK" 1;
  font-size: 18px;
  color: var(--ink-faint);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.quest-step.done .quest-step__num        { color: var(--ok); }
.quest-step.in_progress .quest-step__num { color: var(--warn); }
.quest-step.is-active .quest-step__num   { color: var(--accent-ink); }
.quest-step__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rule-strong);
  transition: background var(--t-fast);
}
.quest-step.done .quest-step__dot        { background: var(--ok); }
.quest-step.in_progress .quest-step__dot { background: var(--warn); }

/* Focus card — the selected objective in detail */
.quest-detail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.quest-detail::-webkit-scrollbar { width: 6px; }
.quest-detail::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: var(--r-pill);
}
.quest-detail__kicker { display: block; margin-bottom: 8px; }
.quest-detail__num {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-weight: 500;
  font-size: 56px;
  color: var(--accent);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.quest-detail__title {
  font-family: var(--serif);
  font-weight: 450;
  font-variation-settings: "opsz" 96, "SOFT" 50, "WONK" 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  color: var(--ink);
}
.quest-detail__desc {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0;
}
.quest-detail__evidence {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 14px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-50);
  border-radius: 0 var(--r) var(--r) 0;
}
.quest-detail__evidence::before { content: "“"; color: var(--accent); font-weight: 700; margin-right: 2px; }
.quest-detail__evidence::after  { content: "”"; color: var(--accent); font-weight: 700; margin-left: 2px; }

.quest-detail__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 14px;
}
.quest-detail__status.pending {
  background: var(--surface);
  color: var(--ink-dim);
  border: 1px solid var(--rule);
}
.quest-detail__status.in_progress {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.quest-detail__status.done {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Notes block (bottom of sidebar) */
.notes {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}
.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.notes-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.notes-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.notes-textarea::placeholder { color: var(--ink-faint); }

/* ==========================================================================
   Banner (toast)
   ========================================================================== */

.banner {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  z-index: 100;
  animation: banner-in 0.3s ease;
}
.banner[data-level="info"]  { background: var(--accent); }
.banner[data-level="error"] { background: var(--danger); }
@keyframes banner-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: min(680px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl);
  overflow: hidden;
  position: relative;
}
.modal-content.modal-sm { width: min(460px, 100%); }
.modal-content.modal-lg { width: min(880px, 100%); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rule);
}
.modal-header .kicker { color: var(--ink-dim); }
.modal-header h2 { font-size: 26px; margin: 4px 0 0; }
.modal-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: var(--rule-soft); color: var(--ink); }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--rule);
  background: var(--surface-alt);
}

/* Evaluation report */
.score-ring {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.score-ring .score {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-weight: 500;
  font-size: 64px;
  line-height: 0.95;
  color: var(--accent);
  letter-spacing: -0.035em;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.score-ring .score small {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink-faint);
  font-weight: 400;
}
.score-ring .score-label {
  flex: 1;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
}

.personal-best {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 10px 14px;
  background: var(--accent-50);
  border-radius: var(--r);
  border: 1px solid var(--accent-soft);
}
.personal-best em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent-ink);
}
.personal-best .kicker { display: block; margin-bottom: 4px; color: var(--accent-ink); }

.eval-narrative {
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.eval-narrative .kicker { display: block; margin-bottom: 8px; }
.eval-narrative p {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.eval-section { margin-top: 22px; }
.eval-section h3 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-dim);
  margin: 0 0 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eval-section h3::before {
  content: "";
  width: 4px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
}
.eval-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.eval-section li {
  position: relative;
  padding: 10px 12px 10px 32px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
}
.eval-section li::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.eval-obj {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  margin-bottom: 8px;
  background: var(--surface);
}
.eval-obj.has-evidence { cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.eval-obj.has-evidence:hover { border-color: var(--accent); background: var(--accent-50); }
.eval-obj-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}
.eval-obj.in_progress .objective-status {
  background: var(--warn);
  border-color: var(--warn);
}
.eval-obj.done .objective-status {
  background: var(--ok);
  border-color: var(--ok);
}
.eval-obj-pin {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent-ink);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.eval-obj-feedback {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 6px 0 0 28px;
}

.history-attempts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.history-attempts li {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 6px 12px;
  border-radius: var(--r);
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 84px;
  font-family: var(--mono);
  font-size: 11px;
}
.history-attempts li.is-current {
  border-color: var(--accent);
  background: var(--accent-50);
}
.history-attempts li em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent-ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* Confirm extras */
.confirm-extra { margin-top: 14px; }
.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
}
.confirm-check input[type="checkbox"] { margin-top: 2px; }
.confirm-check span {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.confirm-check em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent-ink);
}

/* Difficulty modal */
.difficulty-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.difficulty-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--t-fast), background var(--t-fast),
              box-shadow var(--t-fast);
}
.difficulty-option:hover {
  border-color: var(--accent);
  background: var(--accent-50);
}
.difficulty-option.is-active {
  border-color: var(--accent);
  background: var(--accent-50);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.difficulty-option .kicker { color: var(--accent-ink); }
.difficulty-option strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.difficulty-option span {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 13.5px;
  color: var(--ink-dim);
  line-height: 1.5;
}

/* Hint modal */
.hint-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  padding: 16px 18px;
  background: var(--accent-50);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r) var(--r) 0;
}

/* Shortcuts modal */
.shortcuts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 20px;
  margin: 0;
}
.shortcuts dt {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.shortcuts dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.shortcuts kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--sh-xs);
}

/* History modal */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast),
              transform 80ms ease, box-shadow var(--t-base);
}
.history-item:hover {
  border-color: var(--accent);
  background: var(--accent-50);
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}
.history-item h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.history-item .history-meta {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  letter-spacing: 0.02em;
}
.history-item .history-meta .badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent-50);
  color: var(--accent-ink);
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.history-item .history-score {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 96, "SOFT" 100, "WONK" 1;
  font-weight: 500;
  font-size: 30px;
  color: var(--accent);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  align-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.history-item .history-score small {
  font-size: 13px;
  color: var(--ink-faint);
  font-weight: 400;
}
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--serif);
  font-size: 14px;
}

/* ==========================================================================
   Picker (dev fallback when no scenario_id in URL)
   ========================================================================== */

.picker {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 8% -10%, var(--accent-50) 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 100%, var(--warn-soft) 0%, transparent 55%),
    var(--paper);
}
.picker-card {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: 32px 36px 28px;
  position: relative;
}
.picker-head { margin-bottom: 24px; display: flex; flex-direction: column; gap: 4px; }
.picker-card .display { font-size: clamp(24px, 3.5vw, 32px); }
.picker-card .lede code {
  background: var(--accent-50);
  color: var(--accent-ink);
  padding: 1px 8px;
  font-style: normal;
  font-family: var(--mono);
  font-weight: 500;
}

.field {
  display: block;
  margin-top: 18px;
}
.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14.5px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.picker-difficulty {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  width: fit-content;
}
.difficulty-pill {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.difficulty-pill:hover { color: var(--ink); }
.difficulty-pill.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--sh-xs);
}

.picker-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-list .muted {
  padding: 14px;
  background: var(--surface-alt);
  border: 1px dashed var(--rule);
  border-radius: var(--r);
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  text-align: center;
}
.picker-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--t-fast), background var(--t-fast),
              transform 80ms ease, box-shadow var(--t-base);
}
.picker-item:hover {
  border-color: var(--accent);
  background: var(--accent-50);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}
.picker-item:active { transform: translateY(0); }
.picker-item-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.picker-item-desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-dim);
  line-height: 1.5;
  margin-top: 4px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 720px) {
  .masthead {
    padding: 12px 18px;
  }
  .masthead-actions {
    flex-wrap: wrap;
  }
  .chat-head,
  .messages,
  .composer { padding-left: 18px; padding-right: 18px; }
}
