/* curasai-studio — shell layout on top of base.css design tokens. */

:root {
  --toolbar-h: 56px;
  --brand-grad: linear-gradient(100deg, #4ce3ff 0%, #8b5cf6 50%, #ff4cc0 100%);
  --w-left: 22%;
  --w-right: 33%;
}

html, body { height: 100%; margin: 0; }
body { overflow: hidden; }

/* The `hidden` attribute must win over our class-level `display` rules below
   (a class selector otherwise beats the UA `[hidden]{display:none}` rule, which
   would leave the sign-in panel and workbench both visible at once). */
[hidden] { display: none !important; }

/* Every button has rounded corners; the browser's default rectangular
   tap-highlight + focus outline clash with that. Kill them globally and give
   keyboard users a rounded focus ring instead. */
button { -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }
button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }

/* ---- Toolbar (fixed) ---- */
.studio-toolbar {
  position: fixed; inset: 0 0 auto 0; height: var(--toolbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; z-index: 50;
  background: rgba(7, 9, 26, 0.72); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--accent-soft);
}
.studio-brand {
  font-weight: 800; letter-spacing: 0.12em; font-size: 18px;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; user-select: none;
}

/* ---- Account button + menu ---- */
.studio-account { position: relative; }
.studio-user-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--accent-soft); background: var(--bg-1);
  color: var(--fg-1); cursor: pointer; padding: 0; display: grid; place-items: center;
}
.studio-user-btn:hover { border-color: var(--accent-glow); }
.studio-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: var(--fg-0); background-size: cover; background-position: center;
}
.studio-avatar.has-pic { color: transparent; }
.studio-menu {
  position: absolute; top: 46px; right: 0; min-width: 240px;
  background: var(--bg-2); border: 1px solid var(--accent-soft);
  border-radius: 12px; padding: 6px; box-shadow: 0 18px 50px rgba(0,0,0,0.5); z-index: 60;
}
.studio-menu__id { padding: 8px 12px; color: var(--fg-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-menu__item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--fg-0);
  font-size: 14px; cursor: pointer; text-align: left;
}
.studio-menu__item:hover { background: var(--accent-soft); }
.studio-menu__sep { height: 1px; margin: 6px 4px; background: var(--accent-soft); }
.studio-menu__icon { width: 18px; height: 18px; object-fit: contain; }
.studio-menu__icon--ms {
  background:
    linear-gradient(90deg, #f25022 50%, #7fba00 50%) top / 100% 50% no-repeat,
    linear-gradient(90deg, #00a4ef 50%, #ffb900 50%) bottom / 100% 50% no-repeat;
  border-radius: 2px;
}

/* ---- Sign-in gate (no toolbar on this screen → fill the whole viewport so the
   card is dead-center both axes on phone / iPad / desktop) ---- */
.studio-signin {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.studio-signin__card {
  width: min(360px, 100%); max-height: 100%; overflow: auto; padding: 28px;
  border-radius: 16px; text-align: center; box-sizing: border-box;
  background: var(--bg-1); border: 1px solid var(--accent-soft);
}
.studio-signin__brand {
  font-weight: 800; letter-spacing: 0.12em; font-size: 20px; margin-bottom: 14px;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.studio-signin p { color: var(--fg-2); margin: 0 0 18px; }
.studio-signin__btn {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 10px 0; padding: 11px 14px;
  border-radius: 10px; border: 1px solid var(--accent-soft); background: var(--bg-2);
  color: var(--fg-0); font-size: 14px; cursor: pointer; text-align: left;
}
.studio-signin__btn:hover { border-color: var(--accent); }
.studio-signin__icon { width: 20px; height: 20px; object-fit: contain; flex: 0 0 auto; }
.studio-signin__icon.studio-menu__icon--ms { width: 18px; height: 18px; }

/* ---- Workbench: artists | splitter | detail | splitter | agent ---- */
.studio-workbench {
  position: fixed; inset: var(--toolbar-h) 0 0 0;
  display: grid;
  grid-template-columns: var(--w-left) 5px 1fr 5px var(--w-right);
  /* Bound the single row to the viewport height — without this the implicit
     `auto` row grows to content and panes never scroll (they just push the
     page taller). minmax(0,1fr) caps each pane at the available height. */
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
.studio-switcher { display: none; }
.studio-pane { min-height: 0; overflow: auto; }
.studio-pane--artists {
  border-right: 1px solid var(--accent-soft);
  display: flex; flex-direction: column; overflow: hidden;   /* header fixed · list scrolls */
}
.studio-pane--artists .studio-list { flex: 1 1 auto; overflow: auto; }

/* Artist-list header: search + New */
.studio-listhead {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 8px;
  border-bottom: 1px solid var(--accent-soft);
}
.studio-search {
  flex: 1 1 auto; min-width: 0; height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--accent-soft); background: var(--bg-2); color: var(--fg-0); font-size: 13px;
}
.studio-search::placeholder { color: var(--fg-2); }
.studio-search:focus { outline: none; border-color: var(--accent); }
.studio-newbtn {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0; line-height: 1;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-0);
  font-weight: 700; font-size: 20px;
}
.studio-newbtn:hover { border-color: var(--accent); color: var(--accent); }
.studio-pane--agent { border-left: 1px solid var(--accent-soft); display: flex; flex-direction: column; overflow: hidden; }
.studio-agent { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- Studio chat agent ---- */
.studio-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.studio-chat__log { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  /* Subtle light field (like the website) so the dark assistant bubble + its
     tail read against the panel instead of blending into near-black. */
  background: rgba(255, 255, 255, 0.035); }
.studio-chat__hint { color: var(--fg-2); font-size: 12.5px; padding: 8px; line-height: 1.5; }
.studio-chat__bar { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--accent-soft); }
.studio-chat__row { display: flex; align-items: flex-end; gap: 8px; }
/* Clip / attach button — circular, outlined. */
.studio-chat__clip {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-1);
}
.studio-chat__clip:hover { border-color: var(--accent); color: var(--accent); }
/* Pending-attachment chip. */
.studio-chat__attach { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--accent-soft); border-radius: 10px; background: var(--bg-2); }
.studio-attach__thumb { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.studio-attach__doc { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center;
  background: var(--bg-1); border: 1px solid var(--accent-soft); font-size: 9px; font-weight: 700; color: var(--fg-2); }
.studio-attach__name { flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--fg-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-attach__x { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-2); font-size: 11px; display: grid; place-items: center; }
.studio-attach__x:hover { color: var(--accent); border-color: var(--accent); }
.studio-attach__err { font-size: 12px; color: #ff6b6b; }
.studio-chat__input {
  flex: 1 1 auto; min-width: 0; resize: none; max-height: 140px; overflow-y: auto;
  padding: 8px 14px; border-radius: 18px; border: 1px solid var(--accent-soft);
  background: var(--bg-2); color: var(--fg-0); font: inherit; font-size: 13px; line-height: 1.4;
}
.studio-chat__input:focus { outline: none; border-color: var(--accent); }
.studio-chat__send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-grad); color: #07091a; font-size: 18px; font-weight: 700;
}
.studio-chat__send:hover { filter: brightness(1.08); }
/* Message bubbles with tails pointing toward the sender (mirrors the website:
   column group → inner row; avatar always first in DOM, user row reversed). */
.studio-msg-group { display: flex; flex-direction: column; }
.studio-msg-group.is-user { align-items: flex-end; }
.studio-msg-group.is-assistant { align-items: flex-start; }
.studio-msg-row { display: flex; align-items: flex-end; gap: 14px; max-width: 88%; }
.studio-msg-group.is-user .studio-msg-row { flex-direction: row-reverse; }
/* Circular avatar — curasai logo (agent) or login picture / initials (user). */
.studio-avatar {
  position: relative; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; line-height: 1; font-size: 10px; font-weight: 700;
  background: #0b1030;
}
/* Picture / logo fills the whole circle (no rectangle-in-circle, no bg ring). */
.studio-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Initials live in their own pink layer; the photo overlays it when it loads. */
.studio-avatar__txt { position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--magenta); color: #fff; }
.studio-avatar--me { background: var(--magenta); }
.studio-avatar--bot { background: #0b1030; color: var(--fg-0); }
.studio-bubble {
  position: relative; z-index: 1; padding: 9px 13px; border-radius: 18px;
  font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
/* TEMP: strip avatars + tails from the chat so nothing can overlap the message
   text. Re-add deliberately once we've confirmed clean bubbles. */
.studio-msg-row .studio-avatar { z-index: 0; }
/* Tail removed — the ::after SVG was rendering on top of the bubble text.
   Keep the avatars + rounded bubbles. */
.studio-bubble::after { content: none !important; }
.is-user .studio-bubble {
  background: linear-gradient(135deg, #2a4157 0%, #21374a 100%);
  color: #fff; border-bottom-right-radius: 4px;
}
.is-user .studio-bubble::after {
  content: ""; position: absolute; bottom: 0; right: -10px; width: 14px; height: 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'><path d='M0 0 C 0 10 4 16 14 18 C 8 16 4 12 4 0 Z' fill='%232E323F'/></svg>") no-repeat;
  background-size: 100% 100%;
}
.is-assistant .studio-bubble {
  background: linear-gradient(135deg, #2b2548 0%, #221d3a 100%);
  border: 1px solid rgba(255, 255, 255, 0.07); color: var(--fg-0);
  border-bottom-left-radius: 4px;
}
.is-assistant .studio-bubble::after {
  content: ""; position: absolute; bottom: 0; left: -14px; width: 14px; height: 18px;
  /* Faint white stroke = the same hairline edge the agent bubble has, so the
     tail reads on the dark panel instead of dissolving into it. */
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'><path d='M14 0 C 14 10 10 16 0 18 C 6 16 10 12 10 0 Z' fill='%231A1E2E' stroke='white' stroke-opacity='0.10' stroke-width='1'/></svg>") no-repeat;
  background-size: 100% 100%;
}

/* Typing indicator — three bouncing dots in an assistant bubble. */
.studio-typing {
  display: flex; align-items: center; gap: 4px; padding: 9px 14px; width: fit-content;
  background: #1A1E2E; border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px; border-bottom-left-radius: 6px;
}
.studio-typing span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.55);
  animation: studio-typing-dot 1.4s ease-in-out infinite; }
.studio-typing span:nth-child(2) { animation-delay: 0.2s; }
.studio-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes studio-typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30%           { opacity: 1;   transform: scale(1); }
}

/* Rendered markdown inside an assistant bubble — compact, chat-appropriate. */
.studio-bubble--md { white-space: normal; }   /* HTML blocks, not raw newlines */
.studio-bubble--md > :first-child { margin-top: 0; }
.studio-bubble--md > :last-child { margin-bottom: 0; }
.studio-bubble--md p { margin: 0 0 8px; }
.studio-bubble--md h1, .studio-bubble--md h2, .studio-bubble--md h3,
.studio-bubble--md h4 { margin: 10px 0 6px; font-size: 14px; font-weight: 700; line-height: 1.3; }
.studio-bubble--md ul, .studio-bubble--md ol { margin: 6px 0; padding-left: 20px; }
.studio-bubble--md li { margin: 2px 0; }
.studio-bubble--md a { color: var(--accent); text-decoration: underline; }
.studio-bubble--md code {
  background: rgba(255, 255, 255, 0.10); padding: 1px 5px; border-radius: 5px;
  font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.studio-bubble--md pre {
  background: rgba(0, 0, 0, 0.30); border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0;
}
.studio-bubble--md pre code { background: none; padding: 0; font-size: 12px; }
.studio-bubble--md blockquote { margin: 6px 0; padding-left: 10px;
  border-left: 2px solid var(--accent-soft); color: var(--fg-1); }
.studio-bubble--md strong { font-weight: 700; }
.studio-bubble--md hr { border: 0; border-top: 1px solid var(--accent-soft); margin: 10px 0; }
.studio-bubble--md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.studio-bubble--md th, .studio-bubble--md td { border: 1px solid var(--accent-soft); padding: 4px 8px; }
.studio-splitter {
  position: relative; background: var(--accent-soft); cursor: col-resize;
  touch-action: none;            /* don't let the browser claim touch-drag for panning */
}
.studio-splitter:hover { background: var(--accent-glow); }
/* Visible grip: a centered rounded handle with three dots. */
.studio-splitter::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 4px; height: 40px; border-radius: 999px;
  background: radial-gradient(currentColor 1.4px, transparent 1.6px) 0 0 / 4px 7px repeat-y;
  color: var(--fg-2); opacity: 0.7;
}
.studio-splitter:hover::before, .studio-splitter:active::before { color: var(--accent); opacity: 1; }
.studio-splitter.is-dragging { background: var(--accent-glow); }

.studio-placeholder { height: 100%; display: grid; place-items: center; text-align: center;
  color: var(--fg-2); font-size: 13px; letter-spacing: 0.03em; padding: 16px; }
.studio-placeholder small { color: var(--fg-2); opacity: 0.7; }

/* ---- Mobile agent sheet: full-screen, slides up from the bottom ---- */
.studio-sheet {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: var(--bg-0);
  transform: translateY(100%); transition: transform 0.28s ease;
}
.studio-sheet.is-open { transform: translateY(0); }
.studio-sheet__head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid var(--accent-soft); font-weight: 700; font-size: 15px; color: var(--fg-0);
}
.studio-sheet__close {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-0); font-size: 15px;
}
.studio-sheet__close:hover { border-color: var(--accent); color: var(--accent); }
.studio-sheet__body { flex: 1 1 auto; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom); }

/* ---- Middle pane: segmented control + cards ---- */
.studio-pane--detail { display: flex; flex-direction: column; overflow: hidden; }
/* The slot div renderDetail fills — IT is the flex column (header + segbody are
   its direct children, so align-self/flex resolve against it). */
.studio-detail { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* Header row: segmented control centered, the New button docked top-right
   (aligned to the same right edge as the content below). */
.studio-dethead { flex: 0 0 auto; position: relative; display: flex; justify-content: center; align-items: center; }
.studio-newbtn--detail { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
/* True segmented control — a single bordered track with joined inner buttons,
   centered. */
.studio-seg {
  flex: 0 0 auto; align-self: center; display: inline-flex; gap: 0; margin: 10px auto;
  padding: 3px; border-radius: 999px; border: 1px solid var(--accent-soft); background: var(--bg-2);
}
.studio-seg__btn {
  padding: 7px 24px; border-radius: 999px; cursor: pointer; font-size: 13px;
  border: 0; background: transparent; color: var(--fg-1);
  -webkit-tap-highlight-color: transparent;   /* no rectangular flash on tap */
  -webkit-appearance: none; appearance: none; outline: none;
}
.studio-seg__btn:focus { outline: none; }
.studio-seg__btn:focus-visible { box-shadow: 0 0 0 2px var(--accent); }  /* keyboard a11y, follows the pill */
.studio-seg__btn.is-active { background: var(--accent-soft); color: var(--fg-0); }
.studio-segbody { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 12px 16px; }
.studio-cards { display: flex; flex-direction: column; gap: 12px; }

.studio-card { border: 1px solid var(--accent-soft); border-radius: 12px; background: var(--bg-1); overflow: hidden; }
.studio-card__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--accent-soft); }
.studio-card__title { margin: 0; font-size: 13px; font-weight: 700; color: var(--fg-0); letter-spacing: 0.02em; }
.studio-card__actions { display: flex; gap: 6px; }
.studio-card__btn {
  padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-1);
}
.studio-card__btn:hover { border-color: var(--accent); color: var(--accent); }
.studio-card__body { padding: 12px; }
.studio-card__flash { padding: 6px 12px; font-size: 11px; color: var(--accent); border-top: 1px solid var(--accent-soft); }

.studio-prose { color: var(--fg-1); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.studio-muted { color: var(--fg-2); }
.studio-voice__audio { width: 100%; height: 38px; display: block; border-radius: 8px; }
.studio-voice__row { display: flex; gap: 8px; margin-top: 10px; }
.studio-edit { width: 100%; min-height: 120px; resize: vertical; box-sizing: border-box; padding: 10px;
  border-radius: 8px; border: 1px solid var(--accent-soft); background: var(--bg-2); color: var(--fg-0);
  font: inherit; font-size: 13px; line-height: 1.55; }
.studio-kv { display: flex; gap: 10px; padding: 4px 0; font-size: 13px; }
.studio-kv__k { flex: 0 0 96px; color: var(--fg-2); }

/* Portrait hero: the artist photo blown up + blurred as the panel fill, with
   the sharp portrait floating on top. */
.studio-hero {
  position: relative; overflow: hidden; border-radius: 16px;
  border: 1px solid var(--accent-soft); background: var(--bg-2);
  display: grid; place-items: center; padding: 30px 20px;
}
.studio-hero__bg {
  position: absolute; inset: -10%; background-size: cover; background-position: center;
  filter: blur(42px) saturate(1.35) brightness(0.75); transform: scale(1.25);
}
.studio-hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 32%, rgba(7, 9, 26, 0.18), rgba(7, 9, 26, 0.82));
}
.studio-hero__inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.studio-hero__img {
  width: 100%; max-width: 300px; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 16px; box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}
.studio-hero__ph {
  width: 100%; max-width: 300px; aspect-ratio: 1 / 1; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px; font-size: 96px; font-weight: 700; color: #fff;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}
.studio-hero__name { font-size: 16px; font-weight: 700; color: #fff; text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.6); }

/* ---- Tracks segment: list (top) + draggable splitter + detail (bottom) ---- */
.studio-tracks {
  height: 100%; min-height: 0; display: grid;
  /* fr units (not px) so the ratio is preserved on window resize. */
  grid-template-rows: var(--tr-top, 1.25fr) 10px var(--tr-bot, 1fr);
}
.studio-tracklist {
  min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--accent-soft); border-radius: 12px; background: var(--bg-1); padding: 6px;
}
/* Horizontal splitter — drag up/down to resize the two panels. */
.studio-tracksplit {
  position: relative; background: var(--accent-soft); cursor: row-resize;
  touch-action: none; border-radius: 999px; margin: 3px 0;
}
.studio-tracksplit::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 40px; height: 4px; border-radius: 999px;
  background: radial-gradient(currentColor 1.4px, transparent 1.6px) 0 0 / 7px 4px repeat-x;
  color: var(--fg-2); opacity: 0.7;
}
.studio-tracksplit:hover::before { color: var(--accent); opacity: 1; }
.studio-trackrow {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.studio-trackrow:hover { background: var(--accent-soft); }
.studio-trackrow.is-selected { border-color: var(--magenta); background: rgba(255, 76, 192, 0.10); }
.studio-trackrow__cover {
  width: 44px; height: 44px; border-radius: 6px; background: var(--bg-2) center/cover no-repeat;
  border: 1px solid var(--accent-soft);
}
.studio-trackrow__meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-trackrow__title { color: var(--fg-0); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-trackrow__sub { color: var(--fg-2); font-size: 11px; text-transform: capitalize;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* New-track placeholder row — visible while the agent is creating the track. */
.studio-trackrow--draft { opacity: 0.85; }
.studio-trackrow--draft .studio-trackrow__cover {
  background: var(--bg-2); border-style: dashed; animation: studio-pulse 1.6s ease-in-out infinite;
}
.studio-trackrow--draft .studio-trackrow__title { font-style: italic; color: var(--fg-1); }
@keyframes studio-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.studio-trackdetail {
  position: relative; overflow: hidden; min-height: 0;
  border: 1px solid var(--accent-soft); border-radius: 12px; background: var(--bg-1);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.studio-trackdetail__title { position: relative; z-index: 1; flex: 0 0 auto; font-size: 15px; font-weight: 700; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.6); }
/* Blurred cover fills the whole panel; a dark wash keeps text/controls legible. */
.studio-trackdetail__bg {
  position: absolute; inset: -8%; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(40px) saturate(1.35) brightness(0.7);
}
.studio-trackdetail::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: rgba(7, 9, 26, 0.55);
}

/* Square cover (sized to the panel height) on the left, player filling the
   rest on the right — no splitter. */
.studio-td2 {
  position: relative; z-index: 1;
  flex: 1 1 auto; min-height: 0;
  display: flex; gap: 16px; align-items: stretch;
}
.studio-td2__cover {
  /* TRUE square: sized by height only (width follows aspect-ratio). A max-width
     clamp here would make it a rectangle and the rounded corners would vanish. */
  flex: 0 0 auto; height: 100%; width: auto; aspect-ratio: 1 / 1;
  /* Transparent host (no fill/border/shadow) — just the rounded square art
     (`contain`, never cropped) floating over the blurred panel background. */
  background: center/contain no-repeat; border-radius: 14px; overflow: hidden;
}
.studio-td2__right { flex: 1 1 auto; min-width: 0; display: grid; place-items: center; padding: 0 6px; }
.studio-td2__meta { text-align: center; }
.studio-td2__title { font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  overflow: hidden; text-overflow: ellipsis; }
.studio-td2__artist { font-size: 14px; color: rgba(255, 255, 255, 0.78); margin-top: 3px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6); }
.studio-td2__player { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
/* Custom transport — slider on top, controls row (icons + play) below. */
.studio-player { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.studio-player__controls { display: flex; align-items: center; justify-content: center; gap: 14px; }
.studio-iconbtn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-1);
}
.studio-iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.studio-player__play {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #07091a;
  background: linear-gradient(135deg, #4ce3ff 0%, #ff4cc0 100%);
  box-shadow: 0 8px 22px rgba(76, 227, 255, 0.30), 0 6px 14px rgba(255, 76, 192, 0.22);
}
.studio-player__play:hover { background: linear-gradient(135deg, #5dedff 0%, #ff66cc 100%); }
.studio-player__play:active { transform: scale(0.94); }
.studio-player__icon { display: none; }
.studio-player__play[data-state="paused"] .studio-player__icon--play { display: block; }
.studio-player__play[data-state="playing"] .studio-player__icon--pause { display: block; }
.studio-player__icon--play { transform: translateX(1px); }   /* optical center for the triangle */
.studio-player__seek { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
/* New / draft track: the seek row + play button are inert until audio exists,
   but Lyrics/Style in the same controls row stay live (gated by their own data). */
.studio-player__seek--off { opacity: 0.4; pointer-events: none; }
.studio-player__play:disabled { cursor: default; opacity: 0.6; }
.studio-player__play:disabled:hover { background: linear-gradient(135deg, #4ce3ff 0%, #ff4cc0 100%); transform: none; }
.studio-player__time {
  font-size: 11px; color: #fff; font-variant-numeric: tabular-nums; min-width: 34px; text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.studio-player__bar {
  position: relative; flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.20);
  cursor: pointer; touch-action: none;
}
.studio-player__fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, #4ce3ff 0%, #ff4cc0 100%);
}
.studio-player__thumb {
  position: absolute; top: 50%; left: 0%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55); transition: transform 0.1s ease;
}
.studio-player__bar:hover .studio-player__thumb,
.studio-player__bar.is-scrubbing .studio-player__thumb { transform: translate(-50%, -50%) scale(1.25); }
.studio-td2__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.studio-pill {
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--accent-soft); background: transparent; color: var(--fg-1);
}
.studio-pill:hover { border-color: var(--accent); color: var(--accent); }

/* Lyrics sidecar — slides in from the right over the detail pane. */
.studio-lyrics-sidecar {
  position: absolute; top: 0; right: 0; bottom: 0; width: 60%;
  background: rgba(7, 9, 26, 0.78); backdrop-filter: blur(8px);
  border-left: 1px solid var(--accent-soft);
  transform: translateX(100%); transition: transform 0.25s ease; z-index: 6;
  display: flex; flex-direction: column;
}
.studio-lyrics-sidecar.is-open { transform: translateX(0); }
.studio-lyrics-sidecar__head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--accent-soft); font-weight: 700; font-size: 13px; color: var(--fg-0); }
.studio-lyrics-sidecar__head .studio-card__btn {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; display: grid; place-items: center; line-height: 1;
}
.studio-lyrics-sidecar__body { flex: 1 1 auto; overflow: auto; padding: 12px; white-space: pre-wrap;
  font-size: 12.5px; line-height: 1.55; color: var(--fg-1); }

/* Style sidecar: gender segment + style descriptor + the 3 mix knob meters.
   Overrides the body's pre-wrap so the stacked controls lay out normally; the
   style text keeps pre-wrap on its own block. */
.studio-stylepane { white-space: normal; display: flex; flex-direction: column; gap: 16px; }
.studio-stylepane .studio-seg { align-self: flex-start; }
.studio-stylepane .studio-seg__btn[disabled] { cursor: default; opacity: 1; }
.studio-style__text { white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; color: var(--fg-1);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--accent-soft);
  border-radius: 10px; padding: 10px 12px; }
.studio-knobs { display: flex; flex-direction: column; gap: 13px; }
.studio-knob__head { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--fg-2); margin-bottom: 6px; }
.studio-knob__val { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.studio-knob__track { position: relative; height: 6px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.10); overflow: hidden; }
.studio-knob__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--magenta)); }

/* Editable mix: gender segment is interactive (not disabled); the 3 knobs are
   range sliders themed to match the brand. */
.studio-seg--mix .studio-seg__btn { cursor: pointer; }
.studio-knob__range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.10); outline: none; cursor: pointer; }
.studio-knob__range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg-1); box-shadow: 0 0 0 1px var(--accent-soft); cursor: pointer; }
.studio-knob__range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-1); cursor: pointer; }
.studio-mix__status { font-size: 11.5px; min-height: 14px; color: var(--fg-2); }
.studio-mix__status.is-saving { color: var(--fg-2); }
.studio-mix__status.is-saved { color: var(--accent); }
.studio-mix__status.is-error { color: var(--magenta); }

/* AI-gated text editor (lyrics + style sidecars): textarea → review → save. */
.studio-sidecar__actions { display: inline-flex; gap: 6px; align-items: center; }
.studio-card__btn--ghost { background: transparent; }
.studio-edit { white-space: normal; display: flex; flex-direction: column; gap: 10px; min-height: 100%; }
.studio-edit__ta { width: 100%; min-height: 220px; flex: 1 1 auto; resize: vertical;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--accent-soft); border-radius: 10px;
  color: var(--fg-0); font: inherit; font-size: 12.5px; line-height: 1.5; padding: 10px 12px; }
.studio-edit__ta:focus { outline: none; border-color: var(--accent); }
.studio-edit__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.studio-edit__status { font-size: 11.5px; color: var(--fg-2); }
.studio-edit__notes { font-size: 12px; line-height: 1.45; color: var(--accent); }
.studio-edit__suggest { font-size: 12px; color: var(--fg-1); }

/* Canon: per-field inline editing. A small pencil reveals the editor. */
.studio-kv__edit { background: transparent; border: 0; color: var(--fg-2); cursor: pointer;
  font-size: 11px; padding: 0 2px; margin-left: 4px; line-height: 1; }
.studio-kv__edit:hover { color: var(--accent); }
.studio-canonedit { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; width: 100%; }
.studio-canonedit__in { flex: 1 1 160px; min-width: 120px; background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--accent-soft); border-radius: 8px; color: var(--fg-0); font: inherit;
  font-size: 12.5px; padding: 5px 8px; }
.studio-canonedit__in:focus { outline: none; border-color: var(--accent); }

/* Track Workspace: generate + submit actions. */
.studio-gen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.studio-card__btn--accent { background: var(--accent); color: #06121a; border-color: var(--accent); font-weight: 700; }
.studio-card__btn--accent:hover { filter: brightness(1.08); }
.studio-gen__status { font-size: 11.5px; color: var(--fg-2); flex-basis: 100%; }
.studio-gen__status.is-error { color: var(--magenta); }

/* On narrow screens the middle pane scrolls as one block, so the fixed 40/60
   split would collapse — let the Tracks panels flow instead (list capped + own
   scroll, detail below). */
@media (max-width: 860px) {
  .studio-tracks { height: auto; display: flex; flex-direction: column; gap: 12px; }
  .studio-tracksplit { display: none; }
  /* Shorter list (viewport-relative) so the cover + player fit above the
     fixed bottom tab bar without being cut off. */
  .studio-tracklist { max-height: 27vh; }
  .studio-td2 { min-height: 0; }
  /* Lyrics sidecar takes the whole panel on mobile (60% is too narrow to read). */
  .studio-lyrics-sidecar { width: 100%; }
}
@media (max-width: 600px) {
  /* Stack: cover on top, title/artist/player/pills centered underneath. The
     cover is sized in vh (viewport-relative — % would collapse here) so the
     whole detail fits in the space left above the bottom tab bar. */
  .studio-td2 { flex-direction: column; align-items: center; gap: 12px; }
  .studio-td2__cover { height: 30vh; width: auto; max-width: 92%; aspect-ratio: 1 / 1; }
  .studio-td2__right { width: 100%; }
}

/* ---- Artist list (left pane) ---- */
.studio-list { padding: 6px; }
.studio-list__empty { padding: 24px 12px; color: var(--fg-2); font-size: 13px; text-align: center; }
.studio-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px;
  cursor: pointer; user-select: none; border: 1px solid transparent;
}
.studio-row:hover { background: var(--accent-soft); }
/* Selection highlight matches the website's playing-track row
   (.m-player__sidecar-track.is-playing): magenta border + 10% magenta fill. */
.studio-row.is-selected { border-color: var(--magenta); background: rgba(255, 76, 192, 0.10); }
.studio-row__pic {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px;
  background: var(--bg-2) center/cover no-repeat; display: grid; place-items: center;
  font-weight: 700; color: var(--fg-1); font-size: 13px; border: 1px solid var(--accent-soft);
}
.studio-row__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.studio-row__name { color: var(--fg-0); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-row__date { color: var(--fg-2); font-size: 11px; }
.studio-row__live {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  color: var(--accent); text-decoration: none; font-size: 11px; border: 1px solid var(--accent-soft);
}
.studio-row__live:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---- Narrow screens: single active pane + top switcher ---- */
@media (max-width: 860px) {
  .studio-workbench { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .studio-splitter { display: none; }
  /* Bottom tab bar — icon + label, fixed at the bottom like a native app. */
  .studio-switcher {
    display: flex; gap: 0; padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(7, 9, 26, 0.92); backdrop-filter: blur(12px);
    border-top: 1px solid var(--accent-soft);
  }
  .studio-switcher__tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px; border: 0; border-radius: 10px; background: transparent;
    color: var(--fg-2); font-size: 10px; cursor: pointer;
  }
  .studio-switcher__tab.is-active { color: var(--accent); }
  .studio-switcher__icon { display: block; width: 19px; height: 19px; }
  /* Single content row now (the bar is fixed, out of grid flow). */
  .studio-workbench { grid-template-rows: 1fr; }
  .studio-pane { grid-column: 1; grid-row: 1; border: 0 !important; display: none; min-height: 0;
    padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .studio-pane.is-active { display: block; }
  /* Artists pane keeps its flex column (pinned search header + scrolling list). */
  .studio-pane--artists.is-active { display: flex; }
  /* Detail pane: on mobile, let the WHOLE pane scroll as a block (the inner
     flex→grid scroll chain doesn't hold on iOS). Override its desktop
     overflow:hidden and neutralize the inner segbody scroller. */
  .studio-pane--detail.is-active { display: block; overflow: auto; -webkit-overflow-scrolling: touch; }
  .studio-pane--detail .studio-segbody { min-height: auto; overflow: visible; }
}
