/* H13.1: the top bar (bar/model.js barLayout gives the same rectangles; a test checks).
   Round "sphere" buttons by CSS only: a radial highlight, the type's pastel fill, a darker rim
   of the same hue and a soft shadow. A ring marks the current mode, tool or switch; "…" marks
   a button with details in the drawer. The bar box itself takes no pointer; its spheres do. */
#top-bar { position: absolute; z-index: 20; top: 40px; left: 50%; width: min(740px, calc(100% - 16px)); height: 110px; transform: translateX(-50%);
  box-sizing: border-box; padding: 4px 0; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#top-bar .tb-row { display: flex; flex-wrap: nowrap; gap: 6px; height: 48px; min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; overscroll-behavior-x: contain; }
#top-bar .tb-row::-webkit-scrollbar { display: none; }
#top-bar .tb-row > :first-child { margin-left: auto; } /* centred while it fits, scrolls from its start when it does not */
#top-bar .tb-row > :last-child { margin-right: auto; }
#top-bar .tb-btn { position: relative; flex: none; width: 48px; height: 48px; min-width: 0; min-height: 0; padding: 0; margin-top: 0; margin-bottom: 0;
  box-sizing: border-box; border: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #1e1a2e; cursor: pointer; pointer-events: auto; touch-action: pan-x; -webkit-tap-highlight-color: transparent;
  background: radial-gradient(circle at 34% 28%, #ffffff 0, var(--tb-fill) 42%, var(--tb-fill) 62%, var(--tb-rim) 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .5), inset 0 -3px 5px rgba(0, 0, 0, .12); }
#top-bar .tb-btn.tb-gap { margin-left: 12px; }
#top-bar .tb-row > .tb-btn.tb-gap:first-child { margin-left: auto; }
#top-bar .tb-btn:active { transform: scale(.94); }
#top-bar .tb-btn[aria-pressed="true"] { box-shadow: 0 0 0 2px #0a0818, 0 0 0 4px #22e6ff, 0 3px 6px rgba(0, 0, 0, .5); }
#top-bar .tb-btn:disabled { opacity: .4; cursor: default; }
#top-bar .tb-btn:focus-visible { outline: 2px solid #22e6ff; outline-offset: 3px; }
#top-bar .tb-icon { width: 24px; height: 24px; pointer-events: none; }
#top-bar .tb-badge { position: absolute; right: -3px; top: -3px; min-width: 18px; height: 18px; padding: 0 2px; box-sizing: border-box; border-radius: 9px;
  background: #0a0818; border: 1px solid #e6e0ff; color: #e6e0ff; font: 700 11px/14px system-ui, sans-serif; text-align: center; }
#top-bar.tb-playing #tb-actions, #top-bar.tb-playing #tb-modes > .tb-btn:not([data-id="play"]) { display: none; }
/* fill and rim per action type (model.js TYPES holds the same values) */
#top-bar .tb-create { --tb-fill: #bff2d6; --tb-rim: #93d9b5; }
#top-bar .tb-remove { --tb-fill: #ffbfb0; --tb-rim: #f29a86; }
#top-bar .tb-shape { --tb-fill: #d8ccff; --tb-rim: #b5a6f2; }
#top-bar .tb-paint { --tb-fill: #ffcadb; --tb-rim: #f2a5bf; }
#top-bar .tb-select { --tb-fill: #bfe0ff; --tb-rim: #97c4ef; }
#top-bar .tb-animate { --tb-fill: #fff1ad; --tb-rim: #ecd77c; }
#top-bar .tb-world { --tb-fill: #b0f0ea; --tb-rim: #83d8cf; }
#top-bar .tb-sound { --tb-fill: #ebcdf9; --tb-rim: #d3a9ec; }
#top-bar .tb-history { --tb-fill: #dfdfe7; --tb-rim: #bdbdca; }
#top-bar .tb-play { --tb-fill: #c8f5a6; --tb-rim: #a0dd78; }
#top-bar .tb-project { --tb-fill: #f2e2bd; --tb-rim: #dcc690; }

/* The detail drawer: #create-bar shows only the panels of the button that opened it. */
#create-bar[data-drawer] > details:not([data-drawer-show]) { display: none; }
#drawer-close { align-self: flex-end; flex: none; }
@media (min-width: 700px) {
  body.top-bar-on #create-bar { top: 158px; }
  body.top-bar-on #create-bar:not([data-drawer]) { display: none; }
}
@media (max-width: 699px) {
  #drawer-close { display: none; } /* the sheet's own head has the close */
  #top-bar { top: calc(36px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); right: calc(64px + env(safe-area-inset-right));
    width: auto; height: 92px; padding: 0; gap: 4px; transform: none; }
  #top-bar .tb-row { gap: 4px; height: 44px; }
  #top-bar .tb-btn { width: 44px; height: 44px; }
  #top-bar .tb-btn.tb-gap { margin-left: 8px; }
  #top-bar .tb-badge { right: -2px; top: -2px; min-width: 16px; height: 16px; font-size: 10px; line-height: 12px; }
}

/* H13.6: the quick-dial card under the bar (quick-dials.js places it and its rows inline) */
#quick-dials { position: absolute; z-index: 21; box-sizing: border-box; background: rgba(10, 8, 24, .94); border: 1px solid #3a3456; border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .55); color: #e6e0ff; pointer-events: auto; touch-action: none; }
#quick-dials .qd-row { position: absolute; box-sizing: border-box; display: flex; justify-content: space-between; padding: 0 6px; font: 11px/14px system-ui, sans-serif; }
#quick-dials .qd-value { font-variant-numeric: tabular-nums; color: #b5a6f2; }
#quick-dials .qd-dial { position: absolute; left: 0; top: 0; width: 100%; height: 44px; margin: 0; padding: 14px 6px 0; box-sizing: border-box; background: none; accent-color: #22e6ff; cursor: pointer; }
#quick-dials .qd-more { position: absolute; box-sizing: border-box; border: 1px solid #3a3456; border-radius: 22px; background: #1b1730; color: #e6e0ff; font: 13px system-ui, sans-serif; cursor: pointer; }

/* N1: the navigation tree in the bar. A todo sphere is dimmed and only shows its note; a partial
   one carries a small marker; Back stays at the row's left while the row scrolls. */
#top-bar .tb-btn.tb-todo { opacity: .4; filter: saturate(.3); cursor: help; }
#top-bar .tb-btn .tb-part { position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%;
  background: #f2c14e; border: 1.5px solid #1a1530; pointer-events: none; }
#top-bar .tb-btn.tb-back { position: sticky; left: 0; z-index: 1; }
#tb-note { position: fixed; z-index: 31; box-sizing: border-box; min-height: 40px; padding: 10px 12px; border-radius: 10px;
  background: rgba(10, 8, 24, .95); color: #e6e0ff; border: 1px solid #3a3456; font: 13px/1.35 system-ui, sans-serif;
  text-align: center; pointer-events: none; }
#tb-note[hidden] { display: none; }
#nav-map { position: fixed; z-index: 30; top: 158px; right: 12px; width: 380px; max-height: calc(100% - 170px); overflow-y: auto; box-sizing: border-box;
  padding: 6px 10px 10px; background: rgba(10, 8, 24, .95); color: #e6e0ff; border: 1px solid #3a3456; border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .55); font: 12px/1.35 system-ui, sans-serif; overscroll-behavior: contain; }
#nav-map[hidden] { display: none; }
#nav-map .nm-head { display: flex; align-items: center; gap: 6px; }
#nav-map .nm-head h2 { flex: 1; margin: 0; font-size: 14px; }
#nav-map .nm-head button { min-width: 44px; min-height: 44px; }
#nav-map ul { margin: 0; padding-left: 14px; }
#nav-map li.nm-menu { color: #b5a6f2; }
#nav-map li.nm-todo { color: #8f86b3; }
#nav-map li.nm-partial { color: #f2d48e; }
@media (max-width: 699px) {
  #nav-map { top: calc(150px + env(safe-area-inset-top)); left: 8px; right: 8px; bottom: 8px; width: auto; max-height: none; }
}
