/* ── Bottom status area — pill floats over the editor, no layout space taken ── */
#bottom-status-area {
  position: absolute;
  bottom: calc(var(--gap) + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.25em 1.2em;
  border-radius: 999px;
  background-color: var(--bg);
  display: grid;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.34, 1.4, 0.64, 1),
              left 0.3s cubic-bezier(0.34, 1.4, 0.64, 1),
              width 0.25s ease;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 1px 4px var(--shadow), 0 6px 20px var(--shadow-light);
}

/* Suppress position (left/width) transitions when pin state changes while
   the panel is already visible — pill repositions instantly. */
#bottom-status-area.no-position-transition {
  transition: opacity 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) !important;
}

#bottom-status-area[style*="cursor: pointer"]:hover {
  background-color: var(--hover-overlay);
}

/* ── Status message — overlays backup label temporarily ── */
#status-message {
  grid-row: 1;
  grid-column: 1;
  font-size: 11px;
  font-family: Arial, sans-serif;
  text-align: center;
  white-space: nowrap;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.4s ease;
  padding: 1.5px 0;
}

/* ── Buttons (global baseline) ── */
button {
  background-color: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  margin: 0 5px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  cursor: pointer;
}

/* ── Toolbar buttons: minimalist, borderless, Word-style ── */
#button-container .button-group > button:not(.sub-button),
#tools-overflow-row .button-group > button:not(.sub-button) {
  background: none;
  border: none;
  color: var(--muted);
  padding: 3px 10px;
  margin: 0;
  font-size: 13px;
  border-radius: 999px;
}

@media (hover: hover) {
  #button-container .button-group > button:not(.sub-button):hover,
  #tools-overflow-row .button-group > button:not(.sub-button):hover {
    background-color: var(--surface);
    color: var(--text);
  }
}

/* Busy state — dimmed and non-interactive while an async action runs */
button.btn-busy {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Tools overflow row: floating centred popup revealed on "…" hover ────── */
#tools-overflow-row {
  display: flex;
  position: fixed;
  /* top and left are set by JS — centered on the "…" button */
  max-width: calc(100vw - 32px);
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  z-index: 200;
  background-color: var(--bg);
  border-radius: 999px;
  box-shadow: 0 2px 8px var(--shadow), 0 8px 24px var(--shadow-light);
  /* ── Animated appear ── */
  opacity: 0;
  transform: translateY(6px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out, visibility 0.15s ease-out;
}

/* Show only when it has content AND the user is hovering the "…" button */
#tools-overflow-row.has-overflow.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.button-group {
  position: relative;
  display: inline-block;
}

@media (hover: hover) {
  .button-group:hover .sub-buttons {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }
}

/* Mobile: show sub-buttons when JS toggles .active on tap */
.button-group.active .sub-buttons {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.sub-buttons {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  background-color: var(--bg);
  border-radius: 8px;
  box-shadow: 0 2px 6px var(--shadow), 0 8px 20px var(--shadow-light);
  padding: 2px 0;
  /* ── Animated open ── */
  opacity: 0;
  transform: translateY(-4px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out, visibility 0.15s ease-out;
}

.sub-button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  padding: 3px 14px;
  margin: 0;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  border-radius: 0;
}

@media (hover: hover) {
  .sub-button:hover {
    background-color: var(--hover-overlay);
    color: var(--text);
  }
}
