/* W-A2 rhythm and Roman numeral builders (Rhythm: Lego and Grid tabs) and rhythm legos on the page.
   Same glass card, faces, gold and type as the chord card (gn-kit.css tokens); no new look. */

html[data-gn-glow] .overlays-rhythm:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
  gap: 8px;
  min-width: 0;
}
/* The kit's card head carries grid-area: head (the chord card's template); here everything stacks in one column. */
html[data-gn-glow] .overlays-rhythm > * { grid-area: auto; grid-column: 1 / -1; min-width: 0; }
html[data-gn-glow] .overlays-rhythm .gn-ov-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
html[data-gn-glow] .overlays-rhythm .gn-ov-card-head > [data-part="editing"] { flex: 1 1 160px; }
.gn-rb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.gn-rb-row > .gn-k-sub { font-size: var(--gn-k-type-min, 12.5px); }

/* Preview: the engraved lego on paper, with tap targets over each note. */
.gn-rb-preview {
  position: relative;
  min-height: 92px;
  display: grid;
  place-items: center;
  padding: 10px 14px;
  border-radius: var(--gn-k-radius-card, 13px);
  background: var(--gn-k-paper, #fff);
  box-shadow: var(--gn-k-shadow-paper);
  color: #191512;
}
.gn-rb-figure { position: relative; height: 76px; max-width: 100%; display: grid; place-items: center; }
.gn-rb-figure > svg { display: block; height: 100%; width: auto; }
.gn-rb-hits { position: absolute; inset: 0; pointer-events: none; }
.gn-rb-hits > .gn-rb-hit {
  position: absolute;
  top: 0; bottom: 0;
  width: 26px;
  transform: translateX(-50%);
  border: 0; background: transparent; border-radius: 8px;
  pointer-events: auto;
}
.gn-rb-hits > .gn-rb-hit[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--gn-k-gold, #C49A45); }
.gn-rb-hits > .gn-rb-hit[data-over] { background: rgba(58, 40, 32, .05); }

/* Bar meter (V4): thin glass track; a full bar gets a quiet gold seal; overflow is dimmed with the extra count. */
.gn-rb-meter, .gn-lego-meter { display: flex; align-items: center; gap: 8px; }
.gn-rb-meter-track { position: relative; flex: 1; height: 5px; border-radius: 999px; background: var(--gn-k-track); box-shadow: var(--gn-k-track-shadow); overflow: hidden; }
.gn-rb-meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, #E9D9A8, var(--gn-k-gold, #C49A45)); transition: width .18s ease; }
[data-state="full"] > .gn-rb-meter-track { box-shadow: var(--gn-k-gold-rim); }
[data-state="over"] > .gn-rb-meter-fill { background: linear-gradient(90deg, #E9D9A8, #B9A57E); }
[data-state="over"] > span:last-child { color: var(--gn-k-ink-preview, #675B49); }

/* Lego tab: the tray and the bar the pieces snap into. */
.gn-rb-bar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  min-height: 44px; padding: 6px;
  border-radius: var(--gn-k-radius-field, 11px);
  border: 1.5px dashed var(--gn-k-rule-strong);
  background: var(--gn-k-glass-clear);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.gn-rb-bar[data-drop] { border-color: var(--gn-k-gold); box-shadow: 0 0 0 3px rgba(233, 217, 168, .65), 0 0 18px rgba(196, 154, 69, .45); }
.gn-rb-block { padding: 6px 10px; border-radius: var(--gn-k-radius-control, 9px); background: var(--gn-k-face); box-shadow: var(--gn-k-shadow-raised); font-size: var(--gn-k-type-min); cursor: pointer; }
.gn-rb-tray, .gn-rb-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.gn-rb-lego, .gn-rb-preset { display: grid !important; grid-template-rows: 1fr auto; place-items: center; gap: 2px; min-height: 64px; padding: 6px !important; touch-action: none; }
/* The engraving fits its 40 px slot (viewBox meet). Pinned absolutely: WebKit won't resolve a % height in an auto grid row. */
.gn-rb-lego-art { position: relative; display: block; height: 40px; width: 100%; color: #191512; }
.gn-rb-lego-art > svg { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.gn-rb-mine { display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: stretch; }
.gn-rb-ghost { position: fixed; z-index: 2147483000; pointer-events: none; transform: translate(-50%, -50%) scale(1.06); box-shadow: var(--gn-k-gold-rim), var(--gn-k-glass-shadow); opacity: .94; }

/* Grid tab: the beat grid. */
.gn-rb-gridhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gn-rb-grid { display: grid; grid-template-columns: repeat(calc(var(--gn-rb-cols) * 4), minmax(0, 1fr)); gap: 3px; }
.gn-rb-cell {
  min-height: 44px; border: 0; border-radius: 8px;
  background: var(--gn-k-paper-button); box-shadow: var(--gn-k-shadow-raised);
  font: 600 12.5px/1 inherit; color: var(--gn-k-ink-preview);
}
.gn-rb-cell[data-state="on"] { background: var(--gn-k-face-on); box-shadow: var(--gn-k-gold-rim); color: var(--gn-k-ink); }
.gn-rb-cell[data-state="on"]::after { content: ""; display: block; width: 10px; height: 10px; margin: 4px auto 0; border-radius: 50%; background: var(--gn-k-ink); }
.gn-rb-cell[data-state="hold"] { background: linear-gradient(180deg, #F7EFDC, #EBDDBF); box-shadow: var(--gn-k-shadow-pressed); }
.gn-rb-cell[data-state="hold"]::after { content: ""; display: block; height: 4px; margin: 6px -3px 0; background: var(--gn-k-ink); border-radius: 2px; }

.gn-rb-inspector, .gn-rb-settings { display: grid; gap: 6px; padding-top: 4px; border-top: 1px solid var(--gn-k-rule); }
.gn-rb-inspector[data-empty] .gn-ov-chips { opacity: .55; }
.gn-rb-nm { display: inline-flex; align-items: center; gap: 4px; }
.gn-rb-nm > input { width: 52px; min-height: 40px; }
.gn-rb-settings input[type="number"] { width: 72px; min-height: 40px; }
.gn-rn-preview { min-height: 110px; }
.gn-rn-art { display: block; height: 84px; color: #191512; }

/* ---- On the page. */
.annotation-stamp.overlay-lego, .annotation-stamp.overlay-numeral { box-sizing: content-box; padding: 0; filter: none; touch-action: none; }
.annotation-stamp.overlay-numeral > svg { display: block; }
.annotation-stamp.overlay-lego[data-pending] { opacity: 0; }
.annotation-stamp.overlay-lego.gn-lego-fusing, .annotation-stamp.overlay-lego.gn-lego-fuse-partner { box-shadow: 0 0 0 2px rgba(233, 217, 168, .9), 0 0 16px rgba(196, 154, 69, .55); border-radius: 6px; }
.annotation-stamp.overlay-lego.annotation-selected { outline: 2px solid rgba(196, 154, 69, .8); outline-offset: 3px; border-radius: 4px; }
.gn-lego-chrome { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.gn-lego-chrome > * { pointer-events: auto; }

/* V1/V2: the gold guide fades in and out, never a hard flash; reduced motion swaps it for a plain outline. */
.gn-lego-guide {
  position: absolute; width: 2px; margin-left: -1px;
  pointer-events: none !important;
  background: linear-gradient(180deg, rgba(233, 217, 168, 0), #E2C374 18%, #C49A45 50%, #E2C374 82%, rgba(233, 217, 168, 0));
  box-shadow: 0 0 8px 2px rgba(226, 195, 116, .65), 0 0 22px 6px rgba(196, 154, 69, .28);
  opacity: 0;
  transition: opacity .22s ease;
}
.gn-lego-guide.on { opacity: 1; }
.gn-lego-guide[data-kind="beat"] { background: linear-gradient(180deg, #E2C374, #C49A45 70%, rgba(196, 154, 69, .2)); }
.gn-lego-guide.reduced { transition: none; background: none; box-shadow: none; border-left: 2px dashed #7A6020; width: 0; }

.gn-lego-meter { position: absolute; transform: translateY(2px); font: 600 11.5px/1 -apple-system, system-ui, sans-serif; color: var(--gn-k-ink-preview); pointer-events: none !important; }
.gn-lego-tools { position: absolute; display: flex; gap: 4px; padding: 4px; transform: translateY(calc(-100% - 8px)); border-radius: var(--gn-k-radius-card); white-space: nowrap; }
html[data-gn-glow] .gn-lego-tools .gn-k-btn { min-height: 36px; padding: 0 10px; }
.gn-lego-tools [data-lego-free] { align-self: center; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--gn-k-rule-strong); }

/* V10 nudge mode. Handles sit on the noteheads; end handles spread or squeeze the spacing. */
.gn-lego-nudge { position: absolute; }
.gn-lego-handle {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; border: 2px solid #fff;
  background: radial-gradient(circle, #E2C374 0 35%, rgba(196, 154, 69, .35) 36%);
  box-shadow: var(--gn-k-gold-rim); touch-action: none;
}
.gn-lego-handle[data-row="low"] { transform: translateY(32px); }
.gn-lego-handle[data-row="low"]::before { content: ""; position: absolute; left: 50%; bottom: 100%; height: 20px; border-left: 1.5px dotted #C49A45; }
.gn-lego-handle[aria-pressed="true"] { background: radial-gradient(circle, #7A6020 0 35%, rgba(196, 154, 69, .5) 36%); }
.gn-lego-end { position: absolute; top: 15%; bottom: 15%; width: 14px; border-radius: 7px; border: 0; background: var(--gn-k-face); box-shadow: var(--gn-k-gold-rim); touch-action: none; cursor: ew-resize; }
.gn-lego-end[data-nudge-end="left"] { left: -20px; }
.gn-lego-end[data-nudge-end="right"] { right: -20px; }
.gn-lego-nudgebar { position: absolute; left: 50%; top: calc(100% + 14px); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--gn-k-radius-card); white-space: nowrap; }
.gn-lego-nudgebar output { font: 600 12.5px/1 -apple-system, system-ui, sans-serif; color: var(--gn-k-ink); min-width: 170px; text-align: center; }
html[data-gn-glow] .gn-lego-nudgebar .gn-k-btn { min-height: 40px; min-width: 44px; }

/* S6/S9 Bravura symbol catalog (gn-overlay-symbols.js). The faint guide staff shows in the palette only; on the page
   the music's own staff is there. */
.annotation-stamp .gn-sym-staff { display: none; }
.annotation-stamp.overlay-symbol { box-sizing: content-box; filter: none; }
.annotation-stamp.overlay-symbol > svg, .annotation-stamp.overlay-theory > svg { display: block; }
.overlay-symbol-tile { display: block; height: 30px; max-width: 100%; color: currentColor; }
.overlay-symbol-tile > svg { display: block; width: 100%; height: 100%; }

/* S4 My stamps: a full-width "Add your own stamp" button, then the person's own images with a delete corner. */
html[data-gn-glow] #stampGrid > .gn-custom-add,
#stampGrid > .gn-custom-add {
  grid-column: 1 / -1;
  width: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 700;
}
.gn-custom-add > span[aria-hidden] { font-size: 22px; line-height: 1; }
.gn-custom-stamp { position: relative; width: 48px; height: 48px; }
.gn-custom-stamp > .stamp-tile { width: 100%; height: 100%; }
.gn-custom-stamp-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.annotation-stamp.overlay-custom { box-sizing: content-box; display: grid; place-items: center; }
.annotation-stamp.overlay-custom > .gn-custom-stamp-img { width: 100%; height: 100%; }
.gn-custom-stamp-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: var(--gn-k-surface, #fff);
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
