/* Audioshred — tab editor shell. Songsterr-like: sheet in the middle,
   player bar pinned to the bottom, everything achromatic (KONSTRUKT tokens). */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.sh-body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px; /* room for the player bar */
}

/* ── Top bar ──────────────────────────────────────────────── */
.sh-top {
  position: sticky; top: 0; z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--nav-height);
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.sh-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-family: var(--font-display); font-weight: 500; font-size: 12px; letter-spacing: .18em;
}
.sh-brand svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sh-top-center { text-align: center; }
.sh-doc-title {
  display: block;
  font-family: var(--font-display); font-weight: 400; font-size: 18px;
  outline: none; border-radius: 6px; padding: 0 6px;
}
.sh-doc-title:focus { background: var(--fill); }
.sh-doc-meta { display: block; font-size: 11px; color: var(--ink-faint); letter-spacing: .06em; }
.sh-top-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.sh-icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink-dim);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font: 600 13px/1 var(--font);
}
.sh-icon-btn:hover { color: var(--ink); border-color: var(--line-bright); }
.theme-picker { position: relative; }
.theme-icon { display: none; line-height: 0; }
[data-theme-mode="auto"] .theme-icon--auto,
[data-theme-mode="light"] .theme-icon--light,
[data-theme-mode="dark"] .theme-icon--dark { display: inline-block; }
.theme-dropdown[hidden] { display: none; }
.theme-dropdown {
  position: absolute; right: 0; top: 36px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; min-width: 90px;
}
.theme-option {
  border: 0; background: transparent; color: var(--ink-dim); text-align: left;
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font: 500 12px/1 var(--font);
}
.theme-option:hover, .theme-option.is-active { background: var(--fill); color: var(--ink); }

/* ── Sheet ────────────────────────────────────────────────── */
.sh-main { max-width: var(--max-width); margin: 0 auto; padding: 28px 20px 0; }
.sh-sheet { display: flex; flex-direction: column; gap: 26px; }
.sh-row { width: 100%; }
.sh-row svg { display: block; height: auto; overflow: visible; }

.sh-string { stroke: var(--line-bright); stroke-width: 1; }
.sh-barline { stroke: var(--ink-dim); stroke-width: 1.2; }
.sh-barline--end { stroke-width: 2.4; }
.sh-string-name { fill: var(--ink-faint); font: 600 9px/1 var(--font-mono); }
.sh-bar-num { fill: var(--ink-faint); font: 500 10px/1 var(--font); }
.sh-tempo { fill: var(--ink); font: 500 11px/1 var(--font); }
.sh-beat-tick { stroke: var(--line); stroke-width: 1; }
.sh-fret {
  fill: var(--ink);
  font: 600 11.5px/1 var(--font-mono);
  text-anchor: middle; dominant-baseline: central;
  paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round;
}
.sh-fret--ghost { fill: var(--ink-faint); }
.sh-stem { stroke: var(--ink-dim); stroke-width: 1.1; }
.sh-beam { stroke: var(--ink-dim); stroke-width: 2.2; stroke-linecap: butt; }
.sh-flag { fill: var(--ink-dim); stroke: none; }
.sh-dot { fill: var(--ink-dim); }
.sh-rest { fill: var(--ink-faint); }

/* Layer badges: the arrangement of each bar, readable at a glance. */
.sh-layer { cursor: pointer; }
.sh-layer rect { fill: transparent; stroke: var(--line); stroke-width: 1; }
.sh-layer text {
  fill: var(--ink-faint); font: 700 7.5px/1 var(--font); letter-spacing: .06em;
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}
.sh-layer.is-on rect { fill: var(--ink); stroke: var(--ink); }
.sh-layer.is-on text { fill: var(--bg); }
.sh-layer--fixed { cursor: default; }
.sh-layer:not(.sh-layer--fixed):hover rect { stroke: var(--ink); }

.sh-cell { fill: transparent; cursor: text; }
.sh-cell:hover { fill: var(--fill); }
.sh-cursor { fill: var(--fill-2); stroke: var(--ink); stroke-width: 1.2; rx: 4; pointer-events: none; }
.sh-playhead { fill: var(--ink); opacity: .10; pointer-events: none; }
.sh-playhead-line { stroke: var(--ink); stroke-width: 1.4; pointer-events: none; }

.sh-bar-tools { opacity: 0; transition: opacity .15s var(--ease); }
.sh-bar-group:hover .sh-bar-tools, .sh-bar-group.is-active .sh-bar-tools { opacity: 1; }
.sh-bar-tool { cursor: pointer; }
.sh-bar-tool rect { fill: var(--bg-card); stroke: var(--line); rx: 6; }
.sh-bar-tool:hover rect { stroke: var(--ink); }
.sh-bar-tool path, .sh-bar-tool circle, .sh-bar-tool line { stroke: var(--ink-dim); fill: none; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.sh-bar-tool:hover path, .sh-bar-tool:hover circle, .sh-bar-tool:hover line { stroke: var(--ink); }
.sh-bar-tool text { fill: var(--ink-dim); font: 600 9px/1 var(--font); text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.sh-sheet-actions { display: flex; align-items: center; gap: 10px; margin: 18px 0 40px; flex-wrap: wrap; }
.sh-chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink-dim);
  border-radius: var(--radius-pill); padding: 6px 14px; cursor: pointer; font: 500 12px/1 var(--font);
}
.sh-chip:hover { color: var(--ink); border-color: var(--line-bright); }
.sh-sheet-hint { font-size: 12px; color: var(--ink-faint); margin-left: auto; }
.sh-sheet-hint kbd {
  font: 600 10px/1 var(--font-mono); padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-dim);
}

.sh-credit {
  max-width: var(--max-width); margin: 0 auto 40px; padding: 0 20px;
  font-size: 11px; color: var(--ink-faint); letter-spacing: .02em;
}
.sh-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sh-credit a:hover { color: var(--ink); }

/* ── Player bar ───────────────────────────────────────
   One row, one height, one shape. Every control is .sh-item:
   44px tall, same radius, same border, label + value inline.     */
.sh-player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg-card) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.sh-bar {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: 72px; padding: 0 20px;
}
.sh-bar-spacer { flex: 1 1 auto; }

.sh-item {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px; margin: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--ink);
  font: 500 13px/1 var(--font);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.sh-item:hover { border-color: var(--line-bright); }
.sh-item-label {
  font: 600 9.5px/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.sh-item-value { font: 500 13px/1 var(--font); color: var(--ink); }

.sh-item-select, .sh-item-input {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; color: var(--ink);
  font: 500 13px/1 var(--font); padding: 0; margin: 0; cursor: pointer;
}
.sh-item-select {
  padding-right: 15px; max-width: 112px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpolyline points='2,3.5 5,6.5 8,3.5' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center;
}
.sh-item-select:focus, .sh-item-input:focus { outline: none; }
.sh-item-select option { color: #0b0b0c; background: #fff; }
.sh-item-input {
  width: 34px; text-align: left; font-family: var(--font-mono); font-weight: 600;
  -moz-appearance: textfield;
}
.sh-item-input::-webkit-outer-spin-button,
.sh-item-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sh-item--field:focus-within { border-color: var(--ink); }

/* play: the only filled control */
.sh-item--play {
  width: 44px; padding: 0; justify-content: center;
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}
.sh-item--play:hover { border-color: var(--ink); }
.sh-item--play svg { width: 14px; height: 14px; }
.sh-item--play .sh-stop-ico { display: none; }
.sh-item--play.is-playing .sh-play-ico { display: none; }
.sh-item--play.is-playing .sh-stop-ico { display: block; }

/* icon toggles: square, same box, state shown by fill */
.sh-item--icon { width: 44px; padding: 0; justify-content: center; }
.sh-item--icon svg { width: 17px; height: 17px; color: var(--ink-dim); }
.sh-item--icon[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); }
.sh-item--icon[aria-pressed="true"] svg { color: var(--bg); }
.sh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* toggles: pressed state inverts inside the same box */
.sh-item--toggle[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}
.sh-item--toggle[aria-pressed="true"] .sh-item-label { color: var(--bg); opacity: .55; }
.sh-item--toggle[aria-pressed="true"] .sh-item-value { color: var(--bg); }

/* actions on the right: same box, stronger edge */
.sh-item--action { border-color: var(--line-bright); font-weight: 600; letter-spacing: .02em; }
.sh-item--action:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Generate | Demo — two actions, one box, so the row keeps its shape. */
.sh-segment { padding: 0; gap: 0; overflow: hidden; }
.sh-segment:hover { background: transparent; color: var(--ink); }
.sh-segment-btn {
  height: 100%; border: 0; background: transparent; color: inherit; cursor: pointer;
  padding: 0 11px; font: 600 12.5px/1 var(--font); letter-spacing: .02em;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sh-segment-btn:hover { background: var(--ink); color: var(--bg); }
.sh-segment-div { width: 1px; height: 100%; background: var(--line); flex: 0 0 1px; }
.sh-item--action::-webkit-details-marker { display: none; }

.sh-item--sm { height: 32px; padding: 0 10px; gap: 6px; font: 600 12px/1 var(--font); border-radius: 8px; }
.sh-item--sm .sh-item-select { font-size: 12px; max-width: 96px; }
.sh-item--sm .sh-item-label { font-size: 9px; }
.sh-export { position: relative; }
.sh-export summary { list-style: none; }
.sh-export-panel {
  position: absolute; right: 0; top: 40px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 128px;
}
.sh-export-opt {
  border: 0; background: transparent; color: var(--ink-dim); text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: 7px; font: 600 12px/1 var(--font); display: flex; align-items: center; gap: 8px;
}
.sh-export-opt:hover { background: var(--fill); color: var(--ink); }
.sh-export-spin { display: none; width: 10px; height: 10px; border: 1.5px solid var(--line-bright); border-top-color: var(--ink); border-radius: 50%; animation: sh-spin .8s linear infinite; }
.sh-export-opt.is-busy .sh-export-spin { display: inline-block; }
@keyframes sh-spin { to { transform: rotate(360deg); } }

.sh-toast {
  position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 10px);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px;
  font: 500 12px/1.3 var(--font); opacity: 0; pointer-events: none; transition: all .2s var(--ease); z-index: 40;
}
.sh-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Narrow: shrink the track pill and the selects before anything scrolls away. */
/* Narrow: labels drop out first, the row itself never breaks. */
@media (max-width: 1040px) {
  .sh-bar { gap: 6px; padding: 0 12px; }
  .sh-item { padding: 0 10px; gap: 6px; }
  .sh-item-select { max-width: 112px; }
}
@media (max-width: 1120px) {
  /* Field labels go; toggle labels stay, or "Off" would mean nothing. */
  .sh-item--field .sh-item-label { display: none; }
  .sh-bar { gap: 4px; padding: 0 8px; }
  .sh-item { padding: 0 8px; gap: 5px; }
  .sh-item-select { max-width: 78px; font-size: 12.5px; }
  .sh-item--toggle .sh-item-label { font-size: 9px; }
  .sh-bar { overflow-x: auto; scrollbar-width: none; }
  .sh-bar::-webkit-scrollbar { display: none; }
  .sh-bar > * { flex: 0 0 auto; }
  .sh-top { grid-template-columns: auto 1fr auto; }
}
