/* =====================================================================
 * ET+ AI Tutor — UX upgrade stylesheet (2026-05-16)
 *
 * Mobile-responsive + WCAG 2.1 AA accessibility polish + tutor-action
 * bar styling. Layered on top of the existing style.css; nothing here
 * overrides core layout outside its scoped selectors.
 *
 * Sections:
 *   1. Tutor action bar mobile breakpoint
 *   2. Focus rings (a11y)
 *   3. prefers-reduced-motion
 *   4. prefers-contrast: more
 *   5. data-a11y-large-text + data-a11y-reduce-motion (preferences)
 *   6. Dashboard CTA mobile reflow
 *   7. Drafts panel responsive
 * ===================================================================== */

/* 1. Tutor action bar — wrap chips below 600px so they don't push off-screen. */
@media (max-width: 600px) {
  #etp-tutor-actions {
    flex-direction: column;
    align-items: stretch !important;
    gap: 6px !important;
  }
  #etp-tutor-actions button { width: 100%; }
  #etp-tutor-actions span { text-align: center; }
}

/* 2. Visible focus ring on every interactive ET+ UX element. Replaces the
 *    UA default outline with a brand-coloured ring that meets WCAG 2.4.7
 *    (3:1 contrast against the surface, 2px thick). */
#etp-tutor-actions button:focus-visible,
[data-etp-quota-history] :focus-visible,
[data-etp-drafts] :focus-visible,
[data-etp-preferences-form] :focus-visible,
[data-etp-today-cta] :focus-visible,
#etp-ux-toast:focus-visible {
  outline: 2px solid #A5B4FC !important;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Tutor-wide interaction affordance. Several late-mounted controls (session
 * drawer actions, Teaching Assistant scaffolds, attachment/voice buttons)
 * use inline base styles and previously had no hover state of their own.
 * Scope this ring to the Tutor stage so every interactive control has a
 * consistent pointer affordance without changing other standalone pages. */
body[data-etp-stage] button:not(:disabled):hover,
body[data-etp-stage] a[href]:hover,
body[data-etp-stage] select:hover,
body[data-etp-stage] input:not([type="hidden"]):hover,
body[data-etp-stage] textarea:hover {
  box-shadow: 0 0 0 1px rgba(165, 180, 252, 0.72);
}

/* 3. Honour the OS reduced-motion preference globally — no animations,
 *    no transitions, no decorative orbs. Critical for vestibular-disorder
 *    users (WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  #etp-ux-toast { transition: none !important; }
}

/* 4. High-contrast mode — bumps every faint surface to a pure-black /
 *    pure-white border. Triggers on Windows High Contrast + on user-pref
 *    via prefers-contrast: more. */
@media (prefers-contrast: more) {
  [data-etp-quota-history] table td,
  [data-etp-drafts] li,
  [data-etp-preferences-form] select,
  [data-etp-preferences-form] input[type="checkbox"] {
    border-color: #fff !important;
  }
  [data-etp-today-cta] > div {
    border-color: #fff !important;
    background: #000 !important;
  }
}

/* 5. data-a11y-* — driven by Preferences.save (Item 12 → 9). The user's
 *    saved preferences set these attributes on <html> so the CSS rules
 *    apply across every page automatically. */
html[data-a11y-large-text="true"] body {
  font-size: 18px;
  line-height: 1.65;
}
html[data-a11y-large-text="true"] .sidebar-nav__item,
html[data-a11y-large-text="true"] .btn,
html[data-a11y-large-text="true"] input,
html[data-a11y-large-text="true"] select {
  font-size: 16px !important;
}

html[data-a11y-reduce-motion="true"] *,
html[data-a11y-reduce-motion="true"] *::before,
html[data-a11y-reduce-motion="true"] *::after {
  animation: none !important;
  transition: none !important;
}

/* 6. "What's teaching today?" CTA — mobile: chips wrap, hero pads tighter. */
@media (max-width: 640px) {
  [data-etp-today-cta] > div {
    padding: 14px !important;
  }
  [data-etp-today-cta] h2 { font-size: 17px !important; }
}

/* 7. Drafts panel — drop the per-row Open + Share buttons under the title
 *    on narrow screens so the title gets its full width. */
@media (max-width: 560px) {
  [data-etp-drafts] li {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px !important;
  }
  [data-etp-drafts] li > div:last-child {
    justify-content: flex-end;
  }
}

/* 8. Toast — ensure it stays readable on tiny screens. */
@media (max-width: 380px) {
  #etp-ux-toast {
    left: 12px !important;
    right: 12px !important;
    transform: none !important;
    text-align: center;
  }
}


/* ==========================================================================
   9. Theme picker — light + dark + high-contrast (Item 9, 2026-05-18)
   ==========================================================================

   Default theme is the existing dark (no data-etp-theme attr / or
   data-etp-theme="dark" / "auto"). Light + high-contrast override the
   small set of CSS variables that drive bg + surface + text + border.
   Accent + grade-band colours stay constant across themes so brand
   recognition is preserved.
*/

html[data-etp-theme="light"] {
  --bg:           #f4fafc;
  --bg2:          #ebf4f7;
  --bg3:          #e0eef2;
  --surface:      #ffffff;
  --surface2:     #f8fcfd;
  --surface3:     #eef6f9;
  --border:       rgba(0, 91, 116, 0.10);
  --border2:      rgba(0, 91, 116, 0.18);
  --border3:      rgba(0, 91, 116, 0.28);
  --text:         #0a2230;
  --text2:        #2d5a6c;
  --text3:        #6b8a99;
  --text-inverse: #ffffff;
  --shadow-sm:    0 1px 3px rgba(0, 60, 80, 0.10);
  --shadow:       0 4px 14px rgba(0, 60, 80, 0.12);
  --shadow-lg:    0 8px 32px rgba(0, 60, 80, 0.16);
  --shadow-xl:    0 16px 48px rgba(0, 60, 80, 0.20);
}

html[data-etp-theme="high-contrast"] {
  --bg:           #000000;
  --bg2:          #000000;
  --bg3:          #0a0a0a;
  --surface:      #0a0a0a;
  --surface2:     #141414;
  --surface3:     #1e1e1e;
  --border:       #ffffff;
  --border2:      #ffffff;
  --border3:      #ffe100;
  --text:         #ffffff;
  --text2:        #ffffff;
  --text3:        #f5f5f5;
  --text-inverse: #000000;
  --accent:       #ffe100;
  --info:         #ffffff;
  --success:      #00ff00;
  --error:        #ff5555;
  --warning:      #ffe100;
  --shadow-sm:    none;
  --shadow:       none;
  --shadow-lg:    none;
  --shadow-xl:    none;
}

/* High-contrast: stronger focus rings everywhere. */
html[data-etp-theme="high-contrast"] :focus-visible {
  outline: 3px solid #ffe100 !important;
  outline-offset: 2px !important;
}

/* Picker widget — three pill buttons mounted into the chrome. */
.etp-theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
}
.etp-theme-picker button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--text2);
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background var(--duration, 200ms) var(--ease, ease),
              color var(--duration, 200ms) var(--ease, ease);
}
.etp-theme-picker button:hover {
  color: var(--text);
  background: rgba(0, 229, 255, 0.06);
}
.etp-theme-picker button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
}
html[data-etp-theme="light"] .etp-theme-picker {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.10);
}
html[data-etp-theme="high-contrast"] .etp-theme-picker {
  background: #000;
  border-color: #fff;
}


/* ===================================================================
   10. Conversation typography + typing-bob (Wave-B Items 2 + 3)
   ===================================================================

   Goals:
     * Tutor and student messages instantly distinguishable by shape +
       alignment (left-bar = speaker, right-bubble = me).
     * Assistant replies prefer airy 1.65 leading + soft italic on the
       <em>/<strong> emphasis so they read like a person speaking,
       not a database emitting JSON.
     * Typing indicator dots bob gently (not the harsh blink most
       chat UIs use) — feels like the tutor is "thinking."
*/

/* Tutor reply card — frosted, left-aligned, primary-coloured left-bar. */
.message--tutor {
  align-self: flex-start;
  max-width: 86%;
  margin: 8px 12px;
  padding: 12px 16px 14px 18px;
  background: rgba(13, 43, 58, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border, rgba(0, 229, 255, 0.10));
  border-left: 3px solid var(--accent, #00E5FF);
  border-radius: 4px 14px 14px 14px;
  box-shadow: var(--shadow-sm);
}
.message--tutor .message__content {
  color: var(--text, #e8f4fd);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: 0.005em;
}
.message--tutor .message__content em,
.message--tutor .message__content strong {
  font-style: italic;
  font-weight: 600;
  color: var(--accent, #00E5FF);
}
.message--tutor .message__content strong {
  font-style: normal;
}
.message--tutor .message__content p + p {
  margin-top: 0.75em;
}
.message--tutor .message__content code {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  background: rgba(0, 229, 255, 0.07);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
.message--tutor .message__content pre {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.message--tutor .message__content pre code {
  background: transparent;
  padding: 0;
}

/* Student message — right-aligned translucent bubble. */
.message--student {
  align-self: flex-end;
  max-width: 80%;
  margin: 8px 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg,
              rgba(124, 106, 250, 0.18),
              rgba(99, 102, 241, 0.10));
  border: 1px solid rgba(124, 106, 250, 0.30);
  border-radius: 14px 4px 14px 14px;
  color: var(--text, #e8f4fd);
  font-size: 15px;
  line-height: 1.55;
}

/* Both speaker types get a tiny timestamp underneath. */
.message__time {
  font-size: 10px;
  color: var(--text3, #5c99b3);
  margin-top: 4px;
  letter-spacing: 0.03em;
}

/* Item 3 — typing indicator with soft bob (not the blink that most
   chat UIs ship). The visual difference is small but felt. */
#typing-indicator,
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(13, 43, 58, 0.45);
  border: 1px solid var(--border, rgba(0, 229, 255, 0.10));
  margin: 8px 12px;
  align-self: flex-start;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #00E5FF);
  animation: etp-typing-bob 0.9s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes etp-typing-bob {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .typing-dot { animation: none; opacity: 0.7; }
  .etp-face .etp-mouth { transition: none !important; }
  .etp-face .etp-face-eyes { transition: none !important; }
}

/* Item 1 avatar — sit at the top of the tutor header. */
[data-etp-avatar] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-right: 12px;
}

/* High-contrast theme — flatten avatar gradient, lose backdrop blur. */
html[data-etp-theme="high-contrast"] .message--tutor {
  background: #000;
  border-left-color: #fff;
  border-left-width: 4px;
}
html[data-etp-theme="high-contrast"] .message--tutor .message__content em,
html[data-etp-theme="high-contrast"] .message--tutor .message__content strong {
  color: #ffe100;
}

html[data-etp-theme="light"] .message--tutor {
  background: #ffffff;
  border-color: rgba(0, 91, 116, 0.10);
  border-left-color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 60, 80, 0.08);
}
html[data-etp-theme="light"] .message--student {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.20);
}


/* ===================================================================
   11. Wave-C Item 11 — Material restraint theme ("instructor's office")
   ===================================================================
   Picked by setting data-etp-theme="material" on <html>. Calm + soft;
   no glow. Designed for the "looks like a colleague's tablet" feel.
*/

html[data-etp-theme="material"] {
  --bg:           #f6f4ee;       /* warm off-white */
  --bg2:          #f1eee5;
  --bg3:          #ebe7dc;
  --surface:      #ffffff;
  --surface2:     #fbf9f4;
  --surface3:     #f3f1ea;
  --border:       rgba(74, 60, 41, 0.08);
  --border2:      rgba(74, 60, 41, 0.16);
  --border3:      rgba(74, 60, 41, 0.26);
  --text:         #2a241a;
  --text2:        #574a3a;
  --text3:        #8a7e6c;
  --text-inverse: #ffffff;
  --accent:       var(--tenant-accent, #6b4ea8);  /* tenant brand if set */
  --primary-band: var(--accent);
  --shadow-sm:    0 1px 2px rgba(74, 60, 41, 0.06);
  --shadow:      0 4px 12px rgba(74, 60, 41, 0.08);
  --shadow-lg:   0 8px 28px rgba(74, 60, 41, 0.10);
}

html[data-etp-theme="material"] .message--tutor {
  background: #ffffff;
  backdrop-filter: none;
  border: 1px solid var(--border, rgba(74,60,41,0.10));
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-sm);
}
html[data-etp-theme="material"] .message--tutor .message__content em,
html[data-etp-theme="material"] .message--tutor .message__content strong {
  color: var(--accent);
}
html[data-etp-theme="material"] .message--student {
  background: rgba(107, 78, 168, 0.06);
  border-color: rgba(107, 78, 168, 0.16);
}
html[data-etp-theme="material"] #typing-indicator {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--border, rgba(74,60,41,0.10));
}

/* ===================================================================
   12. Wave-C Item 12 — Margin notes pattern
   ===================================================================
   The tutor wraps misconception / worked-example callouts inside
   <aside class="margin-note"> tags (or <aside data-note="...">).
   Render them in the left margin at >= 1100px viewport.
*/

.message--tutor { position: relative; }
.message--tutor aside.margin-note,
.message--tutor [data-note] {
  display: block;
  border-left: 2px solid var(--accent, #00E5FF);
  background: rgba(0, 229, 255, 0.05);
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 13px;
  font-style: italic;
  color: var(--text2);
  border-radius: 0 6px 6px 0;
}
.message--tutor aside.margin-note::before,
.message--tutor [data-note]::before {
  content: attr(data-note-label);
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 8px;
  opacity: 0.8;
}

@media (min-width: 1100px) {
  .message--tutor.has-margin-notes {
    margin-left: 18%;
    max-width: 70%;
  }
  .message--tutor aside.margin-note,
  .message--tutor [data-note] {
    position: absolute;
    left: -19%;
    width: 16%;
    margin: 0;
    top: 8px;
    background: transparent;
    border-left: 2px solid var(--accent);
    border-radius: 0;
  }
}

/* ===================================================================
   13. Wave-C Item 13 — Animated entry/exit for assistant messages
   ===================================================================
*/

.message--tutor {
  animation: etp-msg-enter 0.35s ease-out both;
}
@keyframes etp-msg-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message--student {
  animation: etp-msg-student-enter 0.25s ease-out both;
}
@keyframes etp-msg-student-enter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .message--tutor, .message--student { animation: none; }
}

/* Tutor control strip: keep selectors compact so the response area owns the
   remaining viewport height. Horizontal scrolling is intentional on laptop
   widths; narrow touch layouts wrap into a compact two-column grid below. */
.tutor-controls {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.tutor-controls .form-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: 38px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: var(--text-sm);
}
.tutor-controls #grade-select { width: 150px !important; }
.tutor-controls #subject-select { width: 155px !important; }
.tutor-controls #language-select { width: 125px !important; }
.tutor-controls #standard-select { width: 145px !important; }
.tutor-controls #accreditation-select { width: 150px !important; }
.tutor-controls #lab-select { width: 145px !important; }
.tutor-controls #mode-select { width: 160px !important; }
.tutor-controls #difficulty-select { width: 125px; margin-right: 0 !important; }
.tutor-controls #theme-select { width: 125px; margin-right: 0 !important; }
.tutor-controls > div[style*="flex:1"] { display: none; }
.tutor-controls [data-etp-quota-hud] { flex: 0 0 auto; }
.tutor-layout,
.tutor-messages { min-height: 0; }
.tutor-header { padding: 8px 16px; }
.tutor-header #tutor-avatar {
  --etp-char-width: 72px;
  --etp-char-height: 94px;
}

@media (max-width: 1100px) {
  .tutor-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px 12px;
    overflow-x: hidden;
  }
  .tutor-controls .form-select,
  .tutor-controls #standard-select,
  .tutor-controls #accreditation-select,
  .tutor-controls #lab-select,
  .tutor-controls #mode-select {
    width: 100% !important;
    min-width: 0;
    max-width: none;
  }
  .tutor-controls [data-etp-quota-hud],
  .tutor-controls [data-etp-stop-btn],
  .tutor-controls a.btn { justify-self: stretch; }
}

@media (max-width: 620px) {
  .tutor-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tutor-header #tutor-avatar {
    --etp-char-width: 52px;
    --etp-char-height: 68px;
  }
}

/* ===================================================================
   14. Wave-C Item 14 — Mobile-first tutor.html (bottom-anchored input,
       full-width avatar header, swipe-up modes drawer)
   ===================================================================
*/

@media (max-width: 760px) {
  html,
  body[data-etp-stage],
  .tutor-layout {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  /* Push the input area to the bottom edge of the viewport. */
  .tutor-input,
  .tutor-input,
  footer.tutor-input {
    position: sticky;
    bottom: 0;
    z-index: 25;
    background: var(--bg2, #071a22);
    border-top: 1px solid var(--border, rgba(0,229,255,0.10));
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(0, 20, 30, 0.4);
  }
  /* Compact avatar header — single row, no wrap. */
  .tutor-header {
    flex-wrap: wrap;
    padding: 12px;
    gap: 8px;
  }
  .tutor-header__info h2 { font-size: 18px; }
  /* Smaller messages container so input never overlaps */
  .tutor-messages {
    padding-bottom: 24px;
  }
  /* Hide the in-header decorative elements that crowd small screens. */
  .tutor-controls .btn--ghost,
  .tutor-controls a.btn { font-size: 12px; padding: 6px 8px; }
  /* Mode picker compacts to icons only. */
  #mode-select {
    font-size: 12px;
    max-width: 130px;
  }
  /* Tap targets at least 44px high (WCAG AAA + iOS HIG). */
  .btn, .btn--ghost, button[data-etp-stop-btn] {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  #etp-tutor-whiteboard-frame {
    width: 100vw !important;
    max-width: 100vw !important;
    border-left: 0 !important;
  }
}

/* Swipe-up modes drawer (Item 14) — opens on swipe gesture from
   the bottom 60px of the screen on mobile. Implemented as a CSS
   transform; JS wires the swipe detector in etp-humanize.js. */
.etp-modes-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg2, #071a22);
  border-top: 1px solid var(--border3);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}
.etp-modes-drawer.open { transform: translateY(0); }
.etp-modes-drawer__handle {
  width: 48px; height: 4px; border-radius: 2px;
  background: var(--text3); opacity: 0.4; margin: 0 auto 14px;
}
.etp-modes-drawer h3 {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text3); margin: 0 0 12px;
}
.etp-modes-drawer__list { display: flex; flex-direction: column; gap: 6px; }
.etp-modes-drawer__list button {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border2);
  color: var(--text); font-size: 14px; cursor: pointer;
}

/* ===================================================================
   15. Wave-C Item 15 — "Hand-written" feel for KaTeX maths replies
   ===================================================================
   When the parent .message--tutor carries `data-handwritten="true"`,
   apply a subtle SVG displacement filter to .katex elements so the
   typography looks lightly drawn.

   The SVG filter is injected inline near body-start by etp-humanize.js
   under the id `etp-handwritten-filter`.
*/

.message--tutor[data-handwritten="true"] .katex,
.message--tutor[data-handwritten="true"] .katex-display {
  filter: url(#etp-handwritten-filter);
  font-family: 'KaTeX_Main', Georgia, serif;
}

/* ===================================================================
   16. 2026-06-05 docx Issue 3 fix — STT interim hint span
   ===================================================================
   Lives inside .tutor-input row (between the attach buttons and the
   #tutor-input-field textarea). Populated by tutor-ui.js when
   SpeechRecognition emits non-final results so users see live partial
   recognition without polluting the committed input value.
   Hidden when empty.
*/
.tutor-stt-interim {
  display: block;
  font: italic 12px / 1.3 "DM Sans", system-ui, sans-serif;
  color: rgba(200, 215, 230, 0.55);
  padding: 2px 8px 0;
  min-height: 0;
  pointer-events: none;
}
.tutor-stt-interim:empty {
  display: none;
}

/* ============================================================
   RTL LAYOUT — Arabic (dir="rtl") tutor-page mirroring.
   Activated by multilingual.js setLocale() which sets
   document.documentElement.dir = 'rtl' + lang = 'ar'.
   Flex containers (.tutor-header, .tutor-header__left,
   .tutor-messages, .tutor-input) auto-reverse under dir=rtl;
   these rules mirror the PHYSICAL left/right props (accent
   borders, corner radii, padding, avatar margin, margin-note
   rail) that do NOT auto-flip — so Arabic renders RTL without
   breaking the chat layout. Code/pre/maths stay LTR.
   Scoped to ET+ AI Tutor chat surfaces only.
   ============================================================ */
html[dir="rtl"] .tutor-messages,
html[dir="rtl"] .message__content { text-align: right; }

/* Tutor reply card — accent bar + sharp corner move to the right edge. */
html[dir="rtl"] .message--tutor {
  border-left: 1px solid var(--border, rgba(0, 229, 255, 0.10));
  border-right: 3px solid var(--accent, #00E5FF);
  border-radius: 14px 4px 14px 14px;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
  padding: 12px 18px 14px 16px;
}

/* Student bubble — mirror its sharp corner to the left edge. */
html[dir="rtl"] .message--student {
  border-radius: 4px 14px 14px 14px;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 14px;
  text-align: right;
}

/* Header avatar flips to the inline-end (left) side. */
html[dir="rtl"] [data-etp-avatar] { margin-right: 0; margin-left: 12px; }

/* Desktop margin-note rail flips to the right of the bubble. */
html[dir="rtl"] .message--tutor.has-margin-notes { margin-left: 0; margin-right: 18%; }
html[dir="rtl"] .message--tutor aside.margin-note,
html[dir="rtl"] .message--tutor [data-note] {
  left: auto;
  right: -19%;
  border-left: none;
  border-right: 2px solid var(--accent, #00E5FF);
}
html[dir="rtl"] .message--tutor aside.margin-note::before,
html[dir="rtl"] .message--tutor [data-note]::before {
  margin-right: 0;
  margin-left: 8px;
}

/* Code, pre, and KaTeX maths always read left-to-right. */
html[dir="rtl"] .message__content pre,
html[dir="rtl"] .message__content code,
html[dir="rtl"] .katex,
html[dir="rtl"] .katex-display {
  direction: ltr;
  text-align: left;
  unicode-bidi: embed;
}
