.qb-math-robot-shell[hidden],
.qb-math-robot-panel[hidden],
.qb-math-robot-quick[hidden] { display: none !important; }

.qb-math-robot-shell {
  --mr-ink: #183b68;
  --mr-blue: #245e9c;
  --mr-soft: #eef6ff;
  --mr-teal: #0c7d82;
  position: fixed;
  right: 14px;
  bottom: calc(var(--mr-nav-clearance, 112px) + env(safe-area-inset-bottom, 0px));
  z-index: 1250;
  color: var(--mr-ink);
  font-family: inherit;
}

.qb-math-robot-launcher {
  position: relative;
  display: flex;
  width: 58px;
  min-width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 1.5px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(39, 55, 79, .18);
  color: #667187;
  cursor: pointer;
}

.qb-math-robot-launcher:hover { transform: translateY(-2px); border-color: #9db8d5; box-shadow: 0 11px 26px rgba(39, 55, 79, .22); color: var(--mr-blue); }
.qb-math-robot-launcher-icon {
  display: block;
  width: 28px;
  height: 28px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='16' height='20' x='4' y='2' rx='2'/%3E%3Cline x1='8' x2='16' y1='6' y2='6'/%3E%3Cline x1='8' x2='8' y1='10' y2='10'/%3E%3Cline x1='12' x2='12' y1='10' y2='10'/%3E%3Cline x1='16' x2='16' y1='10' y2='10'/%3E%3Cline x1='8' x2='8' y1='14' y2='14'/%3E%3Cline x1='12' x2='12' y1='14' y2='14'/%3E%3Cline x1='16' x2='16' y1='14' y2='14'/%3E%3Cline x1='8' x2='8' y1='18' y2='18'/%3E%3Cline x1='12' x2='12' y1='18' y2='18'/%3E%3Cline x1='16' x2='16' y1='18' y2='18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='16' height='20' x='4' y='2' rx='2'/%3E%3Cline x1='8' x2='16' y1='6' y2='6'/%3E%3Cline x1='8' x2='8' y1='10' y2='10'/%3E%3Cline x1='12' x2='12' y1='10' y2='10'/%3E%3Cline x1='16' x2='16' y1='10' y2='10'/%3E%3Cline x1='8' x2='8' y1='14' y2='14'/%3E%3Cline x1='12' x2='12' y1='14' y2='14'/%3E%3Cline x1='16' x2='16' y1='14' y2='14'/%3E%3Cline x1='8' x2='8' y1='18' y2='18'/%3E%3Cline x1='12' x2='12' y1='18' y2='18'/%3E%3Cline x1='16' x2='16' y1='18' y2='18'/%3E%3C/svg%3E") center / contain no-repeat;
}
.qb-math-robot-launcher-meta { position: absolute; top: -8px; right: -6px; display: block; line-height: 1; }
.qb-math-robot-launcher strong {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.qb-math-robot-launcher small {
  display: block;
  margin: 0;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--mr-blue);
  box-shadow: 0 3px 9px rgba(20, 55, 95, .24);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}

.qb-math-robot-panel {
  position: fixed;
  right: 14px;
  bottom: calc(var(--mr-nav-clearance, 108px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  width: min(420px, calc(100vw - 24px));
  max-height: min(680px, calc(100dvh - var(--mr-nav-clearance, 108px) - 14px));
  padding: 12px;
  flex-direction: column;
  border: 2px solid #aac9e8;
  border-radius: 20px;
  background: linear-gradient(160deg, #fbfdff 0%, #edf6ff 100%);
  box-shadow: 0 22px 64px rgba(18, 47, 82, .3);
  overflow: hidden;
}

.qb-math-robot-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.qb-math-robot-head > img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(27, 70, 119, .13);
}

.qb-math-robot-kicker,
.qb-math-robot-message-label {
  display: block;
  color: var(--mr-blue);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.qb-math-robot-head h2 { margin: 0 0 1px; color: #163d72; font-size: 20px; line-height: 1.05; }
.qb-math-robot-head p { margin: 0; color: #4d647c; font-size: 10.5px; line-height: 1.25; }
.qb-math-robot-close {
  display: grid;
  width: auto;
  height: 32px;
  padding: 0 9px;
  place-items: center;
  align-self: start;
  border: 1px solid #bdd2e8;
  border-radius: 999px;
  background: #fff;
  color: #47637f;
  font: inherit;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.qb-math-robot-choice {
  margin-top: 9px;
  padding: 8px;
  border: 1px solid #c5daed;
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
}

.qb-math-robot-choice h3 { margin: 0 0 6px; color: #1b426f; font-size: 12px; }
.qb-math-robot-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qb-math-robot-mode {
  display: grid;
  min-width: 0;
  min-height: 58px;
  padding: 7px;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  border: 2px solid #c5d7e8;
  border-radius: 11px;
  background: #fff;
  color: #254662;
  text-align: left;
  cursor: pointer;
}

.qb-math-robot-mode.is-local { --mode-colour: #0b7e72; }
.qb-math-robot-mode.is-ai { --mode-colour: #5b55ae; }
.qb-math-robot-mode:hover { border-color: var(--mode-colour); background: #f8fbff; }
.qb-math-robot-mode.is-selected { border-color: var(--mode-colour); background: color-mix(in srgb, var(--mode-colour) 9%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mode-colour) 16%, transparent); }
.qb-math-robot-mode.is-unavailable { opacity: .62; }
.qb-math-robot-mode-icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--mode-colour) 13%, white); color: var(--mode-colour); font-size: 14px; font-weight: 900; }
.qb-math-robot-mode > span:last-child { display: grid; gap: 2px; min-width: 0; }
.qb-math-robot-mode strong { color: var(--mode-colour); font-size: 11.5px; line-height: 1.15; }
.qb-math-robot-mode strong b { display: inline-block; padding: 1px 4px; border-radius: 999px; background: #eeeefe; color: #454092; font-size: 8px; white-space: nowrap; }
.qb-math-robot-mode small { color: #536b80; font-size: 8.5px; line-height: 1.2; }
.qb-math-robot-mode-note { margin: 6px 1px 0; color: #49637c; font-size: 9.5px; line-height: 1.25; }
.qb-math-robot-choice.has-selection .qb-math-robot-mode-note {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.qb-math-robot-counter { font-weight: 900; }
.qb-math-robot-quick,
.qb-math-robot-reveal-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.qb-math-robot-quick { margin-top: 8px; }
.qb-math-robot-quick button,
.qb-math-robot-reveal-actions button,
.qb-math-robot-inline-choice {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #9abbe3;
  border-radius: 10px;
  background: #fff;
  color: #214f8e;
  font: inherit;
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}

.qb-math-robot-inline-choice { margin-top: 8px; border-color: #63a69d; color: #096d62; }
.qb-math-robot-quick button:hover,
.qb-math-robot-reveal-actions button:hover,
.qb-math-robot-inline-choice:hover { background: #edf7ff; }
.qb-math-robot-reveal-actions button:disabled { cursor: default; opacity: .62; }

.qb-math-robot-messages {
  display: flex;
  min-height: 170px;
  flex: 1 1 auto;
  margin: 8px 0;
  padding: 8px;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  border: 1px solid #c8dbef;
  border-radius: 14px;
  background: rgba(255, 255, 255, .75);
}

.qb-math-robot-messages:empty {
  min-height: 72px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}

.qb-math-robot-messages:empty::before {
  content: 'Choose a tutor, then ask where you got stuck.';
  color: #60758a;
  font-size: 10.5px;
  font-weight: 750;
  text-align: center;
}

.qb-math-robot-message {
  position: relative;
  max-width: 94%;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  color: #263d55;
  box-shadow: 0 1px 5px rgba(31, 69, 111, .07);
}

.qb-math-robot-message-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.qb-math-robot-edit-message,
#qb-math-robot-cancel-edit {
  padding: 2px 6px;
  border: 1px solid #7fa9d9;
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  color: #214f8e;
  font: inherit;
  font-size: 9.5px;
  font-weight: 900;
  cursor: pointer;
}
.qb-math-robot-edit-message:hover,
#qb-math-robot-cancel-edit:hover { background: #fff; }
.qb-math-robot-edit-message:disabled { cursor: default; opacity: .72; }
.qb-math-robot-message.is-editing { outline: 2px solid #5e94cf; outline-offset: 1px; }
.qb-math-robot-message.is-student { align-self: flex-end; background: #dcecff; }
.qb-math-robot-message.is-robot { align-self: flex-start; }
.qb-math-robot-message p { margin: 3px 0; font-size: 12px; line-height: 1.38; }
.qb-worked-calculator-card { width: min(100%, 560px); }
.qb-worked-calculator-guide {
  margin: 6px 0 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #eef6ff;
  color: #234f7e;
  font-size: 10px;
  font-weight: 800;
}
.qb-worked-calculator-line {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  margin-top: 7px;
  padding: 8px;
  border: 1px solid #c9dff4;
  border-radius: 10px;
  background: #f7fbff;
}
.qb-worked-calculator-number {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #2767a7;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}
.qb-worked-calculator-formula {
  display: block;
  overflow-wrap: anywhere;
  color: #173f72;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.35;
}
.qb-worked-calculator-line p { margin-top: 4px; color: #4e6277; }
.qb-math-robot-reveal { margin-top: 7px !important; padding: 7px 8px; border-left: 3px solid #78a8df; background: #eef6ff; }
.qb-math-robot-reveal-actions { margin-top: 7px; }
.qb-math-robot-label { display: block; margin-bottom: 4px; color: #1b426f; font-size: 11px; font-weight: 900; }
.qb-math-robot-compose-label-row { display: flex; min-height: 24px; align-items: center; justify-content: space-between; }
.qb-math-robot-compose-actions { display: flex; gap: 5px; align-items: center; }
#qb-math-robot-symbol-toggle,
#qb-math-robot-cancel-edit { margin-bottom: 4px; }
#qb-math-robot-symbol-toggle {
  padding: 2px 7px;
  border: 1px solid #7fa9d9;
  border-radius: 8px;
  background: #eef6ff;
  color: #214f8e;
  font: inherit;
  font-size: 9.5px;
  font-weight: 900;
  cursor: pointer;
}
#qb-math-robot-symbol-toggle::after { content: ' ▾'; }
#qb-math-robot-symbol-toggle[aria-expanded="true"]::after { content: ' ▴'; }
#qb-math-robot-symbol-toggle:hover:not(:disabled) { background: #fff; }
#qb-math-robot-symbol-toggle:disabled { cursor: default; opacity: .5; }
.qb-math-robot-symbols {
  margin: 0 0 7px;
  padding: 7px;
  border: 1px solid #b8d0eb;
  border-radius: 11px;
  background: #f5f9ff;
}
.qb-math-robot-symbols[hidden] { display: none; }
.qb-math-symbol-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 0 6px;
  border-bottom: 1px solid #c9dbee;
  scrollbar-width: thin;
}
.qb-math-symbol-tabs button {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #49637f;
  font: inherit;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.qb-math-symbol-tabs button[aria-selected="true"] {
  border-color: #7fa9d9;
  background: #dfeeff;
  color: #173f70;
}
.qb-math-symbol-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 7px;
}
.qb-math-symbol-panel[hidden] { display: none; }
.qb-math-symbol-key {
  min-width: 31px;
  min-height: 31px;
  padding: 3px 6px;
  border: 1px solid #90b4df;
  border-radius: 8px;
  background: #fff;
  color: #183e6d;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.qb-math-symbol-key.is-wide { min-width: 43px; font-size: 12px; }
.qb-math-symbol-tabs button:hover:not(:disabled),
.qb-math-symbol-key:hover:not(:disabled) { background: #e4f1ff; }
.qb-math-symbol-tabs button:disabled,
.qb-math-symbol-key:disabled { cursor: default; opacity: .5; }
.qb-math-robot-compose { display: grid; grid-template-columns: minmax(0, 1fr) 82px; gap: 7px; align-items: stretch; }
.qb-math-robot-compose textarea {
  width: 100%;
  min-height: 52px;
  padding: 8px 9px;
  resize: none;
  border: 2px solid #aac6e7;
  border-radius: 12px;
  background: #fff;
  color: #203750;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
}

.qb-math-robot-compose textarea:disabled { background: #edf1f5; color: #6d7c8a; }
.qb-math-robot-compose button {
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--mr-blue);
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.qb-math-robot-compose button:disabled { cursor: default; opacity: .57; }
.qb-math-robot-privacy { display: block; margin-top: 5px; color: #60758a; font-size: 8.5px; line-height: 1.25; }

.qb-math-robot-launcher:focus-visible,
.qb-math-robot-close:focus-visible,
.qb-math-robot-mode:focus-visible,
.qb-math-robot-quick button:focus-visible,
.qb-math-robot-reveal-actions button:focus-visible,
.qb-math-robot-inline-choice:focus-visible,
#qb-math-robot-symbol-toggle:focus-visible,
.qb-math-robot-symbols button:focus-visible,
.qb-math-robot-compose textarea:focus-visible,
.qb-math-robot-compose button:focus-visible { outline: 3px solid #f4b942; outline-offset: 2px; }

@media (max-width: 560px) {
  .qb-math-robot-shell { right: 9px; bottom: calc(var(--mr-nav-clearance, 106px) + env(safe-area-inset-bottom, 0px)); }
  .qb-math-robot-launcher { width: 56px; min-width: 56px; height: 56px; min-height: 56px; }
  .qb-math-robot-launcher-icon { width: 27px; height: 27px; }
  .qb-math-robot-panel { right: 6px; bottom: calc(var(--mr-nav-clearance, 102px) + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 12px); max-height: calc(100dvh - var(--mr-nav-clearance, 102px) - 14px); padding: 10px; border-radius: 17px; }
  .qb-math-robot-head { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
  .qb-math-robot-head > img { width: 40px; height: 40px; }
  .qb-math-robot-head h2 { font-size: 18px; }
  .qb-math-robot-kicker { font-size: 8px; }
  .qb-math-robot-modes { grid-template-columns: 1fr 1fr; gap: 6px; }
  .qb-math-robot-mode { min-height: 56px; padding: 6px; }
  .qb-math-robot-compose { grid-template-columns: minmax(0, 1fr) 76px; }
  .qb-math-robot-compose button { min-height: 40px; }
  .qb-math-robot-message { max-width: 96%; }
  .qb-math-robot-quick { gap: 5px; }
  .qb-math-robot-quick button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .qb-math-robot-launcher:hover { transform: none; }
}
