/* ===== KOSHERMUSIK STUDIO VIEW (DAW-style layers) ===== */
.km-studio {
  --ks-accent: var(--kp-red, #ff2d2d);
  --ks-bg: #0b0b0f;
  --ks-panel: #14141a;
  --ks-line: rgba(255, 255, 255, 0.09);
  --ks-dim: rgba(255, 255, 255, 0.55);
  position: fixed; inset: 0; z-index: 2300;
  display: flex; flex-direction: column;
  background:
    radial-gradient(80% 50% at 50% -10%, rgba(255, 255, 255, 0.05), transparent 70%),
    var(--ks-bg);
  color: #fff;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  transform: translateY(100%); visibility: hidden;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.5s;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.km-studio.is-open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
body.km-studio-open { overflow: hidden; }
body.km-studio-open #kmNowPlayingMini { opacity: 0; pointer-events: none; }

/* transport / title bar */
.ks-top {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--ks-panel); border-bottom: 1px solid var(--ks-line);
}
.ks-close, .ks-tbtn {
  width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.07); color: #fff; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; transition: background 0.2s, transform 0.15s;
}
.ks-close:hover, .ks-tbtn:hover { background: rgba(255, 255, 255, 0.15); }
.ks-close:active, .ks-tbtn:active { transform: scale(0.9); }
.ks-close svg, .ks-tbtn svg { width: 22px; height: 22px; pointer-events: none; }
.ks-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ks-rec { width: 11px; height: 11px; border-radius: 50%; background: #5a2020; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); transition: background 0.2s; }
.km-studio.is-playing .ks-rec { background: #ff3b3b; animation: ksRec 1.2s ease-in-out infinite; }
@keyframes ksRec { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.6); } 50% { box-shadow: 0 0 12px 3px rgba(255, 59, 59, 0.5); } }
.ks-title-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ks-title-text b { font-size: 0.98rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-title-text small { font-size: 0.68rem; color: var(--ks-dim); letter-spacing: 0.04em; }
.ks-clock {
  font: 700 1.1rem 'Space Grotesk', ui-monospace, monospace; font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
  padding: 8px 12px; border-radius: 10px; background: #050507; border: 1px solid var(--ks-line); color: #ffd9a0;
  text-shadow: 0 0 10px rgba(255, 190, 90, 0.45); min-width: 92px; text-align: center;
}
.ks-transport { display: flex; gap: 6px; align-items: center; }
.ks-tplay { background: #fff; color: #0b0b0f; width: 52px; height: 52px; }
.ks-tplay:hover { background: #fff; }
.ks-tplay .ks-i-pause { display: none; }
.km-studio.is-playing .ks-tplay .ks-i-pause { display: block; }
.km-studio.is-playing .ks-tplay .ks-i-play { display: none; }

.ks-banner {
  margin: 8px 12px 0; padding: 10px 14px; border-radius: 12px; font-size: 0.82rem; line-height: 1.4;
  background: rgba(255, 190, 90, 0.1); border: 1px solid rgba(255, 190, 90, 0.35); color: #ffe2b0;
}
.ks-banner[hidden] { display: none; }
.ks-banner button {
  margin-left: 8px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 99px; font: 700 0.82rem inherit;
  background: #ffd9a0; color: #1a1000; cursor: pointer; touch-action: manipulation;
}

/* body: heads column + timeline */
.ks-body {
  --ks-lane-h: 60px; --ks-gap: 3px; --ks-ruler: 26px;
  flex: 1; min-height: 0; display: flex; padding: 10px 12px 6px; gap: 8px; overflow: auto;
}
.ks-heads { flex: 0 0 168px; padding-top: var(--ks-ruler); display: flex; flex-direction: column; gap: var(--ks-gap); }
.ks-timeline { flex: 1; min-width: 0; }
.ks-timeline canvas { display: block; border-radius: 8px; cursor: ew-resize; touch-action: none; outline: none; }
.ks-timeline canvas:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }

.ks-head {
  position: relative; height: var(--ks-lane-h); display: flex; align-items: center; gap: 8px; padding: 0 8px 4px 10px;
  border-radius: 8px; background: var(--ks-panel); border: 1px solid var(--ks-line); overflow: hidden;
  transition: opacity 0.2s;
}
.ks-head.is-muted { opacity: 0.45; }
.ks-chip { width: 4px; align-self: stretch; margin: 6px 0; border-radius: 3px; background: var(--lane); flex-shrink: 0; box-shadow: 0 0 10px var(--lane); }
.ks-hname { flex: 1; min-width: 0; font-size: 0.78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-hname .ks-short { display: none; }
.ks-ms { display: flex; gap: 4px; }
.ks-btn {
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px; background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.75);
  font: 800 0.72rem 'Space Grotesk', sans-serif; cursor: pointer; touch-action: manipulation; position: relative;
  -webkit-tap-highlight-color: transparent; transition: background 0.15s, color 0.15s, transform 0.12s;
}
.ks-btn::after { content: ''; position: absolute; inset: -5px; }   /* bigger hit area than the visible 34px */
.ks-btn:active { transform: scale(0.9); }
.ks-m.on { background: #ff9f1c; border-color: #ff9f1c; color: #1a0f00; }
.ks-s.on { background: #ffd93d; border-color: #ffd93d; color: #1a1500; }
.ks-meter { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.06); }
.ks-meter i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: 0 50%; background: linear-gradient(90deg, var(--lane), #fff); will-change: transform; }
.ks-head.is-master { background: linear-gradient(135deg, rgba(196, 181, 253, 0.12), var(--ks-panel)); }
.ks-head.is-master .ks-hname { letter-spacing: 0.12em; text-transform: uppercase; }

.ks-foot {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 6px 14px 10px;
  font-size: 0.72rem; color: var(--ks-dim);
}
.ks-hint { white-space: nowrap; }

/* phones */
@media (max-width: 640px) {
  .ks-body { padding: 8px 8px 4px; gap: 6px; }
  .ks-heads { flex-basis: 104px; }
  .ks-hname .ks-long { display: none; }
  .ks-hname .ks-short { display: inline; }
  .ks-head { padding: 0 6px 4px 8px; gap: 6px; }
  .ks-ms { gap: 3px; }
  .ks-btn { width: 30px; height: 30px; }
  .ks-top { grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-areas: 'c t k' 'x x x'; gap: 8px; padding: 8px; }
  .ks-top .ks-transport { grid-column: 1 / -1; justify-content: center; }
  .ks-clock { min-width: 0; font-size: 0.95rem; padding: 6px 10px; }
  .ks-hint { display: none; }
  .ks-top .ks-tbtn { width: 44px; height: 44px; }
  .ks-top .ks-tplay { width: 50px; height: 50px; }
}
@media (max-height: 520px) {
  .ks-top { padding: 4px 10px; }
  .ks-top .ks-transport { grid-column: auto; }
  .ks-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .km-studio { transition: none; }
  .km-studio.is-playing .ks-rec { animation: none; }
}

/* the site's global header/footer styles must not leak into the studio chrome */
.km-studio .ks-foot { display: flex; position: static; width: auto; max-width: none; margin: 0; background: none; border: 0; text-align: left; }
.km-studio .ks-top { position: static; width: auto; max-width: none; margin: 0; backdrop-filter: none; }
