/* melody experiment styles (owned by the melody builder) */
.mel-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 100%; }
.mel-scroll { height: 14px; margin: 0; accent-color: var(--accent); cursor: ew-resize; max-width: 100%; }
/* strips under the canvas (M.view.addLane): the view subtracts their height from the canvas */
.mel-wrap > .mel-lane { flex: none; }
/* the load hint sits under the chord header, over the map, so it never covers lanes under the canvas (drums) or the dock */
.vh-stage:has(> .vh-exp[data-exp="melody"]) > .vh-hint { bottom: auto; top: 52px; }

/* layer chips in the dock */
.mel-layers .ic { gap: 6px; }
.mel-chip {
  width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  background: var(--c); opacity: 0.35; transition: opacity var(--ease), transform var(--ease), border-color var(--ease);
}
.mel-chip:hover { opacity: 0.75; }
.mel-chip.on { opacity: 1; transform: scale(1.2); border-color: #fff; }
.mel-chip.muted { background: transparent; border: 2px dashed var(--c); }
.mel-chip.mel-add {
  background: transparent; border: 1px dashed var(--muted); color: var(--muted); opacity: 0.9; font-size: 12px; line-height: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.mel-chip.mel-add:hover { color: var(--text); border-color: var(--text); }

/* drawer rows */
.mel-lbl { font-size: 12px; color: #aab3c8; min-width: 42px; align-self: center; }
.mel-backsel { width: 100%; margin: 4px 0 2px; }
.mel-tone-head b { color: var(--text); font-weight: 600; }
.mel-tone-note { border-left: 2px solid var(--line); padding-left: 8px; }
.vh-ctl input[type="range"]:disabled { opacity: 0.35; }
.mel-seg .vh-btn { min-width: 44px; }
.vh-btn:disabled { opacity: 0.4; cursor: default; }

/* chord picker popover */
.mel-pop {
  position: absolute; z-index: 8; width: min(400px, calc(100% - 16px)); overflow-y: auto;
  background: rgba(20, 24, 36, 0.97); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 10px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6); animation: mel-in 160ms ease;
}
@keyframes mel-in { from { opacity: 0; transform: translateY(-4px); } }
.mel-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.mel-pop-head .vh-icon-btn { width: 28px; height: 28px; font-size: 13px; }
.mel-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin: 8px 0 5px; }
.mel-sub span { text-transform: none; letter-spacing: 0; }
.mel-quick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mel-quick button {
  display: flex; flex-direction: column; align-items: center; padding: 6px 2px 4px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); min-width: 0;
  transition: border-color var(--ease), background var(--ease);
}
.mel-quick b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; max-width: 100%; }
.mel-quick i { font-style: normal; font-size: 10px; color: var(--muted); }
.mel-quick button:hover, .mel-grid button:hover { border-color: var(--accent); }
.mel-grid { display: grid; grid-template-columns: 26px repeat(9, minmax(0, 1fr)); gap: 2px; font-size: 10.5px; }
.mel-grid .qh { text-align: center; color: var(--muted); font-size: 10px; padding-bottom: 2px; }
.mel-grid .rh { color: #aab3c8; align-self: center; font-weight: 600; }
.mel-grid button {
  padding: 3px 0; border-radius: 5px; border: 1px solid transparent; background: rgba(255, 255, 255, 0.04); color: #aab3c8;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 10.5px;
}
.mel-grid button.in { background: rgba(0, 191, 220, 0.16); color: #dff; }
.mel-pop .cur { border-color: var(--accent) !important; background: rgba(111, 163, 255, 0.28) !important; color: #fff !important; }
.mel-none { margin-top: 8px; width: 100%; }

/* floating panels above the dock: layer menu + mixer */
.mel-float {
  position: absolute; z-index: 8; overflow-y: auto; background: rgba(20, 24, 36, 0.97); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px 10px; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6); animation: mel-in 160ms ease;
}
.mel-layermenu { width: min(300px, calc(100% - 16px)); }
.mel-layermenu .mel-pop-head { gap: 8px; }
.mel-name {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; color: var(--text);
}
.mel-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.mel-danger { color: #ffb4b4; }
.mel-danger:hover:not(:disabled) { border-color: #ff6b6b; }
.mel-mixer .mel-mixrow:first-child { border-top: 0; }
.mel-mixrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(255, 255, 255, 0.04); }
.mel-mixrow.quiet .mel-mixname { color: var(--muted); text-decoration: line-through; }
.mel-mixrow.mel-mix-back { border-top-color: var(--line); margin-top: 4px; }
.mel-mixname { width: 104px; flex: none; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mel-mixrow input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--accent); }
.mel-ms {
  width: 26px; height: 24px; flex: none; padding: 0; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
}
.mel-ms[aria-pressed="true"] { background: rgba(255, 201, 60, 0.2); border-color: #ffc93c; color: #fff; }
.mel-ms[title^="Solo"][aria-pressed="true"] { background: rgba(111, 163, 255, 0.25); border-color: var(--accent); }

/* toast + share fallback */
.mel-toast {
  position: absolute; left: 50%; top: 18px; transform: translate(-50%, -6px); z-index: 12; pointer-events: none;
  max-width: calc(100% - 32px); background: rgba(20, 24, 36, 0.95); border: 1px solid var(--accent); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; opacity: 0; transition: opacity 200ms ease, transform 200ms ease;
}
.mel-toast.on { opacity: 1; transform: translate(-50%, 0); }
.mel-sharebox {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 9; width: min(520px, calc(100% - 24px));
  display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); font-size: 12px; color: var(--muted);
}
.mel-sharebox input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px;
  font: 12px var(--mono); color: var(--text);
}
@media (max-width: 460px) {
  .mel-sharebox span { display: none; }
  .mel-quick b { font-size: 12px; }
  .mel-grid { grid-template-columns: 22px repeat(9, minmax(0, 1fr)); font-size: 9.5px; }
  .mel-grid button { font-size: 9px; }
}
@media (max-width: 460px) {
  .vh-exp[data-exp="melody"] .vh-dock { gap: 2px; padding: 4px; }
  .vh-exp[data-exp="melody"] .vh-dock-btn { min-width: 44px; padding: 4px 3px; }
  .vh-exp[data-exp="melody"] .vh-dock-btn .lb { max-width: 58px; }
  .vh-exp[data-exp="melody"] .mel-layers .ic { gap: 4px; }
  .mel-chip { width: 14px; height: 14px; }
  .vh-exp[data-exp="melody"] .mel-layers .lb { display: none; }
  .vh-exp[data-exp="melody"] .mel-dock-share { display: none; }
  .mel-mixname { width: 76px; }
}

/* toast: an optional action button (Undo / Cancel); sticky toasts wait for the user */
.mel-toast .a {
  margin-left: 10px; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--accent); background: rgba(111, 163, 255, 0.18);
  color: #fff; font-size: 12px; cursor: pointer; pointer-events: auto;
}
.mel-toast .a:hover { background: rgba(111, 163, 255, 0.35); }
.mel-toast:not(.on) .a { visibility: hidden; }
.mel-toast.sticky { border-color: #9ff; }
.vh-exp.mel-placing canvas { box-shadow: 0 0 0 2px rgba(159, 255, 255, 0.55), 0 10px 40px rgba(0, 0, 0, 0.45); }

/* dock Tool button + its pop-over */
.mel-toolbtn .lb::after { content: ' ▾'; color: var(--muted); }
.mel-toolpop { width: 190px; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.mel-toolpop button {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; font-size: 13px;
}
.mel-toolpop button:hover { background: var(--surface-2); }
.mel-toolpop button[aria-pressed="true"] { background: rgba(111, 163, 255, 0.16); border-color: rgba(111, 163, 255, 0.5); }
.mel-toolpop .i { font-size: 16px; text-align: center; }
.mel-toolpop kbd {
  min-width: 20px; padding: 0 5px; border: 1px solid #3a4157; border-bottom-width: 2px; border-radius: 5px; background: var(--bg);
  color: var(--muted); font: 11px/1.5 var(--mono); text-align: center;
}

/* hover readout: note · fit % near the pointer */
.mel-readout {
  position: absolute; z-index: 6; pointer-events: none; white-space: nowrap; padding: 3px 8px; border-radius: 7px;
  font: 600 12px/1.3 var(--mono); color: #fff; background: rgba(11, 13, 18, 0.86);
  border: 1px solid rgba(0, 191, 220, calc(0.25 + 0.65 * var(--fit, 0))); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.mel-readout.nochord { border-color: var(--line); color: #cfd5e6; }

/* Song tab: loop region line, Start here */
.mel-regrow { align-items: center; }
.mel-regtxt { flex: 1 1 180px; margin: 0; }
.mel-confirm { align-items: center; padding: 6px 8px; border: 1px solid #5a3a3a; border-radius: 8px; background: rgba(255, 107, 107, 0.06); }
.mel-confirm .vh-desc { flex: 1 1 100%; margin: 0; color: #e6c9c9; }

/* coach marks (tutorial) */
.mel-coach { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.mel-coach-ring {
  position: absolute; border: 2px solid #9ff; border-radius: 12px; box-shadow: 0 0 0 4px rgba(159, 255, 255, 0.14), 0 0 26px rgba(159, 255, 255, 0.28);
  animation: mel-pulse 1.8s ease-in-out infinite;
}
@keyframes mel-pulse { 50% { box-shadow: 0 0 0 7px rgba(159, 255, 255, 0.06), 0 0 30px rgba(159, 255, 255, 0.4); } }
.mel-coach-card {
  position: absolute; pointer-events: auto; width: max-content; max-width: 300px; padding: 10px 12px 10px; border-radius: 12px;
  background: #18203a; border: 1px solid #9ff; color: var(--text); font-size: 13.5px; line-height: 1.4;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6); animation: mel-in 200ms ease;
}
.mel-coach.final .mel-coach-card { max-width: 320px; }
.mel-coach.mel-coach-tabs { z-index: 11; }   /* step 5: above the Settings panel while its tab strip is highlighted */
.mel-coach-sub { display: block; margin-top: 5px; font-size: 12px; color: #b9c2d8; }
.mel-coach-n { font: 11px var(--mono); color: #9ff; margin-bottom: 2px; }
.mel-coach-txt b { color: #fff; }
.mel-coach-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.mel-coach-btns .vh-btn { padding: 4px 11px; font-size: 12.5px; }
.mel-coach-next { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; }
.mel-coach-next:hover { border-color: #fff; }
.mel-coach-confirm { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.mel-coach-confirm span { flex: 1 1 100%; font-size: 12px; color: #c9cfdf; }
.mel-coach-confirm .vh-btn { padding: 4px 10px; font-size: 12px; }
.mel-coach-arrow {
  position: absolute; width: 12px; height: 12px; background: #18203a; border: 1px solid #9ff; transform: rotate(45deg);
}
.mel-coach-arrow.above { bottom: -7px; margin-left: -6px; border-top: 0; border-left: 0; }
.mel-coach-arrow.below { top: -7px; margin-left: -6px; border-bottom: 0; border-right: 0; }
.mel-coach-arrow.left { right: -7px; margin-top: -6px; border-bottom: 0; border-left: 0; }
.mel-coach-arrow.right { left: -7px; margin-top: -6px; border-top: 0; border-right: 0; }
@media (prefers-reduced-motion: reduce) { .mel-coach-ring { animation: none; } }
