/* StoryBorder U6 floating surfaces, using the shared light and dark tokens. */
body[data-sb-tokens] {
  --surface-edge:var(--sb-color-border);
  --surface-dim:rgba(18,18,20,.32);
  --surface-gutter:24px;
}
body[data-sb-theme="dark"] { --surface-dim:rgba(0,0,0,.48); }

body :is(.sbgp-modal,.native-surface,#release-notes-dialog)::backdrop {
  background:var(--surface-dim);
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}
body[data-sb-tokens] dialog.sbgp-modal > .surface-card,
body[data-sb-tokens] dialog.confirm-surface,
body[data-sb-tokens] #release-notes-dialog,
body[data-sb-tokens] dialog.storage-status-dialog {
  background:var(--sb-color-floating);
  border:1px solid var(--surface-edge);
  border-radius:var(--sb-radius-xl);
  color:var(--sb-color-text);
  box-shadow:var(--sb-shadow-floating);
  backdrop-filter:blur(var(--sb-surface-floating-blur));
  -webkit-backdrop-filter:blur(var(--sb-surface-floating-blur));
  font-family:var(--sb-type-family-ui);
  scrollbar-width:thin;
  overscroll-behavior:contain;
}
body .sbgp-modal > .surface-card { max-height:inherit; }
body .sbgp-modal .cloud-library-header {
  border:0;
  padding:20px var(--surface-gutter) 12px;
}
body .sbgp-modal .cloud-library-body,
body .sbgp-modal .support-body { padding:12px var(--surface-gutter) var(--surface-gutter); }
body .sbgp-modal .support-body fieldset { gap:16px; }
body .sbgp-modal :is(.cloud-library-header h2,.cloud-secondary-card h2,.share-heading h2),
#release-notes-dialog h2,
dialog.storage-status-dialog h2,
.confirm-surface h2 { font-size:20px; font-weight:700; line-height:1.4; }
body .sbgp-modal :is(.cloud-library-kicker,.cloud-storage-target,.cloud-project-meta,.share-subtitle,.share-expiration),
.confirm-surface p { color:var(--sb-color-text-muted); }
body[data-sb-tokens] #cloud-library-dialog .cloud-project-card {
  background:var(--sb-color-surface);
  border-color:var(--surface-edge);
  border-radius:var(--sb-radius-l);
  box-shadow:none;
  backdrop-filter:none;
}
body #cloud-library-dialog .cloud-project-card:hover { border-color:var(--sb-color-border-strong); }
body .sbgp-modal :is(.cloud-library-search,.share-url,.note-editor textarea,.support-body > fieldset .glass-input) {
  background:var(--sb-color-surface-raised);
  border-color:var(--surface-edge);
  border-radius:var(--sb-radius-m);
  color:var(--sb-color-text);
  box-shadow:none;
}
body .sbgp-modal :is(input,textarea)::placeholder { color:var(--sb-color-text-subtle); opacity:1; }

body[data-sb-tokens] :is(.dock-account-menu,.cloud-save-menu) button,
body[data-sb-tokens] .sbgp-modal :is(.cloud-action:not(.primary),.cloud-dialog-close,.support-close),
body[data-sb-tokens] .native-surface .cloud-action:not(.primary) {
  background:transparent;
  color:var(--sb-color-text);
  border-color:transparent;
  box-shadow:none;
  border-radius:var(--sb-radius-m);
  transition:background-color 140ms ease, border-color 140ms ease;
}
/* Show visibility immediately so ArrowDown can focus the open group in the next frame. */
:is(.dock-account-menu,.cloud-save-menu)[data-open="true"] {
  transition-property:max-width, margin, opacity, translate;
}
body[data-sb-tokens] :is(.dock-account-menu,.cloud-save-menu) button { font-size:12px; font-weight:600; }
body[data-sb-tokens] :is(.dock-account-menu,.cloud-save-menu) button:hover:not(:disabled),
body[data-sb-tokens] .sbgp-modal :is(.cloud-action:not(.primary),.cloud-dialog-close,.support-close):hover:not(:disabled),
body[data-sb-tokens] .native-surface .cloud-action:not(.primary):hover:not(:disabled),
body[data-sb-tokens] .sbgp-modal .cloud-action[aria-pressed="true"] { background:var(--sb-color-selected); }
:is(.sbgp-modal,.native-surface,.release-dialog,.dock-account-menu,.cloud-save-menu)
:is(button,input,textarea,a):focus-visible, .shot-image-preview:focus-visible, .cloud-image-full:focus-visible {
  outline:2px solid var(--sb-color-focus-ring);
  outline-offset:-2px;
}

.native-surface {
  position:fixed;
  inset:0;
  margin:auto;
  max-width:calc(100vw - 32px);
  max-height:calc(100dvh - 32px);
}
dialog.confirm-surface { width:416px; padding:var(--surface-gutter); }
.confirm-surface h2 { display:flex; align-items:center; gap:10px; }
.confirm-surface h2 svg { flex:none; width:20px; height:20px; color:var(--sb-color-danger); }
.confirm-surface p { margin:12px 0 24px; font-size:14px; line-height:1.6; overflow-wrap:anywhere; }
.confirm-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.confirm-actions .cloud-action { min-height:40px; }
body[data-sb-tokens] .confirm-actions .confirm-danger { color:var(--sb-color-danger); background:var(--sb-color-danger-surface); }
body[data-sb-tokens] .confirm-actions .confirm-danger:hover { border-color:var(--sb-color-danger); background:var(--sb-color-danger-surface); }

dialog.storage-status-dialog {
  width:460px;
  padding:var(--surface-gutter);
  overflow:auto;
  --storage-status-color:#ef4444;
}
.storage-status-dialog[data-save-status="saving"] { --storage-status-color:#fbbf24; }
.storage-status-dialog[data-save-status="saved"] { --storage-status-color:#22c55e; }
.storage-status-header,.storage-status-actions { display:flex; align-items:center; gap:8px; }
.storage-status-header { justify-content:space-between; }
.storage-status-header svg { width:18px; height:18px; }
.storage-status-source { margin:4px 0 16px; font-size:13px; color:var(--sb-color-text-muted); overflow-wrap:anywhere; }
.storage-status-list { margin:0; font-size:14px; }
.storage-status-list > div {
  display:grid;
  grid-template-columns:8em minmax(0,1fr);
  gap:8px;
  align-items:baseline;
  border-top:1px solid var(--surface-edge);
  padding:10px 0;
}
.storage-status-list dt { color:var(--sb-color-text-muted); }
.storage-status-list dd { margin:0; overflow-wrap:anywhere; }
.storage-status-dot {
  display:inline-block;
  width:8px;
  height:8px;
  margin-inline-end:7px;
  border-radius:50%;
  background:var(--storage-status-color);
  transition:background-color 150ms ease;
}
.storage-status-error { margin-block:8px; font-size:13px; color:var(--sb-color-danger); overflow-wrap:anywhere; }
.storage-status-actions { justify-content:flex-end; flex-wrap:wrap; margin-top:16px; }
.storage-status-actions .cloud-action { min-height:40px; }
body.mode-dark .storage-status-actions .cloud-action.primary { background:var(--color-accent); border-color:var(--color-accent); }

#image-modal {
  width:max-content;
  padding:50px 0 0;
  background:transparent;
  border:0;
  color:#fafafa;
  overflow:auto;
}
#image-modal::backdrop { background:rgba(9,9,11,.9); }
#modal-img {
  display:block;
  width:auto;
  height:auto;
  max-width:calc(100vw - 40px);
  max-height:calc(100dvh - 96px);
  object-fit:contain;
}
body[data-sb-tokens] #image-modal .image-close {
  position:absolute;
  right:0;
  top:0;
  min-width:40px;
  min-height:40px;
  background:#27272a;
  color:#fafafa;
  outline-color:#fafafa;
}
body[data-sb-tokens] #image-modal .image-close:hover { background:#3f3f46; }
.shot-image-preview { display:block; width:100%; height:100%; cursor:zoom-in; }
.shot-image-preview img { transition:transform 240ms ease; }
.shot-image-preview:hover img { transform:scale(1.07); }

@media (prefers-reduced-motion:no-preference) {
  .sbgp-modal::backdrop { transition:opacity 180ms ease-out; }
  .sbgp-modal[data-surface-state="closing"]::backdrop { opacity:0; }
  @starting-style { .sbgp-modal[open]::backdrop { opacity:0; } }
  .native-surface:not([open]) { opacity:0; transform:translateY(8px) scale(.98); pointer-events:none; }
  .native-surface {
    transition:opacity 180ms ease-out, transform 180ms var(--sb-motion-ease-enter),
      display 180ms allow-discrete, overlay 180ms allow-discrete;
  }
  .native-surface::backdrop {
    opacity:0;
    transition:opacity 180ms ease-out, display 180ms allow-discrete, overlay 180ms allow-discrete;
  }
  .native-surface[open]::backdrop { opacity:1; }
  @starting-style {
    .native-surface[open] { opacity:0; transform:translateY(8px) scale(.98); }
    .native-surface[open]::backdrop { opacity:0; }
  }
}
@media (prefers-reduced-motion:reduce) {
  #release-notes-dialog,.native-surface,.native-surface::backdrop,.shot-image-preview img { transition:none; }
  .shot-image-preview:hover img { transform:none; }
}
@media (prefers-reduced-transparency:reduce) {
  body[data-sb-tokens] dialog.sbgp-modal > .surface-card,
  body[data-sb-tokens] dialog.confirm-surface,
  body[data-sb-tokens] #release-notes-dialog,
  body[data-sb-tokens] dialog.storage-status-dialog {
    background:var(--sb-color-surface);
    backdrop-filter:none;
  }
}
@media (max-width:600px) { body[data-sb-tokens] { --surface-gutter:16px; } }

body[data-sb-tokens] #assistant-panel #highlight-options-menu {
  padding:4px;
  background:var(--sb-color-surface) !important;
  border-color:var(--surface-edge) !important;
  box-shadow:var(--sb-shadow-floating);
}
body[data-sb-tokens] #assistant-panel #highlight-options-menu .highlight-option {
  width:100%;
  min-height:36px;
  padding:8px 12px;
  border-radius:var(--sb-radius-m);
  text-align:start;
  color:var(--sb-color-text) !important;
  background:transparent !important;
}
body[data-sb-tokens] #assistant-panel #highlight-options-menu .highlight-option:is(:hover,:focus-visible) {
  background:var(--sb-color-selected) !important;
}

#release-notes-dialog { width:480px; padding:var(--surface-gutter); overflow:auto; }
#release-notes-dialog .release-kicker { color:var(--sb-color-text-muted); opacity:1; }
#release-notes-dialog h2 { margin:6px 0 16px; }
#release-notes-dialog .release-history { max-height:min(52dvh,420px); }
#release-notes-dialog .release-history section + section { border-color:var(--surface-edge); }
#release-notes-dialog .release-actions { display:flex; justify-content:flex-end; margin-top:16px; }
#release-notes-dialog .release-actions .primary {
  min-width:80px; min-height:40px; background:var(--color-accent); border-color:var(--color-accent);
}
