/* Experiment: two visible, continuous histories, with one anchored composer. */
#practice #interaction.unified-chat #chat-box.has-whiteboard {
  display: grid !important;
  grid-template-columns: minmax(0, calc(var(--conversation-share, 50%) - 4px)) 8px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: 420px;
  max-height: none;
}
#practice #conversation-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}
#practice #conversation-pane #chat-history {
  flex: 1 1 0;
  min-height: 120px;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
#practice #conversation-pane #practice-form { flex: none; min-width: 0; }
#practice #conversation-pane .composer-input-shell { width: 100%; min-width: 0; }
#practice #interaction.unified-chat #chat-box.has-whiteboard #answer {
  height: 100px;
  min-height: 100px;
  max-height: 180px;
}
#practice #conversation-pane .composer-support-row { flex-wrap: wrap; gap: 6px; }
#practice #conversation-pane .composer-extra-menus { margin-inline-start: auto; }
#practice #conversation-pane .understand-actions { flex-wrap: wrap; }
#practice #conversation-pane .chat-starter-actions { flex-wrap: wrap; }
#practice #conversation-pane .chat-message { max-width: 88%; }
#whiteboard-divider { background: #8da5c566; cursor: col-resize; touch-action: none; position: relative; }
#whiteboard-divider::after { content: ''; position: absolute; top: 45%; left: 3px; width: 2px; height: 36px; border-radius: 2px; background: #52657d; }
#whiteboard-divider:focus-visible { outline: 2px solid #005bea; outline-offset: -2px; }
#whiteboard-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; color: #082a50; }
#whiteboard-pane h2 { flex: none; font: 600 16px/1.4 system-ui, sans-serif; margin: 0; padding: 12px 18px; border-bottom: 2px solid #ff907e; color: #082a50; }
#whiteboard-history { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 18px; }
#whiteboard-cards { list-style: none; padding: 0; margin: 0; }
#whiteboard-cards .whiteboard-card { margin: 0 0 22px; padding: 16px 0 22px; border-bottom: 1px solid #d5dfeb; overflow-wrap: anywhere; }
#whiteboard-cards .whiteboard-example { font: 500 clamp(20px, 2.2vw, 32px)/1.5 system-ui, sans-serif; color: #082a50; white-space: pre-wrap; margin: 0 0 12px; }
#whiteboard-cards .whiteboard-form { font: 400 15px/1.6 system-ui, sans-serif; color: #314d6b; margin: 0; white-space: pre-wrap; }
#whiteboard-cards p.whiteboard-explanation { font: 400 18px/1.65 system-ui, sans-serif; color: inherit; white-space: pre-wrap; margin: 0; }
#whiteboard-pane .whiteboard-empty { color: #52657d; font: 400 14px/1.6 system-ui, sans-serif; }
#practice #chat-box.has-whiteboard #voice-options-panel { max-width: min(560px, calc(100vw - 32px)); }
/* Keep both panes on phones too: a scrollable workspace, never tabs. */
@media (max-width: 700px) {
  #practice #interaction.unified-chat #chat-box.has-whiteboard { grid-template-columns: minmax(260px, 1fr) 8px minmax(260px, 1fr); overflow-x: auto; }
  #whiteboard-divider { cursor: default; }
  #practice #conversation-pane .chat-empty-state { padding: 8px; }
}
/* Override legacy chat-history minimums so the composer and supports never clip. */
#practice #interaction.unified-chat #chat-box.has-whiteboard #conversation-pane #chat-history {
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  flex: 1 1 0 !important;
}
#practice #interaction.unified-chat #chat-box.has-whiteboard { padding: 0 !important; }
#practice #conversation-pane #understand-help:has(#understand-status:empty):has(#understand-reply[hidden]) { display: none; }
html[data-theme='dark'] #whiteboard-pane { background: #111e2e; color: #edf3ff; }
html[data-theme='dark'] #whiteboard-pane h2 { color: #edf3ff; border-bottom-color: #ff907e; }
html[data-theme='dark'] #whiteboard-cards .whiteboard-card { border-bottom-color: #52657d; }
html[data-theme='dark'] #whiteboard-cards .whiteboard-example { color: #edf3ff; }
html[data-theme='dark'] #whiteboard-cards .whiteboard-form,
html[data-theme='dark'] #whiteboard-pane .whiteboard-empty { color: #c5d3e6; }
html[data-theme='dark'] #whiteboard-divider { background: #8da5c555; }
html[data-theme='dark'] #whiteboard-divider::after { background: #a6c7ff; }
/* Adjust the message/composer boundary without moving the whiteboard. */
#practice #conversation-pane #composer-divider {
  flex: 0 0 12px;
  position: relative;
  cursor: row-resize;
  touch-action: none;
  margin: 0 0 4px;
  border-top: 1px solid #8da5c5;
}
#composer-divider::after {
  content: '';
  position: absolute;
  width: 42px;
  height: 3px;
  top: 4px;
  left: calc(50% - 21px);
  border-radius: 2px;
  background: #52657d;
}
#composer-divider:hover::after { background: var(--blue, #005bea); }
#composer-divider:focus-visible { outline: 2px solid var(--blue, #005bea); outline-offset: 1px; }
#practice #interaction.unified-chat #chat-box.has-whiteboard #answer {
  height: var(--composer-height, 100px) !important;
  min-height: 72px !important;
  max-height: none !important;
}
#practice #conversation-pane #chat-history { margin-bottom: 0; border-bottom: 0; }
#practice #toggle-whiteboard {
  flex: none;
  font: inherit;
  font-size: 13px;
  min-height: 40px;
  padding: 8px 10px;
  color: inherit;
  border: 1px solid #52657d;
  background: #edf3fc;
  border-radius: 10px;
}
#practice #interaction.unified-chat #chat-box.has-whiteboard.whiteboard-hidden {
  grid-template-columns: minmax(0, 1fr) !important;
}
#whiteboard-pane[hidden], #whiteboard-divider[hidden] { display: none !important; }
html[data-theme='dark'] #composer-divider::after { background: #a6c7ff; }
html[data-theme='dark'] #practice #toggle-whiteboard { background: #223851; border-color: #8da5c5; }

#practice #toggle-whiteboard { display: inline-flex; align-items: center; gap: 6px; }
#toggle-whiteboard svg { flex: none; color: var(--blue, #005bea); }
#toggle-whiteboard .whiteboard-icon-arrow { stroke: var(--coral, #ff907e); }

/* New writing reveals smoothly, without a cursor or changing the card's size. */
#whiteboard-cards .whiteboard-reveal { display: grid; }
.whiteboard-reserve, .whiteboard-ink { grid-area: 1 / 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.whiteboard-reserve { visibility: hidden; }
#whiteboard-cards .whiteboard-writing .whiteboard-ink { text-shadow: 0 0 12px rgb(255 144 126 / 22%); }
@media (prefers-reduced-motion: reduce) {
  #whiteboard-cards .whiteboard-writing .whiteboard-ink { text-shadow: none; }
}
/* Speaking stays in the same left-hand thread; keep the board's layout intact. */
#practice #interaction.unified-chat.talk-mode #chat-box.has-whiteboard { display: grid !important; }

/* The whole lower pane travels with its divider; only the draft gains height. */
#practice #conversation-pane #composer-section {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 0;
  max-height: calc(100% - 118px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
#practice #conversation-pane #composer-section #practice-form {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: 6px;
  margin: 0;
}
#practice #conversation-pane #composer-section #practice-form > * { flex-shrink: 0; }
#practice #conversation-pane #composer-section #practice-form::after { display: none; }
#practice #conversation-pane #composer-section :is(.composer-support-row, #understand-help, #feedback, #practice-status, #practice-error) { margin: 0; }
#practice #conversation-pane #composer-section :is(#practice-status, #practice-error):empty { display: none; }
#practice #conversation-pane #composer-section .composer-input-shell { flex: none; }
#practice #conversation-pane #composer-section #answer { display: block; margin: 0; }

/* Board visibility belongs to the workspace, leaving the global toolbar compact. */
#whiteboard-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 10px;
  border-bottom: 2px solid #ff907e;
}
#whiteboard-header h2 { min-width: 0; border: 0; padding: 8px; }
#practice #whiteboard-header #toggle-whiteboard { flex-shrink: 0; }
#whiteboard-restore { display: flex; flex: none; justify-content: flex-end; padding-bottom: 6px; }
#whiteboard-restore[hidden] { display: none; }
#practice .unified-chat .composer-toolbar { gap: 6px; }
#practice .unified-chat .composer-toolbar > .practice-header-tools { gap: 10px; }

/* Keep occasional teacher/report help in the footer, outside the composer. */
#practice #chat-panel .chat-footer-tools {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
}
#practice .chat-footer-tools #feedback {
  flex: 0 1 auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  animation: none;
}
#practice .chat-footer-tools #reply-help { margin: 0; }
#practice .chat-footer-tools #reply-help > summary { min-height: 40px; padding-block: 8px; font-size: 13px; }
#practice .chat-footer-tools #feedback:has(#reply-help[open]) { flex-basis: 100%; }

/* Subject visuals retain their layout and never execute model-provided markup. */
#whiteboard-cards .whiteboard-visual {
  margin: 0;
  padding: 12px;
  white-space: pre;
  overflow-x: auto;
  font: 400 15px/1.7 ui-monospace, monospace;
  color: inherit;
  background: color-mix(in srgb, var(--blue, #005bea) 5%, transparent);
  border-inline-start: 3px solid #ff907e;
  border-radius: 6px;
}
#whiteboard-cards .whiteboard-math { font-size: 20px; }

/* Scalable, locally drawn diagrams share the board theme. */
#whiteboard-cards .whiteboard-figure { margin: 0; color: var(--ink); }
#whiteboard-cards .whiteboard-figure > figcaption { font: 600 17px/1.5 system-ui, sans-serif; margin-bottom: 8px; }
#whiteboard-cards .whiteboard-drawing { display: block; width: 100%; height: auto; max-height: none; font-family: system-ui, sans-serif; color: var(--ink); }
#whiteboard-cards .whiteboard-figure > details { margin-top: 6px; font: 400 13px/1.5 system-ui, sans-serif; }
#whiteboard-cards .whiteboard-figure > details > summary { min-height: 32px; padding-block: 6px; cursor: pointer; }


/* Draw outlines first, add color, then reveal labels without a cursor. */
#whiteboard-cards .board-drawing-new .board-pen-stroke {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  fill-opacity: 0;
  animation: board-outline 650ms ease both, board-ink 240ms ease both;
  animation-delay: var(--draw-delay), calc(var(--draw-delay) + 500ms);
}
#whiteboard-cards .board-drawing-new .board-pen-label {
  animation: board-label 450ms steps(14, end) both;
  animation-delay: var(--draw-delay);
}
@keyframes board-outline { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes board-ink { from { fill-opacity: 0; } to { fill-opacity: var(--draw-fill, 1); } }
@keyframes board-label { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  #whiteboard-cards .board-drawing-new .board-pen-stroke { animation: none; stroke-dashoffset: 0; fill-opacity: var(--draw-fill, 1); }
  #whiteboard-cards .board-drawing-new .board-pen-label { animation: none; clip-path: none; }
}

#whiteboard-cards .whiteboard-visual-issue { border-inline-start: 3px solid #e96553; padding-inline-start: 12px; color: var(--ink); font: 400 15px/1.6 system-ui, sans-serif; }

/* Enlarge the whole diagram with Aa, preserving geometry and label placement. */
#whiteboard-cards .whiteboard-figure { max-width: 100%; overflow-x: auto; }
#whiteboard-cards .whiteboard-drawing { width: calc(100% * var(--elvi-text-scale, 1)); max-width: none; }
#whiteboard-cards .whiteboard-drawing text { unicode-bidi: plaintext; }
#whiteboard-cards .whiteboard-figure:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

#whiteboard-header { flex-wrap: wrap; gap: 6px; }
#whiteboard-header > button { min-height: 36px; padding: 6px 10px; font: inherit; }
#whiteboard-cards .board-part-question { display: block; min-height: 44px; width: 100%; margin-block: 4px; text-align: start; white-space: normal; }
#whiteboard-cards [data-board-part] { cursor: pointer; }
#whiteboard-cards [data-board-part]:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
#whiteboard-cards [data-board-part]:hover { filter: drop-shadow(0 0 2px currentColor); }
html:not([data-theme='dark']) #current-speaking-mode { color: #0051cf; }

.skip-learning { position: fixed; inset-block-start: -100px; inset-inline-start: 12px; z-index: 10000; padding: 12px; background: var(--panel, white); color: var(--ink, #05274f); border: 2px solid var(--blue, #005bea); }
.skip-learning:focus { inset-block-start: 12px; }

#transcript-entries:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

#whiteboard-header > button, #whiteboard-cards .board-part-question { display: inline-flex; align-items: center; gap: 6px; }
#whiteboard-header > button > svg, #whiteboard-cards .board-part-question > svg, #whiteboard-cards summary > svg { flex: none; vertical-align: middle; color: var(--blue); }
#whiteboard-cards summary > svg { margin-inline-end: 6px; }

/* Keep enlarged or translated profile controls inside the available page width. */
#practice .unified-chat .composer-toolbar > .practice-header-tools { flex-wrap: wrap; max-width: 100%; min-width: 0; }
#practice .practice-header-tools .learner-level-profile { max-width: 100%; min-width: 0; }
#practice .practice-header-tools #edit-setup { max-width: 100%; }
#practice #learner-level { white-space: normal; overflow-wrap: anywhere; }

/* Phone workspace: retain both continuous histories without sideways scrolling. */
@media (max-width: 700px) {
  #practice #interaction.unified-chat #chat-box.has-whiteboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: auto !important;
    min-height: 0;
    overflow-x: hidden;
  }
  #practice #conversation-pane {
    min-height: 520px;
  }
  #practice #interaction.unified-chat #chat-box.has-whiteboard #conversation-pane #chat-history {
    min-height: 180px !important;
    flex: 1 1 auto !important;
  }
  #practice #conversation-pane #composer-section {
    max-height: none;
    overflow: visible;
  }
  #whiteboard-divider { display: none; }
  #whiteboard-pane { min-height: 320px; border-top: 1px solid #8da5c5; }
  #whiteboard-history { min-height: 220px; max-height: 65dvh; }
}
