/* MarinovOS — Studio app styles (owner: studio worker)
   Instrument surface: precise silver/aluminium chassis, brushed light-grey gradient,
   barely-visible diagonal brushed texture, dark ink labels, one cobalt (--blue-700)
   indicator per knob. The keybed is the dominant object — this reads as an
   instrument, not a settings form. */

.app-studio{
  --studio-metal-1:#f2f4f8; --studio-metal-2:#e3e7ee;
  height:100%;
  display:flex;
  flex-direction:column;
  gap:6px;
  box-sizing:border-box;
  padding:10px var(--space-5) var(--space-3);
  font-size:15px; line-height:1.55; color:var(--ink);
  min-height:0;
}
/* NOTE: theme state lands on `body[data-theme]`, not `:root`; these
   overrides intentionally key off the bare attribute (matches whichever
   element actually carries it) rather than `:root[...]`, or they silently
   never apply. */
[data-theme="dark"] .app-studio{
  --studio-metal-1:#232a40; --studio-metal-2:#1a2036;
}

.app-studio h2{font-size:22px;line-height:1.15;letter-spacing:-.01em;margin:0}
.studio-view[data-view="notes"] h2{font-size:28px;letter-spacing:-.02em;margin-bottom:var(--space-4)}
.app-studio h3{font-size:18px;line-height:1.3}

/* ---------- head (44px) ---------- */
.studio-head{display:flex;justify-content:space-between;align-items:center;gap:var(--space-4);flex:none;height:44px}
.studio-caption{color:var(--ink-3);font-size:13px;margin:2px 0 0}
.studio-head-actions{display:flex;align-items:center;gap:var(--space-3);flex:none}
.sound-status{font-size:13px;font-weight:600;color:var(--ink-2);white-space:nowrap}

/* ---------- intro row: visible last-note / status readout. Sits above the
   chassis, not inside it, so it survives whatever height the chassis itself
   ends up with. The "Play C – E – G" first-gesture control lives in the
   header action row (see below), not here. ---------- */
.studio-intro{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);flex:none;min-height:20px;margin-bottom:4px}
.studio-status{flex:1;min-width:0;margin:0;font-size:12px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* "Play C – E – G" first-gesture control: the most inviting control before
   sound is enabled (primary/cobalt, toggled from studio.js), a quiet
   secondary once sound is already on — .btn/.btn.primary come from
   shell.css, this only adds the pressed feedback while the phrase plays. */
.studio-head-actions [data-act="hint"].is-playing{transform:translateY(1px);box-shadow:none}

/* ---------- instrument view fills the rest ---------- */
.studio-view[data-view="instrument"]{flex:1;min-height:0;display:flex;flex-direction:column}

/* ---------- chassis (the metal surface) ---------- */
.chassis{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:6px;
  background-image:
    repeating-linear-gradient(128deg, rgba(16,24,40,.035) 0 1px, transparent 1px 9px),
    linear-gradient(180deg,var(--studio-metal-1),var(--studio-metal-2));
  border:1px solid var(--line-2);
  border-radius:var(--radius-xl);
  padding:10px var(--space-4);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.9), inset 0 -1px 0 rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}
[data-theme="dark"] .chassis{
  background-image:
    repeating-linear-gradient(128deg, rgba(255,255,255,.045) 0 1px, transparent 1px 9px),
    linear-gradient(180deg,var(--studio-metal-1),var(--studio-metal-2));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.06), inset 0 -1px 0 rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.3);
}
.chassis:focus{outline:none}

/* ---------- top band: knob | display | knob (nominally 96px, but content-
   sized so it never forces a scroll on a shorter clamped window) ---------- */
.chassis-top{
  order:0;
  flex:none;
  display:flex;
  align-items:center;
  gap:var(--space-4);
  border-bottom:1px solid rgba(16,24,40,.08);
  padding-bottom:var(--space-2);
}
[data-theme="dark"] .chassis-top{border-bottom-color:rgba(255,255,255,.08)}

.display{
  flex:1;
  min-width:0;
  height:64px; /* fixed: a canvas child resolving height:100% needs a
                  definite parent height, or it falls back to its 150px
                  intrinsic default and balloons the whole top band */
  border-radius:var(--radius-md);
  background:linear-gradient(180deg,#161c30,#101524);
  box-shadow:inset 0 2px 6px rgba(0,0,0,.35);
  overflow:hidden;
}
.scope{width:100%;height:100%;display:block}

/* ---------- knobs (rotary dial, driven by a hidden real range for a11y,
   plus ONE visible editable text readout — never a second numeric box) ---------- */
.knob-wrap{display:flex;flex-direction:column;align-items:center;gap:4px;width:80px;flex:none}
.ctrl-label{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2);font-weight:600}
.knob{
  width:56px;height:56px;border-radius:50%;position:relative;touch-action:none;cursor:ns-resize;flex:none;
  background:radial-gradient(circle at 34% 28%,#ffffff,#dfe2e7 62%,#c7cad1 100%);
  border:1px solid rgba(16,24,40,.14);
  box-shadow:0 2px 4px rgba(16,24,40,.2), inset 0 1px 1px #fff;
}
[data-theme="dark"] .knob{
  background:radial-gradient(circle at 34% 28%,#3a4262,#242a44 62%,#171c30 100%);
  box-shadow:0 2px 4px rgba(0,0,0,.4), inset 0 1px 1px rgba(255,255,255,.08);
}
.knob-face{position:absolute;inset:5px;border-radius:50%;transform:rotate(var(--rot,-132deg));transition:transform var(--dur-fast) var(--ease-out)}
.knob.is-dragging .knob-face{transition:none}
.knob-tick{position:absolute;top:2px;left:50%;width:3px;height:10px;margin-left:-1.5px;border-radius:2px;background:var(--blue-700)}
.knob:has(+ .sr:focus-visible){outline:3px solid var(--blue-500);outline-offset:3px}
.knob-readout{
  width:64px;height:22px;font-size:12px;text-align:center;font-variant-numeric:tabular-nums;
  border:1px solid var(--line-2);border-radius:var(--radius-sm);background:var(--paper);color:var(--ink);
  padding:0;
}
.knob-readout:focus-visible{outline:3px solid var(--blue-500);outline-offset:1px}
/* One-line explanation of what moving the control actually changes. */
.ctrl-caption{font-size:10px;line-height:1.2;color:var(--ink-3);text-align:center;white-space:nowrap}

/* ---------- chip row (nominally 36px): WAVE + OCT segmented controls,
   each with its own one-line "what this changes" caption underneath ---------- */
.chassis-chips{order:1;flex:none;display:flex;align-items:flex-start;gap:var(--space-6)}
.chip-group{display:flex;flex-direction:column;align-items:flex-start;gap:2px}
.chip-row{display:flex;align-items:center;gap:var(--space-2)}
.chip-label{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2);font-weight:600;flex:none}
.chassis-chips .seg{padding:2px}
.chassis-chips .seg>button{height:28px;padding:0 10px;font-size:13px}
.octave-range{font-size:11px;color:var(--ink-3);font-variant-numeric:tabular-nums}
.chip-group .ctrl-caption{text-align:left}

/* ---------- keybed (dominant object — flexes to fill whatever height the
   window actually grants; 200px is the target, not a hard requirement, so
   the instrument never has to scroll to show it) ---------- */
.chassis-keybed{order:2;flex:1 1 200px;min-height:150px}
.keys{position:relative;height:100%}
.keys-white{display:flex;height:100%;gap:3px}
.keys-black{position:absolute;inset:0;pointer-events:none}

.key{
  border:1px solid var(--line-2);
  color:var(--ink-2);
  transition:transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.key-white{
  flex:1;
  min-width:0;
  border-radius:0 0 8px 8px;
  background:var(--paper);
  box-shadow:inset 0 -2px 0 var(--line-2), 0 4px 8px rgba(16,24,40,.08);
  display:flex;align-items:flex-end;justify-content:center;padding-bottom:10px;
}
[data-theme="dark"] .key-white{background:#2a3150;box-shadow:inset 0 -2px 0 rgba(0,0,0,.4), 0 4px 8px rgba(0,0,0,.3)}
.key-note{font-size:12px;font-weight:600;color:var(--ink-3)}
[data-theme="dark"] .key-note{color:var(--ink-2)} /* the dark key-white surface (#2a3150) is lighter than --paper, so --ink-3 alone falls under 4.5:1 there */
.key-white.is-down{transform:translateY(2px);box-shadow:inset 0 -1px 0 var(--line-2);background:var(--blue-100)}
[data-theme="dark"] .key-white.is-down{background:rgba(143,181,255,.22)}
.key-white.is-down .key-note{color:var(--blue-700)}
[data-theme="dark"] .key-white.is-down .key-note{color:var(--blue-300)}

.key-black{
  position:absolute;top:0;height:60%;
  border-radius:0 0 5px 5px;
  background:#1b2233;
  border-color:#0d1220;
  box-shadow:0 3px 6px rgba(0,0,0,.35);
  pointer-events:auto;
  z-index:2;
}
.key-black.is-down{transform:translateY(2px);background:var(--blue-700);box-shadow:0 1px 2px rgba(0,0,0,.35)}

.key:focus-visible{outline:3px solid var(--blue-500);outline-offset:2px;z-index:3}

/* ---------- foot: physical-key footnote (once, not per-key) + actions ---------- */
.chassis-foot{order:3;flex:none;display:flex;justify-content:space-between;align-items:center;gap:var(--space-3);flex-wrap:wrap}
.key-hint{font-size:12px;color:var(--ink-3);margin:0}
.chassis-foot-actions{display:flex;gap:var(--space-2)}

/* ---------- About this instrument ---------- */
.studio-view[data-view="notes"]{max-width:62ch;overflow:auto}
.back-btn{margin-bottom:var(--space-4)}
.studio-view[data-view="notes"] .note{margin-bottom:var(--space-3)}

/* ---------- mobile: display strip -> pad grid -> chip row -> actions ---------- */
@media (max-width:760px){
  /* The sheet scrolls; the instrument sizes to its contents instead of
     stretching an empty metal panel to fill the phone (strict review §7). */
  .app-studio{padding:var(--space-4);height:auto;min-height:100%}
  .studio-view[data-view="instrument"]{flex:none}
  .chassis{flex:none}
  .studio-head{height:auto;flex-wrap:wrap;align-items:flex-start}
  .studio-head-text{flex:1 1 100%;min-width:0}
  /* Action row: a wrapping row that is never wider than the sheet. The
     desktop rule's flex:none sized this to its content (401px at 390px wide)
     and clipped "Mute Studio" (strict review P1). */
  .studio-head-actions{flex:1 1 100%;width:100%;max-width:100%;min-width:0;align-self:stretch;flex-wrap:wrap;gap:8px}
  .studio-head-actions .btn{flex:1 1 auto;min-width:0;max-width:100%;min-height:44px;padding:0 14px}
  .studio-head-actions .sound-status{flex:1 1 auto;min-height:44px;display:inline-flex;align-items:center}
  .studio-head-actions [data-act="hint"]{min-height:44px} /* stays ≥44px whether primary or secondary */

  .studio-intro{flex-wrap:wrap}

  .chassis{padding:var(--space-3);gap:var(--space-3)}
  .chassis-top{min-height:56px;padding-bottom:var(--space-2)}
  .display{height:40px}
  .knob-wrap{width:68px;gap:3px}
  .knob{width:44px;height:44px}
  .knob-readout{width:56px;height:26px;font-size:12px}
  .ctrl-label{font-size:10px}
  .ctrl-caption{display:none} /* space is precious on the pad layout; the direct-touch feedback carries this on phone */

  .chassis-chips{order:3;flex-wrap:wrap;row-gap:var(--space-2);column-gap:var(--space-4)}
  .chassis-chips .seg>button{min-height:44px}
  .octave-range{display:none}

  .chassis-keybed{order:2;flex:none;min-height:156px}
  .keys-white{gap:4px}
  .keys-black{display:none}
  .key-white{border-radius:12px;box-shadow:0 1px 2px rgba(16,24,40,.1), 0 3px 6px rgba(16,24,40,.08);align-items:center;padding-bottom:0}
  .key-note{font-size:15px}

  .keys{display:grid;grid-template-columns:repeat(4,1fr);grid-template-rows:repeat(2,minmax(72px,1fr));gap:8px}
  .keys-white{display:contents}

  .chassis-foot{order:4}
  .key-hint{display:none}
  .app-studio .btn.quiet{min-height:44px}
}
