/* Tutor chat module — consolidated cascade (R2-E).
   Extracted from styles.css + ui-system.css (Task 4), then deduplicated:
   every selector/property has exactly one authoritative definition below,
   and breakpoint corrections live in @media blocks at the foot of the file.
   The pre-merge sheets achieved this look through five global override
   layers; the winners of those layers are preserved verbatim here and the
   losing layers are gone. The only intentionally changed computed values
   are the viewport-fill geometry (see "Viewport fill" below) — the old
   calc(100svh - 64px) min-heights pinned to a 64px header while the real
   topbar is 67–125px tall, pushing the composer below the fold. */

.tutor-chat-stepper { display: none; }
/* Warm-up rail: a nested paper card on the shell panel — subtle tint, hairline
   border, card radius. (The shell itself is the elevated surface.) */
.tutor-chat-rail { border: 1px solid var(--color-border-subtle); border-radius: var(--radius-card); padding: var(--space-4); background: var(--color-bg-canvas); }
.tutor-chat-rail-title { margin: 0 0 10px; font-family: "SF Mono", Menlo, monospace; font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-tertiary); font-weight: 600; }
.tutor-chat-beats { list-style: none; margin: 0; padding: 0; }
.tutor-chat-beat { position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; color: var(--color-text-secondary); }
/* 1px connector line between beats so the four stations read as one path. */
.tutor-chat-beat + .tutor-chat-beat::before { content: ""; position: absolute; left: 7.5px; top: -5px; width: 1px; height: 10px; background: var(--color-border-subtle); }
.tutor-chat-beat-dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--color-border-strong); flex: none; display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--color-neutral-0); }
.tutor-chat-beat.is-done .tutor-chat-beat-dot { background: var(--color-green-500); border-color: var(--color-green-500); }
.tutor-chat-beat.is-current { color: var(--color-text-primary); font-weight: 600; }
/* Current beat: outlined brand circle on a tint fill, with a solid core dot. */
.tutor-chat-beat.is-current .tutor-chat-beat-dot { background: var(--color-brand-50); border-color: var(--color-brand-600); }
.tutor-chat-beat.is-current .tutor-chat-beat-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--color-brand-600); }
.tutor-chat-beat.is-stopped .tutor-chat-beat-dot { border-color: var(--color-amber-500); background: var(--color-amber-500); }
/* Full-map visibility: todo beats are visibly on the map but clearly unlit —
   lighter than the default body copy so done > current > todo forms a
   deliberate gradient instead of todos blending into the text color.
   (The literal #94A3B8 is pinned by adaptive-tutor-ui.test.mjs.) */
.tutor-chat-beat.is-todo { color: #94A3B8; }
.tutor-chat-beat.is-todo .tutor-chat-beat-dot { border: 1.5px solid var(--color-neutral-300); background: transparent; }
.tutor-chat-rail-node { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border-subtle); font-size: 12px; color: var(--color-text-primary); font-weight: 600; }
.tutor-chat-rail-state { margin-left: 6px; font-family: "SF Mono", Menlo, monospace; font-size: 10px; color: var(--color-text-tertiary); font-weight: 400; }
.tutor-chat-rail-meter { height: 4px; border-radius: 2px; background: var(--color-border-default); margin-top: 8px; overflow: hidden; }
.tutor-chat-rail-meter i { display: block; height: 100%; background: var(--color-brand-600); border-radius: 2px; }
.tutor-chat-rail-suggestion { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--color-text-secondary); }
.tutor-chat-rail.is-free { color: var(--color-text-tertiary); }
.tutor-chat-rail.is-free .tutor-chat-rail-suggestion { color: var(--color-text-tertiary); }
/* Warm-up review bridge (R2-D): fading skills become one-click node-session
   entries; rows stay tappable at 44px and keep the existing amber fading
   semantics from the skill tree — amber survives only as a small status dot. */
.tutor-chat-warmup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.tutor-chat-warmup-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--color-border-subtle); border-radius: var(--radius-card); background: var(--color-bg-surface); box-shadow: var(--shadow-1); color: var(--color-text-primary); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer; transition: border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
.tutor-chat-warmup-item:hover { background: var(--color-brand-50); border-color: var(--color-brand-300); box-shadow: var(--shadow-1); }
.tutor-chat-warmup-item:focus-visible { outline: 2px solid var(--color-focus-ring, #4F46E5); outline-offset: 2px; }
.tutor-chat-warmup-item small { flex: none; padding: 2px 0 2px 13px; font-family: "SF Mono", Menlo, monospace; font-size: 9px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-amber-700); background-image: radial-gradient(circle 3px at 4px 50%, #F59E0B 99%, transparent 100%); background-repeat: no-repeat; }
.adaptive-tutor-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; grid-template-rows: minmax(0, 1fr) auto; align-items: start; column-gap: 20px; }
/* Explicit placement: the thread owns column 1; the error card stacks under
   it instead of auto-placing into the rail column; the rail (and its mobile
   stepper) always sits in column 2 spanning both rows. */
.adaptive-tutor-body > .adaptive-tutor-thread { grid-column: 1; grid-row: 1; }
.adaptive-tutor-body > .tutor-chat-error-card { grid-column: 1; grid-row: 2; }
.adaptive-tutor-body > .tutor-chat-scroll-pill { grid-column: 1; grid-row: 2; justify-self: end; }
.adaptive-tutor-body > .tutor-chat-stepper { grid-column: 2; grid-row: 1; }
.adaptive-tutor-body > .tutor-chat-rail { grid-column: 2; grid-row: 1 / -1; align-self: stretch; }
.tutor-chat-rail-open .tutor-chat-rail { display: block; }

.adaptive-lesson-block {
  margin-top: 10px;
  border: 1px solid var(--color-border-subtle, #E2E8F0);
  border-radius: var(--radius-card);
  background: var(--color-bg-surface);
  padding: 12px 14px;
  display: grid;
  gap: 10px;

}

.adaptive-lesson-part {
  min-width: 0;

}

.adaptive-lesson-part strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-secondary, #475569);
  margin-bottom: 2px;

}

.adaptive-lesson-part p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;

}

.adaptive-lesson-part mark {
  background: var(--color-warning-bg);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;

}

/* --- Viewport fill: the shell always occupies exactly the space the
   portal header leaves, so the thread scrolls internally and the composer
   stays pinned to the visible bottom edge at any viewport size. (Replaces
   the global calc(100svh - 64px) min-heights from the pre-merge sheets,
   which pinned to a 64px header; the real topbar is 121px at <=900 and
   125px at <=720, so the composer sat 73-89px below the fold. The fixed
   height cap plus flex fill has no header-height constant, keeps the shell
   from growing with its content, and leaves the fixed bottom tabs out of
   the flow; ui-system's <=720 padding-bottom on the portal main then lands
   the composer just above the tabs.) --- */
.app-shell:has(.adaptive-tutor-shell) { display: flex; flex-direction: column; height: 100svh; }

.app-shell:has(.adaptive-tutor-shell) .student-app-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-shell:has(.adaptive-tutor-shell) .student-app-main :is(.student-workbench, .student-tutor-page) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-shell:has(.adaptive-tutor-shell) .adaptive-tutor-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* The body is the shell's 1fr row; cap its row and let the thread stretch to
   it so the thread's own overflow-y: auto becomes the internal scroller.
   Row 2 (error card / scroll pill) sizes to content. */
.app-shell:has(.adaptive-tutor-shell) .adaptive-tutor-body {
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

.app-shell:has(.adaptive-tutor-shell) .adaptive-tutor-body .adaptive-tutor-thread {
  align-self: stretch;
}

:is(.student-workbench, .student-tutor-page):has(.adaptive-tutor-shell) {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: var(--space-4) 0 0;
}

.adaptive-tutor-shell {
  width: min(100%, var(--chat-max));
  min-width: 0;
  margin-inline: auto;
  padding: var(--space-6) var(--space-8);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-panel);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
}

.adaptive-tutor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.adaptive-tutor-header > div { display: flex; align-items: baseline; gap: var(--space-3); }

.adaptive-tutor-header h1 { margin: 0; font-size: var(--text-md); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }

.adaptive-tutor-header p { display: none; margin: 0; color: var(--color-text-secondary); font-size: var(--text-sm); }

/* Conversation header stays quiet chrome — the hero opening owns the large
   display size via .adaptive-tutor-welcome-title. Scoped to the header so the
   ID no longer caps the hero greeting. Quiet 15px/600 title per the chat
   panel contract; the hero greeting keeps its display size. */
.adaptive-tutor-header #adaptive-tutor-title { font-size: 15px; line-height: var(--leading-tight); font-weight: 600; }

.adaptive-tutor-session-time { flex: 0 0 auto; padding: 0; color: var(--color-text-tertiary); font-size: 12px; font-weight: 400; }

.adaptive-tutor-practice-mode, .adaptive-tutor-test-mode { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 740; }

.adaptive-tutor-test-mode { color: var(--ink); }

.adaptive-tutor-welcome {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  margin-bottom: 8px;
  padding: 48px 0 32px;
  color: var(--color-text-primary);
  text-align: center;
}

.adaptive-tutor-welcome-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  box-shadow: var(--shadow-2);
}

.adaptive-tutor-welcome p {
  max-width: min(100%, 32ch);
  margin: 0 auto;
  color: var(--color-text-primary);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.adaptive-tutor-thread {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4) 0 var(--space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-thread {
  align-content: safe center;
  justify-content: center;
  padding-bottom: 32px;
}

.adaptive-tutor-thread-item {
  display: grid;
  min-width: 0;

}

.adaptive-tutor-activity-holder {
  display: flex;
  justify-content: center;
  width: 100%;
  min-width: 0;
  margin-top: 10px;

}

.adaptive-tutor-activity-holder .adaptive-tutor-activity {
  width: 100%;
  max-width: 680px;
  margin-top: 0;

}

.adaptive-tutor-thinking {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  padding: var(--space-3) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  animation: none;
}

.adaptive-tutor-thinking .tutor-avatar { box-shadow: var(--shadow-1); }

.adaptive-tutor-thinking-mark {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: min(240px, 60%);
}

.adaptive-tutor-thinking-mark i {
  display: block;
  height: 10px;
  border-radius: 6px;
  border: 0;
  /* Soft brand-to-neutral sweep: the shimmer travels brand-50 → neutral-100. */
  background: linear-gradient(90deg, var(--color-brand-50) 22%, var(--color-neutral-100) 50%, var(--color-brand-50) 78%);
  background-size: 200% 100%;
  animation: tutor-chat-skeleton 1.4s ease-in-out infinite;
}

.adaptive-tutor-thinking-mark i:nth-child(1) { width: 55%; }
.adaptive-tutor-thinking-mark i:nth-child(2) { width: 82%; }
.adaptive-tutor-thinking-mark i:nth-child(3) { width: 38%; }

@keyframes tutor-chat-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.adaptive-tutor-thinking-steps {
  display: grid;
  justify-items: start;

}

.adaptive-tutor-thinking-steps span {
  grid-area: 1 / 1;
  opacity: 0;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  white-space: nowrap;
  animation: adaptiveTutorThinkingStep 5.4s ease-in-out infinite;

}

.adaptive-tutor-thinking-steps span:nth-child(2) { animation-delay: 1.8s; 
}

.adaptive-tutor-thinking-steps span:nth-child(3) { animation-delay: 3.6s; 
}

@keyframes adaptiveTutorThinkingStep {
  0%, 24% { opacity: 0; transform: translateY(5px); }
  33%, 85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-5px); }
}

@keyframes adaptiveTutorThinkingIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tutor thread with Lexora avatars — editorial rhythm (2026-09): tutor turns
   sit directly on the canvas (no box), carried by the Lexora avatar and the
   small label; only the student's messages get a bubble, aligned right.
   Bubbles size to their content (fit-content) instead of stretching to a
   shared width. */
.adaptive-tutor-turn {
  position: relative;
  flex: 0 1 auto;
  width: fit-content;
  min-width: 0;
  max-width: min(100%, 60ch);
  padding: 12px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-soft);
  background: var(--color-bg-surface);
  box-shadow: none;
}

.adaptive-tutor-turn.is-tutor:not(.is-lesson) {
  max-width: 62ch;
  padding-inline: 0;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
}

.adaptive-tutor-turn.is-student {
  margin-left: auto;
  max-width: 78%;
  border-color: var(--color-brand-100);
  border-radius: 12px 2px 12px 12px;
  background: var(--color-brand-50);
  box-shadow: var(--shadow-1);
  color: var(--color-text-primary);
}

.adaptive-tutor-thread-item .adaptive-tutor-turn.is-student { margin-left: auto; }

.adaptive-tutor-thread-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Tutor-side avatar: 28px with a faint brand-50 halo plate behind it. */
.adaptive-tutor-thread-item .tutor-turn-avatar {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-brand-50) 60%, transparent);
}

.adaptive-tutor-thread-item .adaptive-tutor-quick-replies { margin-left: 40px; }

.adaptive-tutor-turn-label {
  display: block;
  margin-bottom: 6px;
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.adaptive-tutor-turn.is-student .adaptive-tutor-turn-label { color: color-mix(in srgb, var(--color-brand-700, #4338CA) 70%, transparent); }

/* Lesson teaching-moment panel: full-width indigo accent (inset shadow per
   design-system contract — no thick side borders) with mono uppercase tag.
   Sits on a 40% brand-50 wash over the panel surface. */
.adaptive-tutor-turn.is-lesson {
  width: 100%;
  max-width: none;
  padding: 14px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--color-brand-50) 40%, var(--color-bg-surface, #fff));
  box-shadow: inset 3px 0 0 #4F46E5;
}

.adaptive-tutor-turn.is-lesson .adaptive-tutor-turn-label {
  display: block;
  margin-bottom: 6px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-brand-600);
  font-weight: 700;
}

.adaptive-tutor-turn.is-long { background: transparent; border-color: transparent; padding-inline: 0; max-width: 62ch; }
.adaptive-tutor-turn.is-long p { line-height: 1.7; }

.adaptive-tutor-turn p {
  margin: 0;
  font-size: 15px;
  line-height: var(--leading-body);
}

.adaptive-tutor-turn p,
.adaptive-tutor-quick-reply,
.adaptive-tutor-activity h3,
.adaptive-tutor-option,
.adaptive-sentence-parts button,
.adaptive-activity-label,
.adaptive-writing-context,
.adaptive-tutor-hint p {
  min-width: 0;
  overflow-wrap: anywhere;
}

.adaptive-tutor-quick-replies { display: flex; flex-wrap: wrap; gap: 8px; max-width: 640px; margin: 10px 0 0; }

.adaptive-tutor-quick-reply {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-round);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.adaptive-tutor-quick-reply:hover:not(:disabled) {
  border-color: var(--color-brand-300);
  background: var(--color-brand-50);
  box-shadow: var(--shadow-1);
}

.adaptive-tutor-quick-reply,
.adaptive-tutor-send,
.adaptive-activity-submit,
.adaptive-tutor-option,
.adaptive-sentence-parts button {
  border-radius: 999px;
  touch-action: manipulation;
  transition: transform 240ms ease, box-shadow 240ms ease, border-color 240ms ease, background-color 240ms ease, padding 240ms ease;

}

.adaptive-tutor-quick-reply:active,
.adaptive-tutor-send:active,
.adaptive-activity-submit:active,
.adaptive-tutor-option:active,
.adaptive-sentence-parts button:active {
  transform: scale(.97);

}

.adaptive-tutor-activity {
  position: relative;
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 720px;
  min-width: 0;
  margin-top: 12px;
  padding: var(--space-6);
  /* The literal #C7D2FE border is pinned by design-system-ui.test.mjs. */
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-card);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-1);
}

.adaptive-tutor-activity.is-test { border-color: var(--color-border-subtle); background: var(--color-bg-surface); }

.adaptive-tutor-activity > header,
.adaptive-activity-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;

}

.adaptive-tutor-activity > header span {
  display: inline-flex;
  gap: 7px;
  align-items: center;

}

.adaptive-tutor-activity > header .icon {
  width: 17px;
  height: 17px;

}

.adaptive-tutor-activity > header small,
.adaptive-activity-footer small {
  color: var(--muted);

}

.adaptive-tutor-activity > h3 {
  max-width: 66ch;
  margin: 0 0 var(--space-4);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.45;
}

.adaptive-tutor-activity-controls,
.adaptive-writing-task,
.adaptive-writing-context,
.adaptive-sentence-workspace {
  display: grid;
  gap: 13px;
  min-width: 0;
}

.adaptive-tutor-option-grid,
.adaptive-sentence-parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.adaptive-tutor-option {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 10px var(--space-4);
  border: 2px solid var(--color-border-default);
  border-radius: var(--radius-soft);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), padding var(--duration-fast) var(--ease-standard);
}

.adaptive-sentence-parts button {
  min-height: 40px;
  padding: 11px 13px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-soft);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: 14px;
  text-align: left;
}

.adaptive-sentence-answer {
  min-height: 64px;
  padding: 14px;
  border: 1px dashed color-mix(in srgb, var(--green-strong) 40%, var(--line));
  border-radius: 12px;
  background: var(--color-bg-surface);

}

.adaptive-sentence-answer span {
  color: var(--muted);
  font-size: 14px;

}

.adaptive-vocabulary-source {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);

}

.adaptive-vocabulary-source mark {
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--color-amber-100);
  color: var(--ink);
  font-weight: 760;

}

.adaptive-activity-label {
  display: block;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.adaptive-activity-label textarea,
.adaptive-writing-task textarea {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--color-bg-surface);
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  resize: vertical;

}

.adaptive-writing-context {
  padding: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-soft);
  background: var(--surface-learning);
}

.adaptive-writing-context p,
.adaptive-writing-context ul {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;

}

.adaptive-writing-context ul {
  padding-left: 20px;

}

.adaptive-activity-submit {
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: var(--radius-button);
  background: var(--color-brand-600);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-1);
  font-size: 15px;
  font-weight: 740;
}

.adaptive-activity-submit:disabled,
.adaptive-tutor-send:disabled {
  border-color: var(--color-disabled-border);
  background: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  box-shadow: none;
}

.adaptive-activity-submit:hover:not(:disabled),
.adaptive-tutor-send:hover:not(:disabled) {
  border-color: var(--color-brand-700);
  background: var(--color-brand-700);
  box-shadow: var(--shadow-1);
  transform: none;
}

.adaptive-tutor-hint {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;

}

.adaptive-tutor-hint summary {
  min-height: 44px;
  width: fit-content;
  padding-block: 11px;
  color: var(--green-strong);
  font-weight: 740;
  cursor: pointer;

}

.adaptive-tutor-hint p {
  margin: 4px 0 0;
  line-height: 1.55;

}

/* --- Composer capsule (Tutor): floating pill — surface fill, default hairline,
   round radius, hover-level shadow; focus swaps to brand border + 4px ring.
   The textarea owns min-width: 0 so the Send button never squeezes the
   input track on narrow screens (390px placeholder-wrap bug). --- */
.adaptive-tutor-composer {
  position: sticky;
  z-index: 5;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 832px;
  justify-self: center;
  margin: var(--space-3) 4px 0;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-round);
  background: var(--color-bg-surface, #fff);
  box-shadow: var(--shadow-2);
  backdrop-filter: none;
}

.adaptive-tutor-composer:focus-within {
  border-color: var(--color-brand-600);
  box-shadow: var(--shadow-2), 0 0 0 4px var(--color-focus-ring);
}

/* Mobile: the shell's bottom padding would leave a background gap between
   the composer and the fixed bottom navigation — dock the composer to the
   shell's bottom edge so it sits flush on the navigation. */
@media (max-width: 720px) {
  .app-shell:has(.adaptive-tutor-shell) .adaptive-tutor-shell {
    padding-bottom: 0;
  }
}

.adaptive-tutor-send:disabled,
.adaptive-tutor-composer textarea:disabled {
  cursor: wait;
}

.adaptive-tutor-composer textarea {
  resize: none;
  overflow-y: auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  max-height: 9.75em;
  padding: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.adaptive-tutor-send {
  display: inline-flex;
  flex: none;
  gap: 7px;
  align-items: center;
  min-height: 40px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-round);
  background: var(--color-brand-600);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

.adaptive-tutor-send .icon { width: 16px; height: 16px; }

.adaptive-tutor-send:active:not(:disabled) { transform: scale(.97); }

.tutor-char-count { flex-basis: 100%; text-align: right; font-family: "SF Mono", Menlo, monospace; font-size: 10px; color: var(--color-neutral-300); }

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-thread-item {
  width: min(100%, 640px);
  margin-inline: auto;

}

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-turn {
  width: 100%;
  max-width: none;
  padding: 16px 18px;

}

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-quick-replies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: none;

}

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-quick-reply {
  min-height: 56px;
  text-align: left;

}

.adaptive-tutor-fallback-note {
  display: block;
  margin-top: var(--space-2);
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.45;

}

/* The exercise panel is a full-width centred working surface, not a chat bubble. */
.adaptive-tutor-thread-item .adaptive-tutor-activity-holder {
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
  margin-left: 0;
  margin-top: var(--space-2);
}

.adaptive-tutor-thread-item .adaptive-tutor-activity-holder .adaptive-tutor-activity {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
}

/* Conversational vocabulary move: word first, then a short reason. */
.adaptive-vocabulary-ask {
  margin: var(--space-2) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;

}

.adaptive-vocabulary-ask strong { color: var(--color-text-primary); font-weight: 600; 
}

.adaptive-vocabulary-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);

}

.adaptive-vocabulary-replies .adaptive-tutor-quick-reply {
  min-height: 38px;
  padding: 6px 12px;

}

.adaptive-vocabulary-replies + .adaptive-activity-label { margin-top: var(--space-3); 
}

.adaptive-vocabulary-replies + .adaptive-activity-label + input {
  width: 100%;
  box-sizing: border-box;

}

.adaptive-tutor-activity[aria-busy="true"] { pointer-events: none; 
}

.adaptive-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);

}

.adaptive-activity-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-button);
  background: var(--color-brand-50);
  color: var(--color-brand-700);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.adaptive-activity-type .icon { width: 13px; height: 13px; 
}

.adaptive-activity-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  font-weight: 500;

}

.adaptive-activity-meta i {
  width: 3px;
  height: 3px;
  border-radius: var(--radius-round);
  background: var(--color-border-strong);

}

.adaptive-activity-meta small { color: var(--color-text-tertiary); font-size: var(--text-xs); 
}

.adaptive-tutor-option:hover:not(:disabled),
.adaptive-tutor-option:focus-visible,
.adaptive-sentence-parts button:hover:not(:disabled),
.adaptive-sentence-parts button:focus-visible {
  border-color: var(--color-brand-600);
  background: var(--color-brand-50);
  box-shadow: var(--shadow-1);

}

.adaptive-tutor-option.is-selected {
  position: relative;
  padding-left: 38px;
  border-color: var(--color-brand-600);
  background: var(--color-brand-50);
  box-shadow: var(--shadow-1);

}

/* Left check mark on the selected option — pure CSS, no DOM change. */
.adaptive-tutor-option.is-selected::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 6px;
  height: 11px;
  border: solid var(--color-brand-600);
  border-width: 0 2px 2px 0;
  transform: translateY(-64%) rotate(45deg);
}

.adaptive-tutor-activity-controls textarea,
.adaptive-tutor-activity-controls input[type="text"],
.adaptive-tutor-activity-controls input:not([type]),
.adaptive-tutor-activity-controls select {
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border-default);
  border-radius: var(--radius-input);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: var(--text-md);
  line-height: 1.5;

}

.adaptive-tutor-activity-controls textarea { min-height: 96px; resize: vertical; 
}

.adaptive-activity-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);

}

.adaptive-activity-footer small { color: var(--color-text-tertiary); font-size: var(--text-xs); 
}

.adaptive-tutor-hint {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);

}

.adaptive-tutor-hint button {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--color-link);
  font-size: var(--text-sm);
  font-weight: 600;

}

.adaptive-tutor-hint p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;

}

.adaptive-activity-feedback {
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;

}

.adaptive-activity-feedback.is-correct { background: var(--color-success-bg); color: var(--color-success-text); 
}

.adaptive-activity-feedback.is-needs_revision { background: var(--color-warning-bg); color: var(--color-warning-text); 
}

.adaptive-activity-feedback.is-inconclusive { background: var(--color-info-bg); color: var(--color-info-text); 
}

.adaptive-activity-feedback.is-error { background: var(--color-danger-bg); color: var(--color-danger-text); 
}

.adaptive-tutor-activity-error { justify-items: center; gap: var(--space-2); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .adaptive-tutor-thinking-mark i { animation: none; background: var(--color-brand-50); }
}

/* Hover-revealed per-turn actions: copy and read-aloud. */
.tutor-chat-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity 0.15s ease; }
.adaptive-tutor-turn:hover .tutor-chat-actions,
.adaptive-tutor-turn:focus-within .tutor-chat-actions { opacity: 1; }
.tutor-chat-actions button { font-size: 12px; font-weight: 600; color: var(--color-link); background: var(--color-selected-bg); border: 0; border-radius: 4px; padding: 3px 8px; cursor: pointer; }

@media (hover: none) {
  .tutor-chat-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tutor-chat-actions { transition: none; }
}

.tutor-chat-scroll-pill {
  position: sticky;
  bottom: 84px;
  margin: -44px 16px 0 auto;
  display: block;
  width: fit-content;
  padding: 8px 14px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-soft, 8px);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-2, 0 4px 12px rgb(2 6 23 / 10%));
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  z-index: 2;
}
.tutor-chat-scroll-pill[hidden] { display: none; }

/* Send failure: a gentle warning card, not an alarm bar — faded danger wash,
   40%-alpha danger border, no heavy side stripe. */
.tutor-chat-error-card {
  margin: var(--space-3) 0 0;
  background: var(--color-danger-bg);
  border: 1px solid color-mix(in srgb, var(--color-danger-border) 40%, transparent);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-1);
}
.tutor-chat-error-card strong { display: block; font-size: 14px; font-weight: 600; color: var(--color-danger-text); }
.tutor-chat-error-card p { margin: 4px 0 10px; font-size: 13px; line-height: var(--leading-body); color: var(--color-text-secondary); }
.tutor-chat-error-card button {
  min-height: 32px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--color-danger-border) 55%, transparent);
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--color-danger-text);
  cursor: pointer;
}
.tutor-chat-error-card button:hover { background: color-mix(in srgb, var(--color-danger-border) 10%, transparent); }

/* ===================== Breakpoint corrections ===================== */

@media (max-width: 390px) {
.adaptive-lesson-block {
    padding: 8px 10px;
  }

.adaptive-tutor-shell,
  .adaptive-tutor-thread,
  .adaptive-tutor-thread-item,
  .adaptive-tutor-activity,
  .adaptive-tutor-composer { max-width: 100%; min-width: 0; }

.adaptive-tutor-composer { overflow-x: clip; }
}

@media (prefers-reduced-motion: reduce) {
.adaptive-tutor-thinking-steps span {
    animation: none;
    opacity: 0;
  }

.adaptive-tutor-thinking-steps span:first-child {
    opacity: 1;
  }

.adaptive-tutor-quick-reply,
  .adaptive-tutor-option,
  .adaptive-sentence-parts button,
  .adaptive-tutor-send,
  .adaptive-activity-submit { scroll-behavior: auto; transition: none; }

.adaptive-tutor-thinking,
  .adaptive-tutor-thinking-mark i { animation: none; }
}

@media (max-width: 900px) {
.student-workbench:has(.adaptive-tutor-shell) { padding: var(--space-4); }

.adaptive-tutor-shell { width: 100%; }

.adaptive-tutor-header { align-items: start; }
}

@media (max-width: 420px) {
.adaptive-tutor-session-time { display: none; }

.adaptive-tutor-thread { gap: 20px; }

.adaptive-tutor-turn { max-width: 92%; padding: 11px 13px; }

.adaptive-tutor-quick-replies { display: grid; }

.adaptive-tutor-quick-reply { width: 100%; text-align: left; }

.adaptive-tutor-option-grid,
  .adaptive-sentence-parts { grid-template-columns: minmax(0, 1fr); }

.adaptive-activity-footer { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
.adaptive-tutor-shell.is-new-chat .adaptive-tutor-thread { padding-bottom: 36px; }

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-quick-replies { grid-template-columns: 1fr; }

.adaptive-tutor-shell.is-new-chat .adaptive-tutor-quick-reply { min-height: 44px; }
}

@media (max-width: 720px) {

  .adaptive-tutor-body { grid-template-columns: minmax(0, 1fr); }
  /* Single column: drop the desktop's explicit two-column placement. */
  .adaptive-tutor-body > .adaptive-tutor-thread,
  .adaptive-tutor-body > .tutor-chat-error-card,
  .adaptive-tutor-body > .tutor-chat-scroll-pill,
  .adaptive-tutor-body > .tutor-chat-stepper,
  .adaptive-tutor-body > .tutor-chat-rail { grid-column: 1; grid-row: auto; }
  .tutor-chat-stepper { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--color-border-subtle); background: transparent; }
  .tutor-chat-stepper-label { font-family: "SF Mono", Menlo, monospace; font-size: 10px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-tertiary); font-weight: 600; white-space: nowrap; }
  .tutor-chat-stepper-seg { height: 4px; flex: 1; border-radius: var(--radius-round); background: var(--color-border-default); }
  .tutor-chat-stepper-seg.is-done { background: var(--color-green-500); }
  .tutor-chat-stepper-seg.is-current { background: var(--color-brand-600); }
  /* Full-map visibility: future segments read as hollow stations to visit,
     not as an invisible track — every segment is visible from beat one. */
  .tutor-chat-stepper-seg.is-todo { background: transparent; border: 1.5px solid var(--color-border-strong); }
  .tutor-chat-rail { display: none; }

.student-workbench:has(.adaptive-tutor-shell) { padding: var(--space-4); }

/* Keep the composer above the fixed bottom tabs structurally (the shell
   ends above the tabs), so sticky needs no offset and never rides up over
   the thread. Replaces the old sticky bottom: 68px, which pulled the
   capsule over the thread once the page no longer scrolls. The 69px base
   matches the navigation's measured height; its own padding already adds
   the safe-area inset, so this pad must not add a second copy. */
.app-shell:has(.adaptive-tutor-shell) .student-app-main { padding-bottom: calc(69px + env(safe-area-inset-bottom, 0px)); }

.adaptive-tutor-shell { padding: var(--space-4); }

.adaptive-tutor-session-time { display: none; }

.adaptive-tutor-turn { max-width: 90%; }

.adaptive-tutor-composer { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 8px max(8px, env(safe-area-inset-bottom, 0px)) 12px; }

.adaptive-tutor-send { width: auto; min-width: 76px; }

.student-workbench:has(.adaptive-tutor-shell) .adaptive-tutor-composer { bottom: 0; }

.adaptive-tutor-thread-item .adaptive-tutor-quick-replies,
  .adaptive-tutor-thread-item .adaptive-tutor-activity-holder { margin-left: 0; width: 100%; }

.adaptive-tutor-activity { padding: var(--space-4); }

.adaptive-activity-header { flex-direction: column; align-items: flex-start; gap: var(--space-2); }

.adaptive-tutor-activity > h3 { font-size: 16px; }

.adaptive-tutor-option { min-height: 50px; font-size: 15px; }
}


/* ==========================================================================
   Hero opening (is-hero-opening): a brand-new chat with no pending warm-up
   becomes one centered editorial column — Lexora, greeting, status line,
   suggestion chips, composer — replacing the scattered
   header / welcome / rail trio. Token-driven: light and dark both follow.
   ========================================================================== */

.adaptive-tutor-shell.is-hero-opening {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-content: stretch;
  gap: 0;
  min-height: calc(100vh - 64px - 120px);
}

/* Stage light behind Lexora — a quiet indigo aura, stronger on dark. */
.adaptive-tutor-shell.is-hero-opening::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(440px 320px at 50% 30%, var(--hero-opening-glow, rgb(79 70 229 / 7%)), transparent 72%);
  pointer-events: none;
}

[data-theme="dark"] .adaptive-tutor-shell.is-hero-opening {
  --hero-opening-glow: rgb(99 102 241 / 13%);
}

/* Dark conversation surfaces: the student bubble trades the light theme's
   paper-indigo tint for a translucent Indigo fill with a hairline border. */
[data-theme="dark"] .adaptive-tutor-turn.is-student {
  background: rgb(99 102 241 / 16%);
  border-color: rgb(129 140 248 / 30%);
  color: var(--color-text-primary);
}

/* Dark: the light paper tints above (amber badge, skeleton shimmer, highlight
   marks, activity hairline) switch to the dark semantic ramps — translucent
   fills at 12% alpha and ink-percentage borders, never paper hexes. */
[data-theme="dark"] .tutor-chat-warmup-item small {
  color: var(--color-warning-text);
  background-image: radial-gradient(circle 3px at 4px 50%, #fbbf24 99%, transparent 100%);
}
[data-theme="dark"] .adaptive-tutor-thinking-mark i {
  background: linear-gradient(90deg, rgb(99 102 241 / 16%) 22%, rgb(237 234 228 / 8%) 50%, rgb(99 102 241 / 16%) 78%);
}
[data-theme="dark"] .adaptive-vocabulary-source mark {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}
[data-theme="dark"] .adaptive-tutor-activity {
  border-color: rgb(129 140 248 / 30%);
}
/* Dark: brand-50 paper tints become translucent indigo fills. */
[data-theme="dark"] .adaptive-tutor-turn.is-lesson {
  background: rgb(99 102 241 / 10%);
}
[data-theme="dark"] .adaptive-tutor-option:hover:not(:disabled),
[data-theme="dark"] .adaptive-tutor-option:focus-visible,
[data-theme="dark"] .adaptive-tutor-option.is-selected,
[data-theme="dark"] .adaptive-sentence-parts button:hover:not(:disabled),
[data-theme="dark"] .adaptive-sentence-parts button:focus-visible,
[data-theme="dark"] .tutor-chat-warmup-item:hover,
[data-theme="dark"] .adaptive-tutor-quick-reply:hover:not(:disabled) {
  background: rgb(99 102 241 / 12%);
}
[data-theme="dark"] .adaptive-tutor-option.is-selected::before {
  border-color: var(--color-brand-300);
}
[data-theme="dark"] .tutor-chat-beat.is-current .tutor-chat-beat-dot { background: rgb(99 102 241 / 16%); }
[data-theme="dark"] .adaptive-tutor-thread-item .tutor-turn-avatar {
  background: rgb(99 102 241 / 14%);
  box-shadow: 0 0 0 4px rgb(99 102 241 / 8%);
}
[data-theme="dark"] .adaptive-tutor-hero-avatar::before {
  background: radial-gradient(circle, transparent 32%, rgb(99 102 241 / 20%) 58%, transparent 76%);
}
[data-theme="dark"] .adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply .icon {
  color: var(--color-brand-300);
}
[data-theme="dark"] .student-bottom-tab.active {
  background: rgb(99 102 241 / 18%);
  color: var(--color-brand-300);
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-body {
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: clamp(28px, 6vh, 72px) 0 4px;
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-thread {
  width: min(640px, 100%);
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-welcome {
  gap: 0;
  margin-bottom: 0;
  padding: 0;
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-welcome-mark {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgb(79 70 229 / 22%);
}

.adaptive-tutor-welcome-title {
  margin: 26px 0 0;
  color: var(--color-text-primary);
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 560;
  letter-spacing: -0.035em;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.adaptive-tutor-welcome-sub {
  max-width: 46ch;
  margin: 14px auto 0;
  color: var(--color-text-secondary);
  font-size: 15px;
  line-height: var(--leading-body);
}

.adaptive-tutor-hero-replies {
  justify-content: center;
  gap: 10px;
  max-width: none;
  margin-top: 30px;
}

/* Hero quick chips: card-style suggestions — surface, hairline border, card
   radius, rest-level shadow, brand icon on the left. Copy and data hooks
   unchanged. */
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  box-shadow: var(--shadow-1);
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply:hover:not(:disabled) {
  border-color: var(--color-brand-300);
  box-shadow: var(--shadow-2);
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply .icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--color-brand-600);
}

.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-composer {
  position: static;
  align-self: start;
  width: min(640px, 100%);
  margin: 8px auto clamp(64px, 13vh, 140px);
}

/* Lexora avatar halo: a faint brand-50 radial wash on the wrapper behind the
   mark (radial-gradient on the container — never a text clip). */
.adaptive-tutor-hero-avatar {
  position: relative;
  display: grid;
  place-items: center;
}

.adaptive-tutor-hero-avatar::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -36px;
  background: radial-gradient(circle, transparent 32%, var(--color-brand-50) 58%, transparent 76%);
  pointer-events: none;
}

.adaptive-tutor-hero-avatar > .tutor-avatar {
  position: relative;
  z-index: 1;
}

@media (max-width: 560px) {
  .adaptive-tutor-shell.is-new-chat .adaptive-tutor-quick-replies {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .adaptive-tutor-shell.is-hero-opening .adaptive-tutor-welcome-title {
    font-size: clamp(26px, 8vw, 32px);
  }
}

/* ==========================================================================
   Conversational refinement — quiet canvas, readable turns, honest motion.
   ========================================================================== */
.adaptive-tutor-shell {
  width: min(100%, 1040px);
  padding: 0 24px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.adaptive-tutor-body { grid-template-columns: minmax(0, 1fr) 208px; column-gap: 32px; }
.adaptive-tutor-header { min-height: 52px; padding: 12px 0; border-bottom-color: var(--color-border-subtle); }
.adaptive-tutor-header #adaptive-tutor-title { font-size: 16px; font-weight: 550; letter-spacing: -.015em; }
.adaptive-tutor-session-time { font-size: 12px; }
.adaptive-tutor-thread { gap: 32px; padding: 20px 0 28px; }
.adaptive-tutor-thread-item { gap: 12px; }
.adaptive-tutor-thread-item .tutor-turn-avatar { width: 28px; height: 28px; margin-top: 1px; border-radius: 8px; box-shadow: none; }
.adaptive-tutor-turn { max-width: 68ch; }
.adaptive-tutor-turn.is-tutor:not(.is-lesson) { max-width: 68ch; padding: 0; border: 0; background: transparent; }
.adaptive-tutor-turn.is-tutor:not(.is-lesson) .adaptive-tutor-turn-label { display: none; }
.adaptive-tutor-turn p { font-size: 16px; line-height: 1.75; }
.adaptive-tutor-turn.is-student {
  max-width: min(80%, 58ch);
  padding: 12px 16px;
  border: 0;
  border-radius: 16px 16px 4px 16px;
  background: var(--color-selected-bg);
  box-shadow: none;
}
.adaptive-tutor-turn.is-student p { line-height: 1.65; }
.adaptive-tutor-thread-item .adaptive-tutor-quick-replies { margin-left: 40px; }
.adaptive-tutor-quick-reply {
  min-height: 44px;
  padding: 9px 14px;
  border-color: var(--color-border-subtle);
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
  transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.adaptive-tutor-quick-reply:hover:not(:disabled) { border-color: var(--color-brand-300); background: var(--color-selected-bg); box-shadow: none; }
.adaptive-tutor-thread-item:has(.is-revealing) > .adaptive-tutor-quick-replies { opacity: .35; }
[data-tutor-turn-copy].is-revealing { cursor: text; }
[data-tutor-turn-copy].is-revealing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  border-radius: 1px;
  background: var(--color-brand-500);
  vertical-align: -.12em;
  animation: tutor-caret-blink .8s ease-in-out infinite;
}
@keyframes tutor-caret-blink { 0%, 100% { opacity: .2; } 50% { opacity: .9; } }

.tutor-chat-actions { gap: 2px; margin-top: 8px; }
.tutor-chat-actions button {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-tertiary);
}
.tutor-chat-actions button:hover { background: var(--color-bg-subtle); color: var(--color-text-primary); }
.tutor-chat-actions button .icon { width: 16px; height: 16px; }
.adaptive-tutor-fallback-note { max-width: 60ch; color: var(--color-text-tertiary); }

.adaptive-tutor-thinking {
  gap: 12px;
  width: min(100%, 760px);
  margin: 0 auto 4px;
  padding: 8px 0;
  justify-self: start;
}
.adaptive-tutor-thinking .tutor-avatar { width: 28px; height: 28px; border-radius: 8px; box-shadow: none; }
.adaptive-tutor-thinking-copy { display: grid; gap: 2px; }
.adaptive-tutor-thinking-copy strong { color: var(--color-text-secondary); font-size: 13px; font-weight: 500; }
.adaptive-tutor-thinking-mark {
  flex-direction: column;
  gap: 3px;
  width: 22px;
  margin-left: 2px;
  opacity: .7;
  animation: tutor-thinking-pulse 1.6s ease-in-out infinite;
}
.adaptive-tutor-thinking-mark i { height: 2px; border-radius: 1px; background: linear-gradient(90deg, var(--color-brand-400), var(--color-brand-200)); animation: none; }
.adaptive-tutor-thinking-steps { display: block; }
.adaptive-tutor-thinking-steps span { display: none; color: var(--color-text-tertiary); font-size: 12px; opacity: 1; animation: none; }
.adaptive-tutor-thinking-steps span:first-child { display: block; }
@keyframes tutor-thinking-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }

.adaptive-tutor-composer {
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: end;
  gap: 12px;
  max-width: 760px;
  margin: 12px auto 0;
  padding: 10px 10px 10px 16px;
  border-color: var(--color-border-default);
  border-radius: 16px;
  background: var(--color-bg-surface);
  box-shadow: 0 8px 28px rgb(15 23 42 / 6%);
}
.adaptive-tutor-composer:focus-within { border-color: var(--color-brand-500); box-shadow: 0 8px 28px rgb(15 23 42 / 6%), 0 0 0 3px var(--color-focus-ring); }
.adaptive-tutor-composer textarea { min-height: 44px; padding: 10px 0; font-size: 16px; line-height: 1.5; }
.adaptive-tutor-composer textarea::placeholder { color: var(--color-text-tertiary); opacity: 1; }
.adaptive-tutor-send {
  justify-content: center;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  box-shadow: none;
}
.adaptive-tutor-send .icon { width: 18px; height: 18px; transform: rotate(-90deg); }
.adaptive-tutor-send.is-stop { background: var(--color-brand-600); color: var(--color-text-inverse); cursor: pointer; }
.adaptive-tutor-send.is-stop .icon { transform: none; }
.adaptive-tutor-send:disabled { background: var(--color-bg-subtle); color: var(--color-text-tertiary); cursor: default; }
.adaptive-tutor-send:hover:not(:disabled) { box-shadow: none; }
.adaptive-tutor-composer textarea:disabled { cursor: wait; }
.tutor-char-count { padding-right: 52px; }

.tutor-chat-rail { padding: 4px 0; border: 0; border-radius: 0; background: transparent; }
.tutor-chat-rail-title { margin-bottom: 16px; font-family: var(--font-ui); font-size: 12px; letter-spacing: 0; text-transform: none; }
.tutor-chat-rail-suggestion { font-size: 12px; line-height: 1.7; }
.tutor-chat-warmup-item { border-color: var(--color-border-subtle); border-radius: 10px; box-shadow: none; font-weight: 500; }
.tutor-chat-warmup-item:hover { box-shadow: none; }
.tutor-chat-scroll-pill { border-radius: 10px; }

.adaptive-tutor-turn.is-lesson { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.adaptive-tutor-turn.is-lesson .adaptive-tutor-turn-label { margin-bottom: 12px; font-family: var(--font-ui); font-size: 12px; letter-spacing: 0; text-transform: none; }
.adaptive-lesson-block { gap: 18px; margin-top: 16px; padding: 20px; border-color: var(--color-border-subtle); border-radius: 14px; }
.adaptive-lesson-part strong { margin-bottom: 5px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.adaptive-lesson-part p { font-size: 15px; line-height: 1.7; }
.adaptive-tutor-activity { gap: 16px; padding: 24px; border-color: var(--color-border-subtle); border-radius: 16px; box-shadow: none; }
.adaptive-activity-header { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.adaptive-activity-type { padding: 0; background: transparent; color: var(--color-text-secondary); font-family: var(--font-ui); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.adaptive-activity-meta small,
.adaptive-activity-meta > i { display: none; }
.adaptive-tutor-activity > h3 { font-size: 18px; font-weight: 550; }
.adaptive-activity-submit { border-radius: 10px; font-weight: 500; box-shadow: none; }
.adaptive-tutor-option { border-width: 1px; border-radius: 10px; }
.adaptive-tutor-option:hover:not(:disabled),
.adaptive-tutor-option:focus-visible,
.adaptive-tutor-option.is-selected { box-shadow: none; }
.adaptive-activity-feedback { border-radius: 10px; }

.adaptive-tutor-shell.is-hero-opening::before { display: none; }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-body { padding: 24px 0 8px; }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-thread { width: min(720px, 100%); }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-welcome-mark { width: 54px; height: 54px; border-radius: 14px; background: var(--color-selected-bg); box-shadow: none; }
.adaptive-tutor-hero-avatar::before { display: none; }
.adaptive-tutor-welcome-title { margin-top: 22px; font-size: clamp(30px, 3.2vw, 38px); font-weight: 550; letter-spacing: -.04em; }
.adaptive-tutor-welcome-sub { margin-top: 12px; font-size: 14px; }
.adaptive-tutor-hero-replies { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 32px; }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply { min-height: 56px; padding: 12px 14px; border-color: var(--color-border-subtle); border-radius: 12px; background: transparent; box-shadow: none; }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-quick-reply:hover:not(:disabled) { border-color: var(--color-brand-300); box-shadow: none; }
.adaptive-tutor-shell.is-hero-opening .adaptive-tutor-composer { width: min(720px, 100%); margin: 12px auto 48px; }

[data-theme="dark"] .adaptive-tutor-turn.is-student { background: rgb(99 102 241 / 15%); border-color: transparent; }
[data-theme="dark"] .adaptive-tutor-composer { background: #16191d; box-shadow: none; }
[data-theme="dark"] .adaptive-tutor-composer:focus-within { box-shadow: 0 0 0 3px var(--color-focus-ring); }
[data-theme="dark"] .adaptive-tutor-thread-item .tutor-turn-avatar { box-shadow: none; }
[data-theme="dark"] .adaptive-tutor-turn.is-lesson { background: transparent; }
[data-theme="dark"] .adaptive-tutor-activity { border-color: var(--color-border-subtle); }

@media (hover: none) {
  .tutor-chat-actions button { width: 40px; min-height: 40px; }
}
@media (max-width: 720px) {
  .adaptive-tutor-shell { padding: 0 16px 12px; }
  .adaptive-tutor-body { grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .adaptive-tutor-thread { gap: 24px; padding: 16px 0 20px; }
  .adaptive-tutor-turn { max-width: 92%; }
  .adaptive-tutor-turn.is-student { max-width: 88%; }
  .adaptive-tutor-turn p { font-size: 16px; }
  .adaptive-tutor-thread-item .adaptive-tutor-quick-replies { margin-left: 0; }
  .adaptive-tutor-composer { grid-template-columns: minmax(0, 1fr) 40px; gap: 8px; margin-top: 4px; padding: 8px 8px 8px 12px; }
  .adaptive-tutor-send { width: 40px; min-width: 40px; }
  .adaptive-tutor-shell.is-hero-opening .adaptive-tutor-body { padding-top: 16px; }
  .adaptive-tutor-welcome-title { font-size: clamp(28px, 8vw, 34px); }
  .adaptive-tutor-hero-replies { grid-template-columns: 1fr; margin-top: 28px; }
  .adaptive-tutor-shell.is-hero-opening .adaptive-tutor-composer { margin-bottom: 28px; }
  .adaptive-tutor-activity { padding: 18px; }
  .adaptive-lesson-block { padding: 16px; }
}
@media (max-width: 420px) {
  .adaptive-tutor-quick-replies { display: grid; grid-template-columns: minmax(0, 1fr); }
  .adaptive-tutor-quick-reply { width: 100%; }
  .adaptive-tutor-turn { max-width: calc(100% - 40px); }
  .adaptive-tutor-turn.is-student { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  [data-tutor-turn-copy].is-revealing::after { display: none; animation: none; }
  .adaptive-tutor-thinking-mark,
  .adaptive-tutor-thinking-steps span { animation: none; }
  .adaptive-tutor-quick-reply { transition: none; }
}
