[data-toantin-standalone="math_graph"] {
  --tt-mg-primary: #1667e8;
  --tt-mg-primary-strong: #0d5bef;
  --tt-mg-navy: #102a56;
  --tt-mg-cyan: #38bdf8;
  --tt-mg-bg: #eef5ff;
  --tt-mg-surface: #ffffff;
  --tt-mg-surface-soft: #f8fbff;
  --tt-mg-border: #d8e5f5;
  --tt-mg-text: #14213d;
  --tt-mg-muted: #64748b;
  min-height: 100vh;
  padding: 22px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--tt-mg-text);
  background: linear-gradient(145deg, #f8fbff 0%, var(--tt-mg-bg) 100%);
}

[data-toantin-standalone="math_graph"] * {
  box-sizing: border-box;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell {
  width: min(1480px, 100%);
  margin-inline: auto;
  padding: 20px;
  border: 1px solid rgba(216, 229, 245, 0.92);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 50px rgba(15, 31, 75, 0.09);
}

[data-toantin-standalone="math_graph"] .tt-mg-header {
  padding: 2px 2px 18px;
}

[data-toantin-standalone="math_graph"] .tt-mg-eyebrow,
[data-toantin-standalone="math_graph"] .tt-mg-section-kicker {
  color: var(--tt-mg-primary);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

[data-toantin-standalone="math_graph"] .tt-mg-title {
  color: var(--tt-mg-navy);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  font-weight: 760;
  letter-spacing: -0.03em;
}

[data-toantin-standalone="math_graph"] .tt-mg-build-badge,
[data-toantin-standalone="math_graph"] .tt-mg-demo-label {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #cfe0fa;
  border-radius: 999px;
  color: var(--tt-mg-primary);
  background: #edf5ff;
  font-size: 0.72rem;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-subtitle,
[data-toantin-standalone="math_graph"] .tt-mg-hint,
[data-toantin-standalone="math_graph"] .tt-mg-note,
[data-toantin-standalone="math_graph"] .tt-mg-footer {
  color: var(--tt-mg-muted);
}

[data-toantin-standalone="math_graph"] .tt-mg-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #cbdcf2;
  border-radius: 11px;
  color: var(--tt-mg-navy);
  background: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 42, 86, 0.04);
}

[data-toantin-standalone="math_graph"] .tt-mg-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-btn:focus-visible {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #f6faff;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--primary {
  border-color: var(--tt-mg-primary-strong);
  color: #fff;
  background: linear-gradient(135deg, var(--tt-mg-primary-strong), #2477ef);
  box-shadow: 0 7px 18px rgba(22, 103, 232, 0.18);
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--primary:hover,
[data-toantin-standalone="math_graph"] .tt-mg-btn--primary:focus-visible {
  color: #fff;
  background: #0d5bef;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-card,
[data-toantin-standalone="math_graph"] .tt-mg-side-card {
  overflow: hidden;
  border: 1px solid var(--tt-mg-border);
  border-radius: 16px;
  background: var(--tt-mg-surface);
  box-shadow: 0 8px 26px rgba(16, 42, 86, 0.06);
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-card__top {
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid #e3ecf8;
  background: var(--tt-mg-surface-soft);
}

[data-toantin-standalone="math_graph"] .tt-mg-function-dot {
  width: 12px;
  height: 12px;
  border: 3px solid #cfe1ff;
  border-radius: 50%;
  background: var(--tt-mg-primary);
  box-shadow: 0 0 0 2px #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-function-label {
  color: var(--tt-mg-navy);
  font-weight: 750;
}

[data-toantin-standalone="math_graph"] .tt-mg-hint {
  font-size: 0.78rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-host {
  min-height: 560px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] [data-toantin-tool="math_graph"],
[data-toantin-standalone="math_graph"] .tt-mg-workspace,
[data-toantin-standalone="math_graph"] .tt-mg-canvas {
  display: block;
  width: 100%;
}

[data-toantin-standalone="math_graph"] .tt-mg-workspace {
  min-height: 560px;
  overflow: hidden;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas {
  cursor: grab;
  user-select: none;
}

[data-toantin-standalone="math_graph"] [data-toantin-tool="math_graph"][data-active="false"] .tt-mg-canvas {
  cursor: default;
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas:active {
  cursor: grabbing;
}

[data-toantin-standalone="math_graph"] .tt-mg-side-card {
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

[data-toantin-standalone="math_graph"] .tt-mg-side-card__section {
  padding: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-viewport-value {
  margin: 10px 0 0;
  color: var(--tt-mg-navy);
  font-size: 1rem;
  font-weight: 720;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-divider {
  height: 1px;
  margin: 17px 0;
  background: #e1ebf7;
}

[data-toantin-standalone="math_graph"] .tt-mg-status-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

[data-toantin-standalone="math_graph"] .tt-mg-status-list span {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #405675;
  font-size: 0.87rem;
  font-weight: 650;
}

[data-toantin-standalone="math_graph"] .tt-mg-status-list i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

[data-toantin-standalone="math_graph"] .tt-mg-note {
  font-size: 0.82rem;
  line-height: 1.6;
}

[data-toantin-standalone="math_graph"] .tt-mg-footer {
  padding: 14px 4px 0;
  font-size: 0.74rem;
}

@media (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    min-height: 500px;
  }
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] {
    padding: 10px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    padding: 13px;
    border-radius: 15px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-header {
    padding-bottom: 13px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-actions {
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-btn {
    min-height: 46px;
    flex: 1 1 0;
    justify-content: center;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-card__top {
    align-items: flex-start;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-hint {
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    min-height: 430px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-card {
    padding: 15px;
  }
}

/* A3 — Expression / Parameter / Teaching UI. Tất cả selector tiếp tục bị khóa trong standalone root. */
[data-toantin-standalone="math_graph"] .min-w-0 {
  min-width: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-top-controls {
  padding: 8px;
  border: 1px solid var(--tt-mg-border);
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.9);
}

[data-toantin-standalone="math_graph"] .tt-mg-compact-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 8px 0 12px;
  border: 1px solid #cbdcf2;
  border-radius: 11px;
  background: #fff;
  color: var(--tt-mg-muted);
  font-size: 0.76rem;
  font-weight: 750;
}

[data-toantin-standalone="math_graph"] .tt-mg-compact-field .form-select {
  width: auto;
  min-width: 92px;
  height: 34px;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  border: 0;
  color: var(--tt-mg-navy);
  background-color: transparent;
  font-size: 0.85rem;
  font-weight: 750;
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--teaching.is-active,
[data-toantin-standalone="math_graph"] .tt-mg-btn--teaching[aria-pressed="true"] {
  border-color: #7c3aed;
  color: #6d28d9;
  background: #f5f0ff;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

[data-toantin-standalone="math_graph"] .tt-mg-main-grid {
  min-height: 650px;
}

[data-toantin-standalone="math_graph"] .tt-mg-panel {
  padding: 17px;
  border: 1px solid var(--tt-mg-border);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 8px 26px rgba(16, 42, 86, 0.055);
}

[data-toantin-standalone="math_graph"] .tt-mg-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

[data-toantin-standalone="math_graph"] .tt-mg-panel__title {
  color: var(--tt-mg-navy);
  font-size: 1rem;
  font-weight: 780;
}

[data-toantin-standalone="math_graph"] .tt-mg-count-badge,
[data-toantin-standalone="math_graph"] .tt-mg-value-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 2px 8px;
  border: 1px solid #d2e2f7;
  border-radius: 999px;
  color: var(--tt-mg-primary);
  background: #edf5ff;
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-form {
  padding: 13px;
  border: 1px solid #dce8f7;
  border-radius: 13px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-form .form-label,
[data-toantin-standalone="math_graph"] .tt-mg-field-label {
  margin-bottom: 6px;
  color: #405675;
  font-size: 0.8rem;
  font-weight: 760;
}

[data-toantin-standalone="math_graph"] .tt-mg-input-group .input-group-text,
[data-toantin-standalone="math_graph"] .tt-mg-input-group .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-add-btn,
[data-toantin-standalone="math_graph"] .tt-mg-number-input {
  min-height: 42px;
}

[data-toantin-standalone="math_graph"] .tt-mg-input-group .input-group-text {
  border-color: #cfdff1;
  color: var(--tt-mg-navy);
  background: #f5f9ff;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-input-group .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-number-input {
  border-color: #cfdff1;
  color: var(--tt-mg-text);
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-input-group .form-control:focus,
[data-toantin-standalone="math_graph"] .tt-mg-number-input:focus,
[data-toantin-standalone="math_graph"] .tt-mg-color-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.2rem rgba(56, 189, 248, 0.15);
}

[data-toantin-standalone="math_graph"] .tt-mg-add-btn {
  border-color: var(--tt-mg-primary);
  color: #fff;
  background: var(--tt-mg-primary);
  font-weight: 760;
}

[data-toantin-standalone="math_graph"] .tt-mg-add-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-add-btn:focus-visible {
  border-color: var(--tt-mg-primary-strong);
  color: #fff;
  background: var(--tt-mg-primary-strong);
}

[data-toantin-standalone="math_graph"] .tt-mg-field-error {
  margin-top: 7px;
  color: #c52736;
  font-size: 0.78rem;
  font-weight: 650;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-list,
[data-toantin-standalone="math_graph"] .tt-mg-parameter-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item {
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item:hover {
  border-color: #a9c8ef;
  transform: translateY(-1px);
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-selected {
  border-color: #7cb0f1;
  background: #f5f9ff;
  box-shadow: 0 7px 18px rgba(22, 103, 232, 0.09);
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-hidden {
  opacity: 0.62;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-swatch,
[data-toantin-standalone="math_graph"] .tt-mg-function-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  margin-top: 3px;
  border: 3px solid color-mix(in srgb, var(--expression-color, #1667e8) 28%, white);
  border-radius: 50%;
  background: var(--expression-color, #1667e8);
  box-shadow: 0 0 0 2px #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-copy strong {
  color: var(--tt-mg-navy);
  font-size: 0.9rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-copy code {
  margin-top: 2px;
  color: #5b6f8f;
  font-size: 0.78rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #d3e0f0;
  border-radius: 9px;
  color: #405675;
  background: #fff;
  font-size: 0.72rem;
  font-weight: 760;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-mini-btn:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-mini-btn.is-active {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #edf5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.28);
  outline-offset: 1px;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn.is-highlight {
  border-color: #c4a7f6;
  color: #6d28d9;
  background: #f5f0ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn.is-primary {
  border-color: #a8caf5;
  color: #0d5bef;
  background: #eef5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-mini-btn--danger {
  border-color: #f2c4ca;
  color: #c52736;
  background: #fff8f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-empty-state {
  display: grid;
  gap: 4px;
  padding: 17px 14px;
  border: 1px dashed #bfd2ea;
  border-radius: 13px;
  color: #64748b;
  background: #f8fbff;
  font-size: 0.8rem;
  line-height: 1.5;
}

[data-toantin-standalone="math_graph"] .tt-mg-empty-state strong {
  color: var(--tt-mg-navy);
  font-size: 0.88rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-empty-state--compact {
  padding: 13px;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-card {
  display: flex;
  min-height: 650px;
  flex-direction: column;
}

[data-toantin-standalone="math_graph"] .tt-mg-host {
  min-height: 0;
  flex: 1 1 auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-workspace {
  min-height: 100%;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
  min-height: 50px;
  padding: 9px 14px;
  border-top: 1px solid #e3ecf8;
  background: #fbfdff;
}

[data-toantin-standalone="math_graph"] .tt-mg-viewport-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 13px;
  color: #5b6f8f;
  font-size: 0.75rem;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-switch {
  color: #405675;
  font-size: 0.78rem;
  font-weight: 700;
}

[data-toantin-standalone="math_graph"] .tt-mg-switch .form-check-input {
  border-color: #aebfd5;
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-switch .form-check-input:checked {
  border-color: var(--tt-mg-primary);
  background-color: var(--tt-mg-primary);
}

[data-toantin-standalone="math_graph"] .tt-mg-color-input {
  width: 100%;
  min-height: 42px;
  padding: 5px;
  border-color: #cfdff1;
  border-radius: 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-normalized {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border-radius: 10px;
  color: #64748b;
  background: #f2f7fd;
  font-size: 0.72rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-normalized code {
  overflow-wrap: anywhere;
  color: var(--tt-mg-navy);
  font-size: 0.78rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-parameter-card {
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 13px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-parameter-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--tt-mg-primary), #7c3aed);
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-style: italic;
}

[data-toantin-standalone="math_graph"] .tt-mg-range {
  accent-color: var(--tt-mg-primary);
}

[data-toantin-standalone="math_graph"] .tt-mg-range-labels {
  color: #7a8ba3;
  font-size: 0.69rem;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-parameter-actions {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-card {
  border-color: #a8caf5;
  box-shadow: 0 12px 34px rgba(22, 103, 232, 0.12);
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-card__top,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-footer {
  background: #f2f7ff;
}

@media (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-grid,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    min-height: 580px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-panel {
    min-height: 100%;
  }
}

@media (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    min-height: 560px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-panel {
    height: auto;
  }
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-top-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-top-controls .tt-mg-compact-field {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-top-controls .tt-mg-btn {
    width: 100%;
    min-height: 46px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-grid {
    min-height: auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    min-height: 520px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-card__top {
    min-height: 64px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-panel {
    padding: 14px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-expression-form {
    padding: 11px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-expression-actions .tt-mg-mini-btn {
    flex: 1 1 auto;
    min-height: 40px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-item,
  [data-toantin-standalone="math_graph"] .tt-mg-btn,
  [data-toantin-standalone="math_graph"] .tt-mg-mini-btn {
    transition: none;
  }
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-select {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-select:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 4px;
  border-radius: 7px;
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-actions .tt-mg-mini-btn,
  [data-toantin-standalone="math_graph"] .tt-mg-parameter-actions .tt-mg-mini-btn,
  [data-toantin-standalone="math_graph"] .tt-mg-top-controls .tt-mg-compact-field {
    min-height: 44px;
  }
}

/* A4 — Trace / Numeric Analysis / Point & Tangent surface. */
[data-toantin-standalone="math_graph"] .tt-mg-btn--trace.is-active,
[data-toantin-standalone="math_graph"] .tt-mg-btn--trace[aria-pressed="true"] {
  border-color: #0ea5e9;
  color: #0369a1;
  background: #ecfeff;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

[data-toantin-standalone="math_graph"] .tt-mg-btn:disabled,
[data-toantin-standalone="math_graph"] .tt-mg-mini-btn:disabled,
[data-toantin-standalone="math_graph"] .tt-mg-secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-actions {
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 13px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-two-actions {
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

[data-toantin-standalone="math_graph"] .tt-mg-secondary-action {
  min-height: 36px;
  border-color: #b8cee9;
  color: var(--tt-mg-primary);
  background: #f4f8ff;
  font-size: 0.76rem;
  font-weight: 760;
}

[data-toantin-standalone="math_graph"] .tt-mg-secondary-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-secondary-action:focus-visible {
  border-color: #75a7e5;
  color: #0d5bef;
  background: #eaf3ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-secondary-action:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-analysis-actions .form-control:focus,
[data-toantin-standalone="math_graph"] .tt-mg-analysis-actions .form-select:focus,
[data-toantin-standalone="math_graph"] .tt-mg-point-builder .form-control:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.18rem rgba(56, 189, 248, 0.15);
}

[data-toantin-standalone="math_graph"] .tt-mg-table-builder {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-table-check {
  color: #506681;
  font-size: 0.74rem;
  font-weight: 680;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-result {
  min-height: 50px;
  padding: 10px 11px;
  border: 1px solid #d8e5f5;
  border-radius: 10px;
  color: #526781;
  background: #f8fbff;
  font-size: 0.76rem;
  line-height: 1.5;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-result[data-tone="success"] {
  border-color: #b8ead9;
  color: #087f5b;
  background: #f0fdf8;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-result[data-tone="warning"] {
  border-color: #f1dfab;
  color: #8a5b08;
  background: #fffbeb;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-result[data-tone="error"] {
  border-color: #f3c4ca;
  color: #b42335;
  background: #fff7f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-result-table-wrap {
  max-height: 180px;
  overflow: auto;
  border: 1px solid #e2ebf6;
  border-radius: 8px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-result-table {
  color: #405675;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-result-table th {
  position: sticky;
  top: 0;
  color: var(--tt-mg-navy);
  background: #f1f6fd;
}

[data-toantin-standalone="math_graph"] .tt-mg-point-builder .input-group-text,
[data-toantin-standalone="math_graph"] .tt-mg-point-builder .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-point-builder .btn {
  min-height: 36px;
}

[data-toantin-standalone="math_graph"] .tt-mg-point-builder .input-group-text {
  color: #526781;
  background: #f6f9fd;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-list {
  display: grid;
  gap: 7px;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-item {
  padding: 6px;
  border: 1px solid #dce7f5;
  border-radius: 11px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-select {
  min-width: 0;
  padding: 4px 6px;
  border: 0;
  color: #405675;
  background: transparent;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-select strong {
  overflow: hidden;
  color: var(--tt-mg-navy);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-select span {
  color: #73849a;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-select:hover,
[data-toantin-standalone="math_graph"] .tt-mg-object-select:focus-visible {
  color: var(--tt-mg-primary);
  background: #f4f8ff;
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-object-select:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.28);
  outline-offset: 1px;
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-top-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-compact-field {
    min-height: 46px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-analysis-actions .btn,
  [data-toantin-standalone="math_graph"] .tt-mg-analysis-actions .form-control,
  [data-toantin-standalone="math_graph"] .tt-mg-analysis-actions .form-select,
  [data-toantin-standalone="math_graph"] .tt-mg-point-builder .input-group-text,
  [data-toantin-standalone="math_graph"] .tt-mg-point-builder .form-control,
  [data-toantin-standalone="math_graph"] .tt-mg-point-builder .btn,
  [data-toantin-standalone="math_graph"] .tt-mg-object-item > .btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-item,
  [data-toantin-standalone="math_graph"] .tt-mg-btn,
  [data-toantin-standalone="math_graph"] .tt-mg-mini-btn {
    transition: none;
  }
}

/* A5 — Standalone UX / Save-Load / Keypad / Help / Teaching / Fullscreen. */
[data-toantin-standalone="math_graph"] .tt-mg-utility-actions {
  justify-content: flex-end;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--utility {
  min-height: 40px;
  border-color: #d4e2f3;
  color: #294e85;
  background: #f8fbff;
  box-shadow: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--utility:hover,
[data-toantin-standalone="math_graph"] .tt-mg-btn--utility:focus-visible {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #eef6ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 300px;
  padding: 7px 11px;
  border: 1px solid #d8e5f5;
  border-radius: 11px;
  color: #526781;
  background: #ffffff;
  font-size: 0.76rem;
  font-weight: 680;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status__dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.11);
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status[data-tone="working"] .tt-mg-shell-status__dot {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.11);
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status[data-tone="success"] {
  border-color: #c6eadf;
  color: #087f5b;
  background: #f3fdf9;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status[data-tone="success"] .tt-mg-shell-status__dot {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status[data-tone="error"] {
  border-color: #f3c4ca;
  color: #b42335;
  background: #fff7f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status[data-tone="error"] .tt-mg-shell-status__dot {
  background: #ef3340;
  box-shadow: 0 0 0 4px rgba(239, 51, 64, 0.1);
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad {
  border: 1px solid #dbe7f5;
  border-radius: 12px;
  background: #fbfdff;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad__summary {
  min-height: 40px;
  padding: 9px 11px;
  color: #405675;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 760;
  list-style-position: inside;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad__summary:hover,
[data-toantin-standalone="math_graph"] .tt-mg-keypad__summary:focus-visible {
  color: var(--tt-mg-primary);
  background: #f2f7ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad__summary:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.24);
  outline-offset: 2px;
  border-radius: 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad__content {
  display: grid;
  gap: 11px;
  padding: 0 11px 11px;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-group {
  display: grid;
  gap: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-group__label {
  color: #728399;
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-keys {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-key {
  min-width: 0;
  min-height: 38px;
  padding: 6px 5px;
  border: 1px solid #d4e2f3;
  border-radius: 9px;
  color: #294e85;
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 720;
  box-shadow: 0 1px 4px rgba(16, 42, 86, 0.04);
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-key:hover,
[data-toantin-standalone="math_graph"] .tt-mg-keypad-key:focus-visible {
  border-color: #8db8f2;
  color: #0d5bef;
  background: #eef6ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-keypad-key:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.28);
  outline-offset: 1px;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: min(86vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #cadcf2;
  border-radius: 18px;
  color: var(--tt-mg-text);
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 31, 75, 0.24);
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog::backdrop {
  background: rgba(15, 31, 75, 0.42);
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: inherit;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__header,
[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__footer {
  padding: 18px 20px;
  background: #f8fbff;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__header {
  border-bottom: 1px solid #e2ebf6;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__footer {
  border-top: 1px solid #e2ebf6;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__title {
  color: var(--tt-mg-navy);
  font-size: 1.35rem;
  font-weight: 780;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__lead {
  color: var(--tt-mg-muted);
  font-size: 0.86rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px;
  overflow: auto;
  background: #ffffff;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-section {
  padding: 14px;
  border: 1px solid #dce7f5;
  border-radius: 13px;
  background: #fbfdff;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-section:first-child {
  grid-column: 1 / -1;
  border-color: #bdd7f7;
  background: #f2f7ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-section__title {
  margin: 0 0 7px;
  color: #163b73;
  font-size: 0.92rem;
  font-weight: 780;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-section__body,
[data-toantin-standalone="math_graph"] .tt-mg-help-steps {
  color: #526781;
  font-size: 0.8rem;
  line-height: 1.62;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-steps {
  display: grid;
  gap: 5px;
  padding-left: 1.2rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 1px solid #cfdeef;
  border-radius: 11px;
  color: #405675;
  background: #ffffff;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-icon-btn:focus-visible {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #eef6ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-btn:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.25);
  outline-offset: 2px;
}

/* Teaching Mode chỉ đổi surface bố cục; canonical state và Tool Core vẫn giữ nguyên. */
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-expression-column,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-tools-column {
  display: none;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-column {
  width: 100%;
  flex: 0 0 100%;
  max-width: 100%;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-card {
  min-height: 720px;
  border-color: #9ec5f5;
  box-shadow: 0 16px 42px rgba(22, 103, 232, 0.13);
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-function-label {
  font-size: 1rem;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-hint,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-viewport-inline,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-switch {
  font-size: 0.88rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen {
  width: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog__content {
    grid-template-columns: 1fr;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-help-section:first-child {
    grid-column: auto;
  }
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-utility-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-utility-actions .tt-mg-btn--utility {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell-status {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    min-height: 44px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-keypad__summary,
  [data-toantin-standalone="math_graph"] .tt-mg-keypad-key {
    min-height: 44px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-keypad-keys {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog {
    width: calc(100% - 16px);
    max-height: 92vh;
    border-radius: 15px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog__header,
  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog__footer,
  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog__content {
    padding: 14px;
  }

  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-graph-card {
    min-height: 560px;
  }
}

@media (max-width: 389.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-keypad-keys {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  [data-toantin-standalone="math_graph"] .tt-mg-utility-actions {
    grid-template-columns: 1fr 1fr;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-utility-actions .tt-mg-btn--utility span {
    font-size: 0.78rem;
  }
}

@media (min-width: 1400px) {
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-shell {
    width: min(1720px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-keypad-key,
  [data-toantin-standalone="math_graph"] .tt-mg-shell-status,
  [data-toantin-standalone="math_graph"] .tt-mg-help-dialog {
    transition: none;
  }
}

/* A7 — Focus keyboard rõ trên canvas, không phụ thuộc hover. */
[data-toantin-standalone="math_graph"] .tt-mg-canvas:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.5);
  outline-offset: -3px;
}

/* A9 / V1.1 — Owner refinement. Chỉ scope trong standalone root. */
[data-toantin-standalone="math_graph"] .tt-mg-brand__logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(22, 103, 232, 0.14));
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-note {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #d8e5f5;
  border-radius: 999px;
  color: #526883;
  background: #f8fbff;
  font-size: 0.78rem;
  font-weight: 720;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-note__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.11);
}

[data-toantin-standalone="math_graph"] .tt-mg-actionbar {
  padding: 8px;
  border: 1px solid var(--tt-mg-border);
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.96);
  box-shadow: 0 4px 18px rgba(16, 42, 86, 0.04);
}

[data-toantin-standalone="math_graph"] .tt-mg-actionbar__group {
  align-items: center;
  padding-right: 8px;
  border-right: 1px solid #dfe9f5;
}

[data-toantin-standalone="math_graph"] .tt-mg-actionbar__group:last-of-type {
  padding-right: 0;
  border-right: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #cbdcf2;
  border-radius: 11px;
  color: var(--tt-mg-navy);
  background: #fff;
  box-shadow: 0 2px 8px rgba(16, 42, 86, 0.04);
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-icon-action:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-icon-action[aria-pressed="true"] {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #edf5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-action:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-icon-action svg,
[data-toantin-standalone="math_graph"] .tt-mg-panel-collapse svg,
[data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail svg,
[data-toantin-standalone="math_graph"] .tt-mg-add-function svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-main-layout {
  display: grid;
  grid-template-columns: minmax(260px, 318px) minmax(0, 1fr) minmax(280px, 332px);
  gap: 16px;
  min-height: 650px;
  align-items: stretch;
  transition: grid-template-columns 180ms ease;
}

[data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
  grid-template-columns: 52px minmax(0, 1fr) minmax(280px, 332px);
}

[data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
  grid-template-columns: minmax(260px, 318px) minmax(0, 1fr) 52px;
}

[data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout {
  grid-template-columns: 52px minmax(0, 1fr) 52px;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column {
  display: block;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-side-body,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-side-header {
  display: none;
}

[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-collapsed-rail {
  display: flex;
}

[data-toantin-standalone="math_graph"] .tt-mg-side-column,
[data-toantin-standalone="math_graph"] .tt-mg-graph-column {
  min-width: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel {
  position: relative;
  height: 100%;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-side-header {
  min-height: 44px;
}

[data-toantin-standalone="math_graph"] .tt-mg-panel-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #d3e0f0;
  border-radius: 10px;
  color: #405675;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-panel-collapse:hover,
[data-toantin-standalone="math_graph"] .tt-mg-panel-collapse:focus-visible {
  border-color: #8db8f2;
  color: var(--tt-mg-primary);
  background: #edf5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-radius: 14px;
  color: var(--tt-mg-primary);
  background: linear-gradient(180deg, #f8fbff, #eef5ff);
  font-size: 0.72rem;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.05em;
}

[data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-expression-column .tt-mg-side-header,
[data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-expression-column .tt-mg-side-body,
[data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column .tt-mg-side-header,
[data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column .tt-mg-side-body {
  display: none;
}

[data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-expression-column .tt-mg-collapsed-rail,
[data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column .tt-mg-collapsed-rail {
  display: flex;
}

[data-toantin-standalone="math_graph"] .tt-mg-add-function {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 1px solid #9fc3f5;
  border-radius: 11px;
  color: #0d5bef;
  background: #eef5ff;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-add-function:hover,
[data-toantin-standalone="math_graph"] .tt-mg-add-function:focus-visible {
  border-color: #5f9eec;
  background: #e2efff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-select {
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #dce7f5;
  border-radius: 9px;
  color: #526883;
  background: #f8fbff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 160ms ease;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-toggle::before {
  transform: rotate(-45deg) translate(-1px, 1px);
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-details {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-line-style-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 700;
}

[data-toantin-standalone="math_graph"] .tt-mg-line-style-sample {
  width: 30px;
  border-top: 2px solid currentColor;
}

[data-toantin-standalone="math_graph"] .tt-mg-line-style-sample[data-line-dash="dashed"] { border-top-style: dashed; }
[data-toantin-standalone="math_graph"] .tt-mg-line-style-sample[data-line-dash="dotted"] { border-top-style: dotted; }

[data-toantin-standalone="math_graph"] .tt-mg-inspector-stack {
  display: grid;
  gap: 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-section {
  overflow: hidden;
  border: 1px solid #dce7f5;
  border-radius: 13px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 50px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  color: var(--tt-mg-navy);
  background: #f8fbff;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary::-webkit-details-marker { display: none; }

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-section[open] .tt-mg-inspector-summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary strong,
[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary .tt-mg-section-kicker {
  display: block;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary strong {
  margin-top: 2px;
  font-size: 0.88rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-content {
  padding: 12px;
  border-top: 1px solid #e4edf8;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  cursor: crosshair;
  touch-action: none;
  background: rgba(14, 165, 233, 0.035);
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-selection {
  position: absolute;
  min-width: 40px;
  min-height: 40px;
  border: 2px dashed #0d5bef;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.06);
  box-shadow: 0 0 0 9999px rgba(15, 31, 75, 0.12);
  cursor: move;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0d5bef;
  box-shadow: 0 1px 4px rgba(15, 31, 75, 0.25);
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="n"] { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="e"] { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="s"] { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-capture-handle[data-handle="w"] { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-capture-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid #cfe0f5;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 31, 75, 0.16);
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-export,
[data-toantin-standalone="math_graph"] .tt-mg-capture-cancel {
  min-height: 36px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-export {
  border-color: #1667e8;
  color: #fff;
  background: #1667e8;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-cancel {
  border-color: #d8e5f5;
  color: #526883;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu {
  position: fixed;
  z-index: 20;
  width: min(310px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid #cfe0f5;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 31, 75, 0.2);
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 9px;
  color: var(--tt-mg-navy);
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__section {
  display: grid;
  gap: 6px;
  padding: 8px 4px;
  border-top: 1px solid #edf2f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__label {
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__action {
  min-height: 38px;
  border: 1px solid #d8e5f5;
  border-radius: 9px;
  color: #405675;
  background: #f8fbff;
  font-size: 0.76rem;
  font-weight: 760;
  text-align: left;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__action:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__action.is-active {
  border-color: #8db8f2;
  color: #0d5bef;
  background: #edf5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-menu__action.is-danger {
  color: #c52736;
  background: #fff7f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-context-color {
  width: 100%;
  min-height: 38px;
  padding: 4px;
  border: 1px solid #d8e5f5;
  border-radius: 9px;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker-list {
  display: grid;
  gap: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid #dce7f5;
  border-radius: 10px;
  background: #f8fbff;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7c3aed;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker[data-kind="extremum"] .tt-mg-analysis-marker__dot { background: #10b981; }
[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker[data-kind="inflection"] .tt-mg-analysis-marker__dot { background: #f59e0b; }

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker__coord {
  min-width: 0;
  color: #405675;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker__remove {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #f0d1d5;
  border-radius: 8px;
  color: #c52736;
  background: #fff;
  font-size: 1rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-brand-row {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-header {
  padding-top: 0;
  padding-bottom: 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-main-layout {
  min-height: calc(100vh - 96px);
}

@media (min-width: 768px) and (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }

  [data-toantin-standalone="math_graph"] .tt-mg-tools-column {
    grid-column: 1 / -1;
  }

  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: 1 / -1;
    min-height: 52px;
  }
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] {
    padding: 10px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    padding: 12px;
    border-radius: 16px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-brand__logo {
    width: 48px;
    height: 48px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-actionbar,
  [data-toantin-standalone="math_graph"] .tt-mg-actionbar__group {
    width: 100%;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-actionbar__group {
    padding-right: 0;
    padding-bottom: 7px;
    border-right: 0;
    border-bottom: 1px solid #dfe9f5;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-actionbar__icons {
    width: auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout {
    grid-template-columns: 1fr;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-column { grid-row: 1; }
  [data-toantin-standalone="math_graph"] .tt-mg-expression-column { grid-row: 2; }
  [data-toantin-standalone="math_graph"] .tt-mg-tools-column { grid-row: 3; grid-column: 1; }

  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-expression-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    min-height: 52px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail {
    flex-direction: row;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail span {
    writing-mode: horizontal-tb;
    transform: none;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-context-menu {
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-height: 70vh;
    overflow: auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-capture-actions {
    top: 8px;
    right: 8px;
    max-width: calc(100% - 16px);
  }
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-actionbar__group:not(.tt-mg-actionbar__icons) .tt-mg-btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 46px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-compact-field {
    width: 100%;
    justify-content: space-between;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-icon-action,
  [data-toantin-standalone="math_graph"] .tt-mg-panel-collapse,
  [data-toantin-standalone="math_graph"] .tt-mg-expression-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-capture-export,
  [data-toantin-standalone="math_graph"] .tt-mg-capture-cancel,
  [data-toantin-standalone="math_graph"] .tt-mg-context-menu__action {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"] .tt-mg-expression-toggle::before,
  [data-toantin-standalone="math_graph"] .tt-mg-inspector-summary::after {
    transition: none;
  }
}

/* A10 / V1.1.1 — Full-page fluid workspace + fullscreen teaching layout. */
@media (min-width: 1200px) {
  [data-toantin-standalone="math_graph"] {
    width: 100%;
    height: 100dvh;
    min-height: 720px;
    padding: 14px;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    display: flex;
    width: 100%;
    height: calc(100dvh - 28px);
    min-height: 692px;
    max-width: none;
    margin: 0;
    flex-direction: column;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-header,
  [data-toantin-standalone="math_graph"] .tt-mg-a2-note {
    flex: 0 0 auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout {
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    height: 100%;
    min-height: 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    display: flex;
    flex-direction: column;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    overscroll-behavior: contain;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap {
    display: flex;
    min-height: 0;
    flex: 1 1 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"],
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"] {
    display: flex;
    flex-direction: column;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-a2-note {
    margin-top: 8px;
    padding-block: 7px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding: 10px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-brand-row {
    display: none;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-header {
    padding: 0 0 8px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-main-layout {
    min-height: 0;
    flex: 1 1 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-a2-note {
    display: none;
  }
}

[data-toantin-standalone="math_graph"] .tt-mg-actionbar__home {
  padding-right: 8px;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker__coord {
  cursor: grab;
}

[data-toantin-standalone="math_graph"] .tt-mg-analysis-marker__coord:active {
  cursor: grabbing;
}


/* A11.1 / V1.1.2 — TRUE VIEWPORT-FILL WORKSPACE.
   Mục tiêu: Standalone dùng toàn bộ phần màn hình khả dụng ở mọi laptop/desktop,
   không chỉ viewport >=1200px. Graph stage luôn nhận toàn bộ chiều rộng + chiều cao
   còn lại sau header/toolbar/note; không dùng aspect-ratio hoặc height suy từ width. */
[data-toantin-standalone="math_graph"] {
  width: 100%;
  min-height: 100dvh;
  padding: clamp(8px, 1.15vw, 14px);
}

[data-toantin-standalone="math_graph"] .tt-mg-shell {
  width: 100%;
  max-width: none;
  margin: 0;
}

@media (min-width: 768px) {
  [data-toantin-standalone="math_graph"] {
    display: flex;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    display: flex;
    height: 100%;
    min-height: 0;
    padding: clamp(10px, 1vw, 14px);
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-header,
  [data-toantin-standalone="math_graph"] .tt-mg-a2-note {
    flex: 0 0 auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout {
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    height: 100%;
    min-height: 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    display: flex;
    flex-direction: column;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    overscroll-behavior: contain;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-card__top,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
    flex: 0 0 auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap {
    display: flex;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"],
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"] {
    display: flex;
    flex-direction: column;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-a2-note {
    margin-top: 6px;
    padding-block: 5px;
  }
}

/* Từ laptop phổ biến 992px trở lên, giữ đúng mô hình 3 cột để panel phải không rơi xuống
   hàng dưới và lấy mất chiều cao của graph. */
@media (min-width: 992px) and (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout {
    grid-template-columns: minmax(220px, 270px) minmax(0, 1fr) minmax(240px, 290px);
    grid-template-rows: minmax(0, 1fr);
  }

  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 52px minmax(0, 1fr) minmax(240px, 290px);
  }

  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: minmax(220px, 270px) minmax(0, 1fr) 52px;
  }

  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-tools-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: auto;
    grid-row: auto;
    min-height: 0;
  }
}

/* Mobile vẫn graph-first và cuộn được; graph không bị ép về một khung thấp. */
@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    width: 100%;
    max-width: none;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    min-height: max(430px, 62dvh);
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap,
  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"],
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    width: 100%;
    min-width: 0;
  }
}

/* A11.2 / V1.1.3 — Workspace & UI polish completion.
   Brand/header là một khối độc lập có thể thu gọn. Fullscreen chỉ ẩn brand,
   giữ toolbar + hai sidebar; Focus Graph thu phần phụ để ưu tiên graph. */
[data-toantin-standalone="math_graph"] .tt-mg-brand-panel {
  flex: 0 0 auto;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--tt-mg-border);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(248, 251, 255, 0.98), rgba(255, 255, 255, 0.98));
  box-shadow: 0 4px 16px rgba(16, 42, 86, 0.04);
  transition: padding 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-tools {
  flex: 0 0 auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-compact {
  display: none;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-compact__identity {
  color: var(--tt-mg-navy);
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-compact__logo {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
}

[data-toantin-standalone="math_graph"].is-brand-collapsed .tt-mg-brand-panel {
  padding: 5px 8px 5px 10px;
  border-color: #dfe9f5;
  box-shadow: 0 2px 10px rgba(16, 42, 86, 0.035);
}

[data-toantin-standalone="math_graph"].is-brand-collapsed .tt-mg-brand-expanded {
  display: none;
}

[data-toantin-standalone="math_graph"].is-brand-collapsed .tt-mg-brand-compact {
  display: flex;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-toggle {
  flex: 0 0 auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell {
  flex: 0 0 auto;
  min-width: 0;
  margin-bottom: 8px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  padding: 7px 8px;
}

[data-toantin-standalone="math_graph"] .tt-mg-actionbar__icons {
  padding-right: 0;
  border-right: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-btn--focus[aria-pressed="true"] {
  border-color: #7aaaf0;
  color: #0d5bef;
  background: #eaf3ff;
  box-shadow: inset 0 0 0 1px rgba(22, 103, 232, 0.08);
}

[data-toantin-standalone="math_graph"] .tt-mg-usage-tip {
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 0;
  border: 1px solid #dfe9f5;
  border-radius: 10px;
  background: #f8fbff;
  color: #526883;
  font-size: 0.78rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-usage-tip summary {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  cursor: pointer;
  list-style: none;
  color: #405675;
  user-select: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-usage-tip summary::-webkit-details-marker {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-usage-tip > span:last-child {
  display: block;
  padding: 0 9px 7px 30px;
  line-height: 1.45;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-card,
[data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel {
  box-shadow: 0 5px 18px rgba(16, 42, 86, 0.045);
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-section {
  box-shadow: none;
}

/* Focus mode không thay canonical graph state; chỉ thu chrome Standalone. */
[data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-a2-note {
  display: none;
}

[data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-graph-card__top > .tt-mg-hint:last-child {
  display: none;
}

/* Fullscreen semantics A11.2: header/branding biến mất hoàn toàn.
   Toolbar và hai sidebar vẫn ở lại, sidebar tiếp tục thu/mở độc lập. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-brand-panel {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  display: block;
  flex: 0 0 auto;
  margin-bottom: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-a2-note {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-graph-card__top > .tt-mg-hint:last-child {
  display: none;
}

@media (min-width: 768px) {
  [data-toantin-standalone="math_graph"] .tt-mg-brand-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell,
  [data-toantin-standalone="math_graph"] .tt-mg-a2-note {
    flex-shrink: 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen {
    display: flex;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 8px;
    border-radius: 0;
    flex-direction: column;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-main-layout {
    min-height: 0;
    flex: 1 1 0;
  }
}

@media (min-width: 992px) {
  [data-toantin-standalone="math_graph"] .tt-mg-brand-row {
    min-height: 64px;
  }

  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
  }
}

@media (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-brand-panel {
    padding: 8px 10px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-brand__logo {
    width: 48px;
    height: 48px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-title {
    font-size: clamp(1.35rem, 4vw, 1.8rem);
  }
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-brand-panel {
    margin-bottom: 6px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell {
    margin-bottom: 6px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-brand-compact {
    min-height: 44px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-usage-tip summary {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-brand-panel {
    transition: none;
  }
}

/* Focus Graph ưu tiên tuyệt đối diện tích graph từ tablet trở lên. */
@media (min-width: 768px) and (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    grid-template-rows: minmax(0, 1fr);
  }

  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-tools-column {
    grid-column: auto;
    grid-row: auto;
    min-height: 0;
  }
}

/* A11.3 / V1.1.4 — NORMAL MODE AUTO-HEIGHT + RELIABLE INSPECTOR ACCORDION.
   Chế độ thường không còn là viewport bị khóa: trang được phép cao theo nội dung,
   browser cuộn tự nhiên, còn graph luôn có min-height bằng phần màn hình còn trống.
   Fullscreen vẫn là viewport cố định để phục vụ trình chiếu. */
[data-toantin-standalone="math_graph"] .tt-mg-inspector-section:not([open]) > .tt-mg-inspector-content {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-section[open] > .tt-mg-inspector-content {
  display: block;
}

[data-toantin-standalone="math_graph"] .tt-mg-inspector-summary[aria-expanded="true"] {
  background: #f4f9ff;
}

@media (min-width: 768px) {
  /* Normal mode: min-height theo viewport nhưng height là auto để nội dung có thể nở xuống. */
  [data-toantin-standalone="math_graph"] {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell {
    display: flex;
    height: auto;
    min-height: calc(100dvh - 28px);
    overflow: visible;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    height: auto;
    min-height: var(--tt-mg-normal-workspace-min-height, 620px);
    flex: 0 0 auto;
    overflow: visible;
    align-items: stretch;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column {
    display: flex;
    height: auto;
    min-height: var(--tt-mg-normal-workspace-min-height, 620px);
    align-self: stretch;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    width: 100%;
    height: auto;
    min-height: 100%;
    flex: 1 1 auto;
    overflow: visible;
  }

  /* Sidebar ở mode thường không tự tạo "cửa sổ cuộn bên trong cửa sổ".
     Khi section/biểu thức dài, chính document sẽ dài ra và scroll theo browser. */
  [data-toantin-standalone="math_graph"] .tt-mg-side-body {
    min-height: auto;
    flex: 0 0 auto;
    overflow: visible;
    overscroll-behavior: auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-card {
    display: flex;
    flex-direction: column;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap {
    width: 100%;
    height: auto;
    min-height: var(--tt-mg-normal-graph-min-height, 520px);
    flex: 1 1 auto;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-host > [data-toantin-tool="math_graph"],
  [data-toantin-standalone="math_graph"] .tt-mg-workspace {
    width: 100%;
    height: 100%;
    min-height: var(--tt-mg-normal-graph-min-height, 520px);
  }

  /* Fullscreen là ngoại lệ có chủ đích: khóa vào viewport và cho sidebar scroll nội bộ. */
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-main-layout {
    height: auto;
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-side-column,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-side-column .tt-mg-panel,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-graph-card {
    height: 100%;
    min-height: 0;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-side-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    overscroll-behavior: contain;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-graph-stage-wrap,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-host,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-host > [data-toantin-tool="math_graph"],
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-workspace {
    height: 100%;
    min-height: 0;
  }
}

/* A11.4 / V1.1.5 — SPACE-OPTIMIZED GRAPH-FIRST UI + SCALE-PRESERVING RESIZE.
   Mọi chrome được nén có chủ đích để ưu tiên graph. Toolbar luôn một hàng icon-only;
   container resize chỉ làm lộ thêm miền nhìn, không tự thay đổi tỷ lệ đồ thị. */
[data-toantin-standalone="math_graph"] .tt-mg-brand-panel {
  margin-bottom: 6px;
  padding: 7px 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-row {
  min-height: 52px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand__logo {
  width: 44px;
  height: 44px;
}

[data-toantin-standalone="math_graph"] .tt-mg-subtitle {
  margin-top: 3px;
  font-size: 0.74rem;
}

[data-toantin-standalone="math_graph"].is-brand-collapsed .tt-mg-brand-panel {
  padding: 3px 7px 3px 9px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-compact {
  min-height: 34px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-compact__logo {
  width: 26px;
  height: 26px;
}

[data-toantin-standalone="math_graph"] .tt-mg-brand-toggle {
  width: 34px;
  height: 34px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell {
  margin-bottom: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  display: flex;
  min-height: 42px;
  padding: 3px 5px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  overscroll-behavior-inline: contain;
  background: #fbfdff;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"] .tt-mg-icon-action.tt-mg-toolbar-action {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  flex: 0 0 36px;
  border-radius: 9px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-action svg {
  width: 17px;
  height: 17px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-separator {
  width: 1px;
  height: 22px;
  margin-inline: 2px;
  flex: 0 0 1px;
  background: #dce7f5;
}

[data-toantin-standalone="math_graph"] .tt-mg-angle-action {
  position: relative;
}

[data-toantin-standalone="math_graph"] .tt-mg-angle-mode-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  min-width: 13px;
  padding: 0 2px;
  border-radius: 5px;
  color: #0d5bef;
  background: #eaf3ff;
  font-size: 0.56rem;
  font-weight: 900;
  line-height: 13px;
  text-align: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status {
  position: sticky;
  right: 0;
  z-index: 2;
  min-height: 30px;
  max-width: 180px;
  padding: 4px 8px;
  flex: 0 0 auto;
  gap: 6px;
  border-radius: 9px;
  box-shadow: -8px 0 10px #fbfdff;
  font-size: 0.7rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell-status__dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-card__top {
  min-height: 38px;
  padding: 5px 9px;
  flex-wrap: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip {
  overflow: hidden;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-active-function-source {
  min-width: 0;
  max-width: min(38vw, 360px);
  color: #70839f;
  font-family: inherit;
  font-size: 0.7rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-hud {
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid #dce7f5;
  border-radius: 10px;
  background: rgba(248, 251, 255, 0.96);
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-hud__label {
  padding-inline: 6px 3px;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-hud-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #36577f;
  background: transparent;
}

[data-toantin-standalone="math_graph"] .tt-mg-hud-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-hud-action:focus-visible {
  color: var(--tt-mg-primary);
  background: #eaf3ff;
  outline: 2px solid rgba(56, 189, 248, 0.25);
  outline-offset: 1px;
}

[data-toantin-standalone="math_graph"] .tt-mg-hud-action svg,
[data-toantin-standalone="math_graph"] .tt-mg-status-tip svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
  min-height: 34px;
  padding: 4px 9px;
  flex-wrap: nowrap;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-viewport-inline {
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 4px 10px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.69rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-status-tip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 7px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  color: #526883;
  background: transparent;
  font-size: 0.69rem;
  font-weight: 700;
}

[data-toantin-standalone="math_graph"] .tt-mg-status-tip:hover,
[data-toantin-standalone="math_graph"] .tt-mg-status-tip:focus-visible {
  color: var(--tt-mg-primary);
  background: #edf5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-footer-switches {
  flex: 0 0 auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-switch {
  font-size: 0.7rem;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-collapsed-rail {
  gap: 6px;
  padding: 6px 2px;
  border-radius: 10px;
  font-size: 0.64rem;
}

@media (min-width: 992px) {
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px minmax(0, 1fr) minmax(280px, 332px);
  }

  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: minmax(260px, 318px) minmax(0, 1fr) 36px;
  }

  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px minmax(0, 1fr) minmax(240px, 290px);
  }

  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: minmax(220px, 270px) minmax(0, 1fr) 36px;
  }

  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }
}

@media (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-hud__label {
    display: none;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-active-function-source {
    max-width: 30vw;
  }
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-action,
  [data-toantin-standalone="math_graph"] .tt-mg-icon-action.tt-mg-toolbar-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-basis: 44px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
    min-height: 50px;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell-status__text,
  [data-toantin-standalone="math_graph"] .tt-mg-status-tip span,
  [data-toantin-standalone="math_graph"] .tt-mg-switch .form-check-label,
  [data-toantin-standalone="math_graph"] .tt-mg-active-function-source {
    display: none;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-shell-status {
    min-width: 30px;
    width: 30px;
    padding: 0;
    justify-content: center;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-status-tip {
    width: 30px;
    padding: 0;
    justify-content: center;
  }

  [data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
    gap: 5px;
  }
}

/* A12 / V1.2.0 — UNIFIED INTERACTION & OBJECT PROPERTIES.
   Standalone fallback chrome only; integrated mode vẫn để Host sở hữu toolbar/window chrome. */
[data-toantin-standalone="math_graph"] .tt-mg-floating-window {
  position: absolute;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100% - 16px));
  height: min(560px, calc(100% - 16px));
  min-width: 300px;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid #cbdcf1;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 42, 86, 0.2);
}

[data-toantin-standalone="math_graph"] .tt-mg-floating-window[hidden] { display: none; }

[data-toantin-standalone="math_graph"] .tt-mg-floating-window__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid #dce7f5;
  background: #f8fbff;
  cursor: move;
  user-select: none;
  touch-action: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-floating-window__title {
  margin: 1px 0 0;
  color: var(--tt-mg-navy);
  font-size: 0.98rem;
  font-weight: 800;
}

[data-toantin-standalone="math_graph"] .tt-mg-floating-window__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

[data-toantin-standalone="math_graph"] .tt-mg-window-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #36577f;
  background: transparent;
}

[data-toantin-standalone="math_graph"] .tt-mg-window-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-window-action:focus-visible {
  border-color: #bfd5f1;
  color: var(--tt-mg-primary);
  background: #eaf3ff;
  outline: 2px solid rgba(56, 189, 248, 0.25);
}

[data-toantin-standalone="math_graph"] .tt-mg-window-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-floating-window__content {
  min-height: 0;
  padding: 12px;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
}

[data-toantin-standalone="math_graph"] .tt-mg-floating-window.is-maximized {
  border-radius: 12px;
}

[data-toantin-standalone="math_graph"] .tt-mg-window-resize {
  position: absolute;
  z-index: 2;
  touch-action: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--n { top: -3px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--s { bottom: -3px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--e { top: 12px; right: -3px; bottom: 12px; width: 8px; cursor: ew-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--w { top: 12px; left: -3px; bottom: 12px; width: 8px; cursor: ew-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--ne,
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--nw,
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--se,
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--sw { width: 16px; height: 16px; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--ne { top: -4px; right: -4px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--nw { top: -4px; left: -4px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--se { right: -4px; bottom: -4px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-window-resize--sw { left: -4px; bottom: -4px; cursor: nesw-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-properties-section + .tt-mg-properties-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e1eaf5;
}

[data-toantin-standalone="math_graph"] .tt-mg-properties-section__title {
  margin: 0 0 8px;
  color: #36577f;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

[data-toantin-standalone="math_graph"] .tt-mg-properties-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-field__label {
  color: #526883;
  font-size: 0.72rem;
  font-weight: 750;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-field__help,
[data-toantin-standalone="math_graph"] .tt-mg-property-note {
  color: #70839f;
  font-size: 0.72rem;
  line-height: 1.45;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-toggle {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #e0e9f5;
  border-radius: 10px;
  background: #fbfdff;
  font-size: 0.76rem;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-color {
  width: 100%;
  min-height: 36px;
}

[data-toantin-standalone="math_graph"] .tt-mg-properties-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-danger {
  min-height: 38px;
  border: 1px solid #fecdd3;
  color: #be123c;
  background: #fff7f8;
  font-size: 0.76rem;
  font-weight: 750;
}

[data-toantin-standalone="math_graph"] .tt-mg-property-danger:hover,
[data-toantin-standalone="math_graph"] .tt-mg-property-danger:focus-visible {
  border-color: #fb7185;
  color: #9f1239;
  background: #fff1f2;
}

[data-toantin-standalone="math_graph"] .tt-mg-help-dialog__footer {
  flex: 0 0 auto;
  padding: 8px 12px 10px;
  border-top: 1px solid #e1eaf5;
  background: #fbfdff;
}

[data-toantin-standalone="math_graph"] .tt-mg-range-axis {
  position: relative;
  display: flex;
  min-height: 18px;
  margin: 1px 4px 5px;
  justify-content: space-between;
  color: #70839f;
  font-size: 0.62rem;
  line-height: 1;
}

[data-toantin-standalone="math_graph"] .tt-mg-range-axis::before {
  position: absolute;
  top: 3px;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: #d9e5f3;
}

[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick {
  position: relative;
  padding-top: 8px;
  min-width: 14px;
  text-align: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 6px;
  content: "";
  background: #9fb4cf;
}

[data-toantin-standalone="math_graph"] .tt-mg-xy-finder {
  padding: 8px;
  border: 1px solid #dfe9f5;
  border-radius: 10px;
  background: #f8fbff;
}

[data-toantin-standalone="math_graph"] .tt-mg-xy-finder__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-xy-finder__result {
  min-height: 18px;
  margin-top: 5px;
  color: #64748b;
  font-size: 0.66rem;
  line-height: 1.35;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell {
  position: relative;
  z-index: 30;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-right: 1px solid #dce7f5;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #526883;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn[aria-pressed="true"] {
  border-color: #c5d9f1;
  color: var(--tt-mg-primary);
  background: #eaf3ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"].is-toolbar-floating .tt-mg-toolbar-shell {
  position: absolute;
  z-index: 35;
  width: max-content;
  max-width: calc(100% - 8px);
  margin: 0;
  border: 1px solid #cbdcf1;
  border-radius: 12px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 12px 34px rgba(15, 42, 86, .16);
}

[data-toantin-standalone="math_graph"].is-toolbar-floating .tt-mg-toolbar-grip { cursor: move; touch-action: none; }

[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell .tt-mg-actionbar,
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-chrome {
  flex-direction: column;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell {
  width: 48px;
  max-height: calc(100% - 8px);
  overflow-y: auto;
  overflow-x: hidden;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-chrome { border-right: 0; border-bottom: 1px solid #dce7f5; }
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell .tt-mg-actionbar { overflow: visible; }
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-separator { width: 24px; height: 1px; min-height: 1px; }

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell .tt-mg-actionbar { display: none; }
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell { width: max-content; }

[data-toantin-standalone="math_graph"].is-point-create-mode .tt-mg-host canvas { cursor: crosshair; }

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-floating-window {
    min-width: 0;
    width: calc(100% - 8px);
    max-width: none;
    min-height: 240px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-properties-grid { grid-template-columns: 1fr; }
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn { width: 40px; height: 40px; }
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  display: flex;
  align-items: stretch;
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar { flex: 1 1 auto; min-width: 0; }
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell { display: flex; align-items: center; }
[data-toantin-standalone="math_graph"] .tt-mg-shell { position: relative; }
[data-toantin-standalone="math_graph"] .tt-mg-range-axis { display: block; }
[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-window { container-type: inline-size; }
@container (max-width: 380px) {
  [data-toantin-standalone="math_graph"] .tt-mg-properties-grid { grid-template-columns: 1fr; }
  [data-toantin-standalone="math_graph"] .tt-mg-properties-actions { flex-direction: column; }
}

/* === A13 — toolbar collapse/pin + guided function construction === */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-collapsed-launcher,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-collapsed-launcher {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #bdd3ee;
  border-radius: 9px;
  color: var(--tt-mg-primary);
  background: #f4f8ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-collapsed-launcher svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}
[data-toantin-standalone="math_graph"].is-toolbar-pinned .tt-mg-toolbar-grip {
  cursor: not-allowed;
  opacity: .5;
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell {
  position: relative;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  overflow: visible;
  align-items: center;
  justify-content: center;
  padding: 3px;
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-collapsed-launcher { display: inline-flex; }
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-chrome,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell .tt-mg-actionbar { display: none; }
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open .tt-mg-toolbar-chrome {
  position: absolute;
  z-index: 2;
  top: calc(100% + 5px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 32px);
  gap: 3px;
  padding: 5px;
  border: 1px solid #cadcf1;
  border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,.99);
  box-shadow: 0 12px 28px rgba(15,42,86,.15);
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open .tt-mg-toolbar-shell .tt-mg-actionbar {
  position: absolute;
  z-index: 3;
  top: calc(100% + 45px);
  left: 0;
  display: grid;
  grid-template-rows: repeat(2, 34px);
  grid-auto-flow: column;
  grid-auto-columns: 34px;
  gap: 3px;
  width: max-content;
  max-width: min(92vw, 390px);
  padding: 6px;
  overflow-x: auto;
  border: 1px solid #cadcf1;
  border-radius: 0 10px 10px 10px;
  background: rgba(255,255,255,.99);
  box-shadow: 0 14px 30px rgba(15,42,86,.16);
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open .tt-mg-shell-status,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open .tt-mg-toolbar-separator { display: none; }
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open.is-toolbar-vertical .tt-mg-toolbar-chrome {
  top: 0;
  left: calc(100% + 5px);
  grid-template-columns: repeat(2, 32px);
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open.is-toolbar-vertical .tt-mg-toolbar-shell .tt-mg-actionbar {
  top: 0;
  left: calc(100% + 79px);
  grid-template-columns: repeat(2, 34px);
  grid-template-rows: none;
  grid-auto-flow: row;
  grid-auto-rows: 34px;
  max-height: min(82vh, 360px);
  max-width: none;
  overflow-y: auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-add-function-wrap { position: relative; }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu {
  position: absolute;
  z-index: 26;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  padding: 8px;
  border: 1px solid #cbdcf1;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15,42,86,.14);
}
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__title {
  margin: 1px 4px 7px;
  color: #56708f;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 5px;
}
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid .btn,
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__custom {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 50px;
  padding: 7px 9px;
  border: 1px solid #d9e5f3;
  border-radius: 9px;
  color: #17375f;
  background: #f8fbff;
  text-align: left;
}
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid .btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid .btn:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__custom:hover,
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__custom:focus-visible {
  border-color: #8fb8ee;
  background: #edf5ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu small { color: #667b96; font-size: .67rem; }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__custom { width: 100%; margin-top: 5px; }

[data-toantin-standalone="math_graph"] .tt-mg-construction-builder {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #c8dcf4;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f3f8ff);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-title { margin: 2px 0 3px; font-size: .91rem; color: #102a56; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-formula { color: #0d5bef; font-size: .76rem; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-close {
  width: 30px; height: 30px; padding: 0; border-radius: 8px; color: #61758f; background: #fff; border: 1px solid #d6e3f1;
}
[data-toantin-standalone="math_graph"] .tt-mg-coefficient-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 5px;
  margin-bottom: 9px;
}
[data-toantin-standalone="math_graph"] .tt-mg-coefficient-field span { display: block; margin-bottom: 2px; color: #526883; font-size: .68rem; font-weight: 800; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table-wrap { overflow-x: auto; border: 1px solid #dbe7f4; border-radius: 9px; background: #fff; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table { width: 100%; min-width: 250px; border-collapse: collapse; font-size: .72rem; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table th,
[data-toantin-standalone="math_graph"] .tt-mg-construction-table td { padding: 5px; border-right: 1px solid #e5edf7; border-bottom: 1px solid #e5edf7; text-align: center; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table th { color: #17375f; background: #f5f9ff; font-weight: 850; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table input { min-width: 68px; text-align: center; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table input:disabled { opacity: 1; color: #405a78; background: #edf3fa; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-solution { min-width: 120px; margin-top: 4px; font-size: .66rem; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-notes { margin-top: 7px; color: #5e728c; font-size: .68rem; line-height: 1.4; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-error { margin-bottom: 7px; padding: 7px 8px; border: 1px solid #f3c2c7; border-radius: 8px; color: #9f2331; background: #fff4f5; font-size: .7rem; }

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid { grid-template-columns: 1fr; }
  [data-toantin-standalone="math_graph"] .tt-mg-coefficient-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  [data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-collapsed-open .tt-mg-toolbar-shell .tt-mg-actionbar { max-width: 86vw; }
}

/* === A14 / PATCH_01 — toolbar reflow, footer status, construction readability === */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  --tt-mg-toolbar-cols: 7;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  width: min(500px, 100%);
  min-width: min(360px, calc(100% - 8px));
  height: 88px;
  min-height: 82px;
  overflow: hidden;
  border: 1px solid #d7e3f2;
  border-radius: 12px;
  background: rgba(255,255,255,.98);
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome {
  display: grid;
  grid-template-columns: repeat(5, 30px);
  grid-auto-rows: 30px;
  align-content: center;
  gap: 3px;
  padding: 6px;
  border-right: 1px solid #dce7f5;
  border-bottom: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  display: grid;
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), minmax(34px, 1fr));
  grid-auto-rows: 34px;
  align-content: center;
  justify-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 7px 8px;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  margin: 0;
  justify-self: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-separator {
  display: none;
}

/* Launcher A13 chỉ giữ để backward patch parity; A14 collapse dùng đúng ba control chrome. */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-collapsed-launcher,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-collapsed-launcher {
  display: none;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-vertical .tt-mg-toolbar-shell {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 108px;
  min-width: 108px;
  max-width: 108px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  padding: 3px;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-chrome,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-vertical .tt-mg-toolbar-chrome {
  position: static;
  display: grid;
  grid-template-columns: repeat(3, 32px);
  grid-template-rows: 32px;
  gap: 2px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  justify-content: space-between;
  gap: 5px;
}
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
  display: inline-flex;
  flex: 0 0 36px;
  margin: 0;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed #toolbar-orientation,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed #toolbar-reset-position,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell .tt-mg-actionbar {
  display: none;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed #toolbar-collapse svg {
  transform: rotate(180deg);
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  width: 118px;
  min-width: 96px;
  max-width: min(220px, calc(100% - 8px));
  min-height: 190px;
  max-height: calc(100% - 8px);
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(3, 30px);
  justify-content: center;
  border-right: 0;
  border-bottom: 1px solid #dce7f5;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), minmax(34px, 1fr));
  grid-auto-flow: row;
  align-content: start;
  padding: 7px;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle {
  position: absolute;
  z-index: 5;
  display: block;
  touch-action: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom {
  left: 12px;
  right: 12px;
  height: 7px;
  cursor: ns-resize;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top { top: -1px; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom { bottom: -1px; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--left,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--right {
  top: 12px;
  bottom: 12px;
  width: 7px;
  cursor: ew-resize;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--left { left: -1px; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--right { right: -1px; }
[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-resize-handle { display: none; }

[data-toantin-standalone="math_graph"] .tt-mg-footer-status {
  min-width: 0;
  max-width: min(260px, 28vw);
  min-height: 28px;
  padding: 3px 8px;
  flex: 0 1 auto;
  overflow: hidden;
  border-color: transparent;
  background: #f6f9fd;
  white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-footer-status .tt-mg-shell-status__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .min-w-0 {
  flex: 1 1 auto;
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-formula {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid #d8e6f6;
  border-radius: 9px;
  color: #0d4fb8;
  background: #ffffff;
  font-family: inherit;
  font-size: .94rem;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
    grid-template-columns: repeat(var(--tt-mg-toolbar-cols), minmax(44px, 1fr));
    grid-auto-rows: 44px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-footer-status {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    padding: 0;
    justify-content: center;
  }
}

/* === A15 / PATCH_02 — adaptive toolbar + compact professional Property Inspector === */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  min-width: min(360px, calc(100% - 8px));
  min-height: 48px;
  max-height: calc(100% - 8px);
  height: auto;
  overflow: hidden;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), 34px);
  grid-template-rows: repeat(var(--tt-mg-toolbar-rows), 34px);
  grid-auto-rows: 34px;
  align-content: center;
  justify-content: start;
  justify-items: center;
  height: auto;
  min-height: 48px;
  padding: 7px 8px;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  width: auto;
  min-width: 96px;
  height: auto;
  min-height: 190px;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), 34px);
  grid-template-rows: repeat(var(--tt-mg-toolbar-rows), 34px);
  align-content: start;
  justify-content: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-range-axis {
  display: block;
  min-height: 20px;
  margin: 2px 7px 5px;
  overflow: visible;
}
[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick {
  position: absolute;
  top: 0;
  min-width: 0;
  padding-top: 8px;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick:first-child { transform: translateX(0); text-align: left; }
[data-toantin-standalone="math_graph"] .tt-mg-range-axis__tick:last-child { transform: translateX(-100%); text-align: right; }

[data-toantin-standalone="math_graph"] .tt-mg-properties-window {
  width: 286px;
  height: auto;
  min-width: 250px;
  min-height: 220px;
  max-width: min(520px, calc(100% - 12px));
  max-height: min(78vh, calc(100% - 12px));
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(29, 58, 96, .16), 0 2px 8px rgba(29, 58, 96, .08);
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-floating-window__header {
  min-height: 54px;
  padding: 8px 10px 8px 12px;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-section-kicker {
  font-size: .67rem;
  letter-spacing: .055em;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-floating-window__title {
  margin: 2px 0 0;
  color: #102a56;
  font-size: .98rem;
  line-height: 1.2;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-floating-window__actions { gap: 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-window-action {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 6px;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-floating-window__content {
  padding: 10px 12px 12px;
  overflow: auto;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-section + .tt-mg-properties-section {
  margin-top: 9px;
  padding-top: 9px;
  border-top-color: #e6edf6;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-section__title {
  margin-bottom: 6px;
  color: #3e5f85;
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .045em;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-color--compact {
  width: 38px;
  height: 34px;
  min-height: 34px;
  padding: 3px;
  border-radius: 7px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  margin: 0;
  padding: 5px 7px 5px 9px;
  padding-left: 9px;
  border: 1px solid #e4ecf6;
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle__label {
  min-width: 0;
  color: #334d6f;
  font-size: .75rem;
  line-height: 1.25;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle__input.form-check-input {
  float: none;
  flex: 0 0 auto;
  width: 2.05em;
  height: 1.08em;
  margin: 0;
  margin-left: auto;
  border-color: #aebfd5;
  box-shadow: none;
  cursor: pointer;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle__input.form-check-input:checked {
  border-color: #0d6efd;
  background-color: #0d6efd;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-field { gap: 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-property-field__help,
[data-toantin-standalone="math_graph"] .tt-mg-property-note {
  font-size: .68rem;
  line-height: 1.38;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-danger,
[data-toantin-standalone="math_graph"] .tt-mg-property-primary {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .73rem;
  font-weight: 800;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-primary {
  border: 1px solid #bfd6fb;
  color: #0d4fb8;
  background: #f3f8ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-primary:hover,
[data-toantin-standalone="math_graph"] .tt-mg-property-primary:focus-visible {
  border-color: #75a7f5;
  background: #eaf3ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-actions { gap: 5px; }
[data-toantin-standalone="math_graph"] .tt-mg-properties-actions .tt-mg-mini-btn {
  min-height: 32px;
  padding: 4px 7px;
  font-size: .67rem;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-readonly {
  grid-column: 1 / -1;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: .73rem;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
    grid-template-columns: repeat(var(--tt-mg-toolbar-cols), 44px);
    grid-template-rows: repeat(var(--tt-mg-toolbar-rows), 44px);
    grid-auto-rows: 44px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-properties-window {
    width: min(94vw, 330px);
    min-width: min(280px, calc(100% - 12px));
  }
  [data-toantin-standalone="math_graph"] .tt-mg-property-toggle { min-height: 44px; }
  [data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-property-field > .form-control,
  [data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-property-field > .form-select,
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window { container-type: inline-size; }

/* === A16 — pointer modes, point naming, persistence UX === */
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-pointer-mode="select"] { cursor: default; }
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-pointer-mode="pan"] { cursor: grab; }
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-pointer-mode="pan"]:active { cursor: grabbing; }
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-integer-snap="true"] {
  box-shadow: inset 0 0 0 2px rgba(22, 103, 232, .16);
}
[data-toantin-standalone="math_graph"] #pointer-select-action.is-active,
[data-toantin-standalone="math_graph"] #pointer-pan-action.is-active {
  color: #fff;
  border-color: #1667e8;
  background: #1667e8;
  box-shadow: 0 0 0 2px rgba(22, 103, 232, .12);
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-danger:hover,
[data-toantin-standalone="math_graph"] .tt-mg-memory-danger:focus-visible {
  color: #b42318;
  border-color: #fecaca;
  background: #fff1f2;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-name-input {
  min-width: 0;
  height: 34px;
  padding: 4px 8px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-auto-name { white-space: nowrap; }
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 42, 86, .34);
  backdrop-filter: blur(2px);
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog-backdrop[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  width: min(430px, calc(100vw - 28px));
  padding: 18px;
  border: 1px solid #dbe7f4;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 42, 86, .26);
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #b42318;
  background: #fff1f2;
  font-weight: 900;
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__title {
  margin: 0 0 6px;
  color: #102a56;
  font-size: 1.05rem;
  font-weight: 850;
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__copy {
  margin: 0;
  color: #506681;
  font-size: .9rem;
  line-height: 1.5;
}
[data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-memory-dialog { grid-template-columns: 1fr; }
  [data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__actions { flex-direction: column-reverse; }
  [data-toantin-standalone="math_graph"] .tt-mg-memory-dialog__actions .btn { width: 100%; min-height: 44px; }
}

/* A17 — context menu object-scoped, dùng chung cho right-click và long-press. */
[data-toantin-standalone="math_graph"] .tt-mg-context-menu {
  position: absolute;
  z-index: 36;
  min-width: 190px;
  max-width: min(280px, calc(100% - 12px));
  padding: .35rem;
  border: 1px solid #d8e5f5;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 31, 75, .16);
}
[data-toantin-standalone="math_graph"] .tt-mg-context-menu[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: .45rem .65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #102a56;
  font: inherit;
  font-weight: 600;
  text-align: left;
}
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__item:hover,
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__item:focus-visible { background: #eef5ff; outline: 2px solid #60a5fa; outline-offset: -2px; }
[data-toantin-standalone="math_graph"] .tt-mg-context-menu__item.is-danger { color: #ef3340; }
[data-toantin-standalone="math_graph"] canvas[data-direct-transform] { cursor: grabbing; }
[data-toantin-standalone="math_graph"] [data-pointer-mode="select"] .tt-mg-canvas { touch-action: none; }
[data-toantin-standalone="math_graph"] canvas[data-direct-transform] { cursor: grabbing; }

/* === FIX05 — toolbar LCD readability + viewport-safe floating + wheel zoom toggle === */
[data-toantin-standalone="math_graph"].is-toolbar-floating .tt-mg-toolbar-shell {
  position: fixed;
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - 8px);
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), 40px);
  grid-template-rows: repeat(var(--tt-mg-toolbar-rows), 40px);
  grid-auto-rows: 40px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action svg,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action svg {
  width: 21px;
  height: 21px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(5, 36px);
  grid-auto-rows: 36px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn {
  width: 36px;
  height: 36px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-chrome__btn svg {
  width: 18px;
  height: 18px;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-vertical .tt-mg-toolbar-shell {
  width: 122px;
  min-width: 122px;
  max-width: 122px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
}

[data-toantin-standalone="math_graph"].is-toolbar-collapsed .tt-mg-toolbar-chrome,
[data-toantin-standalone="math_graph"].is-toolbar-collapsed.is-toolbar-vertical .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(3, 36px);
  grid-template-rows: 36px;
  gap: 3px;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  width: 132px;
  min-width: 106px;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(3, 36px);
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols), minmax(40px, 1fr));
}

[data-toantin-standalone="math_graph"] .tt-mg-wheel-toggle[aria-pressed="true"],
[data-toantin-standalone="math_graph"] .tt-mg-wheel-toggle.is-active {
  color: #ffffff;
  border-color: #10b981;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, .14);
}

[data-toantin-standalone="math_graph"] .tt-mg-wheel-toggle[aria-pressed="false"] {
  color: #526883;
  background: #ffffff;
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-middle-pan="true"] {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
    grid-template-columns: repeat(var(--tt-mg-toolbar-cols), 46px);
    grid-template-rows: repeat(var(--tt-mg-toolbar-rows), 46px);
    grid-auto-rows: 46px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
  }
}

/* PATCH_08 — graph labels, rich math text, expression ordering and Add Text. */
[data-toantin-standalone="math_graph"] .tt-mg-math-equation,
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation,
[data-toantin-standalone="math_graph"] .tt-mg-active-equation {
  display: inline;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

[data-toantin-standalone="math_graph"] .tt-mg-math-equation sup,
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation sup,
[data-toantin-standalone="math_graph"] .tt-mg-active-equation sup {
  position: relative;
  top: -0.38em;
  margin-left: 1px;
  font-size: 0.7em;
  line-height: 0;
  vertical-align: baseline;
}

[data-toantin-standalone="math_graph"] .tt-mg-math-equation sub,
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation sub,
[data-toantin-standalone="math_graph"] .tt-mg-active-equation sub {
  position: relative;
  top: 0.25em;
  margin-left: 1px;
  font-size: 0.7em;
  line-height: 0;
  vertical-align: baseline;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  grid-template-columns: 30px minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-copy {
  min-width: 0;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-equation {
  display: block;
  overflow: hidden;
  color: #243d65;
  font-size: 0.82rem;
  font-weight: 770;
  text-overflow: ellipsis;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-drag,
[data-toantin-standalone="math_graph"] .tt-mg-expression-order-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #dce7f5;
  border-radius: 8px;
  color: #5b6f8f;
  background: #fff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-drag {
  cursor: grab;
  touch-action: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-drag:active { cursor: grabbing; }

[data-toantin-standalone="math_graph"] .tt-mg-expression-drag svg,
[data-toantin-standalone="math_graph"] .tt-mg-expression-order-btn svg {
  width: 16px;
  height: 16px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-order-actions {
  display: inline-flex;
  gap: 3px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-drag:hover,
[data-toantin-standalone="math_graph"] .tt-mg-expression-drag:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-expression-order-btn:hover:not(:disabled),
[data-toantin-standalone="math_graph"] .tt-mg-expression-order-btn:focus-visible {
  border-color: #9fc3f5;
  color: var(--tt-mg-primary);
  background: #eef5ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-order-btn:disabled {
  cursor: default;
  opacity: 0.32;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-dragging { opacity: 0.55; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-drag-over {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

[data-toantin-standalone="math_graph"].is-text-create-mode .tt-mg-host canvas {
  cursor: crosshair;
}

[data-toantin-standalone="math_graph"] .tt-mg-annotation-text-input {
  min-height: 68px;
  resize: vertical;
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
    grid-template-columns: 30px minmax(0, 1fr) 34px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-expression-order-actions {
    grid-column: 2 / 3;
    justify-self: start;
  }
}

/* PATCH_09 — card hàm tách hàng, selection theo màu graph, inline Text Object. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-item {
  --expression-color: #1667e8;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-selected {
  border-color: var(--expression-color);
  background: #f4f8ff;
  box-shadow: 0 0 0 2px var(--expression-color), 0 9px 22px rgba(15, 31, 75, .10);
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 34px;
  gap: 7px;
  align-items: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-select {
  min-width: 0;
  border: 0;
  background: transparent;
  color: #102a56;
  text-align: left;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-name {
  display: block;
  overflow: hidden;
  font-size: .86rem;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-equation-row {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 7px;
  padding: 6px 8px;
  overflow: hidden;
  border: 1px solid #e2ebf7;
  border-radius: 9px;
  background: #fbfdff;
  color: #163b73;
  text-align: left;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-equation-row:hover,
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation-row:focus-visible {
  border-color: color-mix(in srgb, var(--expression-color) 52%, #dce7f5);
  background: #f4f8ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-equation {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: .84rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-reorder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-reorder-label {
  color: #7a8ba6;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .025em;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-order-actions {
  margin-left: auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-reorder-row {
  display: flex;
}

[data-toantin-standalone="math_graph"] .tt-mg-workspace {
  position: relative;
}

[data-toantin-standalone="math_graph"] .tt-mg-inline-text-editor {
  box-sizing: border-box;
  min-width: 120px;
  min-height: 34px;
  padding: 5px 8px;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 7px 20px rgba(15, 31, 75, .18);
  font-family: inherit;
}

[data-toantin-standalone="math_graph"] .tt-mg-inline-text-editor:focus {
  border-color: #0d5bef;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .18), 0 7px 20px rgba(15, 31, 75, .18);
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-rotate-handle="true"] {
  cursor: grab;
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-rotate-active="true"] {
  cursor: grabbing;
}

/* ================================================================
   T1 / Unified Toolbar & Workspace UI V2
   Scoped Standalone fallback only; Integrated mode keeps Host chrome.
   ================================================================ */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell {
  position: relative;
  overflow: visible;
  --tt-mg-toolbar-cell: 40px;
  --tt-mg-toolbar-gap: 4px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-actionbar {
  display: grid;
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols, 9), var(--tt-mg-toolbar-cell));
  grid-auto-rows: var(--tt-mg-toolbar-cell);
  gap: var(--tt-mg-toolbar-gap);
  width: 100%;
  min-height: 48px;
  padding: 4px 6px;
  align-content: start;
  justify-content: start;
  overflow: hidden;
  background: rgba(248, 251, 255, 0.96);
  backdrop-filter: blur(8px);
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-toolbar-shell .tt-mg-actionbar {
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols, 1), var(--tt-mg-toolbar-cell));
  grid-template-rows: repeat(var(--tt-mg-toolbar-rows, 9), var(--tt-mg-toolbar-cell));
  grid-auto-flow: column;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  flex-basis: 40px;
  border-radius: 10px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action svg {
  width: 21px;
  height: 21px;
}

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-separator {
  align-self: center;
  width: 1px;
  height: 24px;
  margin: 0 1px;
  background: #d9e5f4;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-trigger[aria-expanded="true"] {
  border-color: #77aaf0;
  color: #0d5bef;
  background: #eaf3ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-menu {
  position: absolute;
  z-index: 48;
  top: calc(100% + 8px);
  right: 0;
  width: min(344px, calc(100vw - 28px));
  max-height: min(68vh, 620px);
  padding: 10px;
  overflow: auto;
  border: 1px solid #d6e4f4;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 31, 75, 0.18);
}

[data-toantin-standalone="math_graph"] .tt-mg-more-menu[hidden] { display: none; }

[data-toantin-standalone="math_graph"] .tt-mg-more-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #edf2f8;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-group:last-child { border-bottom: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-more-group h3 {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  color: #526883;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid #dce7f5;
  border-radius: 10px;
  color: #163b73;
  background: #fbfdff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-more-action:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-more-action[aria-pressed="true"] {
  border-color: #8db8f2;
  color: #0d5bef;
  background: #eef6ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-switch {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid #dce7f5;
  border-radius: 10px;
  background: #fbfdff;
  font-size: 0.78rem;
  font-weight: 700;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-secondary .tt-mg-priority-overflow {
  width: 100%;
  height: auto;
  min-height: 40px;
}

[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 6px;
  overflow-x: auto;
  border: 1px solid #d8e5f5;
  border-radius: 11px;
  background: #f4f8ff;
  box-shadow: inset 3px 0 0 #3b82f6;
  scrollbar-width: thin;
}

[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar__label {
  flex: 0 0 auto;
  padding: 0 7px;
  color: #163b73;
  font-size: 0.7rem;
  font-weight: 850;
  white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 5px;
}
[data-toantin-standalone="math_graph"] .tt-mg-context-btn,
[data-toantin-standalone="math_graph"] .tt-mg-context-control {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid #cbdcf2;
  border-radius: 9px;
  color: #163b73;
  background: #fff;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-context-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; }
[data-toantin-standalone="math_graph"] .tt-mg-context-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-context-btn:focus-visible { border-color: #8db8f2; color: #0d5bef; background: #edf5ff; }
[data-toantin-standalone="math_graph"] .tt-mg-context-control[type="color"] { width: 38px; padding: 3px; }
[data-toantin-standalone="math_graph"] select.tt-mg-context-control { padding-right: 24px; }

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-tooltip {
  position: absolute;
  z-index: 52;
  max-width: 250px;
  padding: 6px 9px;
  pointer-events: none;
  border-radius: 8px;
  color: #fff;
  background: #102a56;
  box-shadow: 0 7px 20px rgba(15, 31, 75, 0.22);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.35;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-tooltip[hidden] { display: none; }

[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top-left,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top-right,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom-left,
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom-right {
  position: absolute;
  z-index: 5;
  width: 14px;
  height: 14px;
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top-left { top: -5px; left: -5px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--top-right { top: -5px; right: -5px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom-left { bottom: -5px; left: -5px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-resize-handle--bottom-right { right: -5px; bottom: -5px; cursor: nwse-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-column-splitter { display: none; }
@media (min-width: 992px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 318px) 6px minmax(0, 1fr) 6px var(--tt-mg-right-width, 332px);
    gap: 8px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter {
    position: relative;
    display: block;
    width: 6px;
    min-height: 100%;
    align-self: stretch;
    cursor: col-resize;
    border-radius: 999px;
    background: transparent;
    touch-action: none;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter::after {
    position: absolute;
    top: 10%;
    bottom: 10%;
    left: 2px;
    width: 2px;
    border-radius: 999px;
    background: #d8e5f5;
    content: "";
    transition: background 150ms ease, box-shadow 150ms ease;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter:hover::after,
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter:focus-visible::after,
  [data-toantin-standalone="math_graph"].is-splitter-dragging .tt-mg-column-splitter::after {
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 6px var(--tt-mg-right-width, 332px);
  }
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 318px) 6px minmax(0, 1fr) 0 36px;
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 0 36px;
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-column-splitter--left,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-column-splitter--right,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-column-splitter,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-column-splitter { display: none; }
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell { --tt-mg-toolbar-cell: 44px; }
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-toolbar-action,
  [data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-more-menu { left: 0; right: auto; width: min(328px, calc(100vw - 24px)); }
  [data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter::after { transition: none; }
}
[data-toantin-standalone="math_graph"] .tt-mg-more-action.tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"] .tt-mg-context-btn.tt-mg-toolbar-action {
  width: auto;
  height: auto;
  min-width: 0;
  flex-basis: auto;
}

/* T2 — Capture true-alpha + Text Object hoàn thiện. */
[data-toantin-standalone="math_graph"] .tt-mg-capture-size {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  padding: 3px 7px;
  border: 1px solid rgba(13, 91, 239, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 2px 8px rgba(15, 31, 75, .10);
  color: #163b73;
  font-size: .68rem;
  font-weight: 800;
  pointer-events: none;
  white-space: nowrap;
}

[data-toantin-standalone="math_graph"] .tt-mg-capture-layer:focus-visible {
  outline: 2px solid rgba(13, 91, 239, .34);
  outline-offset: -2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="e"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="w"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="e"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="w"] { cursor: ew-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="n"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="s"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="n"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="s"] { cursor: ns-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="nw"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="se"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="nw"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="se"] { cursor: nwse-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="ne"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-handle="sw"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="ne"],
[data-toantin-standalone="math_graph"] .tt-mg-canvas[data-text-resize-active="sw"] { cursor: nesw-resize; }

[data-toantin-standalone="math_graph"] .tt-mg-shell { position: relative; }
[data-toantin-standalone="math_graph"] .tt-mg-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 32;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid #cfe0f5;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 38px rgba(15, 31, 75, .18);
  color: #102a56;
  font-size: .82rem;
  font-weight: 700;
}
[data-toantin-standalone="math_graph"] .tt-mg-toast[data-tone="success"] { border-color: #a7e8d0; background: #f0fdf8; color: #08795b; }
[data-toantin-standalone="math_graph"] .tt-mg-toast[data-tone="warning"] { border-color: #f5d99a; background: #fffaf0; color: #8a5a00; }
[data-toantin-standalone="math_graph"] .tt-mg-toast[data-tone="error"] { border-color: #f3b4bc; background: #fff5f6; color: #b4232e; }
@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-toast { transition: none; }
}

/* ======================================================================
   PATCH_12 — Toolbar overlay hardening after Owner runtime test.
   More + Contextual are viewport overlays; they MUST NOT grow Main Toolbar.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-more-menu {
  position: fixed;
  z-index: 96;
  top: 8px;
  left: 8px;
  right: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  grid-auto-rows: 44px;
  align-content: start;
  gap: 7px;
  min-width: 220px;
  min-height: 180px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: 12px;
  overflow: auto;
  resize: none;
  overscroll-behavior: contain;
  border: 1px solid #cbdcf2;
  border-radius: 14px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 20px 54px rgba(15, 31, 75, .22);
  backdrop-filter: blur(10px);
}

[data-toantin-standalone="math_graph"] .tt-mg-more-menu[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-more-group { display: contents; }
[data-toantin-standalone="math_graph"] .tt-mg-more-group h3,
[data-toantin-standalone="math_graph"] .tt-mg-more-action > span:not(.tt-mg-angle-mode-badge),
[data-toantin-standalone="math_graph"] .tt-mg-more-switch .form-check-label,
[data-toantin-standalone="math_graph"] .tt-mg-more-action__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action,
[data-toantin-standalone="math_graph"] .tt-mg-more-secondary .tt-mg-priority-overflow,
[data-toantin-standalone="math_graph"] .tt-mg-more-switch {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  justify-self: center;
  align-self: start;
  gap: 0;
  padding: 0;
  border: 1px solid #d8e5f5;
  border-radius: 11px;
  color: #163b73;
  background: #fbfdff;
  text-align: center;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action svg,
[data-toantin-standalone="math_graph"] .tt-mg-more-switch svg {
  width: 21px;
  height: 21px;
  margin: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-switch .form-check-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-switch:has(.form-check-input:checked) {
  border-color: #82b2ef;
  color: #0d5bef;
  background: #eaf3ff;
  box-shadow: inset 0 0 0 1px rgba(13, 91, 239, .08);
}

[data-toantin-standalone="math_graph"] .tt-mg-more-action:hover,
[data-toantin-standalone="math_graph"] .tt-mg-more-action:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-more-switch:hover,
[data-toantin-standalone="math_graph"] .tt-mg-more-switch:focus-within {
  border-color: #82b2ef;
  color: #0d5bef;
  background: #eef6ff;
  outline: 2px solid rgba(59, 130, 246, .18);
  outline-offset: 1px;
}

[data-toantin-standalone="math_graph"] .tt-mg-angle-mode-badge {
  right: 2px;
  bottom: 2px;
}

[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle {
  position: absolute;
  z-index: 3;
  display: block;
  touch-action: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top,
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom {
  left: 10px;
  width: calc(100% - 20px);
  height: 9px;
  cursor: ns-resize;
}
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top { top: -4px; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom { bottom: -4px; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--left,
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--right {
  top: 10px;
  width: 9px;
  height: calc(100% - 20px);
  cursor: ew-resize;
}
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--left { left: -4px; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--right { right: -4px; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top-left,
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top-right,
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom-left,
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom-right {
  width: 16px;
  height: 16px;
}
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top-left { top: -6px; left: -6px; cursor: nwse-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--top-right { top: -6px; right: -6px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom-left { bottom: -6px; left: -6px; cursor: nesw-resize; }
[data-toantin-standalone="math_graph"] .tt-mg-more-resize-handle--bottom-right { right: -6px; bottom: -6px; cursor: nwse-resize; }

/* Contextual Toolbar nổi độc lập; chọn Text/Graph không được thay chiều cao Main Toolbar. */
[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar {
  position: fixed;
  z-index: 92;
  top: 8px;
  left: 8px;
  width: max-content;
  max-width: calc(100vw - 16px);
  min-height: 42px;
  margin: 0;
  padding: 4px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #cbdcf2;
  border-radius: 11px;
  background: rgba(244, 248, 255, .98);
  box-shadow: 0 12px 30px rgba(15, 31, 75, .14), inset 3px 0 0 #3b82f6;
  backdrop-filter: blur(8px);
  scrollbar-width: thin;
}

[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar__actions {
  min-width: max-content;
}
[data-toantin-standalone="math_graph"] .tt-mg-context-btn,
[data-toantin-standalone="math_graph"] .tt-mg-context-control {
  min-height: 34px;
  max-height: 34px;
}
[data-toantin-standalone="math_graph"] .tt-mg-contextual-toolbar__label {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tooltip phải theo viewport vì More/Contextual đã tách khỏi flow của Toolbar. */
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-tooltip {
  position: fixed;
  z-index: 110;
}

/* Vertical Toolbar dùng natural geometry riêng, không kế thừa khoảng trắng của horizontal. */
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  min-width: 106px;
  max-width: min(260px, calc(100vw - 8px));
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  align-content: start;
  justify-content: start;
}

/* Inline editor luôn là overlay trong graph stage; tuyệt đối không tham gia normal flow. */
[data-toantin-standalone="math_graph"] .tt-mg-inline-text-editor {
  position: absolute;
  max-width: calc(100% - 8px);
  contain: layout paint style;
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-more-menu {
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    grid-auto-rows: 48px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-more-action,
  [data-toantin-standalone="math_graph"] .tt-mg-more-secondary .tt-mg-priority-overflow,
  [data-toantin-standalone="math_graph"] .tt-mg-more-switch {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}
[data-toantin-standalone="math_graph"] .tt-mg-toolbar-shell .tt-mg-more-menu .tt-mg-more-action,
[data-toantin-standalone="math_graph"] .tt-mg-more-menu .tt-mg-more-action,
[data-toantin-standalone="math_graph"] .tt-mg-more-menu .tt-mg-more-switch {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

/* ======================================================================
   PATCH_13 — Unified Property Inspector V1 + session contextual position.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-header-home {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid #d8e5f5;
  border-radius: 999px;
  color: #24466e;
  background: #fff;
  font-size: .72rem;
  font-weight: 800;
  text-decoration: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-header-home svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-toantin-standalone="math_graph"] .tt-mg-header-home:hover,
[data-toantin-standalone="math_graph"] .tt-mg-header-home:focus-visible {
  border-color: #86b4ef;
  color: #0d5bef;
  background: #eef6ff;
}

[data-toantin-standalone="math_graph"] .tt-mg-contextual-drag {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 5px;
  border: 0;
  border-right: 1px solid #d8e5f5;
  border-radius: 7px 0 0 7px;
  color: #6b7f98;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-contextual-drag:active { cursor: grabbing; }
[data-toantin-standalone="math_graph"] .tt-mg-contextual-drag svg,
[data-toantin-standalone="math_graph"] .tt-mg-context-reset svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-toantin-standalone="math_graph"] .tt-mg-context-reset {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  padding: 5px;
}

/* Inspector rộng vừa đủ cho bảng 3 cột, nhưng vẫn compact. */
[data-toantin-standalone="math_graph"] .tt-mg-properties-window {
  width: 414px;
  min-width: 340px;
  max-width: min(640px, calc(100% - 12px));
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head,
[data-toantin-standalone="math_graph"] .tt-mg-property-row {
  display: grid;
  grid-template-columns: minmax(92px, .9fr) minmax(130px, 1.5fr) minmax(64px, .7fr);
  gap: 7px;
  align-items: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head {
  position: sticky;
  z-index: 2;
  top: 0;
  margin: -2px 0 8px;
  padding: 6px 7px;
  border: 1px solid #dbe6f3;
  border-radius: 8px;
  color: #405e82;
  background: rgba(247, 250, 255, .96);
  font-size: .64rem;
  font-weight: 850;
  line-height: 1.15;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head > :last-child { text-align: center; }
[data-toantin-standalone="math_graph"] .tt-mg-properties-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row-stack {
  display: grid;
  grid-column: 1 / -1;
  gap: 5px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row {
  min-height: 36px;
  padding: 4px 6px;
  border: 1px solid #e6edf6;
  border-radius: 8px;
  background: #fbfdff;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__label {
  min-width: 0;
  color: #405b7c;
  font-size: .71rem;
  font-weight: 780;
  line-height: 1.2;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value {
  display: grid;
  min-width: 0;
  gap: 3px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > .form-select,
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > textarea {
  width: 100%;
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__batch {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-batch {
  display: inline-flex;
  width: 32px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 1px solid #dce6f3;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-batch__input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  cursor: pointer;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-batch-na {
  color: #9aabbd;
  font-size: .72rem;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle-control {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 3px 7px;
  border: 1px solid #dde8f5;
  border-radius: 7px;
  background: #fff;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle-state {
  color: #526d8e;
  font-size: .7rem;
  font-weight: 700;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-toggle-control .tt-mg-property-toggle__input {
  margin: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-note,
[data-toantin-standalone="math_graph"] .tt-mg-properties-actions,
[data-toantin-standalone="math_graph"] .tt-mg-property-danger,
[data-toantin-standalone="math_graph"] .tt-mg-property-primary,
[data-toantin-standalone="math_graph"] .tt-mg-property-readonly,
[data-toantin-standalone="math_graph"] .tt-mg-point-name-row {
  grid-column: 1 / -1;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-field {
  grid-column: auto;
}

@container (max-width: 370px) {
  [data-toantin-standalone="math_graph"] .tt-mg-property-table-head { display: none; }
  [data-toantin-standalone="math_graph"] .tt-mg-property-row {
    grid-template-columns: minmax(90px, 1fr) minmax(125px, 1.5fr) 42px;
  }
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-properties-window {
    width: min(96vw, 390px);
    min-width: min(290px, calc(100% - 10px));
  }
  [data-toantin-standalone="math_graph"] .tt-mg-property-table-head { display: none; }
  [data-toantin-standalone="math_graph"] .tt-mg-property-row {
    grid-template-columns: minmax(86px, .9fr) minmax(118px, 1.4fr) 40px;
    gap: 5px;
    padding: 5px;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-property-row__label { font-size: .69rem; }
}

/* ======================================================================
   PATCH_14 — Property Inspector 3-column polish + Quick Properties split.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Full Inspector: đúng 3 cột; mỗi property là một row độc lập. */
[data-toantin-standalone="math_graph"] .tt-mg-properties-window {
  width: 500px;
  min-width: 420px;
  max-width: min(720px, calc(100vw - 12px));
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head,
[data-toantin-standalone="math_graph"] .tt-mg-property-row {
  grid-template-columns: minmax(122px, 1fr) minmax(190px, 1.6fr) minmax(108px, .75fr);
  gap: 8px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head {
  padding: 7px 8px;
  font-size: .67rem;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head > span {
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-table-head > :last-child {
  white-space: normal;
  text-wrap: balance;
  line-height: 1.15;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row {
  min-height: 38px;
  padding: 5px 7px;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value {
  align-items: stretch;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > .form-select,
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > textarea,
[data-toantin-standalone="math_graph"] .tt-mg-property-row__value > .tt-mg-property-toggle-control {
  max-width: 100%;
}
[data-toantin-standalone="math_graph"] .tt-mg-property-batch {
  width: 34px;
  min-width: 34px;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-name-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-name-control .tt-mg-point-name-input {
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-section {
  margin-bottom: 10px;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-section__title {
  margin-bottom: 6px;
}

/* Right Sidebar = Quick Properties; không duplicate Full Inspector. */
[data-toantin-standalone="math_graph"] .tt-mg-quick-properties {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}
[data-toantin-standalone="math_graph"] .tt-mg-quick-property-row {
  display: grid;
  grid-template-columns: minmax(72px, .8fr) minmax(0, 1.35fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
}
[data-toantin-standalone="math_graph"] .tt-mg-quick-property-row__label {
  color: #405b7c;
  font-size: .72rem;
  font-weight: 780;
  line-height: 1.2;
}
[data-toantin-standalone="math_graph"] .tt-mg-quick-property-row .form-control,
[data-toantin-standalone="math_graph"] .tt-mg-quick-property-row .form-select {
  width: 100%;
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-quick-properties-note {
  margin-top: 2px;
  margin-bottom: 8px;
}
[data-toantin-standalone="math_graph"] .tt-mg-quick-properties-full {
  width: 100%;
  min-height: 34px;
  justify-content: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-selection-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Reset của Contextual Toolbar là icon-only. */
[data-toantin-standalone="math_graph"] .tt-mg-context-reset {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
}

@media (max-width: 575.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-properties-window {
    width: min(96vw, 430px);
    min-width: min(300px, calc(100vw - 10px));
  }
  [data-toantin-standalone="math_graph"] .tt-mg-property-table-head {
    display: grid;
    grid-template-columns: minmax(88px, .9fr) minmax(120px, 1.35fr) minmax(62px, .7fr);
    gap: 5px;
    font-size: .61rem;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-property-row {
    grid-template-columns: minmax(88px, .9fr) minmax(120px, 1.35fr) minmax(44px, .45fr);
    gap: 5px;
  }
}

/* ======================================================================
   PATCH_15 — Full Inspector invariant: ONE PROPERTY = ONE ROW.
   Legacy compact style groups must never lay child property rows sideways.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-property-row-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  width: 100%;
}
[data-toantin-standalone="math_graph"] .tt-mg-properties-window .tt-mg-property-row-stack > .tt-mg-property-row {
  grid-column: 1;
  width: 100%;
}

/* PATCH_15 — Sidebar collapse guard.
   Keep collapse semantics stable across desktop/tablet/mobile after the T1 splitter layout.
   The left column must actually shrink instead of leaving an empty legacy track. */
@media (min-width: 1200px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 318px) 6px minmax(0, 1fr) 6px var(--tt-mg-right-width, 332px);
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 6px var(--tt-mg-right-width, 332px);
  }
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 318px) 6px minmax(0, 1fr) 0 36px;
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 0 36px;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 270px) 6px minmax(0, 1fr) 6px var(--tt-mg-right-width, 290px);
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 6px var(--tt-mg-right-width, 290px);
  }
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width, 270px) 6px minmax(0, 1fr) 0 36px;
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-teaching .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-focus-mode .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0, 1fr) 0 36px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout {
    grid-template-columns: minmax(240px, var(--tt-mg-left-width, 300px)) minmax(0, 1fr);
  }
  [data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"].is-left-collapsed.is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  [data-toantin-standalone="math_graph"] .tt-mg-tools-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: 1 / -1;
  }
}

/* ======================================================================
   PATCH_16 — P0 workspace grid authority.
   T1 introduced two splitter tracks, so desktop/laptop >= 992 px is a
   five-track grid: Left | splitter | Graph | splitter | Right.
   Older responsive rules must never make the right sidebar span 1/-1 in
   that range. Explicit placement here is the final source of truth.
   ====================================================================== */
@media (min-width: 992px) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-column {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter--left {
    grid-column: 2;
    grid-row: 1;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-column-splitter--right {
    grid-column: 4;
    grid-row: 1;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-tools-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: 5;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-expression-column {
    grid-column: 1;
    grid-row: 1;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column {
    grid-column: 2;
    grid-row: 1;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-tools-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
  }
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column {
    grid-column: 1;
    grid-row: 1;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-expression-column {
    grid-column: 1;
    grid-row: 2;
  }
  [data-toantin-standalone="math_graph"] .tt-mg-tools-column,
  [data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column {
    grid-column: 1;
    grid-row: 3;
  }
}

/* ======================================================================
   PATCH_17 — ELASTIC WORKSPACE / AUTO FOCUS GRAPH.
   Collapsing both sidebars must return both width and comfortable height
   to the graph. Manual height remains a UI preference only; graph math
   keeps pixels-per-unit through resizeViewportPreservingScale().
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 12px;
  align-items: center;
  justify-content: center;
  min-height: 12px;
  margin: 0 10px;
  cursor: ns-resize;
  touch-action: none;
  outline: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize > span {
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: #d3e2f4;
  box-shadow: inset 0 0 0 1px rgba(96, 125, 163, .08);
  transition: width 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
[data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize:hover > span,
[data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize:focus-visible > span,
[data-toantin-standalone="math_graph"].is-graph-height-dragging .tt-mg-graph-height-resize > span,
[data-toantin-standalone="math_graph"].is-graph-height-manual .tt-mg-graph-height-resize > span {
  width: 76px;
  background: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
[data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize:focus-visible {
  outline: 2px solid rgba(59, 130, 246, .38);
  outline-offset: -2px;
  border-radius: 8px;
}

@media (min-width: 768px) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap {
    transition: min-height 170ms ease, grid-template-columns 180ms ease;
  }

  /* Both sidebars collapsed = automatic graph-first workspace. */
  [data-toantin-standalone="math_graph"].is-elastic-graph-focus .tt-mg-graph-card {
    box-shadow: 0 10px 30px rgba(15, 58, 110, .09);
  }
}

@media (min-width: 992px) {
  /* Rails remain reachable but consume less space while Auto Focus is active. */
  [data-toantin-standalone="math_graph"].is-elastic-graph-focus .tt-mg-main-layout {
    grid-template-columns: 30px 0 minmax(0, 1fr) 0 30px;
    gap: 6px;
  }
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-graph-height-resize {
  display: none;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize {
    min-height: 16px;
    flex-basis: 16px;
    margin-inline: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-main-layout,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-column,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-stage-wrap,
  [data-toantin-standalone="math_graph"] .tt-mg-graph-height-resize > span {
    transition: none;
  }
}

/* ======================================================================
   PATCH_18 — FULLSCREEN SMART TOOLBAR V2.
   Fullscreen-only chrome layer: smooth dock, optional auto-hide + Light Rail.
   Normal toolbar is intentionally untouched. Integrated TOÁN TIN continues
   to use Host-owned outer toolbar/fullscreen chrome.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-smart-state]:not([data-toolbar-smart-state="NORMAL"]) .tt-mg-toolbar-shell {
  z-index: 84;
  border-color: rgba(166, 194, 228, .9);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 12px 34px rgba(15, 42, 86, .16);
  transition:
    left 280ms cubic-bezier(.2, .72, .2, 1),
    top 280ms cubic-bezier(.2, .72, .2, 1),
    transform 270ms cubic-bezier(.2, .72, .2, 1),
    opacity 180ms ease,
    box-shadow 180ms ease;
  will-change: left, top, transform;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen.is-fs-smart-measuring .tt-mg-toolbar-shell {
  transition: none;
}

/* Fullscreen Smart Toolbar is content-fit: manual desktop-window resize handles
   are intentionally disabled only in fullscreen. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-resize-handle {
  display: none;
}

/* Auto-hide is a fullscreen-only control. Outside fullscreen the native hidden
   attribute keeps it out of the normal Toolbar layout. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-auto-hide:not([hidden]) {
  display: inline-flex;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-auto-hide:disabled {
  opacity: .46;
  cursor: not-allowed;
}

[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-close {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  margin: 0 8px 0 0;
  padding: 0;
  border: 1px solid rgba(202, 57, 57, .34);
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(180deg, #ff8f88 0%, #ef4e45 48%, #cf2f28 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 7px 14px rgba(177, 31, 31, .22), 0 2px 0 rgba(132, 18, 18, .16);
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:hover,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:focus-visible {
  border-color: rgba(176, 26, 26, .44);
  background: linear-gradient(180deg, #ff9c95 0%, #f15b53 48%, #d7362f 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.62), 0 10px 18px rgba(177, 31, 31, .28), 0 0 0 3px rgba(255, 110, 103, .18);
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.4), 0 5px 10px rgba(177, 31, 31, .22);
}

/* A sixth chrome control + dedicated fullscreen Close live only in fullscreen. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(6, 36px);
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-chrome {
  grid-template-columns: repeat(3, 36px);
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
  margin: 0 0 8px;
  justify-self: center;
}

/* Hidden state retracts the toolbar completely. The discoverable surface is a
   separate 5–8px visual Light Rail with a larger transparent hit target. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"] .tt-mg-toolbar-shell {
  pointer-events: none;
  opacity: .985;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"][data-toolbar-dock-edge="top"] .tt-mg-toolbar-shell {
  transform: translateY(calc(-100% - 12px));
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"][data-toolbar-dock-edge="bottom"] .tt-mg-toolbar-shell {
  transform: translateY(calc(100% + 12px));
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"][data-toolbar-dock-edge="left"] .tt-mg-toolbar-shell {
  transform: translateX(calc(-100% - 12px));
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"][data-toolbar-dock-edge="right"] .tt-mg-toolbar-shell {
  transform: translateX(calc(100% + 12px));
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-auto-hide="true"] .tt-mg-fullscreen-toolbar-rail {
  position: fixed;
  z-index: 85;
  display: block;
  padding: 0;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  border: 0;
  outline: 0;
  background: transparent;
  transition: opacity 160ms ease;
  touch-action: manipulation;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"] .tt-mg-fullscreen-toolbar-rail {
  pointer-events: auto;
  opacity: 1;
}
[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail > span {
  position: absolute;
  border-radius: 999px;
  background: rgba(36, 119, 239, .48);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .72), 0 2px 10px rgba(22, 103, 232, .16);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="top"] .tt-mg-fullscreen-toolbar-rail > span,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="bottom"] .tt-mg-fullscreen-toolbar-rail > span {
  right: 0;
  left: 0;
  height: 6px;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="top"] .tt-mg-fullscreen-toolbar-rail > span { top: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="bottom"] .tt-mg-fullscreen-toolbar-rail > span { bottom: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="left"] .tt-mg-fullscreen-toolbar-rail > span,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="right"] .tt-mg-fullscreen-toolbar-rail > span {
  top: 0;
  bottom: 0;
  width: 6px;
}
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="left"] .tt-mg-fullscreen-toolbar-rail > span { left: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-dock-edge="right"] .tt-mg-fullscreen-toolbar-rail > span { right: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail:hover > span,
[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail:focus-visible > span {
  background: rgba(13, 91, 239, .72);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .82), 0 0 12px rgba(56, 189, 248, .34);
  transform: scale(1.04);
}
[data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail:focus-visible {
  outline: 2px solid rgba(13, 91, 239, .72);
  outline-offset: -2px;
  border-radius: 8px;
}

/* More/Contextual/Tooltip are re-parented into the fullscreen element in JS.
   Their existing viewport-fixed geometry remains authoritative and therefore
   they stay interactive in browser fullscreen without growing Main Toolbar. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-more-menu,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-contextual-toolbar,
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-tooltip {
  max-width: calc(100vw - 16px);
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-toolbar-chrome {
    grid-template-columns: repeat(3, 40px);
  }
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-right: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-smart-state]:not([data-toolbar-smart-state="NORMAL"]) .tt-mg-toolbar-shell,
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-auto-hide="true"] .tt-mg-fullscreen-toolbar-rail,
  [data-toantin-standalone="math_graph"] .tt-mg-fullscreen-toolbar-rail > span {
    transition: none;
  }
}


/* ======================================================================
   PATCH_21 — TRUE ADAPTIVE SINGLE-ROW TOOLBAR.
   Horizontal Main Toolbar consumes available width; safe frequent commands
   are promoted from More and lower priorities overflow back into More.
   ====================================================================== */
[data-toantin-standalone="math_graph"]:not(.is-toolbar-vertical):not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  /* PATCH_22 final visual tuning: command cells never stretch to fill free space.
     A fixed 8px rhythm keeps the toolbar compact/professional; spare width stays
     available for adaptive promotion instead of becoming exaggerated icon gaps. */
  --tt-mg-toolbar-gap: 8px;
  grid-template-columns: repeat(var(--tt-mg-toolbar-cols, 1), var(--tt-mg-toolbar-cell));
  grid-template-rows: var(--tt-mg-toolbar-cell);
  grid-auto-flow: column;
  grid-auto-columns: var(--tt-mg-toolbar-cell);
  grid-auto-rows: var(--tt-mg-toolbar-cell);
  column-gap: var(--tt-mg-toolbar-gap);
  row-gap: 0;
  align-content: center;
  justify-content: start;
  justify-items: center;
  overflow: hidden;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"]:not(.is-toolbar-vertical):not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
    --tt-mg-toolbar-gap: 6px;
  }
}

/* Standalone fullscreen has one canonical exit owner: the red X chrome. */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen #fullscreen-action {
  display: none;
}

/* Promoted More commands stay icon-only on the Main Toolbar. */
[data-toantin-standalone="math_graph"] .tt-mg-actionbar .tt-mg-toolbar-promoted > span:not(.tt-mg-angle-mode-badge),
[data-toantin-standalone="math_graph"] .tt-mg-actionbar .tt-mg-toolbar-promoted .tt-mg-more-action__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* More remains compact after commands have been promoted; scroll only when needed. */
[data-toantin-standalone="math_graph"] .tt-mg-more-menu {
  min-height: 70px;
  max-height: min(62vh, 520px);
}


/* ======================================================================
   PATCH_23 — VERTICAL TOOLBAR OVERLAY / NO WORKSPACE PUSH.
   Vertical orientation is always viewport-floating; fullscreen specificity
   must not fall back to the older relative-position rule.
   ====================================================================== */
[data-toantin-standalone="math_graph"].is-toolbar-floating .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell,
[data-toantin-standalone="math_graph"].is-toolbar-vertical.is-toolbar-floating .tt-mg-toolbar-shell {
  position: fixed;
  z-index: 86;
  margin: 0;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  align-content: start;
  height: auto;
  max-height: calc(100vh - 8px);
  overflow: hidden;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  min-height: 0;
  align-content: start;
  overflow: hidden;
}

/* Canonical fullscreen vertical chrome: Close belongs at the TOP end. */
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto max-content;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  margin: 8px 0 6px;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-chrome {
  grid-column: 1;
  grid-row: 2;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-actionbar {
  grid-column: 1;
  grid-row: 3;
}

/* ======================================================================
   PATCH_24 — FINAL COMPACT VERTICAL TOOLBAR.
   Vertical means compact overlay, not a mini-window. The shell is content-fit,
   commands stay in a strict 2-column rhythm and fullscreen Close remains top chrome.
   ====================================================================== */
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
  width: 148px;
  min-width: 148px;
  max-width: 156px;
  height: auto;
  min-height: 0;
  max-height: calc(100vh - 16px);
  align-content: start;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255,255,255,.985);
  box-shadow: 0 14px 38px rgba(15,42,86,.18);
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-chrome {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  grid-auto-rows: 36px;
  justify-content: center;
  align-content: start;
  gap: 4px;
  width: 100%;
  padding: 7px 6px;
  border-right: 0;
  border-bottom: 1px solid #dce7f5;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  grid-template-rows: repeat(var(--tt-mg-toolbar-rows, 1), 40px);
  grid-auto-flow: row;
  grid-auto-columns: 40px;
  grid-auto-rows: 40px;
  justify-content: center;
  justify-items: center;
  align-content: start;
  gap: 6px;
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 8px 7px 9px;
  overflow: hidden;
}

[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-toolbar-action,
[data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-icon-action.tt-mg-toolbar-action {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  margin: 0;
}

/* Fullscreen vertical: Close is compact chrome at the top-right of the toolbar,
   visually separated but without spending a full empty row. */
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-shell {
  grid-template-columns: 1fr;
  grid-template-rows: 44px auto auto;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-fullscreen-close:not([hidden]) {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  width: 36px;
  height: 36px;
  margin: 5px 7px 3px 0;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-toolbar-chrome {
  grid-column: 1;
  grid-row: 2;
}
[data-toantin-standalone="math_graph"].is-toolbar-vertical .tt-mg-shell.is-fullscreen .tt-mg-actionbar {
  grid-column: 1;
  grid-row: 3;
}

@media (max-width: 767.98px) {
  [data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell {
    width: 156px;
    min-width: 156px;
    max-width: 156px;
  }
  [data-toantin-standalone="math_graph"].is-toolbar-vertical:not(.is-toolbar-collapsed) .tt-mg-toolbar-shell .tt-mg-actionbar {
    grid-template-columns: repeat(2, 44px);
    grid-template-rows: repeat(var(--tt-mg-toolbar-rows, 1), 44px);
    grid-auto-columns: 44px;
    grid-auto-rows: 44px;
    gap: 6px;
  }
}


/* ======================================================================
   PATCH_25 — UNIFIED FULLSCREEN SMART TOOLBAR + CLOSE/EXIT CONTRACT V1.
   Fullscreen defaults to docked auto-hide; hidden dock and X retract together.
   Standalone fullscreen action inside More is explicitly removed from the
   interaction tree while fullscreen is active, leaving one canonical red X.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen #fullscreen-action[hidden] {
  display: none;
}

[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-toolbar-hidden="true"] .tt-mg-fullscreen-close {
  pointer-events: none;
}

/* ======================================================================
   PATCH_26 — ESC-SAFE MANAGED FULLSCREEN.
   Standalone fullscreen covers the viewport without browser Fullscreen API,
   allowing Esc to stay a Tool-local safety key while red X remains the only
   fullscreen exit control. Normal mode and canonical geometry/state are intact.
   ====================================================================== */
[data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-fullscreen-owner="tool-managed"] {
  position: fixed;
  inset: 0;
  z-index: 70;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  isolation: isolate;
  overscroll-behavior: contain;
}

@supports not (height: 100dvh) {
  [data-toantin-standalone="math_graph"] .tt-mg-shell.is-fullscreen[data-fullscreen-owner="tool-managed"] {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
  }
}


/* PATCH_27 — LCD / classroom typography. Scoped presentation controls only. */
[data-toantin-standalone="math_graph"] .tt-mg-graph-card__top {
  min-height: 58px;
  padding: 9px 12px;
  gap: 12px;
}
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip { min-width: 0; gap: 9px; }
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-function-label,
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-active-function-source,
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-active-equation {
  font-size: 20px;
  line-height: 1.35;
}
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-function-label { font-weight: 800; flex: 0 0 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-active-function-source {
  max-width: min(44vw, 650px);
  color: #385b85;
  font-weight: 650;
  text-overflow: ellipsis;
  overflow: hidden;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-wrap { position: relative; flex: 0 0 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-hud-font { font-size: 15px; font-weight: 850; width: 38px; min-width: 38px; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-panel {
  position: fixed;
  z-index: 110;
  top: 58px;
  left: 8px;
  width: min(350px, calc(100vw - 28px));
  padding: 13px;
  border: 1px solid #bfd4f2;
  border-radius: 14px;
  background: rgba(255,255,255,.99);
  box-shadow: 0 14px 34px rgba(16,42,86,.2);
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-panel[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-title { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 800; color: #102a56; margin-bottom: 10px; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-dismiss { font-size: 23px; color: #546c8d; padding: 0 8px; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row { display: grid; grid-template-columns: minmax(0, 1fr) 36px 44px 36px; align-items: center; gap: 5px; margin-bottom: 10px; font-size: 14px; font-weight: 700; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid #c8dbf5; border-radius: 9px; color: #165cbe; background: #f2f7ff; font-size: 22px; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row button:disabled { opacity: .35; cursor: not-allowed; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row output { text-align: center; color: #102a56; font-variant-numeric: tabular-nums; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-reset { width: 100%; min-height: 36px; border: 1px solid #c8dbf5; border-radius: 9px; color: #155ab9; background: #f4f8ff; font-size: 14px; font-weight: 750; }
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row button:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-reset:focus-visible { outline: 3px solid #80b5fa; outline-offset: 1px; }

[data-toantin-standalone="math_graph"] .tt-mg-construction-builder {
  --tt-mg-builder-font-size: 16px;
  font-size: var(--tt-mg-builder-font-size);
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder .tt-mg-section-kicker,
[data-toantin-standalone="math_graph"] .tt-mg-construction-title,
[data-toantin-standalone="math_graph"] .tt-mg-construction-formula,
[data-toantin-standalone="math_graph"] .tt-mg-coefficient-field span,
[data-toantin-standalone="math_graph"] .tt-mg-coefficient-field input,
[data-toantin-standalone="math_graph"] .tt-mg-construction-table,
[data-toantin-standalone="math_graph"] .tt-mg-construction-table input,
[data-toantin-standalone="math_graph"] .tt-mg-construction-notes,
[data-toantin-standalone="math_graph"] .tt-mg-construction-notes p,
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions button,
[data-toantin-standalone="math_graph"] .tt-mg-construction-solution,
[data-toantin-standalone="math_graph"] .tt-mg-construction-error {
  font-size: var(--tt-mg-builder-font-size);
  line-height: 1.35;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-font-btn { width: 34px; height: 34px; padding: 0; border: 1px solid #d1dff2; border-radius: 8px; background: #f2f7ff; color: #1155af; font-size: 15px; font-weight: 800; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-font-value { color: #64748b; font-size: 12px; min-width: 31px; text-align: center; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-font-btn:disabled { opacity: .4; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-formula { padding: 9px; white-space: normal; overflow-wrap: anywhere; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table-wrap { overflow-x: auto; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table { min-width: max(290px, 100%); }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table th,
[data-toantin-standalone="math_graph"] .tt-mg-construction-table td { padding: 6px 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-table input { min-width: 56px; width: 100%; padding: 7px 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-coefficient-grid input { min-width: 0; padding: 7px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions button { min-height: 45px; }
@media (max-width: 800px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-card__top { flex-wrap: wrap; }
  [data-toantin-standalone="math_graph"] .tt-mg-active-function-strip .tt-mg-active-function-source { max-width: calc(100vw - 115px); }
  [data-toantin-standalone="math_graph"] .tt-mg-graph-hud { margin-left: auto; }
}
@media (max-width: 390px) {
  [data-toantin-standalone="math_graph"] .tt-mg-construction-header { flex-wrap: wrap; }
  [data-toantin-standalone="math_graph"] .tt-mg-construction-header-tools { width: 100%; justify-content: flex-end; }
}

/* PATCH_28 — LCD-friendly editor cards, quick eye actions and safe floating panels.
   All selectors scoped to this standalone Tool; Presenter chrome remains Host-owned. */
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row .tt-mg-font-default-btn {
  width: auto; min-width: 44px; padding: 0 2px; font-size: 13px; font-weight: 850;
  font-variant-numeric: tabular-nums; background: #eaf3ff; white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row .tt-mg-font-default-btn:hover,
[data-toantin-standalone="math_graph"] .tt-mg-construction-font-value:hover,
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-reset:hover { border-color: #2a78de; background: #dcecff; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between;
  gap: 4px; margin-bottom: 8px;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .min-w-0 { min-width: 0; flex: 1 1 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-title {
  margin: 0; line-height: 1.35; font-size: var(--tt-mg-builder-font-size, 16px); font-weight: 800;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header-tools { width: auto; flex: 0 0 auto; display: flex; flex-wrap: nowrap; gap: 2px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-font-value {
  min-width: 36px; padding: 0 3px; min-height: 34px; border: 1px solid #d1dff2;
  border-radius: 8px; background: #f2f7ff; color: #1559b6; font-size: 12px; font-weight: 700;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header .tt-mg-panel-move,
[data-toantin-standalone="math_graph"] .tt-mg-construction-header .tt-mg-panel-reset,
[data-toantin-standalone="math_graph"] .tt-mg-card-float-grip,
[data-toantin-standalone="math_graph"] .tt-mg-card-float-reset {
  display: grid; place-items: center; min-width: 29px; width: 29px; height: 34px;
  padding: 0; border: 1px solid #d1dff2; border-radius: 8px;
  background: #f4f8ff; color: #426da4; font-size: 21px; line-height: 1;
}
[data-toantin-standalone="math_graph"] .tt-mg-panel-move,
[data-toantin-standalone="math_graph"] .tt-mg-card-float-grip {
  cursor: grab; touch-action: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-panel-move:active,
[data-toantin-standalone="math_graph"] .tt-mg-card-float-grip:active { cursor: grabbing; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header .tt-mg-panel-reset,
[data-toantin-standalone="math_graph"] .tt-mg-card-float-reset { display: none; }
[data-toantin-standalone="math_graph"] .is-floating-config .tt-mg-panel-reset,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config > .tt-mg-card-float-reset { display: grid; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder > .tt-mg-construction-formula {
  display: block; width: 100%; margin-bottom: 9px;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder .tt-mg-coefficient-grid { margin-top: 6px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder .tt-mg-construction-notes p { line-height: 1.45; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item {
  --tt-mg-expression-card-font-size: 16px;
  font-size: var(--tt-mg-expression-card-font-size);
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-name,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-equation,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-reorder-label,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-field-label,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-field,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-finder__result,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-mini-btn,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-secondary-action,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .form-control {
  font-size: var(--tt-mg-expression-card-font-size);
  line-height: 1.4;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  grid-template-columns: 30px minmax(0, 1fr) 34px 34px 29px;
  gap: 4px;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-eye-action { width: 34px; height: 34px; padding: 6px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-eye-action svg { width: 20px; height: 20px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-reorder-row { flex-wrap: wrap; gap: 5px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-controls { display: inline-flex; align-items: center; gap: 3px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-btn,
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-reset {
  padding: 0 5px; min-width: 30px; height: 34px; border: 1px solid #cbdcf4;
  border-radius: 8px; background: #f3f8ff; color: #105bc3; font-size: 14px; font-weight: 800;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-reset { min-width: 47px; font-size: 12px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-font-btn:disabled { opacity: .42; }
[data-toantin-standalone="math_graph"] .tt-mg-eye-action {
  display: inline-grid; place-items: center; flex: 0 0 auto; min-width: 36px; min-height: 36px;
  padding: 6px; background: #eff6ff; border: 1px solid #c8daf1;
  border-radius: 9px; color: #145dbe;
}
[data-toantin-standalone="math_graph"] .tt-mg-eye-action[aria-pressed="false"] { color: #73849d; background: #f5f7fb; }
[data-toantin-standalone="math_graph"] .tt-mg-eye-action svg { width: 21px; height: 21px; }
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer {
  position: fixed; inset: 0; z-index: 82; pointer-events: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer > .is-floating-config {
  position: fixed; box-sizing: border-box; pointer-events: auto;
  max-height: calc(100dvh - 20px); overflow: auto; overscroll-behavior: contain;
  border: 1px solid #a9cafa; border-radius: 14px;
  background: #f8fbff; box-shadow: 0 16px 42px rgba(19,57,107,.22);
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer > .tt-mg-expression-item.is-floating-config {
  padding: 10px 11px; margin: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer > .tt-mg-construction-builder.is-floating-config {
  padding: 12px; margin: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer > .is-floating-config .tt-mg-card-float-reset {
  margin: 8px auto 0; width: auto; padding: 0 10px; height: 32px;
}
[data-toantin-standalone="math_graph"] .tt-mg-reveal-all:disabled { opacity: .5; cursor: not-allowed; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item button:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder button:focus-visible,
[data-toantin-standalone="math_graph"] .tt-mg-eye-action:focus-visible { outline: 3px solid #77b4ff; outline-offset: 2px; }
@media (max-width: 390px) {
  [data-toantin-standalone="math_graph"] .tt-mg-construction-header { flex-wrap: wrap; }
  [data-toantin-standalone="math_graph"] .tt-mg-construction-header-tools { width: 100%; justify-content: flex-end; }
}

/* PATCH_29 — Teaching projection clarity and compact draggable expression inspector. */
[data-toantin-standalone="math_graph"] .tt-mg-visibility-hud-wrap { display: inline-flex; position: relative; }
[data-toantin-standalone="math_graph"] .tt-mg-visibility-hud-panel {
  position: fixed; top: 58px; left: 8px; z-index: 111;
  width: min(345px, calc(100vw - 20px)); padding: 14px;
  border: 1px solid #c0d6f3; border-radius: 14px; background: #fff;
  box-shadow: 0 14px 34px rgba(16,42,86,.19);
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-hud-panel[hidden] { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 10px 11px; margin-bottom: 7px;
  border: 1px solid #dfebfb; border-radius: 9px;
  color: #153767; background: #f8fbff; font-weight: 750; font-size: 15px;
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-eye {
  font-size: 22px; font-weight: 800; color: #168a5a;
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[aria-pressed="false"] .tt-mg-visibility-eye {
  color: #8896a9;
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row:focus-visible,
[data-toantin-standalone="math_graph"] #visibility-hud-trigger:focus-visible {
  outline: 3px solid #7ab4fb; outline-offset: 2px;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row [data-marker-reset] {
  width: 44px; font-size: 13px; font-weight: 800;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 4px; flex-wrap: nowrap; min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-compact-swatch {
  display: inline-block; flex: 0 0 10px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--expression-color);
  border: 2px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 1px var(--expression-color);
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-expression-font-controls,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-expression-order-actions {
  display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap;
  margin: 0; gap: 3px;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-eye-action { margin-left: auto; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header > button { flex: 0 0 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-item__header { display: flex; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation-row { margin-top: 4px; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation { white-space: nowrap; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-selected,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-current-panel {
  border: 2px solid var(--expression-color, #1667e8);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--expression-color, #1667e8) 38%, transparent), 0 12px 25px rgba(13,45,82,.15);
  background: color-mix(in srgb, var(--expression-color, #1667e8) 5%, #f8fbff);
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-icon-only {
  min-width: 36px; width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; line-height: 1; vertical-align: middle;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-trash-action {
  color: #cc2735; background: #fff4f5; border-color: #ffc1c9;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-actions.d-flex { flex-wrap: nowrap; overflow-x: auto; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-actions .tt-mg-mini-btn { white-space: nowrap; flex-shrink: 0; }
[data-toantin-standalone="math_graph"] .tt-mg-xy-finder__fields {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
[data-toantin-standalone="math_graph"] .tt-mg-xy-field {
  display: flex; flex-direction: row; flex-wrap: nowrap;
  align-items: center; gap: 5px; min-width: 0; white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-xy-field > span { flex: 0 0 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-xy-field > input {
  flex: 1 1 0; width: 0; min-width: 0; margin: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-floating-card-layer > .tt-mg-expression-item.is-floating-config {
  overflow-y: auto; overflow-x: auto; scrollbar-width: thin;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config .tt-mg-xy-finder,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config .tt-mg-xy-finder__fields {
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config .tt-mg-xy-finder__result {
  white-space: nowrap; overflow-x: auto;
}

[data-toantin-standalone="math_graph"] .tt-mg-visibility-eye svg {
  width: 23px; height: 23px; display: block; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[aria-pressed="true"] .tt-mg-visibility-eye-off,
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[aria-pressed="false"] .tt-mg-visibility-eye-on { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header {
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-eye-action[aria-pressed="true"] {
  color: #0b8b5b; background: #e8f9f2; border-color: #a6e2c6;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-eye-action[aria-pressed="false"] {
  color: #8997aa; background: #f4f6f9; border-color: #d7e0ea;
}

/* PATCH_30 — owner-approved unified LCD panel clean-up; Standalone scoped only. */
[data-toantin-standalone="math_graph"] .tt-mg-math-fraction {
  display: inline-flex;
  flex-flow: column nowrap;
  align-items: stretch;
  vertical-align: middle;
  max-width: 100%;
  line-height: 1.15;
  white-space: nowrap;
  text-align: center;
  margin-inline: .15em;
  font-variant-numeric: lining-nums;
}
[data-toantin-standalone="math_graph"] .tt-mg-math-fraction__top,
[data-toantin-standalone="math_graph"] .tt-mg-math-fraction__bottom {
  display: block;
  padding: .12em .36em;
  white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-math-fraction__top {
  border-bottom: 2px solid currentColor;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-formula,
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation,
[data-toantin-standalone="math_graph"] .tt-mg-active-equation {
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder > .tt-mg-construction-formula {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  font-size: var(--tt-mg-builder-font-size, 16px);
  font-weight: 750;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-equation-row {
  min-height: 42px;
  display: flex;
  align-items: center;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-btn--primary {
  min-width: 116px;
  flex: 1 1 auto;
  white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-construction-eye,
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-construction-delete,
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-panel-reset {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid #cee0f9;
  background: #f5f9ff;
  border-radius: 10px;
  font-size: 21px;
  line-height: 1;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-construction-eye.is-visible {
  color: #009366;
  background: #e8faf3;
  border-color: #97e0c3;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-construction-eye:not(.is-visible) {
  color: #8895a5;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-construction-delete {
  color: #ce253a;
  background: #fff4f5;
  border-color: #fac4cc;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-actions > .tt-mg-panel-reset { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder.is-floating-config .tt-mg-construction-actions > .tt-mg-panel-reset { display: grid; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-actions .tt-mg-card-float-reset {
  flex: 0 0 36px;
  margin: 0;
  display: none;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config .tt-mg-expression-actions .tt-mg-card-float-reset {
  display: grid;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header:not(:has(.tt-mg-construction-title)) {
  justify-content: flex-end;
}

[data-toantin-standalone="math_graph"] .tt-mg-construction-eye svg,
[data-toantin-standalone="math_graph"] .tt-mg-construction-delete svg {
  display: block; width: 21px; height: 21px; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* PATCH_31 — one canonical expression header, container-responsive at any sidebar width. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-column,
[data-toantin-standalone="math_graph"] .tt-mg-expression-column .tt-mg-panel,
[data-toantin-standalone="math_graph"] .tt-mg-expression-column .tt-mg-side-body,
[data-toantin-standalone="math_graph"] .tt-mg-expression-list,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item,
[data-toantin-standalone="math_graph"] .tt-mg-expression-details,
[data-toantin-standalone="math_graph"] .tt-mg-expression-actions,
[data-toantin-standalone="math_graph"] .tt-mg-xy-finder { min-width:0; max-width:100%; box-sizing:border-box; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item:not(.is-floating-config) { width:100%; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-item__header {
  display:flex; flex-flow:row wrap; gap:4px; align-items:center;
  width:100%; min-width:0; max-width:100%; overflow:visible;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-eye-action { margin-left:auto; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-trash-action {
  min-width:34px; height:34px; width:34px; padding:0;
  display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-trash-action svg,
[data-toantin-standalone="math_graph"] .tt-mg-expression-toggle svg {
  width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-toggle::before,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-toggle::before { display:none; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-order-actions { flex:0 0 auto; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-equation-row,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-equation,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .input-group,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-finder__fields { min-width:0; max-width:100%; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-equation { overflow-x:auto; text-overflow:clip; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .input-group .form-control { flex:1 1 0; width:0; min-width:0; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-actions { overflow-x:auto; flex-wrap:nowrap; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item:not(.is-floating-config) .tt-mg-expression-actions { flex-wrap:wrap; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-finder__fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-field { min-width:0; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-xy-field > input { min-width:0; width:0; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-form {
  position:sticky; top:0; z-index:2; border:1px solid #88b8f9;
  background:linear-gradient(155deg,#fff 0%,#eff6ff 100%);
  box-shadow:0 7px 0 -4px #94bffd,0 10px 25px rgba(23,80,161,.2);
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-form:focus-within { border-color:#0d6efd; box-shadow:0 0 0 3px rgba(13,110,253,.12),0 12px 26px rgba(23,80,161,.25); }
[data-toantin-standalone="math_graph"] .tt-mg-expression-form .form-label { font-size:16px; font-weight:850; color:#1357b3; }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__custom { min-width:0; width:100%; margin:0; }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-menu__grid > button { min-width:0; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header { display:flex; flex-wrap:wrap; gap:6px; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header-tools { flex-wrap:wrap; min-width:0; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-eye,
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-delete {
  flex:0 0 36px; display:grid; place-items:center;
  width:36px; height:36px; border:1px solid #cbdffb; border-radius:9px; padding:6px;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-eye.is-visible { color:#038558;background:#e9faf1; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-eye:not(.is-visible) { color:#8997aa; }
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-delete {color:#d42136; background:#fff4f5;}
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-eye svg,
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-construction-delete svg { width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round; }
[data-toantin-standalone="math_graph"] .tt-mg-builder-order { min-width:32px;height:34px;padding:3px 7px;border:1px solid #cbdcf4;border-radius:9px;color:#1559b3;background:#f4f8ff;}
[data-toantin-standalone="math_graph"] .tt-mg-builder-order:disabled { opacity:.38; }
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config { max-width:calc(100vw - 20px); }

[data-toantin-standalone="math_graph"] .tt-mg-expression-form { margin-bottom:12px; }

/* PATCH_31: Empty inline action row must not reserve height after eye/trash move to header. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-item:not(.is-floating-config) .tt-mg-expression-actions:has(> .tt-mg-card-float-reset:only-child) {
  display:none;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-trash-action svg {
  width:20px; height:20px;
}

/* PATCH_31: position reset follows trash in the shared top chrome. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-card-float-reset,
[data-toantin-standalone="math_graph"] .tt-mg-construction-header > .tt-mg-panel-reset {
  display:none; flex:0 0 34px; width:34px; min-width:34px; height:34px;
  padding:4px; margin:0; align-items:center; justify-content:center;
  border:1px solid #cbdcf4; border-radius:9px; color:#145dbe; background:#f4f8ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-floating-config .tt-mg-expression-item__header .tt-mg-card-float-reset,
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder.is-floating-config .tt-mg-construction-header > .tt-mg-panel-reset {
  display:inline-flex;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-expression-actions:empty { display:none; }

/* PATCH_32 — Một đồ thị / một thẻ cấu hình; trình nhập chỉ xuất hiện theo yêu cầu. */
[data-toantin-standalone="math_graph"] #expression-form[hidden],
[data-toantin-standalone="math_graph"] #construction-builder[hidden],
[data-toantin-standalone="math_graph"] #add-function-menu[hidden] { display:none; }
[data-toantin-standalone="math_graph"] .tt-mg-custom-form-head {
  display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px;
}
[data-toantin-standalone="math_graph"] .tt-mg-custom-form-close,
[data-toantin-standalone="math_graph"] .tt-mg-construction-cancel {
  flex:0 0 36px; width:36px; height:36px; padding:0; border:1px solid #c6d8f3;
  border-radius:10px; background:#f7fbff; color:#436184; font-size:22px; line-height:1;
}
[data-toantin-standalone="math_graph"] .tt-mg-custom-form-close:hover,
[data-toantin-standalone="math_graph"] .tt-mg-construction-cancel:hover { background:#e7f1ff; }
[data-toantin-standalone="math_graph"] .tt-mg-add-function-wrap { position:static; }
/* Khi đặt trong thẻ của đồ thị, bảng mẫu dựng chỉ là phần nội dung, không là panel thứ hai. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-construction-builder--embedded {
  display:block; width:100%; min-width:0; max-width:100%; box-sizing:border-box;
  margin:10px 0 0; padding:0; border:0; border-radius:0; box-shadow:none; background:transparent;
  font-size:var(--tt-mg-builder-font-size,16px);
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-construction-builder--embedded .tt-mg-coefficient-grid {
  min-width:0; max-width:100%; margin-top:0;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-construction-builder--embedded .tt-mg-construction-table-wrap {
  max-width:100%; min-width:0; overflow-x:auto;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-construction-builder--embedded .tt-mg-construction-actions {
  display:flex; align-items:center; margin-top:10px;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item .tt-mg-construction-builder--embedded .tt-mg-construction-actions > .tt-mg-btn--primary {
  width:100%; min-width:0; flex:1 1 auto;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.has-construction-editor .tt-mg-expression-details {
  min-width:0; max-width:100%;
}
/* Tay nắm nổi luôn ở đầu hàng, không được bị đẩy xuống hàng 2 khi kéo hẹp cột. */
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item.is-collapsed .tt-mg-expression-item__header {
  display:flex; flex-flow:row nowrap; align-items:center; justify-content:flex-start;
  min-width:0; max-width:100%; width:100%; gap:4px; overflow-x:auto; overflow-y:hidden;
  scrollbar-width:thin; overscroll-behavior-inline:contain;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header > *,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-expression-font-controls,
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-expression-order-actions {
  flex:0 0 auto; white-space:nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-card-float-grip {
  order:-1; flex-shrink:0; margin:0;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item__header .tt-mg-eye-action { margin-left:auto; }
/* Tránh bảng dựng tạm bị che bởi CSS chia cột cũ. */
[data-toantin-standalone="math_graph"] #construction-builder:not([hidden]) { max-width:100%; min-width:0; }
/* Grid 4 hệ số trong sidebar hẹp: tránh intrinsic input width tràn khỏi từng ô. */
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder--embedded .tt-mg-coefficient-field {
  display:block; min-width:0; max-width:100%; overflow:hidden;
}
[data-toantin-standalone="math_graph"] .tt-mg-construction-builder--embedded .tt-mg-coefficient-field > input {
  display:block; box-sizing:border-box; width:100%; max-width:100%; min-width:0;
}
[data-toantin-standalone="math_graph"] .tt-mg-expression-item:not(.is-floating-config) .tt-mg-construction-builder--embedded .tt-mg-coefficient-grid {
  grid-template-columns:repeat(2,minmax(0,1fr));
}

/* PATCH_33 — Add Function menu MUST open in the visible sidebar flow.
   PATCH_32 changed the wrapper to position:static while leaving its menu
   position:absolute/top:100%, so the menu could appear below the whole
   column or outside the viewport when the Add button was clicked. */
[data-toantin-standalone="math_graph"] .tt-mg-add-function-wrap {
  position: relative;
}
[data-toantin-standalone="math_graph"] #add-function-menu:not([hidden]) {
  position: static;
  inset: auto;
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(60vh, 460px);
  overflow-x: hidden;
  overflow-y: auto;
  margin-top: 8px;
  box-sizing: border-box;
}
[data-toantin-standalone="math_graph"] #add-function-menu[hidden] {
  display: none;
}

/* PATCH_34 — Presentation-scale HUD: 2 independent axis units, compact LCD controls. */
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-divider {
  margin: 4px 0 10px; padding-top: 10px; border-top: 1px solid #d8e5f7;
  font-size: 12px; font-weight: 750; color: #476285;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-panel {
  max-height: calc(100dvh - 20px); overflow-y: auto; overscroll-behavior: contain;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row [data-axis-reset] {
  min-width: 44px; width: auto; padding: 0 2px; font-size: 13px; font-weight: 850;
  font-variant-numeric: tabular-nums; white-space: nowrap; background: #eaf3ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-presentation-font-row [data-axis-reset]:hover {
  background: #dcecff; border-color: #2a78de;
}

/* PATCH_35 — Nhãn/tọa độ điểm: 2 công tắc nhỏ gọn trên thanh thuộc tính nhanh. */
[data-toantin-standalone="math_graph"] .tt-mg-context-btn.tt-mg-point-label-eye {
  min-width: 36px; padding-inline: 6px; font-size: 12px;
  font-weight: 800; letter-spacing: -.025em;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-label-eye[aria-pressed="true"] {
  color: #047857; background: #e3f8ee; border-color: #7ed7b0;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-label-eye[aria-pressed="false"] {
  color: #8895aa; background: #f3f6fb; border-color: #dbe4ef;
}
[data-toantin-standalone="math_graph"] .tt-mg-point-label-icon { white-space: nowrap; pointer-events: none; }
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[data-visibility-state="mixed"] {
  border-color: #b6ceef; background: #f3f8ff;
}
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[data-visibility-state="mixed"] .tt-mg-visibility-eye { opacity: .65; }

/* Trạng thái hiển thị một phần: mắt mở màu hổ phách, không hiện 2 SVG cùng lúc. */
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[aria-pressed="mixed"] .tt-mg-visibility-eye-off { display: none; }
[data-toantin-standalone="math_graph"] .tt-mg-visibility-all-row[aria-pressed="mixed"] .tt-mg-visibility-eye { color: #ad6800; opacity: 1; }

/* PATCH_36 — TEACHING SIDE RAIL REOPEN + LCD VIEW HUD. */
/* Display policy only hides a side which is really collapsed; a manual reopen
   immediately exits teaching via the public command, never a DOM-only hack. */
/* PATCH_37: PATCH_36's :not(.is-left/right-collapsed) teaching overrides
   displayed full side headers inside 36px focus tracks and removed their
   reopening rails. Teaching owns compact rails until it is exited; never
   unhide panel content while the teaching grid still reserves only 36px. */
[data-toantin-standalone="math_graph"] .tt-mg-zoom-percent {
  flex: 0 0 auto; min-width: 48px; height: 30px; padding: 2px 5px;
  border: 1px solid #c9ddfa; border-radius: 8px;
  background: #edf5ff; color: #0754c4; font-size: 12px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-zoom-percent:hover,
[data-toantin-standalone="math_graph"] .tt-mg-zoom-percent:focus-visible { background: #dbeafe; outline: 2px solid #93c5fd; outline-offset: 1px; }
[data-toantin-standalone="math_graph"] .tt-mg-graph-footer {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-viewport-inline {
  flex: 0 1 auto; max-width: 47%; min-width: 0;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
[data-toantin-standalone="math_graph"] .tt-mg-view-origin {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; min-height: 30px; padding: 3px 7px; border: 1px solid #bdd5f5;
  border-radius: 8px; background: #eef5ff; color: #0754c4;
  font-weight: 750; font-size: 12px; white-space: nowrap;
}
[data-toantin-standalone="math_graph"] .tt-mg-view-origin svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
[data-toantin-standalone="math_graph"] .tt-mg-view-origin:hover,
[data-toantin-standalone="math_graph"] .tt-mg-view-origin:focus-visible { background: #dbeafe; outline: 2px solid #93c5fd; }
[data-toantin-standalone="math_graph"] .tt-mg-contextual-tip {
  flex: 0 1 auto; margin-left: auto; min-width: 90px; max-width: min(38%, 430px);
  overflow: hidden; background: transparent;
}
[data-toantin-standalone="math_graph"] .tt-mg-contextual-tip span {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
@media (max-width: 990px) {
  [data-toantin-standalone="math_graph"] .tt-mg-viewport-inline { max-width: 36%; }
  [data-toantin-standalone="math_graph"] .tt-mg-contextual-tip { max-width: 33%; }
  [data-toantin-standalone="math_graph"] .tt-mg-view-origin { padding-inline: 5px; }
}
@media (max-width: 650px) {
  [data-toantin-standalone="math_graph"] .tt-mg-graph-hud__label { display: none; }
  [data-toantin-standalone="math_graph"] .tt-mg-zoom-percent { min-width: 40px; font-size: 11px; }
  [data-toantin-standalone="math_graph"] .tt-mg-viewport-inline { max-width: 32%; font-size: 10px; }
  [data-toantin-standalone="math_graph"] .tt-mg-view-origin span { display: none; }
  [data-toantin-standalone="math_graph"] .tt-mg-contextual-tip { max-width: 32%; }
  [data-toantin-standalone="math_graph"] .tt-mg-footer-status { display: none; }
}

/* PATCH_37 — SIDEBAR STATE AUTHORITY / SAFE RAIL RECOVERY. */
/* A teaching workspace always exposes usable reopen rails, never the
   300px contents packed into a 36px grid track. A rail click exits teaching
   before changing collapse state via the single JS controller. */
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-side-header,
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-side-body { display: none; }
[data-toantin-standalone="math_graph"].is-teaching .tt-mg-side-column .tt-mg-collapsed-rail {
  display: flex; min-width: 0; width: 100%; z-index: 2;
}
/* When teaching and graph-focus are both off, real collapse flags are the
   sole source of truth for the five desktop tracks. These final selectors
   override historical mode/resize rules without forced priority declarations or Host CSS. */
@media (min-width: 1200px) {
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode):not(.is-left-collapsed):not(.is-right-collapsed) .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width,318px) 6px minmax(0,1fr) 6px var(--tt-mg-right-width,332px);
  }
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode).is-left-collapsed:not(.is-right-collapsed) .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0,1fr) 6px var(--tt-mg-right-width,332px);
  }
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode):not(.is-left-collapsed).is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width,318px) 6px minmax(0,1fr) 0 36px;
  }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode):not(.is-left-collapsed):not(.is-right-collapsed) .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width,270px) 6px minmax(0,1fr) 6px var(--tt-mg-right-width,290px);
  }
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode).is-left-collapsed:not(.is-right-collapsed) .tt-mg-main-layout {
    grid-template-columns: 36px 0 minmax(0,1fr) 6px var(--tt-mg-right-width,290px);
  }
  [data-toantin-standalone="math_graph"]:not(.is-teaching):not(.is-focus-mode):not(.is-left-collapsed).is-right-collapsed .tt-mg-main-layout {
    grid-template-columns: var(--tt-mg-left-width,270px) 6px minmax(0,1fr) 0 36px;
  }
}
/* Keep the rail as the highest interactive child in the collapsed panel. */
[data-toantin-standalone="math_graph"].is-left-collapsed .tt-mg-expression-column .tt-mg-collapsed-rail,
[data-toantin-standalone="math_graph"].is-right-collapsed .tt-mg-tools-column .tt-mg-collapsed-rail {
  z-index: 3; cursor: pointer;
}

/* PATCH_38 — NORMAL HORIZONTAL SMART STICKY TOOLBAR.
   The actual Main Toolbar remains in document flow and sticks to the top of
   the browser scrolling viewport. No duplicate toolbar, scroll listener,
   JS position takeover or persisted preference is introduced.
   Fullscreen Smart Dock, floating/dragged, vertical and collapsed modes retain
   their existing independent positioning rules. */
[data-toantin-standalone="math_graph"]:not(.is-toolbar-floating):not(.is-toolbar-vertical):not(.is-toolbar-collapsed)
.tt-mg-shell:not(.is-fullscreen) > .tt-mg-toolbar-shell {
  position: sticky;
  top: 0;
  z-index: 72;
  /* Existing translucent chrome remains readable over scrolled content. */
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 5px 18px rgba(16, 42, 86, .09);
}
