:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182235;
  background: #f4f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; height: 100vh; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  color: white;
  background: #243b6b;
}
.topbar h1 { margin: 0 0 4px; font-size: 1.8rem; }
.topbar p { margin: 0; opacity: .86; }
.question-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.question-controls label { display: grid; gap: 5px; font-size: .82rem; }
select, input {
  border: 1px solid #c5cedd;
  border-radius: 9px;
  padding: 9px 11px;
  background: white;
  color: #182235;
}
.question-controls select { min-width: 185px; }

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, .85fr);
  align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
  gap: 22px;
  width: 100%;
  max-width: 1500px;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  padding: 24px;
}
.workspace-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.problem-card, .model-card, .tutor-panel {
  background: white;
  border: 1px solid #dde3ec;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(31, 49, 82, .07);
}
.problem-card { padding: 22px 24px; }
.problem-meta { display: flex; gap: 8px; color: #5f6f88; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.problem-body { font-size: 1.2rem; line-height: 1.55; margin: 16px 0 8px; }
.problem-question { font-size: 1.28rem; font-weight: 700; line-height: 1.45; margin: 0; }

.model-card { padding: 20px; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: auto; }
.model-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.model-heading h2, .tutor-heading h2 { margin: 0 0 4px; font-size: 1.15rem; }
.model-heading p, .tutor-heading p { margin: 0; color: #67758c; font-size: .92rem; }
.group-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.workspace { display: grid; flex: 1; gap: 14px; margin-top: 18px; min-height: 310px; }
.workspace.two-column { grid-template-columns: 1fr 1fr; }

.zone {
  border: 2px dashed #c4ccda;
  border-radius: 14px;
  min-height: 135px;
  padding: 14px;
  background: #f9fbfe;
  transition: border-color .15s ease, background .15s ease;
}
.zone.drop-active { border-color: #3e67c6; background: #edf3ff; }
.zone h3 { margin: 0 0 10px; font-size: .95rem; color: #475773; }
.object-list { display: flex; flex-wrap: wrap; gap: 9px; min-height: 58px; align-content: flex-start; }

.object-token {
  width: 72px;
  min-height: 76px;
  border: 1px solid #d8deea;
  border-radius: 12px;
  background: white;
  display: grid;
  place-items: center;
  padding: 5px;
  user-select: none;
  box-shadow: 0 3px 10px rgba(43, 59, 91, .08);
}
.object-token[draggable="true"] { cursor: grab; }
.object-token[draggable="true"]:active { cursor: grabbing; }
.object-token.selected { outline: 3px solid #f0a44c; }
.object-token.locked { background: #eef2f7; opacity: .85; }
.object-token img { width: 36px; height: 36px; object-fit: contain; pointer-events: none; }
.object-token .emoji-fallback { font-size: 30px; line-height: 1; }
.object-token small { max-width: 66px; font-size: .62rem; line-height: 1.15; text-align: center; overflow-wrap: anywhere; color: #5d6b80; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.group-zone { min-height: 150px; }
.group-zone h3 { display: flex; align-items: center; gap: 7px; }
.group-icon { font-size: 1.3rem; }
.empty-note { color: #8994a6; font-size: .85rem; }

.answer-row {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 210px);
  gap: 12px;
  margin-top: 16px;
}
.equation-box, .answer-input {
  border: 1px solid #dce2eb;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fafcff;
}
.equation-box { display: grid; gap: 4px; }
.equation-box .label, .answer-input { font-size: .82rem; color: #637086; }
.equation-box strong { color: #213b74; font-size: 1.12rem; }
.answer-input { display: grid; gap: 6px; }
.answer-input input { width: 100%; }

.action-row { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.primary, .secondary {
  border-radius: 9px;
  padding: 9px 14px;
  border: 1px solid transparent;
  font-weight: 650;
}
.primary { background: #315db9; color: white; }
.primary:hover { background: #254c9e; }
.secondary { background: white; color: #31415f; border-color: #c9d1de; }
.secondary:hover { background: #f1f4f9; }
button:disabled { cursor: not-allowed; opacity: .5; }

.tutor-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  overflow: hidden;
}
.tutor-heading { display: flex; justify-content: space-between; gap: 12px; }
.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 12px;
  padding-right: 4px;
}
.message { max-width: 90%; border-radius: 14px; padding: 11px 13px; }
.message p { margin: 2px 0 0; line-height: 1.45; }
.message-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .65; }
.message.tutor { align-self: flex-start; background: #edf3ff; color: #233c72; }
.message.student { align-self: flex-end; background: #243b6b; color: white; }
.message.system { align-self: center; background: #f0f2f5; color: #5c687a; font-size: .85rem; }
.message.thinking { opacity: .86; }
.message.tutor-loading {
  min-width: 220px;
  border: 1px solid #cbd9f2;
  box-shadow: 0 5px 16px rgba(35, 60, 114, .08);
}
.loading-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 25px;
  margin-top: 3px;
}
.loading-text { font-size: .93rem; font-weight: 600; }
.typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: .35;
  animation: tutor-dot-pulse 1.15s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .16s; }
.typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes tutor-dot-pulse {
  0%, 70%, 100% { transform: translateY(0); opacity: .28; }
  35% { transform: translateY(-4px); opacity: .95; }
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots span { animation: none; opacity: .65; }
}

.support-panel {
  border-top: 1px solid #e2e7ef;
  padding-top: 12px;
}
.support-title { margin: 0 0 9px; color: #5e6b80; font-size: .84rem; font-weight: 700; }
.support-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.support-options button {
  min-height: 48px;
  border: 1px solid #cbd5e4;
  border-radius: 10px;
  padding: 9px 10px;
  background: #f8faff;
  color: #2b3f67;
  text-align: left;
  line-height: 1.25;
}
.support-options button:hover { background: #edf3ff; border-color: #7d9bd5; }
.support-options button:last-child { grid-column: 1 / -1; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  body { height: auto; overflow: auto; }
  .topbar { flex-direction: column; }
  .page-grid { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; min-height: 0; }
  .workspace-panel { min-height: 0; height: auto; }
  .tutor-panel { height: auto; min-height: 520px; }
  .support-options { grid-template-columns: 1fr; }
  .support-options button:last-child { grid-column: auto; }
}

@media (max-width: 640px) {
  .topbar, .page-grid { padding: 16px; }
  .question-controls { align-items: stretch; flex-direction: column; }
  .question-controls select { width: 100%; }
  .workspace.two-column, .answer-row { grid-template-columns: 1fr; }
  .model-heading { flex-direction: column; }
  .group-controls { justify-content: flex-start; }
}

#question-select, label:has(> #question-select) { display: none !important; }


.info-button { background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.45); }
.info-button:hover { background: rgba(255,255,255,.22); }
.info-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  color: #182235;
  box-shadow: 0 24px 70px rgba(14, 28, 54, .32);
}
.info-dialog::backdrop { background: rgba(15, 27, 49, .58); }
.info-dialog-header { display: flex; justify-content: space-between; gap: 18px; align-items: start; padding: 22px 24px; border-bottom: 1px solid #e2e7ef; }
.info-dialog-header h2 { margin: 0 0 4px; }
.info-dialog-header p { margin: 0; color: #67758c; }
.info-content { padding: 6px 24px 24px; overflow-y: auto; }
.info-content section { padding-top: 16px; }
.info-content h3 { margin: 0 0 7px; color: #243b6b; }
.info-content p, .info-content li { line-height: 1.55; }
.info-content ol { padding-left: 22px; }


.thinking-input { display: grid; gap: 7px; margin-top: 12px; color: #526078; font-size: .84rem; font-weight: 700; }
.thinking-input small { font-weight: 500; color: #7a879b; }
.thinking-input textarea { width: 100%; resize: vertical; min-height: 74px; max-height: 150px; border: 1px solid #cbd5e4; border-radius: 10px; padding: 10px 11px; font: inherit; color: #24344f; background: #fff; }
.thinking-input textarea:focus { outline: 2px solid #9eb7e7; border-color: #6f8fc9; }

/* Interactive learning cards — v0.26.8 */
.learning-cards { margin-top: 16px; }
.learning-cards-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.learning-cards-heading.compact { margin-bottom: 8px; }
.learning-cards-heading h2, .learning-cards-heading h3 { margin: 0 0 3px; color: #243b6b; font-size: .98rem; }
.learning-cards-heading p { margin: 0; color: #718097; font-size: .8rem; line-height: 1.35; }
.flip-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.flip-card { min-width: 0; }
.flip-card-toggle {
  width: 100%;
  min-height: 108px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  perspective: 900px;
  text-align: left;
}
.flip-card-toggle:focus-visible { outline: 3px solid #86a7e2; outline-offset: 3px; }
.flip-card-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 108px;
  transform-style: preserve-3d;
  transition: transform .42s ease;
}
.flip-card.is-flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 108px;
  padding: 12px;
  border: 1px solid #cad6e8;
  border-radius: 12px;
  backface-visibility: hidden;
  box-shadow: 0 4px 13px rgba(37, 60, 106, .08);
}
.flip-card-front { background: linear-gradient(145deg, #f9fbff, #edf3ff); }
.flip-card-back { background: #fff8e9; border-color: #ead3a5; transform: rotateY(180deg); }
.flip-card-face strong { color: #233c72; font-size: .9rem; line-height: 1.25; }
.flip-card-face small { color: #66758c; font-size: .72rem; line-height: 1.35; }
.card-kicker { color: #6a7fa9; font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }

.story-clues { padding-top: 13px; border-top: 1px solid #e8ecf2; }
.story-clues .flip-card-toggle, .story-clues .flip-card-inner, .story-clues .flip-card-face { min-height: 96px; }


@media (prefers-reduced-motion: reduce) {
  .flip-card-inner { transition: none; }
}


@media (max-width: 980px) {
  .flip-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .flip-card-grid { grid-template-columns: 1fr; }
}


/* v0.27.0: ordered two-part ratio workspace */
.ratio-banks,.ratio-collections{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;width:100%;}
.ratio-collections{margin-top:1rem;}
.ratio-zone{border-width:2px;}
@media(max-width:760px){.ratio-banks,.ratio-collections{grid-template-columns:1fr;}}

.open-ended-chat {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.send-open-ended {
  justify-self: end;
  min-width: 88px;
}
