/* tracker: a pocket sequencer. the song name and a two position mode switch on top, a limits rack that is always in sight,
   transport as hardware keys with a green lcd, then four tabs. notes are a grid of 44 point squares: four voices at a time
   on a phone, all eight on a wide screen. the note sheet lifts from the bottom and leaves the grid tappable above it */
#view-tracker { --tk-green: var(--green, #5be3a1); --tk-amber: var(--amber, #ffc94d); --tk-red: var(--red, #ff4458); --tk-violet: var(--violet, #a99bff); }
.tk-grid .tile-media { aspect-ratio: 16 / 9; font-size: 28px; }
.tk-card-meter { display: block; height: 6px; margin-top: 6px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); position: relative; overflow: hidden; }
.tk-card-meter i { position: absolute; inset: 0 auto 0 0; background: var(--tk-green); }
.tk-card-meter.warn i { background: var(--tk-amber); }
.tk-card-meter.bad i { background: var(--tk-red); }
.tk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-bar .title-input { flex: 1 1 180px; min-width: 0; min-height: 44px; }
.tk-mode { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line-2); }
.tk-mode button { min-height: 44px; padding: 0 14px; border: 0; background: transparent; cursor: pointer; color: var(--ink-2); font: 600 12px var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; }
.tk-mode button[aria-pressed="true"] { background: var(--chi); color: var(--chi-ink); }
.tk-mode button[data-mode="free"][aria-pressed="true"] { background: var(--tk-violet); }

.tk-modebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tk-modebar .hint { flex: 1 1 160px; min-width: 0; }
.tk-rack { position: sticky; top: 0; z-index: 6; display: flex; flex-direction: column; gap: 6px; padding: 6px 0; background: var(--bg); }
.tk-limits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 6px 12px 8px; background: var(--panel-solid); box-shadow: inset 0 0 0 1px var(--line-2); }
.tk-lim { display: grid; gap: 3px; min-width: 0; }
.tk-lim .name { font: 10px var(--font-label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.tk-lim .val { font: 700 17px var(--font-display); letter-spacing: 0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tk-lim .val small { font: 11px var(--font-label); color: var(--ink-3); letter-spacing: 0.06em; }
.tk-meter { position: relative; height: 8px; overflow: hidden; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.tk-meter b { position: absolute; inset: 0 auto 0 0; background: var(--tk-green); transition: width 0.25s, background 0.25s; }
.tk-lim.warn .tk-meter b { background: var(--tk-amber); }
.tk-lim.bad .tk-meter b { background: var(--tk-red); }
.tk-lim.warn .val { color: var(--tk-amber); }
.tk-lim.bad .val { color: var(--tk-red); }
.tk-say { grid-column: 1 / -1; margin: 0; padding: 8px 10px; font-size: 13px; line-height: 1.45; border-left: 3px solid var(--tk-green); background: var(--panel-hi); }
.tk-say.warn { border-color: var(--tk-amber); }
.tk-say.bad { border-color: var(--tk-red); }

.tk-transport { display: flex; align-items: center; gap: 8px; }
.tk-tr { display: grid; place-items: center; align-content: center; gap: 0; width: 46px; height: 46px; padding: 0; border: 1px solid var(--line-2); border-radius: 50%; cursor: pointer; color: var(--ink); background: linear-gradient(var(--panel-solid), var(--well)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 3px 8px rgba(0, 0, 0, 0.4); font: 10px var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; }
.tk-tr span { margin-top: -3px; font-size: 9px; }
.tk-tr:active { transform: translateY(1px); }
.tk-tr.main { width: 56px; height: 56px; color: #021418; border-color: #0b6b80; background: radial-gradient(circle at 35% 30%, #5ef2ff, #19a9c4 70%, #0c6d82); }
.tk-tr.small { width: 44px; height: 44px; }
.tk-say { margin: 0; }
.tk-tr[aria-pressed="true"] { color: var(--chi); border-color: var(--chi); }
.tk-tr:disabled { opacity: 0.35; cursor: default; }
.tk-lcd { flex: 1; min-width: 0; display: grid; gap: 1px; padding: 6px 10px; background: #03120f; box-shadow: inset 0 0 0 1px #0f3a30, inset 0 0 18px rgba(77, 255, 200, 0.08); font: 11px var(--font-label); letter-spacing: 0.1em; color: #52b7a0; }
.tk-lcd span, .tk-lcd b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-lcd b { font: 600 17px var(--font-display); letter-spacing: 0.07em; color: #8dffe0; text-shadow: 0 0 8px rgba(77, 255, 200, 0.5); }

.tk-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tk-tabs button { min-height: 48px; border: 0; cursor: pointer; background: var(--panel-solid); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); font: 600 15px var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; }
.tk-tabs button[aria-selected="true"] { background: var(--chi); color: var(--chi-ink); }
.tk-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tk-panel[hidden] { display: none; }
.tk-block { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--panel-solid); box-shadow: inset 0 0 0 1px var(--line); }
.tk-keys { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tk-keys .field { flex: 1 1 140px; }
.tk-keys input[type="number"], .tk-block select, .tk-keys select { min-height: 44px; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-chip { min-height: 44px; min-width: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; border: 0; background: var(--well); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font: 13px var(--font-label); }
.tk-chip[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--chi); color: var(--chi); }
.tk-chip.sound[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--tk-violet); color: var(--tk-violet); background: rgba(169, 155, 255, 0.1); }
.tk-chip small { color: var(--ink-3); font-size: 11px; }
.tk-chip:disabled { opacity: 0.35; cursor: default; }
.tk-slider { display: grid; grid-template-columns: 96px minmax(0, 1fr) 64px; align-items: center; gap: 8px; font: 11px var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.tk-slider input { min-height: 44px; width: 100%; accent-color: var(--chi); }
.tk-slider output { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.tk-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.tk-check.inline { margin-left: auto; }
.tk-check input { width: 22px; height: 22px; accent-color: var(--chi); flex: none; }

/* the grid */
.tk-pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-pages { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tk-chip.plain { cursor: default; background: none; box-shadow: none; color: var(--ink-2); padding: 0 4px; }
.tk-help summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font: 11px var(--font-label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.tk-editor.sheet-open { padding-bottom: 68vh; }
.tk-grid-notes { position: relative; display: grid; grid-template-columns: 36px repeat(var(--cols, 4), minmax(0, 1fr)); gap: 2px; max-height: 56vh; overflow-y: auto; overscroll-behavior: contain; padding: 2px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); font: 13px var(--font-label); }
.tk-h { position: sticky; top: 0; z-index: 2; padding: 6px 4px; text-align: center; background: var(--panel-solid); color: var(--ink-3); font: 600 13px var(--font-display); letter-spacing: 0.1em; }
.tk-h.used { color: var(--chi); }
.tk-h.over { color: var(--tk-red); }
.tk-rn { display: grid; place-items: center; min-height: 44px; color: var(--ink-3); }
.tk-rn.beat { color: var(--ink-2); }
.tk-cell { min-height: 44px; min-width: 0; padding: 0 6px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; border: 0; cursor: pointer; text-align: left; background: rgba(255, 255, 255, 0.025); color: var(--ink-3); font: 14px var(--font-label); }
.tk-cell.beat { background: rgba(255, 255, 255, 0.055); }
.tk-cell.has { color: var(--ink); }
.tk-cell .n { color: var(--chi); }
.tk-cell .s { color: var(--tk-violet); font-size: 12px; }
.tk-cell .v { margin-left: auto; color: var(--tk-green); font-size: 12px; }
.tk-cell .x { color: var(--tk-amber); font-size: 12px; }
.tk-cell.cut .n { color: var(--ink-2); }
.tk-cell.sel { box-shadow: inset 0 0 0 2px var(--chi); background: var(--chi-dim); }
.tk-cell.high .n { color: var(--tk-amber); }
.tk-rn.play, .tk-cell.play { background: rgba(91, 227, 161, 0.22); }
.tk-cell:focus-visible { outline: 2px solid var(--chi); outline-offset: -2px; }

/* note sheet: transparent wrapper so the grid stays visible and tappable above the sheet */
.tk-sheet-wrap { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; pointer-events: none; z-index: 56; }
.tk-sheet { pointer-events: auto; width: min(640px, 100%); max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); background: var(--panel-solid); box-shadow: inset 0 1px 0 var(--line-2), 0 -22px 44px rgba(0, 0, 0, 0.6); animation: sheet-up 0.28s var(--spring, ease-out); }
.tk-piano { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; height: 100px; flex: none; }
.tk-sheet .tk-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.tk-sheet .tk-chip { flex: none; }
.tk-wk { border: 0; padding: 0 0 6px; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; background: #e9eef7; color: #0b0f18; font: 11px var(--font-label); min-width: 0; }
.tk-wk:active, .tk-wk.on { background: var(--chi); }
.tk-bk { position: absolute; top: 0; height: 58px; width: 10%; transform: translateX(-50%); border: 1px solid #000; cursor: pointer; background: #11161f; color: #fff; padding: 0; }
.tk-bk:active, .tk-bk.on { background: var(--chi); }
.tk-wk:disabled, .tk-bk:disabled { opacity: 0.3; cursor: default; }
#tk-sheet-oct { color: var(--ink-2); margin-left: 6px; }

/* sounds */
.tk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tk-sound { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-width: 0; background: var(--panel-solid); box-shadow: inset 0 0 0 1px var(--line); }
.tk-sound-head { display: flex; align-items: center; gap: 8px; }
.tk-sound-head input { flex: 1; min-width: 0; min-height: 44px; font: 600 16px var(--font-display); letter-spacing: 0.04em; }
.tk-kb { font: 12px var(--font-label); color: var(--ink-3); white-space: nowrap; }
.tk-wave { width: 100%; height: 56px; display: block; background: #02060a; box-shadow: inset 0 0 0 1px var(--line); }
.tk-gen { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--well); box-shadow: inset 0 0 0 1px var(--tk-violet); }
.tk-gen .section-head > h2 { color: var(--tk-violet); }
.tk-sound details { display: contents; }
.tk-sound summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font: 11px var(--font-label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.tk-used { font: 11px var(--font-label); color: var(--ink-3); }

/* export */
.tk-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tk-checks li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; padding: 8px 10px; background: var(--well); border-left: 3px solid var(--tk-green); font-size: 14px; }
.tk-checks li.warn { border-color: var(--tk-amber); }
.tk-checks li.bad { border-color: var(--tk-red); }
.tk-checks b { font: 600 12px var(--font-label); letter-spacing: 0.1em; }
.tk-checks li.warn b { color: var(--tk-amber); }
.tk-checks li.bad b { color: var(--tk-red); }
.tk-checks small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.tk-formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.tk-format { min-height: 72px; padding: 10px 12px; display: grid; gap: 3px; align-content: start; text-align: left; cursor: pointer; border: 0; color: var(--ink); background: var(--well); box-shadow: inset 0 0 0 1px var(--line-2); }
.tk-format b { display: flex; justify-content: space-between; gap: 8px; font: 700 16px var(--font-display); letter-spacing: 0.06em; }
.tk-format b em { font: 11px var(--font-label); font-style: normal; color: var(--chi); letter-spacing: 0.08em; }
.tk-format span { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.tk-format.main { box-shadow: inset 0 0 0 2px var(--chi); }
.tk-format:disabled { opacity: 0.45; cursor: default; }

@media (min-width: 760px) {
  .tk-grid-notes { --cols: 8; }
  .tk-grid-notes.wide16 { --cols: 8; }
}
@media (max-width: 480px) {
  .tk-slider { grid-template-columns: 78px minmax(0, 1fr) 56px; }
  .tk-lim .val { font-size: 17px; }
  .tk-mode button { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-meter b, .tk-sheet { transition: none; animation: none; }
}
