@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/OpenDyslexic-Regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/OpenDyslexic-Bold.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 700;
}

:root {
  --spm-orange: #ff9f1c;
  --spm-orange-dark: #9f4800;
  --spm-orange-soft: #fff6e8;
  --spm-orange-border: #ffc66e;
  --spm-ink: #172033;
  --spm-muted: #5b6579;
  --spm-border: #ead8c3;
  --spm-surface: #ffffff;
  --spm-focus: #ffbf47;
}

.spm-root {
  box-sizing: border-box;
  width: 100%;
  max-height: 0;
  margin: 0;
  color: var(--spm-ink);
  background: var(--spm-surface);
  border: 0 solid var(--spm-border);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(24, 45, 86, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-0.6rem);
  transition: max-height 260ms ease, margin 260ms ease, opacity 180ms ease, transform 260ms ease, border-width 0ms linear 260ms;
}

.spm-root.spm-panel-open {
  max-height: 40rem;
  margin: 0 0 1.25rem;
  border-width: 1px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition: max-height 320ms ease, margin 320ms ease, opacity 180ms ease 40ms, transform 320ms ease, border-width 0ms linear;
}

.spm-root *,
.spm-popover * {
  box-sizing: border-box;
}

.spm-mainbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
}

.spm-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  white-space: nowrap;
}

.spm-brand-icon {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  color: #fff;
  background: var(--spm-orange);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.spm-launcher {
  display: inline-grid !important;
  flex: 0 0 auto !important;
  width: 2.25rem !important;
  min-width: 2.25rem !important;
  height: 2.25rem !important;
  min-height: 2.25rem !important;
  margin: 0 0.4rem 0 0 !important;
  padding: 0 !important;
  place-items: center !important;
  color: var(--spm-orange-dark) !important;
  background: rgba(255, 255, 255, 0.82) !important;
  border: 1px solid var(--spm-orange-border) !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 7px rgba(24, 45, 86, 0.1) !important;
  cursor: pointer !important;
  font: 700 0.8rem/1 OpenDyslexic, Inter, system-ui, sans-serif !important;
}

.spm-launcher:hover,
.spm-launcher:focus-visible,
.spm-launcher-active {
  color: #fff !important;
  background: var(--spm-orange) !important;
  border-color: var(--spm-orange) !important;
}

.spm-launcher-fallback {
  display: grid !important;
  align-self: flex-end !important;
  justify-self: end !important;
  margin: 0 0 0.55rem auto !important;
}

.spm-language-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.spm-label {
  color: var(--spm-muted);
  font-size: 0.875rem;
  font-weight: 650;
}

.spm-language,
.spm-root button {
  min-height: 2.5rem;
  margin: 0;
  border-radius: 8px;
  font: inherit;
}

.spm-language {
  min-width: 12rem;
  padding: 0.45rem 2.2rem 0.45rem 0.7rem;
  color: var(--spm-ink);
  background-color: #fff;
  border: 1px solid #aeb9cc;
}

.spm-primary {
  padding: 0.5rem 0.9rem;
  color: #fff;
  background: var(--spm-orange);
  border: 1px solid var(--spm-orange);
  cursor: pointer;
  font-weight: 700;
}

.spm-primary:hover {
  background: var(--spm-orange-dark);
  border-color: var(--spm-orange-dark);
}

.spm-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  background: #fffaf3;
  border-top: 1px solid var(--spm-border);
}

.spm-toolgroup {
  display: inline-flex;
}

.spm-toolgroup .spm-tool {
  border-radius: 0;
  border-right-width: 0;
}

.spm-toolgroup .spm-tool:first-child {
  border-radius: 7px 0 0 7px;
}

.spm-toolgroup .spm-tool:last-child {
  border-right-width: 1px;
  border-radius: 0 7px 7px 0;
}

.spm-tool {
  min-width: 2.5rem;
  padding: 0.4rem 0.65rem;
  color: #25304a;
  background: #fff;
  border: 1px solid #bdc7d8;
  cursor: pointer;
  font-size: 0.875rem !important;
  font-weight: 650;
}

.spm-tool:hover,
.spm-tool[aria-pressed="true"] {
  color: var(--spm-orange-dark);
  background: var(--spm-orange-soft);
  border-color: var(--spm-orange-border);
}

.spm-remove {
  margin-left: auto !important;
  color: #8a2632;
  background: #fff8f8;
  border-color: #e9b7bc;
}

.spm-status {
  min-height: 0;
  padding: 0 1rem;
  color: var(--spm-muted);
  font-size: 0.875rem;
}

.spm-status:not(:empty) {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  border-top: 1px solid var(--spm-border);
}

.spm-status-error { color: #9f1e2d; background: #fff3f4; }
.spm-status-success { color: #17623a; background: #f1fbf5; }
.spm-status-loading::before {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  margin-right: 0.5rem;
  border: 2px solid #efd9b9;
  border-top-color: var(--spm-orange);
  border-radius: 50%;
  content: "";
  vertical-align: -0.1rem;
  animation: spm-spin 0.8s linear infinite;
}

@keyframes spm-spin { to { transform: rotate(360deg); } }

.spm-root button:focus-visible,
.spm-root select:focus-visible,
.spm-term:focus-visible,
.spm-popover button:focus-visible {
  outline: 3px solid var(--spm-focus) !important;
  outline-offset: 2px;
}

.spm-root button:disabled,
.spm-root select:disabled {
  cursor: wait;
  opacity: 0.6;
}

.spm-content {
  transition: color 150ms ease, background-color 150ms ease;
}

.spm-content.spm-readable,
.spm-content.spm-readable *,
.spm-root.spm-readable,
.spm-root.spm-readable *,
html.spm-readable-page #masteriyo-interactive-course,
html.spm-readable-page #masteriyo-interactive-course * {
  font-family: OpenDyslexic, Verdana, Arial, sans-serif !important;
  letter-spacing: 0.018em !important;
  line-height: 1.65 !important;
  word-spacing: 0.075em !important;
}

.spm-term {
  display: inline !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  color: #9a4708 !important;
  background: linear-gradient(to top, rgba(245, 158, 11, 0.16) 35%, transparent 35%) !important;
  border: 0 !important;
  border-bottom: 2px dotted currentColor !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: help !important;
  font: inherit !important;
  font-weight: 650 !important;
  line-height: inherit !important;
  text-align: inherit;
}

.spm-term:hover,
.spm-term[aria-expanded="true"] {
  color: #713304 !important;
  background-color: rgba(245, 158, 11, 0.2) !important;
}

.spm-speaking {
  background: #fff1aa !important;
  color: #182033 !important;
  border-radius: 5px;
  box-shadow: 0 0 0 4px #fff1aa;
}

.spm-popover {
  position: fixed;
  z-index: 999999;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(34rem, calc(100vh - 2rem));
  overflow: auto;
  color: #182033;
  background: #fff;
  border: 1px solid #b9c5d9;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(12, 27, 57, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: contain;
}

.spm-popover-single {
  width: min(30rem, calc(100vw - 2rem));
}

.spm-popover[hidden] { display: none !important; }

.spm-popover-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  color: #fff;
  background: var(--spm-orange);
}

.spm-popover-close {
  display: grid;
  width: 2rem;
  height: 2rem;
  min-height: 0;
  padding: 0;
  place-items: center;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 7px;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.spm-popover-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.spm-popover-columns-single {
  grid-template-columns: minmax(0, 1fr);
}

.spm-popover-column {
  min-width: 0;
  padding: 1rem;
}

.spm-popover-column + .spm-popover-column {
  background: var(--spm-orange-soft);
  border-left: 1px solid var(--spm-orange-border);
}

.spm-language-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
  color: var(--spm-orange-dark);
  font-size: 0.9rem;
  font-weight: 750;
}

.spm-language-flag {
  display: inline-flex !important;
  flex: 0 0 1em !important;
  width: 1em !important;
  height: 1em !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  font-size: 1em !important;
  line-height: 1 !important;
}

.spm-language-flag img,
.spm-language-flag img.emoji,
.spm-language-name img.emoji {
  display: inline-block !important;
  width: 1em !important;
  min-width: 1em !important;
  max-width: 1em !important;
  height: 1em !important;
  min-height: 1em !important;
  max-height: 1em !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: contain !important;
  vertical-align: -0.1em !important;
}

.spm-definition + .spm-definition { margin-top: 0.9rem; }

.spm-definition-label {
  display: block;
  margin-bottom: 0.15rem;
  color: #69748a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spm-definition p {
  margin: 0;
  color: inherit;
  font: inherit;
}

.spm-manual-anchor {
  display: none !important;
}

@media (max-width: 700px) {
  .spm-mainbar { align-items: flex-start; flex-direction: column; }
  .spm-language-controls { width: 100%; justify-content: flex-start; }
  .spm-language { flex: 1 1 11rem; min-width: 0; }
  .spm-primary { flex: 1 1 auto; }
  .spm-remove { width: 100%; margin-left: 0 !important; }
  .spm-popover-columns { grid-template-columns: 1fr; }
  .spm-popover-column + .spm-popover-column { border-top: 1px solid var(--spm-orange-border); border-left: 0; }
  .spm-root.spm-panel-open { max-height: 52rem; }
}
