/* Stemma: the History panel, its dialogs, and the marks on the score. history-ui.js builds the markup.
   Desktop: a panel on the right over the chart-text side. Narrow windows and phones: a sheet over the bottom. */

#hxPanel { position: fixed; right: 0; top: 96px; bottom: 0; width: 400px; z-index: 55; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 2px solid var(--line); box-shadow: -8px 0 28px #1f23501f; font: 14px/1.4 var(--ui); color: var(--text); }
#hxPanel[hidden], #hxBanner[hidden] { display: none; }
#hxPanel button { min-height: 38px; }
.hx-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px 14px; flex: none; }
.hx-title { flex: 1; min-width: 0; font: 800 16px/1.2 var(--ui); }
.hx-name { color: var(--accent); }
.hx-sub { font-weight: 600; color: var(--muted); font-size: 13px; }
.hx-branchchip { font: 700 12px/1 var(--ui); padding: 5px 9px; border-radius: 999px; background: #e3eaff; color: #1d3a8f; border: 1px solid var(--blue); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.hx-x { width: 40px; padding: 0; font-size: 18px; flex: none; }
.hx-tabs { display: flex; gap: 4px; padding: 0 10px 8px; flex: none; border-bottom: 1px solid var(--line); }
.hx-tabs button { flex: 1 1 0; padding: 7px 6px; font-size: 13px; border-radius: 8px; white-space: normal; line-height: 1.15; }
.hx-tabs button.on { background: var(--text); color: #fff; border-color: var(--text); }
#hxPanel.hx-comparing .hx-tabs { opacity: .55; }
.hx-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 12px 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.hx-help { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.hx-fine { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.hx-ok { color: #12703f; font-weight: 700; }
.hx-h3 { margin: 12px 0 4px; font: 800 12px/1.2 var(--ui); letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.hx-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; background: #fff; }
.hx-card h3 { margin: 0 0 4px; font: 800 14px/1.2 var(--ui); }
.hx-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: flex-end; }
.hx-row button { flex: 0 1 auto; white-space: normal; }
.hx-form .hx-grow { flex: 1 1 180px; min-width: 0; }
.hx-lab { display: block; font: 700 12px/1.2 var(--ui); color: var(--muted); margin: 6px 0 3px; }
#hxPanel input[type=text], .hx-dlg input[type=text], .hx-dlg textarea, .hx-dlg select, #hxPanel select { width: 100%; font: 600 15px var(--ui); padding: 8px 10px; border: 1px solid #c9bda4; border-radius: 8px; background: #fff; color: var(--text); min-height: 40px; }
.hx-dlg input[type=number] { width: 4.6em; font: 700 15px var(--ui); padding: 6px 8px; min-height: 38px; border: 1px solid #c9bda4; border-radius: 8px; }
.hx-primary { background: var(--blue) !important; color: #fff !important; border-color: var(--blue) !important; }
.hx-primary:hover { filter: brightness(1.08); }
.hx-warn { color: #8a2b00; border-color: #e0a68e; }
.hx-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.hx-check input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
#hxPanel button.on, #hxPanel button[aria-pressed=true] { background: #e3eaff; border-color: var(--blue); color: #1d3a8f; }
.hx-notice { background: #fff6d6; border: 1px solid #e3c35a; border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; font-weight: 600; }
.hx-notice button { margin-top: 6px; }

.hx-status { padding: 7px 10px; border-radius: 10px; font-weight: 700; font-size: 13.5px; margin: 0 0 8px; }
.hx-status.ok { background: #e3f4ea; color: #12703f; }
.hx-status.edit { background: #fff1d6; color: #7a4a00; }

.hx-scrub { margin: 10px 0 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.hx-scrub label { font: 800 12px/1.2 var(--ui); letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.hx-scrub input[type=range] { width: 100%; height: 36px; margin: 4px 0 0; accent-color: var(--blue); }
.hx-scrubtxt { font-size: 13px; color: var(--text); min-height: 2.6em; }

.hx-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hx-snap { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 2px 10px 8px; }
.hx-snap.open { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }
.hx-snap.starred { background: #fffaf0; }
.hx-snap.hx-now { background: #fff6e5; border-style: dashed; }
.hx-snap.cur { border-color: var(--blue); }
.hx-snaphead { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; width: 100%; text-align: left; border: 0; background: none; box-shadow: none; padding: 8px 0 4px; white-space: normal; cursor: pointer; }
.hx-snaphead.static { cursor: default; }
.hx-snaphead:hover { background: none; }
.hx-star { color: #a9a493; font-size: 17px; line-height: 1; }
.hx-star.on { color: #c58a00; }
.hx-sname { font: 800 15px/1.25 var(--ui); flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.hx-kind { font: 700 11px/1 var(--ui); padding: 3px 7px; border-radius: 999px; background: #eceff9; color: #3b4577; }
.hx-tag { display: inline-block; font: 700 11.5px/1 var(--ui); padding: 4px 8px; border-radius: 999px; background: #fdecc8; color: #6b4300; border: 1px solid #e8c26d; }
.hx-tag.x { cursor: pointer; min-height: 30px; }
.hx-meta { flex: 1 1 100%; color: var(--muted); font-size: 12.5px; }
.hx-sum { margin: 0 0 4px; padding: 0 0 0 18px; font-size: 13.5px; }
.hx-sum li { margin: 1px 0; }
.hx-sum .hx-more { color: var(--muted); list-style: none; margin-left: -18px; padding-left: 18px; }
.hx-note { margin: 4px 0; font-style: italic; color: #3a3f63; }
.hx-acts { display: none; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hx-acts.show { display: flex; }
.hx-acts button { flex: 1 1 140px; white-space: normal; font-size: 13.5px; }
.hx-tagrow { flex: 1 1 100%; display: flex; gap: 6px; flex-wrap: wrap; }
.hx-acts .hx-fine { flex: 1 1 100%; }
.hx-empty { color: var(--muted); padding: 8px 4px; }

.hx-lookbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff1d6; border-bottom: 1px solid #e3c35a; font-weight: 700; flex: none; }
.hx-lookbar span { flex: 1; min-width: 0; }

.hx-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hx-sel label { min-width: 0; }
.hx-seg { display: flex; gap: 6px; margin: 8px 0; }
.hx-seg button { flex: 1; }
.hx-legend { margin: 4px 0 0; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lg { padding-left: 14px; position: relative; font-weight: 700; }
.lg::before { content: ""; position: absolute; left: 0; top: 3px; width: 10px; height: 10px; border-radius: 3px; background: currentColor; }
.lg.add { color: #12703f; } .lg.del { color: #b02820; } .lg.chg { color: #9a6a00; } .lg.lyr { color: #6a3fa0; }
.hx-changes { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hx-chg { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; white-space: normal; padding: 8px 10px; }
.hx-bar { font: 800 13px/1.2 var(--ui); color: var(--blue); }
.hx-txt { font-size: 13.5px; }
.hx-det { font-size: 12px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; }
.hx-mini { margin: 4px 0 0; font-size: 13px; min-height: 36px; }

.hx-blame ul { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.hx-blame .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* the note above the score while an older version is on it */
#hxBanner { position: fixed; z-index: 56; left: 12px; top: 120px; max-width: 560px; padding: 8px 12px; border-radius: 10px; background: #1f2350; color: #fff; font: 700 13.5px/1.35 var(--ui); box-shadow: 0 6px 20px #1f235055; pointer-events: none; }

/* the dialogs */
.hx-dlg { width: min(520px, 94vw); max-height: 90vh; overflow-y: auto; border: 2px solid var(--blue); border-radius: 16px; padding: 16px 18px; background: var(--panel); color: var(--text); font: 14px/1.45 var(--ui); box-shadow: 0 24px 60px #1f235066; }
.hx-dlg.wide { width: min(720px, 96vw); }
/* the app makes dialogs full-screen sheets on narrow windows; these ones are a sheet from the bottom, as tall as they need */
@media (max-width: 820px) {
  dialog.hx-dlg, dialog.hx-dlg.wide { width: 100vw; max-width: 100vw; height: auto; max-height: 92dvh; margin: auto 0 0 0; border-radius: 16px 16px 0 0; border-width: 2px 0 0; }
  dialog.hx-dlg > form { min-height: 0; }
}
.hx-dlg::backdrop { background: #1f235066; }
.hx-dlg h2 { margin: 0 0 6px; font: 800 20px/1.2 var(--ui); }
.hx-dlg .hx-help { font-size: 14px; }
.hx-opt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 4px; font-weight: 600; min-height: 44px; }
.hx-opt input[type=radio] { width: 20px; height: 20px; flex: none; }
.hx-opt select { width: auto; max-width: 100%; }
.hx-conf { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; padding: 4px 10px 6px; background: #fff; }
.hx-conf legend { font-weight: 800; padding: 0 6px; }
.hx-code { font: 600 12.5px ui-monospace, Consolas, monospace; background: #f3efe4; padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.hx-bulk { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.hx-bulk button { font-size: 13px; white-space: normal; }
.hx-sticky { position: sticky; bottom: -16px; background: var(--panel); padding: 10px 0 4px; margin-bottom: 0; border-top: 1px solid var(--line); }

/* a comparison or an old version on the score: nothing there can be edited */
body.hx-viewing #score { box-shadow: inset 0 0 0 4px #e8a317; }
body.hx-viewing #score svg { cursor: default; }

/* narrow windows: a sheet over the bottom */
body.hx-narrow #hxPanel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 52dvh; border-left: 0; border-top: 2px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -10px 28px #1f23502a; }
body.phone #hxPanel { bottom: calc(52px + env(safe-area-inset-bottom)); height: 50dvh; }
body.phone.hx-open #phSheet { display: none !important; }
body.hx-narrow.hx-open .workspace { padding-bottom: 52dvh; }
body.phone.hx-open .workspace { padding-bottom: 0; }
body.phone #hxPanel button, body.phone .hx-dlg button, body.phone .hx-dlg input[type=text], body.phone .hx-dlg select { min-height: 44px; }
body.phone .hx-acts button { flex: 1 1 100%; }
body.phone #hxBanner { font-size: 12.5px; padding: 6px 10px; }
@media (max-width: 480px) {
  .hx-sel { grid-template-columns: 1fr; }
  .hx-tabs button { font-size: 12.5px; padding: 6px 3px; }
}
@media (pointer: coarse) { #hxPanel button, .hx-dlg button { min-height: 44px; } }
