/* Floating Report Bugs — icon-only FAB, center bottom (#425).
   Do not center with transform: iPhone treats that as a scroll layer
   so the beetle rides the page (#753). */
.imd-bug-fab {
  position: fixed;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  transform: none;
  bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
  z-index: 11000;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(24, 28, 40, 0.92);
  color: #e8eaf2;
  box-shadow: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.imd-bug-fab.visible {
  display: inline-flex;
}
/* Hide while a field is focused so the beetle does not sit on the keyboard (#755). */
.imd-bug-fab.imd-bug-fab-kb {
  visibility: hidden;
  pointer-events: none;
}
/* Sit above Prev/Next instead of covering the left dock button (#253). */
html:not([data-exam-style="usmle"]) body.has-tr-dock .imd-bug-fab {
  bottom: calc(var(--tr-dock-h, 3.55rem) + 0.45rem);
}
html[data-exam-style="usmle"] body.exam-run .imd-bug-fab {
  bottom: calc(var(--usmle-bot-h, 3.2rem) + var(--imd-vv-bottom, 0px) + 0.45rem);
}
/* Always-visible YGBRP strip: sit above the chips, same as .imd-section-fab. */
html[data-hl-bar-pos="bottom"]:not([data-reader-bars="floating"]) .imd-bug-fab {
  bottom: calc(var(--imd-hl-bot, 3.4rem) + env(safe-area-inset-bottom, 0px) + var(--imd-vv-bottom, 0px) + 0.45rem);
}
html:not([data-exam-style="usmle"])[data-hl-bar-pos="bottom"]:not([data-reader-bars="floating"]) body.has-tr-dock .imd-bug-fab {
  bottom: calc(var(--imd-hl-bot, 3.4rem) + var(--tr-dock-h, 3.55rem) + 0.45rem);
}
html[data-exam-style="usmle"][data-hl-bar-pos="bottom"]:not([data-reader-bars="floating"]) body.exam-run .imd-bug-fab {
  bottom: calc(var(--imd-hl-bot, 3.4rem) + var(--usmle-bot-h, 3.2rem) + var(--imd-vv-bottom, 0px) + 0.45rem);
}
/* Parked in #usmle-bottom on wide exam screens (#495). */
html[data-exam-style="usmle"] body.exam-run #usmle-bug-slot > .imd-bug-fab {
  position: relative !important;
  left: auto;
  right: auto;
  transform: none;
  bottom: auto;
  width: auto;
  height: auto;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.22rem 0.5rem;
  border-radius: 2px;
  box-shadow: none;
}
.imd-bug-fab:hover {
  border-color: rgba(255, 139, 122, 0.55);
  background: rgba(40, 28, 28, 0.95);
  color: #ffc4ba;
  box-shadow: none;
}
.imd-bug-fab svg {
  width: 22px;
  height: 22px;
  display: block;
}
/* Unread admin reply waiting: a dot rather than a count, so it reads at 44px. */
.imd-bug-fab.has-unread::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid rgba(24, 28, 40, 0.92);
  box-sizing: border-box;
}
html[data-theme="light"] .imd-bug-fab.has-unread::after {
  border-color: #fff;
}
.imd-bug-mine {
  margin-right: auto;
  align-self: center;
  font-weight: 650;
  font-size: 0.9rem;
  color: #8fa6ff;
  text-decoration: none;
}
.imd-bug-mine:hover {
  text-decoration: underline;
}
html[data-theme="light"] .imd-bug-mine {
  color: #3d52d9;
}
.imd-bug-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0; inset: 0;
  z-index: 11050;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  /* Phone: sit on the floor. Center looks "stuck in the middle" (#757). */
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
@media (min-width: 720px) {
  .imd-bug-overlay:not(.imd-kb) {
    align-items: center;
  }
}
/* Sit on the visual-viewport floor so the card is not 100lvh behind the keyboard. */
.imd-bug-overlay.imd-kb {
  align-items: flex-end;
  padding: 0.45rem 0.65rem max(0.45rem, env(safe-area-inset-bottom, 0px));
}
.imd-bug-overlay[hidden] {
  display: none !important;
}
.imd-bug-card {
  position: relative;
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--card, rgba(24, 28, 40, 0.96));
  border: 1px solid var(--border, rgba(98, 115, 180, 0.28));
  border-radius: 14px;
  padding: 1rem 1.05rem 1.1rem;
  color: var(--text, #e8eaf2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}
.imd-bug-card h2 {
  margin: 0 0 0.35rem;
  /* clear of the close button */
  padding-right: 2.4rem;
  font-size: 1.1rem;
}
/* #1883: close button. Like Cancel and Esc it discards the draft. */
.imd-bug-x {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #8b92a8);
  font: inherit;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.imd-bug-x:hover,
.imd-bug-x:focus-visible {
  color: var(--text, #e8eaf2);
  background: rgba(127, 127, 127, 0.16);
}
/* #1883: says where the text goes, so the dialog is not used as a notepad. */
.imd-bug-hint {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted, #8b92a8);
}
.imd-bug-card .sub {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--muted, #8b92a8);
}
.imd-bug-card label {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted, #8b92a8);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.55rem 0 0.3rem;
}
.imd-bug-card textarea,
.imd-bug-card input[type="file"] {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: inherit;
}
.imd-bug-card input[type="file"] {
  padding: 0.35rem 0;
  min-height: 2.4rem;
}
.imd-bug-file-name {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--muted, #8b92a8);
  overflow-wrap: anywhere;
}
.imd-bug-card textarea {
  min-height: 4.5rem;
  max-height: min(9rem, 32vh);
  font-size: 16px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border, rgba(98, 115, 180, 0.28));
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.imd-bug-overlay.imd-kb .imd-bug-card textarea {
  min-height: 2.6rem;
  max-height: min(5.5rem, 22vh);
}
.imd-bug-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}
.imd-bug-actions button {
  font: inherit;
  font-weight: 650;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #2c3348;
  color: inherit;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  box-shadow: none;
}
.imd-bug-actions button:hover:not(:disabled) {
  box-shadow: none;
}
.imd-bug-actions button.primary {
  background: #4f6fff;
  border-color: transparent;
  color: #fff;
}
.imd-bug-msg {
  margin: 0.55rem 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
}
.imd-bug-msg.ok {
  color: #9af0e4;
}
.imd-bug-msg.err {
  color: #ffc4ba;
}
html[data-theme="light"] .imd-bug-fab {
  background: #fff;
  color: #222;
  border-color: rgba(0, 0, 0, 0.14);
  box-shadow: none;
}
html[data-theme="light"] .imd-bug-card {
  background: #f7f8fc;
  color: #1a1d28;
  border-color: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .imd-bug-card textarea {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.14);
  color: #1a1d28;
}
html[data-theme="light"] .imd-bug-actions button {
  background: #e4e8f2;
  color: #1a1d28;
}
html[data-theme="light"] .imd-bug-actions button.primary {
  background: #3d52d9;
  color: #fff;
}
