/* Shared final layer: title/navigation occupy one 56px row, in every skin. */
:root { --site-header-height: 56px; --page-top-gap: 12px; }
html body > .navbar {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 12px;
  height: var(--site-header-height) !important; min-height: var(--site-header-height) !important;
  padding: 0 20px !important; margin: 0; box-sizing: border-box;
  position: relative; z-index: 140; flex: none;
}
html body .navbar > [hidden] { display: none !important; }
html body .navbar-brand { min-width: 0; min-height: 44px; white-space: nowrap; }
html body .navbar-brand-text { white-space: nowrap; }
html body .navbar .game-theme-character { display: none !important; }
html body .navbar-actions { gap: 8px; margin-left: auto; flex: none; }
html body .navbar :is(.theme-toggle-btn, .studio-account-link, .studio-menu-button) {
  min-height: 44px; height: 44px; white-space: nowrap;
}
html body .navbar #skinPickerName { display: none; }
html body .navbar .skin-picker-button { min-width: 44px; width: auto; color: var(--text); }
html body .navbar .skin-picker-label { display: inline; color: var(--text); opacity: 1; }
html body .navbar .studio-menu-button { min-width: 44px; padding: 0 8px; }
html body .navbar .studio-menu-button::after { display: none; }
html body .navbar .skin-picker-menu { z-index: 160; max-height: calc(100dvh - 72px); }
html[data-skin^="studio_"].studio-navigation-open .studio-sidebar { top: var(--site-header-height); }

html body .navbar .compact-page-header {
  display: flex; flex: 1 1 0; flex-wrap: nowrap; align-items: center; gap: 12px;
  min-width: 0; width: auto; height: 44px; min-height: 44px;
  padding: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--text); order: 0;
}
html body .navbar .compact-page-header::before,
html body .navbar .compact-page-header::after { display: none; }
html body .navbar .compact-back {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px; margin: 0;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: none; font: 500 14px/1.4 var(--font-body, sans-serif);
  white-space: nowrap; text-align: center; text-decoration: none;
}
html body .navbar .compact-title {
  display: block; flex: 1 1 0; min-width: 0; width: auto; max-width: none;
  margin: 0; padding: 0; font: 600 20px/32px var(--font-body, sans-serif);
  color: var(--text); letter-spacing: 0; text-shadow: none; white-space: nowrap;
  /* Long user document names can be scrolled/focused, not lost to ellipsis. */
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; overflow-wrap: normal;
}
html body .navbar .compact-title > svg { display: none; }
html body .navbar .compact-header-more { flex: none; position: relative; margin: 0; }
html body .navbar .compact-header-more > summary {
  display: none; min-width: 44px; min-height: 44px; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; padding: 0 8px;
  background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 14px; list-style: none;
}
.compact-header-more > summary::-webkit-details-marker { display: none; }
html body .navbar .compact-header-actions,
html body .navbar .compact-header-actions > :is(.notes-top-actions,.motion-top-actions,.motion-tabs) {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin: 0; width: auto; height: auto;
}
html body .navbar .compact-header-actions :is(button, .btn, a) {
  display: inline-flex; align-items: center; justify-content: center; text-align: center; vertical-align: middle;
  min-height: 44px; margin: 0; padding: 8px 12px; white-space: nowrap;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: none; font: 500 14px/1.4 var(--font-body, sans-serif); cursor: pointer;
}
html[data-image-skin="1"] body .navbar .compact-back {
  padding-block: 2px 0;
}
html[data-image-skin="1"] body .navbar .compact-header-actions :is(button, .btn, a) {
  padding-block: 9px 7px;
}
html body .navbar .compact-header-actions button[aria-pressed="true"] {
  background: var(--accent); color: var(--on-accent, var(--bg)); border-color: var(--accent);
}
html body .navbar .compact-header-actions .notes-current-user { margin: 0; width: auto; white-space: nowrap; }
html body .navbar :is(.compact-back, .compact-title, summary, button, a):focus-visible {
  outline: 2px solid var(--accent-text, var(--accent)); outline-offset: 2px;
}
html body.has-compact-header .main-content { padding-top: var(--page-top-gap) !important; }
/* Progressive fallback if enhancement fails: never force the title onto row two. */
html body .main-content .tool-page-header { flex-wrap: nowrap; gap: 12px; margin-bottom: 12px; }
html body .main-content .tool-page-header > .tool-title { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow-x: auto; }

/* Motion search and selection identity belong to their panels, not another masthead. */
html body.motion-library-page.has-compact-header .main-content { padding: 0 !important; }
html body.motion-library-page .motion-app { border-radius: 0; border: 0; }
html body.motion-library-page .motion-workspace { height: calc(100dvh - 110px); min-height: 520px; }
html body.motion-library-page #selection { grid-template-rows: 48px minmax(0, 1fr); }
html body.motion-library-page .motion-preview-heading { min-height: 48px; padding: 2px 12px; text-align: left; }
html body.motion-library-page .motion-preview-heading > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
html body.motion-library-page .motion-preview-heading h2 { white-space: nowrap; overflow-x: auto; min-width: 0; }
html body.motion-library-page .motion-preview-kind { margin: 0; white-space: nowrap; }
html body.motion-library-page .motion-searchbar { padding: 4px 12px; gap: 8px; }

@media (max-width: 1100px) {
  html body .navbar .compact-header-more > summary { display: flex; }
  html body .navbar .compact-header-more:not([open]) > .compact-header-actions { display: none; }
  html body .navbar .compact-header-actions {
    position: fixed; top: calc(var(--site-header-height) + 4px); right: 12px;
    width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - 76px); overflow-y: auto;
    padding: 12px; border: 1px solid var(--border); border-radius: 10px;
    flex-direction: column; align-items: stretch; gap: 12px;
    background: var(--bg-card); box-shadow: 0 8px 24px rgb(0 0 0 / 20%); z-index: 155;
  }
  html body .navbar .compact-header-actions > :is(.notes-top-actions,.motion-top-actions,.motion-tabs) {
    flex-wrap: wrap; gap: 8px; order: initial;
  }
  html body .navbar .compact-header-actions :is(button,.btn,a) { white-space: normal; }
  html body.motion-library-page .motion-workspace { height: auto; min-height: 0; }
  html body.motion-library-page #selection { grid-template-rows: 48px auto auto; }
}
@media (max-width: 760px) {
  html body > .navbar { padding-inline: 8px !important; gap: 6px; }
  html body .navbar .compact-page-header { gap: 8px; }
  html body .navbar .compact-back { padding: 0; }
  html body .navbar .compact-back-text { display: none; }
  html body .navbar .compact-title { font-size: 16px; line-height: 32px; }
  html body .navbar .navbar-actions { gap: 4px; }
  html body .navbar :is(.studio-account-link,.account-nav-link) { display: none; }
  html body .navbar .skin-picker-button { padding: 0 8px; min-width: 44px; gap: 0; }
  html body .navbar :is(.skin-picker-icon,.skin-picker-caret) { display: none; }
  html body .navbar .skin-picker-label { font-size: 14px; }
  html body .navbar-brand-text { font-size: 14px; }
  html body .navbar-brand-mark { display: none; }
  html body.motion-library-page .motion-preview-kind { display: none; }
}
