/* Header layout owner. One row on desktop; compact stacked rows when needed;
   button IDs and handlers remain shared with the study and wagon views. */
:root { --top-bar-h: 70px; }
#top-bar {
  height: var(--top-bar-h); box-sizing: border-box;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 20px 32px; gap: 6px 20px;
  padding: 6px 20px;
  background: linear-gradient(180deg, #1c1911, #100e09);
  border-bottom: 1px solid #665030;
  box-shadow: 0 4px 18px #0005;
}
#top-bar.hidden { display: none; }
#top-bar .top-bar-left, #top-bar .top-bar-right { display: flex; align-items: center; min-width: 0; gap: 20px; }
#top-bar .top-bar-title { display: flex; flex-shrink: 0; white-space: nowrap; font-size: 13px; letter-spacing: .08em; }
#top-bar .top-bar-user { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
#top-bar .top-bar-right { width: auto; justify-content: flex-end; gap: 18px; }
#top-bar .top-stat { white-space: nowrap; font-size: 12px; gap: 5px; }
#top-bar .top-stat-label { color: var(--text2); font-weight: 400; }
#top-bar .top-bar-nav { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-width: 0; }
#top-bar .top-bar-primary, #top-bar .top-bar-utilities { display: flex; align-items: center; gap: 8px; min-width: 0; }
#top-bar .top-bar-primary { position: relative; }
#top-bar .ghost-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  box-sizing: border-box; height: 32px; min-height: 32px; flex-shrink: 0;
  padding: 0 12px; margin: 0; border-radius: 8px;
  font: 600 12px/1 var(--font-ui); letter-spacing: .02em;
  white-space: nowrap; text-decoration: none;
  color: #cbbfa5; border: 1px solid #524831;
  background: linear-gradient(180deg, #2b271e, #211e17);
  box-shadow: inset 0 1px 0 #ffffff06;
}
#top-bar .ghost-btn.hidden { display: none; }
#top-bar .ghost-btn:hover { color: #f0d69c; border-color: #a98549; background: #332c1d; }
#top-bar .ghost-btn[aria-current="page"] { color: #f3d393; border-color: #bb8b3c; background: linear-gradient(180deg, #44351d, #2d2417); }
#top-bar .ghost-btn:focus-visible, #top-bar .renown-plaque:focus-visible { outline: 2px solid #9ad9df; outline-offset: 2px; }
#top-bar .btn-label { display: inline; }
@media (max-width: 1439px) {
  #top-bar #study-remote-open { width: 32px; padding: 0; }
  #top-bar #study-remote-open .btn-label { display: none; }
}
#top-bar .renown-plaque { height: 32px; box-sizing: border-box; margin: 0; min-width: 176px; width: auto; padding: 2px 10px 2px 6px; border-radius: 8px; }
#top-bar .renown-plaque-copy { display: flex; }
#top-bar .renown-plaque-rank { max-width: 138px; font-size: 10px; line-height: 1.3; }
#top-bar .renown-plaque-kicker { font-size: 8px; }
#top-bar .fg3-nav-badge { position: absolute; top: -4px; right: -4px; pointer-events: none; }
@media (max-width: 900px) {
  :root { --top-bar-h: 108px; }
  #top-bar { grid-template-rows: 20px 70px; padding: 6px 16px; }
  #top-bar .top-bar-nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  #top-bar .top-bar-primary { display: flex; }
  #top-bar .top-bar-primary .ghost-btn { flex: 1 1 0; min-width: 0; }
  #top-bar .top-bar-utilities { justify-content: flex-end; }
}
@media (max-width: 700px) {
  #top-bar { padding: 6px 12px; column-gap: 12px; }
  #top-bar .top-bar-title { font-size: 11px; letter-spacing: .02em; }
  #top-bar .top-bar-user { display: none; }
  #top-bar .top-bar-right { gap: 10px; }
  #top-bar .top-stat { font-size: 11px; gap: 3px; }
  #top-bar .top-stat-label { display: none; }
  #top-bar .top-bar-primary .icon-glyph, #top-bar .nav-wide-label { display: none; }
  #top-bar .ghost-btn { padding: 0 10px; font-size: 11px; }
  #top-bar .renown-plaque { width: 32px; min-width: 32px; justify-content: center; padding: 4px; margin-right: auto; }
  #top-bar .renown-plaque-copy { display: none; }
  #top-bar .top-bar-utilities { gap: 8px; }
}
@media (max-width: 360px) {
  #top-bar { padding-left: 8px; padding-right: 8px; column-gap: 6px; }
  #top-bar .top-bar-title { font-size: 10px; }
  #top-bar .top-bar-right { gap: 6px; }
  #top-bar .top-stat { font-size: 10px; }
  #top-bar .top-stat img { width: 12px; height: 12px; }
  #top-bar .ghost-btn { padding: 0 8px; font-size: 10px; }
}

/* Wide screens keep study content close to the top of the page. */
@media (min-width: 1100px) {
  :root { --top-bar-h: 48px; }
  #top-bar { grid-template-columns: minmax(170px, 1fr) auto auto; grid-template-rows: 32px; gap: 12px; padding: 8px 16px; }
  #top-bar .top-bar-left { flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; }
  #top-bar .top-bar-user { max-width: 100%; font-size: 10px; }
  #top-bar .top-bar-right { gap: 12px; }
  #top-bar .top-bar-nav { grid-column: auto; gap: 16px; }
}

@media (min-width: 1100px) and (max-width: 1439px) {
  #top-bar .top-bar-title { font-size: 11px; letter-spacing: .03em; }
  #top-bar .top-stat-label { display: none; }
  #top-bar .top-bar-nav { gap: 12px; }
  #top-bar .ghost-btn { padding: 0 10px; font-size: 11px; }
}

/* Browser zoom reduces CSS viewport width. Keep the desktop row usable at
   125% zoom on common laptop displays, including the extra Co2027 Clinic tab. */
@media (min-width: 1100px) and (max-width: 1199px) {
  #top-bar { grid-template-columns: minmax(135px, 1fr) auto auto; gap: 8px; padding-inline: 12px; }
  #top-bar .top-bar-title { font-size: 11px; letter-spacing: 0; }
  #top-bar .top-bar-right { gap: 7px; }
  #top-bar .top-bar-nav { gap: 9px; }
  #top-bar .top-bar-primary, #top-bar .top-bar-utilities { gap: 5px; }
  #top-bar .ghost-btn { padding-inline: 8px; }
  #top-bar .renown-plaque { min-width: 32px; max-width: 32px; width: 32px; padding: 4px; justify-content: center; }
  #top-bar .renown-plaque-copy, #top-bar .renown-plaque::before, #top-bar .renown-plaque::after { display: none; }
}
/* The tablet navigation row also needs the compact Renown seal when Remote
   and local admin tools are present. Rank remains available through the menu. */
@media (min-width: 901px) and (max-width: 1099px) {
  #top-bar .renown-plaque { min-width: 32px; max-width: 32px; width: 32px; padding: 4px; justify-content: center; }
  #top-bar .renown-plaque-copy, #top-bar .renown-plaque::before, #top-bar .renown-plaque::after { display: none; }
}
