/* RACK v2 — js/rackui.js. Only the site's own theme tokens (--t-*), so all five themes follow. Every target ≥ 44px
   on a phone; a collapsed card is one 56px row; detail opens in a sheet so the picture never scrolls away. */

/* the old list and plug-in grid are replaced, not deleted: their code still runs, their sections are hidden */
html.rv2 #rackp section[data-sec="in use"], html.rv2 #rackp section[data-sec="plug-ins"] { display: none; }

#rv2 { --rv-row: 56px; --rv-tap: 44px; padding: 10px var(--tb-inset, 14px) 24px; }
#rv2 button { font: inherit; color: inherit; }
#rv2 button:focus-visible, #rvsheet button:focus-visible, #rvsheet input:focus-visible, #rvsheet select:focus-visible { outline: 2px solid var(--t-accent); outline-offset: 2px; }

/* whole looks */
.rv-recipes { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.rv-recipes::-webkit-scrollbar { display: none; }
.rv-rc { flex: 0 0 auto; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; background: none; border: 0; padding: 0; cursor: pointer; min-height: var(--rv-tap); }
.rv-rc .th { width: 84px; height: 47px; border-radius: 4px; overflow: hidden; border: 1px solid var(--t-rule); background: var(--t-well, #000); display: grid; place-items: center; }
.rv-rc .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-rc .th.dice { font-size: 22px; color: var(--t-mute); background: var(--t-panel); }
.rv-rc .lb { font-size: var(--fs-label); color: var(--t-mute); }
.rv-rc:hover .th { border-color: var(--t-edge); }
.rv-rc.on .th { border-color: var(--t-hot); box-shadow: 0 0 0 1px var(--t-hot); }
.rv-rc.on .lb { color: var(--t-hot); }

/* header */
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--t-rule); border-bottom: 1px solid var(--t-rule); }
.rv-head .t { font-size: var(--fs-data); color: var(--t-mute); }
.rv-head .t b { font-weight: inherit; color: var(--t-ink); }
.rv-head .acts { display: flex; gap: 8px; }
.rv-btn { min-height: 32px; padding: 0 12px; border: 1px solid var(--t-hair); border-radius: 6px; background: var(--t-panel); cursor: pointer; font-size: var(--fs-sec); color: var(--t-ink); }
.rv-btn:hover { border-color: var(--t-edge); }
.rv-btn.pri { border-color: var(--t-ink); }
.rv-btn:disabled { opacity: .4; cursor: default; }

/* the vertical graph */
.rv-list { position: relative; padding: 8px 0 0 30px; }
.rv-lane { position: absolute; left: 11px; top: 22px; bottom: 22px; width: 2px; background: var(--t-hair); border-radius: 1px; }
.rv-src, .rv-out { position: relative; display: flex; align-items: center; height: 36px; font-size: var(--fs-sec); color: var(--t-dim); }
.rv-src::before, .rv-out::before, .rv-card::before { content: ""; position: absolute; left: -24px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--t-bg); border: 2px solid var(--t-edge); transform: translateY(-50%); }
.rv-card::before { top: 28px; }
.rv-card.off::before { border-style: dashed; }
.rv-lab { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0 6px; font-size: var(--fs-label); color: var(--t-mute); }
.rv-lab i { font-style: normal; color: var(--t-mute); opacity: .8; }
.rv-lab.sm { margin: 14px 0 6px; }
.rv-lab.off { margin-top: 18px; }
.rv-empty { font-size: var(--fs-label); color: var(--t-dim); padding: 6px 0 8px; }
.rv-cut { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--rv-tap); margin: 8px 0; padding: 0; background: none; border: 0; cursor: pointer; text-align: left; }
.rv-cut::before { content: ""; position: absolute; left: -27px; width: 12px; height: 12px; border-radius: 2px; background: var(--t-ink); transform: rotate(45deg); }
.rv-cut .ln { flex: 1; height: 1px; background: var(--t-edge); }
.rv-cut .lb { font-size: var(--fs-sec); color: var(--t-ink); white-space: nowrap; }
.rv-cut .lb i { font-style: normal; color: var(--t-dim); }
.rv-cut:hover .ln { background: var(--t-ink); }

/* cards */
.rv-card { position: relative; margin: 0 0 8px; border: 1px solid var(--t-rule); border-radius: 8px; background: var(--t-panel); }
.rv-card.open { border-color: var(--t-edge); }
.rv-card.off { opacity: .55; }
.rv-card.drag { opacity: .35; }
.rv-card.dropabove, .rv-cut.dropabove { box-shadow: 0 -2px 0 var(--t-accent); }
.rv-card.dropbelow, .rv-cut.dropbelow { box-shadow: 0 2px 0 var(--t-accent); }
.rv-row { display: flex; align-items: center; gap: 6px; height: var(--rv-row); padding: 0 4px 0 0; }
.rv-grip { flex: 0 0 30px; height: var(--rv-tap); display: grid; place-items: center; background: none; border: 0; color: var(--t-dim); cursor: grab; touch-action: none; font-size: 15px; }
.rv-nm { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-height: var(--rv-tap); justify-content: center; }
.rv-nm b { font-weight: inherit; font-size: var(--fs-data); color: var(--t-ink); white-space: nowrap; }
.rv-nm span { font-size: var(--fs-label); color: var(--t-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rv-card .lk { flex: 0 0 40px; height: 23px; border-radius: 3px; overflow: hidden; border: 1px solid var(--t-rule); }
.rv-card .lk img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-card .amt { flex: 0 0 24px; text-align: right; font-size: var(--fs-label); color: var(--t-mute); font-variant-numeric: tabular-nums; }
.rv-ib { flex: 0 0 38px; height: var(--rv-tap); display: grid; place-items: center; background: none; border: 0; border-radius: 6px; cursor: pointer; color: var(--t-dim); padding: 0; touch-action: none; }
.rv-ib svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.rv-ib:hover { color: var(--t-ink); }
.rv-card.open .rv-ib.chev svg { transform: rotate(180deg); }
html.rv-comparing .rv-ib[data-a=compare] { color: var(--t-accent); }
.rv-body { padding: 0 10px 12px 30px; }
.rv-body .what { margin: 0 0 10px; font-size: var(--fs-sec); line-height: 1.45; color: var(--t-mute); }
.rv-looks { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.rv-look { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; background: none; border: 0; padding: 0; cursor: pointer; }
.rv-look .th { width: 88px; height: 50px; border-radius: 4px; overflow: hidden; border: 1px solid var(--t-rule); background: var(--t-well, #000); }
.rv-look .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-look .lb { font-size: var(--fs-label); color: var(--t-mute); }
.rv-look:hover .th { border-color: var(--t-edge); }
.rv-look.on .th { border-color: var(--t-hot); box-shadow: 0 0 0 1px var(--t-hot); }
.rv-look.on .lb { color: var(--t-hot); }
.rv-amt { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; }
.rv-amt .lb { font-size: var(--fs-label); color: var(--t-dim); }
.rv-amt input[type=range] { flex: 1; min-width: 60px; height: 32px; accent-color: var(--t-ink); }
.rv-amt .v { width: 28px; text-align: right; font-size: var(--fs-label); color: var(--t-mute); font-variant-numeric: tabular-nums; }
.rv-mv { min-width: 44px; height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--t-hair); background: var(--t-bg); cursor: pointer; font-size: var(--fs-label); color: var(--t-mute); white-space: nowrap; }
.rv-mv.on { border-color: var(--t-accent); color: var(--t-accent); }
.rv-cardfoot { display: flex; gap: 8px; margin-top: 10px; }
.rv-cardfoot .rv-btn { flex: 1; min-height: 36px; }
.rv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-chip { min-height: 32px; padding: 0 12px; border: 1px solid var(--t-hair); border-radius: 16px; background: none; cursor: pointer; font-size: var(--fs-sec); color: var(--t-mute); }
.rv-chip.on { border-color: var(--t-hot); color: var(--t-hot); }
.rv-stray { display: flex; align-items: center; gap: 8px; min-height: 44px; padding-left: 30px; font-size: var(--fs-sec); color: var(--t-dim); }
.rv-stray span { flex: 1; }
.rv-foot { display: flex; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--t-rule); }

/* sheets */
#rvsheet[hidden] { display: none; }
#rvsheet .rv-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; }
#rvsheet .rv-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 72vh; display: flex; flex-direction: column;
  background: var(--t-panel); border-top: 1px solid var(--t-hair); border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); color: var(--t-ink); }
html:not(.narrow) #rvsheet .rv-sheet { right: auto; max-width: 560px; }
.rv-sh { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--t-rule); }
.rv-sh b { font-weight: inherit; font-size: var(--fs-data); }
.rv-sb { overflow-y: auto; padding: 8px 14px 18px; }
.rv-srow { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; min-height: 48px; border-bottom: 1px solid var(--t-rule); }
.rv-srow .n { font-size: var(--fs-sec); color: var(--t-ink); }
.rv-srow .n small { display: block; font-size: var(--fs-cap); color: var(--t-dim); }
.rv-in { width: 88px; min-height: 32px; padding: 0 8px; border: 1px solid var(--t-hair); border-radius: 6px; background: var(--t-bg); color: var(--t-ink); font: inherit; font-size: var(--fs-sec); text-align: right; font-variant-numeric: tabular-nums; }
select.rv-in { text-align: left; width: auto; }
.rv-mvtag { font-size: var(--fs-label); color: var(--t-accent); }
.rv-how { margin: 14px 0 0; font-size: var(--fs-sec); line-height: 1.5; color: var(--t-mute); }
.rv-how b { font-weight: inherit; color: var(--t-ink); }
.rv-opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; margin: 0 0 8px; padding: 6px 10px; border: 1px solid var(--t-rule); border-radius: 8px; background: var(--t-bg); cursor: pointer; text-align: left; color: var(--t-ink); font: inherit; }
.rv-opt:hover { border-color: var(--t-edge); }
.rv-opt.on { border-color: var(--t-accent); }
.rv-opt .th { flex: 0 0 64px; height: 36px; border-radius: 3px; overflow: hidden; border: 1px solid var(--t-rule); background: var(--t-well, #000); }
.rv-opt .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-opt .d { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rv-opt .d b { font-weight: inherit; font-size: var(--fs-data); }
.rv-opt .d span { font-size: var(--fs-label); color: var(--t-dim); }
.rv-srow .rv-opt { margin: 4px 0; }
.rv-range { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-sec); color: var(--t-mute); }
.rv-range label { display: flex; align-items: center; gap: 8px; }

/* phones: nothing below 11px, and the whole card is easier to hit */
html.narrow #rv2 { --fs-label: 11px; --fs-cap: 11px; }
html.narrow .rv-rc .th { width: 76px; height: 43px; }
@media (prefers-reduced-motion: reduce) { #rv2 *, #rvsheet * { transition: none !important; } }

/* the picture is the transport */
#b { touch-action: manipulation; }
#rvplay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .5); display: grid; place-items: center; cursor: pointer; z-index: 3; padding: 0; }
#rvplay svg { width: 18px; height: 18px; fill: var(--t-whot, #fff); }
html.rv-playing #rvplay, html.rv-nosource #rvplay { display: none; }
#rvmute { display: none; }
html.narrow #rvmute { display: block; position: absolute; right: calc(var(--tb-inset, 14px) + 40px); bottom: var(--tb-inset, 14px); z-index: 3; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 4px; background: rgba(0, 0, 0, .55); color: var(--t-whot, #fff); font: inherit; font-size: 11px; cursor: pointer; }
html.narrow #rvmute.off { color: var(--t-wmute, #aaa); }
html.rv-comparing #b::after { content: "without effects"; position: absolute; right: var(--tb-inset, 14px); top: calc(var(--tb-inset, 14px) + 28px); z-index: 3;
  padding: 3px 7px; border-radius: 3px; background: var(--t-accent); color: #fff; font-size: 11px; }
/* on a phone the transport row and the song line go; the time and cut already sit in the picture's corners */
html.narrow #transport, html.narrow #tsong { display: none !important; }

/* patch view — desktop only. The right side becomes the graph; the picture is a monitor in its top-right corner. */
.rv-desk { }
html.narrow .rv-desk, html.narrow .rv-patchbtn { display: none !important; }
html:not(.narrow) #app.rv-patch #env, html:not(.narrow) #app.rv-patch #transport, html:not(.narrow) #app.rv-patch #tsong,
html:not(.narrow) #app.rv-patch #splitVid { display: none !important; }
html:not(.narrow) #app.rv-patch #b { position: absolute; z-index: 6; bottom: 16px; right: 16px; width: min(400px, 46%); height: auto; flex: none;
  border: 1px solid var(--t-edge); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
html:not(.narrow) #app.rv-patch #graph { flex: 1 1 auto; min-height: 0; }
html:not(.narrow) #app.rv-patch #graph .layer { padding-bottom: 240px; }   /* scroll room so the last card can sit clear of the monitor */
html:not(.narrow) #app.rv-patch #b .corner.tl, html:not(.narrow) #app.rv-patch #b .zc { display: none; }

/* groups in the add sheet, and the group word on each card */
.rv-grp { margin: 4px 0 14px; }
.rv-grph { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--t-rule); }
.rv-grph b { font-weight: inherit; font-size: var(--fs-sec); color: var(--t-ink); }
.rv-grph span { font-size: var(--fs-label); color: var(--t-dim); }
.rv-nm b em { font-style: normal; font-size: var(--fs-label); color: var(--t-dim); margin-left: 6px; }

/* a look with no still shows its name instead of an empty box */
.rv-look .th.word { display: grid; place-items: center; padding: 4px; text-align: center; font-size: var(--fs-label); color: var(--t-mute); background: var(--t-bg); }
/* iOS Safari zooms the whole page when a focused field is under 16px */
html.narrow .rv-in, html.narrow #rvsheet select { font-size: 16px; }
/* phones: nothing on any panel under 11px */
html.narrow { --fs-cap: 11px; }
html.narrow #listen .d, html.narrow #listen .go, html.narrow #export .note { font-size: 11px; }
