.smi-fi {
  --f-bg: #FFFFFF;
  --f-surface: #F0F1FD;
  --f-ink: #131739;
  --f-ink-deep: #05060F;
  --f-accent: #2235DD;
  --f-accent-hover: #1A2BC6;
  --f-line: #E4E7FD;
  --f-ease: cubic-bezier(.22, .61, .36, 1);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9990;
  font-family: 'Albert Sans', sans-serif;
  color: var(--f-ink);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.smi-fi *,
.smi-fi *::before,
.smi-fi *::after { box-sizing: border-box; }

/* The theme sets uppercase and tracking on every button. Sentence case reads
   better here and keeps the widget consistent with the course pages. */
.smi-fi button,
.smi-fi a {
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* Launcher */
.smi-fi .smi-fi__launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  order: 2;
  margin: 0;
  padding: 13px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--f-accent);
  color: #FFFFFF;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 14px 30px -14px rgba(34, 53, 221, .7);
  transition: background .2s var(--f-ease), transform .2s var(--f-ease);
}

.smi-fi .smi-fi__launch:hover {
  background: var(--f-accent-hover);
  transform: translateY(-2px);
}

.smi-fi .smi-fi__launch:focus-visible {
  outline: 3px solid var(--f-ink-deep);
  outline-offset: 3px;
}

.smi-fi__launch-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 999px;
  border: 2px solid #FFFFFF;
  position: relative;
}

.smi-fi__launch-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 9px;
  height: 2px;
  border-radius: 2px;
  background: #FFFFFF;
  transform: rotate(45deg);
}

.smi-fi.is-open .smi-fi__launch-label { display: none; }
.smi-fi.is-open .smi-fi__launch { padding: 13px; }

/* Panel */
.smi-fi .smi-fi__panel {
  order: 1;
  width: min(370px, calc(100vw - 40px));
  max-height: min(560px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  background: var(--f-bg);
  border: 1px solid var(--f-line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 26px 60px -26px rgba(34, 53, 221, .55);
}

.smi-fi.is-open .smi-fi__panel { display: flex; }

.smi-fi__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  background: var(--f-surface);
  border-bottom: 1px solid var(--f-line);
}

.smi-fi .smi-fi__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--f-ink-deep);
}

.smi-fi .smi-fi__progress {
  margin: 3px 0 0;
  font-size: .8rem;
  font-weight: 600;
  color: var(--f-accent);
}

.smi-fi .smi-fi__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--f-line);
  border-radius: 999px;
  background: #FFFFFF;
  color: var(--f-ink-deep);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s var(--f-ease);
}

.smi-fi .smi-fi__close:hover { background: var(--f-surface); }

.smi-fi__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
}

.smi-fi .smi-fi__q {
  margin: 0 0 14px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--f-ink-deep);
}

.smi-fi .smi-fi__opts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.smi-fi .smi-fi__opts li { margin: 0; }

.smi-fi .smi-fi__opt {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  text-align: left;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--f-ink-deep);
  background: #FFFFFF;
  border: 1px solid var(--f-line);
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s var(--f-ease), border-color .18s var(--f-ease), transform .18s var(--f-ease);
}

.smi-fi .smi-fi__opt:hover {
  background: var(--f-surface);
  border-color: var(--f-accent);
  transform: translateX(2px);
}

.smi-fi .smi-fi__opt:focus-visible {
  outline: 3px solid var(--f-accent);
  outline-offset: 2px;
}

/* Results */
.smi-fi .smi-fi__note {
  margin: 0 0 14px;
  padding: 11px 13px;
  font-size: .85rem;
  line-height: 1.45;
  background: var(--f-surface);
  border-radius: 10px;
}

.smi-fi .smi-fi__results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.smi-fi .smi-fi__res {
  margin: 0;
  padding: 14px;
  background: #FFFFFF;
  border: 1px solid var(--f-line);
  border-radius: 10px;
}

.smi-fi .smi-fi__res.is-top {
  background: var(--f-surface);
  border-color: var(--f-accent);
}

.smi-fi .smi-fi__badge {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--f-accent);
  border-radius: 999px;
}

.smi-fi .smi-fi__res h4 {
  margin: 0 0 3px;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.28;
  color: var(--f-ink-deep);
}

.smi-fi .smi-fi__meta {
  margin: 0 0 9px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--f-ink);
}

.smi-fi a.smi-fi__link {
  display: inline-block;
  font-size: .85rem;
  font-weight: 700;
  color: var(--f-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.smi-fi a.smi-fi__link:hover {
  color: var(--f-accent-hover);
  text-decoration-thickness: 2px;
}

.smi-fi__actions {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.smi-fi a.smi-fi__btn {
  display: block;
  padding: 13px 18px;
  text-align: center;
  font-size: .92rem;
  font-weight: 700;
  color: #FFFFFF !important;
  background: var(--f-accent);
  border: 2px solid var(--f-accent);
  border-radius: 999px;
  text-decoration: none;
  transition: background .2s var(--f-ease);
}

.smi-fi a.smi-fi__btn:hover {
  background: var(--f-accent-hover);
  border-color: var(--f-accent-hover);
}

.smi-fi .smi-fi__restart {
  padding: 11px 18px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  color: var(--f-ink-deep);
  background: #FFFFFF;
  border: 1px solid var(--f-line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s var(--f-ease);
}

.smi-fi .smi-fi__restart:hover { background: var(--f-surface); }

/* Footer */
.smi-fi__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  background: var(--f-surface);
  border-top: 1px solid var(--f-line);
}

.smi-fi .smi-fi__back {
  padding: 7px 14px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  color: var(--f-ink-deep);
  background: #FFFFFF;
  border: 1px solid var(--f-line);
  border-radius: 999px;
  cursor: pointer;
}

.smi-fi .smi-fi__back:hover { background: var(--f-line); }

.smi-fi .smi-fi__foot-note {
  margin: 0;
  font-size: .74rem;
  line-height: 1.35;
  color: var(--f-ink);
  text-align: right;
}

.smi-fi__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Card highlight on the New Courses page */
.smi-page .smi-card--hit {
  animation: smi-fi-hit 2.6s var(--f-ease, ease);
}

@keyframes smi-fi-hit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 53, 221, 0); }
  12%, 70% { box-shadow: 0 0 0 4px rgba(34, 53, 221, .55); }
}

/* Phones: full width sheet */
@media (max-width: 600px) {
  .smi-fi {
    right: 14px;
    bottom: 14px;
    left: 14px;
    align-items: stretch;
  }

  .smi-fi .smi-fi__launch {
    align-self: flex-end;
    padding: 12px 18px;
  }

  .smi-fi .smi-fi__panel {
    width: 100%;
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
  }

  .smi-fi .smi-fi__foot-note { font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .smi-fi .smi-fi__launch,
  .smi-fi .smi-fi__opt,
  .smi-fi a.smi-fi__btn,
  .smi-fi .smi-fi__close,
  .smi-fi .smi-fi__restart { transition: none; }

  .smi-fi .smi-fi__launch:hover,
  .smi-fi .smi-fi__opt:hover { transform: none; }

  .smi-page .smi-card--hit { animation: none; outline: 3px solid #2235DD; }
}
