/* Strumming view. Every rule is scoped to .view-strum so it can't leak into the other views. */
.view-strum {
  --bg: #0f0e15;
  --panel: #18161f;
  --panel-2: #221f2b;
  --line: #2c2838;
  --text: #f3f1f7;
  --muted: #918ba3;
  --accent: #a78bfa;
  --down: #a78bfa;
  --up: #2dd4bf;
  --mute: #fbbf24;
  --stop: #f87171;
  --radius: 18px;
}
.view-strum, .view-strum * { box-sizing: border-box; }
.view-strum h1, .view-strum h2, .view-strum h3, .view-strum p, .view-strum ol { margin: 0; padding: 0; }
.view-strum {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
  -webkit-font-smoothing: antialiased;
}
.view-strum header, .view-strum main { width: 100%; max-width: 960px; }
.view-strum header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.view-strum header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.view-strum .stat { text-align: right; }
.view-strum .stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.view-strum .stat .value { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; }
.view-strum main { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Pattern card ---------- */
.view-strum .st-card { background: var(--panel); border-radius: 28px; padding: 24px; }
.view-strum .st-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.view-strum .st-name { font-size: clamp(1.4rem, 3.5vw, 2rem); font-weight: 700; letter-spacing: -0.01em; }
.view-strum .st-meta { color: var(--muted); margin-top: 4px; font-size: 0.95rem; }
.view-strum .st-chords { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; }
.view-strum .st-chords li {
  min-width: 48px; padding: 6px 12px; text-align: center;
  background: var(--panel-2); border: 2px solid transparent; border-radius: 10px;
  font-size: 1.15rem; font-weight: 700; color: var(--muted);
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.view-strum .st-chords li.next { border-color: var(--line); color: var(--text); }
.view-strum .st-chords li.on { background: var(--accent); color: #150f24; transition: none; }

/* The grid: one box per beat, one cell per step inside it */
.view-strum .st-grid {
  display: grid;
  grid-template-columns: repeat(var(--beats, 4), minmax(0, 1fr));
  gap: clamp(6px, 1.5vw, 14px);
  margin: 24px 0 14px;
}
.view-strum .st-beat {
  display: grid;
  grid-template-columns: repeat(var(--sub, 2), minmax(0, 1fr));
  gap: 2px;
  background: var(--panel-2);
  border-radius: 14px;
  padding: 6px;
}
.view-strum .st-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 2px 6px;
  border-radius: 10px;
  transition: background 0.3s ease-out;
}
.view-strum .st-sym { display: block; width: 100%; max-width: 64px; color: var(--down); transition: transform 0.2s ease-out, filter 0.3s ease-out; }
.view-strum .st-sym svg { display: block; width: 100%; height: auto; }
.view-strum .st-step.up .st-sym { color: var(--up); }
.view-strum .st-step.mute .st-sym { color: var(--mute); }
.view-strum .st-step.rest .st-sym { color: var(--muted); opacity: 0.35; }
.view-strum .st-step.rest path { stroke-dasharray: 0.1 12; }   /* dotted ghost arrow: the hand moves but misses */
.view-strum .st-num { font-size: 0.95rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.view-strum .st-step:first-child .st-num { color: var(--text); }

/* Playhead: the step being played now */
.view-strum .st-step.on { background: rgba(255, 255, 255, 0.09); transition: none; }
.view-strum .st-step.on .st-sym { transform: scale(1.14); filter: drop-shadow(0 0 14px currentColor); transition: none; }
.view-strum .st-step.rest.on .st-sym { opacity: 0.6; filter: none; }
.view-strum .st-step.on .st-num { color: var(--text); }
.view-strum .st-grid.counting .st-step { opacity: 0.4; }

.view-strum .st-progress { height: 4px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.view-strum .st-progress i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

.view-strum .st-status { min-height: 2.6rem; margin-top: 14px; font-size: 1.1rem; line-height: 2.6rem; font-weight: 600; color: var(--muted); }
.view-strum .st-status strong { color: var(--text); }
.view-strum .st-status .st-count-num { font-size: 2.2rem; color: var(--accent); margin-left: 8px; vertical-align: middle; }

.view-strum .st-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.view-strum .st-legend span { display: inline-flex; align-items: center; gap: 6px; }
.view-strum .st-legend svg { width: 12px; height: 16px; fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.view-strum .st-legend .down svg { stroke: var(--down); }
.view-strum .st-legend .up svg { stroke: var(--up); }
.view-strum .st-legend .mute svg { stroke: var(--mute); }
.view-strum .st-legend .rest svg { stroke: var(--muted); stroke-dasharray: 0.1 12; }

/* ---------- Buttons and inputs ---------- */
.view-strum button {
  font: inherit; color: var(--text);
  background: var(--panel-2);
  border: none; border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  touch-action: manipulation;   /* no double-tap-zoom delay on phones */
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .view-strum button:hover { background: #2d2939; } }
.view-strum button:active { transform: scale(0.96); }
.view-strum button:focus-visible, .view-strum select:focus-visible { outline: 2px solid var(--up); outline-offset: 2px; }
.view-strum input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 180px; height: 6px; border-radius: 3px;
  background: var(--panel-2); outline: none;
}
.view-strum input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.view-strum input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: var(--accent); cursor: pointer;
}
.view-strum input[type=range]:focus-visible { outline: 2px solid var(--up); outline-offset: 6px; }
.view-strum select {
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}

/* On/off pills: count-in and the backing layers */
.view-strum .st-toggle { padding: 10px 16px; font-weight: 600; color: var(--muted); border: 2px solid var(--line); background: transparent; }
.view-strum .st-toggle[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: rgba(167, 139, 250, 0.14); }

/* ---------- Transport bar ---------- */
.view-strum .st-controls {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
}
.view-strum .group { display: flex; align-items: center; gap: 12px; }
.view-strum .group-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 4px; }
.view-strum .bpm-value { font-size: 2.4rem; font-weight: 700; min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }
.view-strum .bpm-unit { color: var(--muted); font-size: 0.9rem; margin-left: -6px; }
.view-strum .step { width: 44px; height: 44px; font-size: 1.4rem; font-weight: 600; }
.view-strum .start {
  padding: 16px 44px; min-width: 170px;
  font-size: 1.3rem; font-weight: 700;
  background: var(--accent); color: #150f24;
}
.view-strum .start.running { background: var(--stop); color: #200a0a; }
@media (hover: hover) {
  .view-strum .start:hover { background: #c4b5fd; }
  .view-strum .start.running:hover { background: #fca5a5; }
}

/* ---------- Library and backing panels ---------- */
.view-strum .st-panels { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.view-strum .st-panel { background: var(--panel); border-radius: var(--radius); padding: 20px; }
.view-strum .st-panel-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.view-strum .st-group { font-size: 0.95rem; font-weight: 700; margin: 14px 0 8px; }
.view-strum .st-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.view-strum .st-pat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 12px; text-align: left;
  border: 2px solid transparent;
}
.view-strum .st-pat-name { font-weight: 600; }
.view-strum .st-pat-steps { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9rem; color: var(--accent); letter-spacing: 0.08em; }
.view-strum .st-pat-steps span { white-space: nowrap; }
.view-strum .st-pat-meta { font-size: 0.75rem; color: var(--muted); }
.view-strum .st-pat.active { border-color: var(--accent); background: rgba(167, 139, 250, 0.12); }
.view-strum .st-pat.queued { border-color: var(--accent); border-style: dashed; }

.view-strum .st-field { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 18px; }
.view-strum .st-layers { display: flex; flex-direction: column; gap: 12px; }
.view-strum .st-layer { display: flex; align-items: center; gap: 14px; }
.view-strum .st-layer .st-toggle { flex: none; width: 136px; }
.view-strum .st-layer input[type=range] { flex: 1; width: auto; }
.view-strum .st-note { margin-top: 16px; font-size: 0.85rem; line-height: 1.45; color: var(--muted); }

.view-strum .hint { color: var(--muted); font-size: 0.8rem; margin-top: 16px; text-align: center; }
.view-strum kbd { background: var(--panel-2); border-radius: 5px; padding: 1px 6px; font-family: inherit; }

/* ---------- Narrower screens ---------- */
@media (max-width: 820px) {
  .view-strum .st-panels { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .view-strum { padding: 12px 12px 20px; }
  .view-strum header { margin-bottom: 8px; }
  .view-strum header h1 { font-size: 0.85rem; }
  .view-strum .stat .value { font-size: 1.6rem; }
  .view-strum main { gap: 14px; }
  .view-strum .st-card { padding: 16px 12px; border-radius: 20px; }
  .view-strum .st-grid { margin: 16px 0 10px; }
  /* sixteenths wrap to two beats per row so every cell stays readable */
  .view-strum .st-grid.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-strum .st-beat { padding: 4px; border-radius: 12px; }
  .view-strum .st-step { padding: 8px 0 4px; gap: 4px; }
  .view-strum .st-num { font-size: 0.8rem; }
  .view-strum .st-status { font-size: 1rem; line-height: 1.4; min-height: 2.8rem; margin-top: 10px; }

  /* controls stack: each group takes a full row, tap targets are at least 44px */
  .view-strum .st-controls { padding: 16px; gap: 16px; }
  .view-strum .st-controls .group { width: 100%; justify-content: center; flex-wrap: wrap; row-gap: 12px; }
  .view-strum .step { width: 48px; height: 48px; }
  .view-strum .st-controls input[type=range] { flex: 1 1 100%; width: auto; height: 8px; }
  .view-strum input[type=range]::-webkit-slider-thumb { width: 28px; height: 28px; }
  .view-strum input[type=range]::-moz-range-thumb { width: 28px; height: 28px; }
  .view-strum .st-toggle { min-height: 48px; }
  .view-strum .start { flex: 1; min-width: 0; padding: 16px; }
  .view-strum .st-panel { padding: 16px; }
  .view-strum .st-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .view-strum .st-layer .st-toggle { width: 124px; padding: 10px 8px; white-space: nowrap; }
}

/* Touchscreens have no keyboard shortcuts to hint at */
@media (hover: none) and (pointer: coarse) {
  .view-strum .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view-strum .st-step.on .st-sym { transform: none; }
  .view-strum button:active { transform: none; }
}
