/* Persistence warning bar — "your work is not being saved to your account".
 *
 * Pinned to the top of the viewport and above every window and flyout (windows
 * top out well below this, toasts sit at 9600). It has to survive whatever the
 * user opens on top of it, because the whole point is that they see it before
 * they spend an afternoon producing work that exists in one browser. */

#biostudio-persistence-bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10100;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: #2a1a00;
  background: #ffd97a;
  border-bottom: 1px solid #d9a733;
  box-shadow: 0 2px 10px rgb(0 0 0 / 18%);
}

/* A guest session is expected to be local, so it informs rather than warns. */
#biostudio-persistence-bar[data-mode="guest"] {
  color: #10243a;
  background: #cfe4f7;
  border-bottom-color: #7fa9cd;
}

/* Configured but failing is the loudest state: it is the one that can lose
   work the user believes is already saved. */
#biostudio-persistence-bar[data-mode="error"] {
  color: #fff;
  background: #a32d28;
  border-bottom-color: #7d211d;
}

.persistence-bar-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.persistence-bar-text strong { font-weight: 700; }
.persistence-bar-text span { opacity: 0.92; }

.persistence-bar-dismiss {
  flex: none;
  padding: 4px 12px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  background: rgb(255 255 255 / 45%);
  border: 1px solid currentColor;
  border-radius: 5px;
}

#biostudio-persistence-bar[data-mode="error"] .persistence-bar-dismiss {
  background: rgb(255 255 255 / 18%);
}

.persistence-bar-dismiss:hover { background: rgb(255 255 255 / 70%); }
#biostudio-persistence-bar[data-mode="error"] .persistence-bar-dismiss:hover {
  background: rgb(255 255 255 / 30%);
}
.persistence-bar-dismiss:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* The shell measures its own height from the viewport, so push it down rather
   than letting the bar cover the taskbar or the top of a maximized window.

   persistence-status.js appends the bar to <body>, after #os, so #os can find
   it as a later sibling. Keep the :has() on #os itself: `body:has(...) #os`
   made <body> a :has() anchor, and Chrome then re-checked every :has() subject
   in the page (every table cell and icon) on each hover or focus change.
   Same specificity as the body:has() form. */
body > #os:has(~ #biostudio-persistence-bar) {
  top: var(--persistence-bar-h, 44px);
  height: calc(100% - var(--persistence-bar-h, 44px));
}

@media (max-width: 720px) {
  #biostudio-persistence-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .persistence-bar-dismiss { align-self: flex-end; }
}
