:root {
  --le-coral: #f18478;
  --le-coral-dark: #d9685e;
  --le-coral-soft: #fff2ef;
  --le-ink: #20262d;
  --le-muted: #5e6a78;
  --le-line: rgba(32, 38, 45, 0.14);
  --le-teal: #167c73;
  --le-teal-soft: #e8f6f3;
  --le-purple: #7654a8;
  --le-purple-soft: #f3eef9;
  color-scheme: light;
}

html {
  min-width: 0;
  background: transparent;
}

body.le-math-embed {
  min-width: 0;
  margin: 0;
  padding: clamp(10px, 2.5vw, 24px);
  overflow-x: hidden;
  background: transparent;
  color: var(--le-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.le-math-embed *,
.le-math-embed *::before,
.le-math-embed *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

.le-math-embed button,
.le-math-embed input,
.le-math-embed select,
.le-math-embed textarea {
  font: inherit;
}

.le-math-embed button {
  min-height: 44px;
}

.le-math-embed button:focus-visible,
.le-math-embed input:focus-visible,
.le-math-embed select:focus-visible {
  outline: 3px solid rgba(22, 124, 115, 0.28) !important;
  outline-offset: 2px;
}

.le-math-embed .quiz-container,
.le-math-embed .panel,
.le-math-embed .kalk-shell {
  border-color: rgba(241, 132, 120, 0.48) !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 16px 38px rgba(32, 38, 45, 0.08) !important;
}

.le-math-embed .header,
.le-math-embed .hero,
.le-math-embed .kalk-hero {
  border-radius: 8px !important;
  background: var(--le-coral) !important;
}

.le-math-embed .header h1,
.le-math-embed .hero h1,
.le-math-embed .hero h2,
.le-math-embed .kalk-hero h2 {
  color: #fff !important;
  letter-spacing: 0 !important;
}

.le-math-embed .hidden {
  display: none !important;
}

.le-math-embed .correct {
  color: #146b4b !important;
}

.le-math-embed .incorrect {
  color: #b53c35 !important;
}

.le-math-embed--fractions .quiz-container,
.le-math-embed--percentages .quiz-container,
.le-math-embed--pythagoras .quiz-container,
.le-math-embed--flat-shapes .quiz-container {
  width: min(860px, 100%);
  max-width: none;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.le-math-embed--fractions #startButton,
.le-math-embed--fractions .buttons button,
.le-math-embed--percentages .start-container button,
.le-math-embed--percentages .buttons button,
.le-math-embed--pythagoras .level-buttons button,
.le-math-embed--pythagoras .buttons button,
.le-math-embed--flat-shapes .level-buttons button,
.le-math-embed--flat-shapes .buttons button {
  border-color: var(--le-coral-dark) !important;
  border-radius: 6px !important;
  background: var(--le-coral) !important;
  color: #fff !important;
  font-weight: 800 !important;
}

.le-math-embed--fractions input,
.le-math-embed--percentages input,
.le-math-embed--pythagoras input,
.le-math-embed--flat-shapes input {
  min-height: 44px;
  border: 1px solid var(--le-line) !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: var(--le-ink) !important;
}

.le-math-embed--fractions li,
.le-math-embed--pythagoras li,
.le-math-embed--flat-shapes li {
  border-radius: 8px !important;
}

.le-math-embed--geometry .header {
  margin-bottom: 12px;
}

.le-math-embed--geometry .wrap,
.le-math-embed--visualizer .container {
  width: min(1180px, 100%);
  max-width: none;
}

.le-math-embed--geometry .card,
.le-math-embed--geometry .question-card,
.le-math-embed--geometry .result-card {
  border-radius: 8px !important;
}

.le-math-embed--visualizer .hero {
  margin-bottom: 14px;
}

.le-math-embed--visualizer .panel {
  padding: clamp(12px, 2.5vw, 20px);
}

.le-math-embed--calculator .kalk-wrap {
  padding-top: 0;
}

.le-math-embed--calculator .kalk-shell {
  width: min(560px, 100%);
  max-width: none;
}

.le-math-embed--calculator .kalk-hero {
  width: min(560px, 100%);
  max-width: none;
}

@media (max-width: 560px) {
  body.le-math-embed {
    padding: 8px;
  }

  .le-math-embed .quiz-container,
  .le-math-embed .panel,
  .le-math-embed .kalk-shell {
    box-shadow: none !important;
  }

  .le-math-embed--fractions .quiz-container,
  .le-math-embed--percentages .quiz-container,
  .le-math-embed--pythagoras .quiz-container,
  .le-math-embed--flat-shapes .quiz-container {
    padding: 14px;
  }
}

/* A bounded workspace inside the iframe, with independent help/result panes. */
html:has(body.le-math-embed),
body.le-math-embed { height: 100dvh; min-height: 0; overflow: hidden; }
body.le-math-embed { padding: 6px; }
.le-math-embed [hidden], .le-math-embed .hidden { display: none !important; }
.le-math-embed .quiz-wrapper { height: 100%; min-height: 0; }
.le-math-embed .quiz-container { height: 100%; min-height: 0; display: flex; flex-direction: column; padding: 12px; overflow: hidden; }
.le-math-embed .quiz-container > p,
.le-math-embed .quiz-container > .header { flex-shrink: 0; margin: 0 0 8px; font-size: 1rem; line-height: 1.35; padding: 4px; }
.le-math-embed #quizContent { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.le-math-embed #quizForm { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.le-math-embed #questionList { flex: 1; min-height: 0; padding: 0; margin: 0; overflow: auto; overscroll-behavior: contain; }
.le-math-embed #questionList > li { margin: 0; padding: 8px; min-height: 0; gap: 6px; }
.le-math-embed .question-row,
.le-math-embed .question-content { gap: 6px; }
.le-math-embed .question-content > div:first-child { font-size: clamp(1rem, 2.8vh, 1.25rem); }
.le-math-embed .question-content canvas { height: clamp(70px, 28vh, 150px); width: auto; max-width: 100%; margin: 0; object-fit: contain; }
.le-math-embed .progress-container { flex-shrink: 0; margin-bottom: 6px; }
.le-math-embed .progress-bar { height: 18px; line-height: 18px; font-size: .75rem; }
.le-math-embed .progress-info { flex-direction: row; gap: 12px; margin-bottom: 6px; font-size: .8rem; }
.le-math-embed .buttons { display: flex; flex-shrink: 0; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.le-math-embed .buttons button { flex: 1; min-height: 44px; margin: 0; padding: 6px; font-size: .85rem; line-height: 1.2; }
.le-math-embed .result,
.le-math-embed #result { margin-top: 6px; line-height: 1.35; font-size: .9rem; }
.le-math-embed #result:empty,
.le-math-embed .result:empty { display: none; }
.le-math-embed .level-buttons { margin: auto 0; overflow: auto; gap: 8px; }
.le-math-embed .level-buttons button { padding: 10px; }
.le-math-embed .math-continue-hint { display: block; font-size: .75rem; margin: 6px 0 0; color: var(--le-muted); }
.le-math-embed .modal-content { overflow: auto; }
.le-math-embed .modal-content canvas { max-height: calc(100dvh - 120px); object-fit: contain; }
.le-math-embed .modal-content .close-button { position: static; align-self: end; }
.le-math-embed--fractions #questionList > li { height: 100%; justify-content: center; }
.le-math-embed--fractions .question-content > div:first-child { font-size: 2rem; }
.le-math-embed--fractions .input-group { width: 100%; }
.le-math-embed--fractions .input-group input { width: 100%; }
.le-math-embed--percentages #taskContainer { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.le-math-embed--percentages .task-text { margin: 4px 0; line-height: 1.3; }
.le-math-embed--percentages .cross-container { gap: 6px; margin: 8px 0; font-size: .95rem; }
.le-math-embed--percentages .equation-line,
.le-math-embed--percentages .blank-line { gap: 5px; margin: 0; font-size: .85rem; max-width: 100%; }
.le-math-embed--percentages .equation-line input { min-width: 0; width: 22% !important; }
.le-math-embed--percentages .blank-line input { width: 40%; }
.le-math-embed--percentages .result-line { margin: 0; }
.le-math-embed--percentages .feedback { flex-shrink: 0; min-height: 0; margin: 4px 0; }
.le-math-embed--percentages .instruction { position: absolute; inset: 8px 8px 62px; margin: 0; z-index: 5; overflow: auto; overscroll-behavior: contain; }
.le-math-embed--geometry { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.le-math-embed--geometry .header { padding: 4px; margin-bottom: 6px; }
.le-math-embed--geometry .header h1 { font-size: 1rem; margin: 0; }
.le-math-embed--geometry .header p { display: none; }
.le-math-embed--geometry .wrap { padding: 0; min-height: 0; height: 100%; overflow: hidden; }
.le-math-embed--geometry #sSetup,
.le-math-embed--geometry #sRes { height: 100%; overflow: auto; overscroll-behavior: contain; }
.le-math-embed--geometry #sSetup > .btn-start { position: sticky; bottom: 3px; }
.le-math-embed--geometry #sQuiz { height: 100%; display: flex; flex-direction: column; }
.le-math-embed--geometry .prog-row { margin-bottom: 6px; }
.le-math-embed--geometry .q-card { flex: 1; min-height: 0; overflow: auto; padding: 8px; overscroll-behavior: contain; }
.le-math-embed--geometry .q-badge { font-size: .65rem; margin-bottom: 4px; }
.le-math-embed--geometry .q-fig-name { font-size: 1rem; margin-bottom: 4px; }
.le-math-embed--geometry .q-svg { margin-bottom: 4px; }
.le-math-embed--geometry .q-svg svg { height: clamp(64px, 21vh, 130px); }
.le-math-embed--geometry .q-chips { margin-bottom: 4px; gap: 4px; }
.le-math-embed--geometry .chip { padding: 2px 6px; font-size: .8rem; }
.le-math-embed--geometry .opts { gap: 6px; margin-top: 6px; }
.le-math-embed--geometry .opt-btn { min-height: 44px; padding: 6px; font-size: .85rem; }
.le-math-embed--geometry .num-row { margin-top: 6px; }
.le-math-embed--geometry .fb { padding: 6px; margin-top: 6px; font-size: .85rem; line-height: 1.3; }
.le-math-embed--geometry .btn-next { min-height: 44px; padding: 6px; margin-top: 6px; position: sticky; bottom: 0; }
.le-math-embed--geometry .q-card:has(.btn-next.show) .q-svg svg { height: 64px; }
.le-math-embed--calculator .kalk-wrap,
.le-math-embed--visualizer .container { height: 100%; padding: 0; display: flex; flex-direction: column; min-height: 0; }
.le-math-embed--calculator .kalk-hero,
.le-math-embed--visualizer .hero { padding: 4px; margin-bottom: 6px; }
.le-math-embed--calculator .kalk-hero h2,
.le-math-embed--visualizer .hero h1 { font-size: 1rem; }
.le-math-embed--visualizer .hero p { font-size: .75rem; margin: 0; }
.le-math-embed--calculator .kalk-shell { flex: 1; min-height: 0; padding: 8px; overflow: auto; overscroll-behavior: contain; }
.le-math-embed--calculator .kalk-dsp { position: sticky; top: 0; z-index: 3; min-height: 70px; }
.le-math-embed--calculator .kalk-toprow { min-height: 70px; }
.le-math-embed--calculator .kb { min-height: 40px; }
.le-math-embed--visualizer .app-grid { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.le-math-embed--visualizer .panel { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.le-math-embed--visualizer .expr-display { position: sticky; top: 0; z-index: 2; }
.le-math-embed--visualizer .panel > .kb-grid:last-child { position: sticky; bottom: 0; background: white; }
@media (max-width: 700px) {
  .le-math-embed--visualizer .app-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .le-math-embed--visualizer .panel { padding: 8px; }
  .le-math-embed--visualizer .panel h2 { font-size: 1rem; }
}
