  :root {
    --bg: #101011;
    --bg2: #171718;
    --surface: #171718;
    --surface2: #1E1E20;
    --line: #29292C;
    --line2: #3A3A3E;
    --ink: #f2f2f2;
    --dim: #A7A7AA;
    --faint: #858589;
    --accent: #B8B8BC;
    --accent-ink: #1E1E20;
    --accent-dim: rgba(184, 184, 188, .13);
    --danger: #A7A7AA;
    --sans: "IBM Plex Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --serif: Fraunces, "Hoefler Text", Georgia, serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    --nav-h: 54px;
  }
  * { box-sizing: border-box; }
  html { color-scheme: dark; }
  body {
    margin: 0;
    min-height: 100vh;
    padding-top: var(--nav-h);
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.45 var(--sans);
    -webkit-font-smoothing: antialiased;
  }
  button, textarea, select, input { font: inherit; }
  button, select { -webkit-tap-highlight-color: transparent; }
  .nav {
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(16, 16, 17, .88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    text-decoration: none;
    font: 600 20px/1 var(--serif);
  }
  .brand img { width: 24px; height: 24px; }
  .nav-links { display: flex; gap: 2px; }
  .nav-links a {
    padding: 7px 11px;
    border-radius: 7px;
    color: var(--dim);
    text-decoration: none;
    font-weight: 500;
  }
  .nav-links a:hover, .nav-links a.active { color: var(--ink); background: var(--surface2); }
  .nav-right { margin-left: auto; }
  .profile {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: none;
    color: var(--dim);
    cursor: pointer;
  }
  .avatar {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface2);
    color: var(--accent);
    font: 600 12px var(--mono);
  }
  main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 100px; }
  .page-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
  }
  h1 { margin: 0 0 5px; font: 600 30px/1.12 var(--serif); letter-spacing: 0; }
  .page-head p { margin: 0; color: var(--dim); }
  .segmented {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg2);
  }
  .segmented button {
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--dim);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }
  .segmented button[aria-selected="true"] { background: var(--surface2); color: var(--ink); }
  .voice-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }
  .field {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    outline: none;
    background: var(--bg2);
    color: var(--ink);
  }
  .field:focus { border-color: var(--accent); }
  .search {
    width: min(320px, 100%);
    padding: 8px 11px;
  }
  .provider-select, .control-select { padding: 8px 32px 8px 10px; cursor: pointer; }
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 24px;
    margin-top: 26px;
    padding: 22px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
  }
  .label-row label, .control-label { color: var(--dim); font-size: 12px; font-weight: 600; }
  .script-meta { color: var(--faint); font: 11px var(--mono); white-space: nowrap; }
  textarea {
    width: 100%;
    min-height: 176px;
    padding: 13px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: var(--bg2);
    color: var(--ink);
    line-height: 1.55;
  }
  textarea:focus { border-color: var(--accent); }
  textarea::placeholder, input::placeholder { color: #58585E; }
  .side-controls { display: grid; align-content: start; gap: 14px; }
  .control { display: grid; gap: 6px; }
  .selected-voice {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
  }
  .selected-initial {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 700;
  }
  .selected-copy { display: grid; min-width: 0; }
  .selected-copy strong, .selected-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .selected-copy strong { font-size: 12px; }
  .selected-copy span { color: var(--faint); font-size: 11px; }
  .range-row { display: grid; grid-template-columns: 1fr 40px; align-items: center; gap: 8px; }
  input[type="range"] { width: 100%; accent-color: var(--accent); }
  .pace-value { color: var(--dim); font: 11px var(--mono); text-align: right; }
  .control.disabled { opacity: .45; }
  .action-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
  .qty {
    display: grid;
    grid-template-columns: 32px 28px 32px;
    align-items: center;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
  }
  .qty button { height: 100%; border: 0; background: var(--bg2); color: var(--dim); cursor: pointer; }
  .qty button:hover { color: var(--ink); background: var(--surface2); }
  .qty span { text-align: center; font: 600 12px var(--mono); }
  .generate {
    flex: 1;
    min-width: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 14px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 750;
    cursor: pointer;
  }
  .generate:disabled { opacity: .48; cursor: default; }
  .generate-cost { font: 650 11px var(--mono); opacity: .78; }
  .music-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
  .preset {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--dim);
    cursor: pointer;
  }
  .preset:hover { color: var(--ink); border-color: var(--line2); }
  .history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 32px;
    margin-bottom: 13px;
  }
  h2 { margin: 0; font: 600 19px/1.2 var(--serif); }
  .history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .audio-item {
    min-width: 0;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }
  .audio-item.pending { opacity: .68; }
  .item-head { display: flex; align-items: start; gap: 8px; min-height: 34px; }
  .item-type {
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
    font: 600 9px var(--mono);
    text-transform: uppercase;
  }
  .item-model { min-width: 0; font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .item-date { margin-left: auto; color: var(--faint); font: 10px var(--mono); white-space: nowrap; }
  .item-prompt {
    min-height: 40px;
    margin: 9px 0;
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink);
    font-size: 12px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .item-status { min-height: 32px; display: flex; align-items: center; color: var(--faint); font-size: 11px; }
  .audio-item audio { width: 100%; height: 32px; display: block; }
  .item-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
  .item-actions a, .item-actions button {
    min-height: 29px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--dim);
    text-decoration: none;
    font-size: 11px;
    cursor: pointer;
  }
  .item-actions a:hover, .item-actions button:hover { color: var(--ink); border-color: var(--line2); }
  .item-actions .delete { margin-left: auto; color: var(--danger); }
  .empty { padding: 58px 0; color: var(--faint); text-align: center; }
  .toast {
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: max(22px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 28px);
    padding: 10px 15px;
    border: 1px solid var(--line2);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--ink);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: .18s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  [hidden] { display: none !important; }
  @media (max-width: 900px) {
    .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 680px) {
    :root { --nav-h: 96px; }
    .nav { height: var(--nav-h); padding: 8px 12px; flex-wrap: wrap; align-content: center; gap: 7px 10px; }
    .brand { font-size: 18px; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
    .nav-links a { padding: 6px 8px; white-space: nowrap; font-size: 12px; }
    .nav-right { margin-left: auto; }
    #profileName { display: none; }
    main { padding: 20px 14px 80px; }
    .page-head { align-items: stretch; flex-direction: column; margin-bottom: 20px; }
    h1 { font-size: 26px; }
    .segmented { width: 100%; }
    .voice-toolbar { align-items: stretch; }
    .search { min-width: 0; flex: 1; }
    .provider-select { width: 120px; }
    .workspace { grid-template-columns: 1fr; gap: 18px; padding: 18px 0; }
    textarea { min-height: 154px; }
    .side-controls { grid-template-columns: 1fr 1fr; }
    .side-controls .selected-control, .side-controls .action-row { grid-column: 1 / -1; }
    .history-grid { grid-template-columns: 1fr; }
    .history-head { align-items: stretch; flex-direction: column; }
    .history-head .segmented { width: 100%; }
  }
  @media (max-width: 390px) {
    .side-controls { grid-template-columns: 1fr; }
    .side-controls .selected-control, .side-controls .action-row { grid-column: auto; }
  }

  /* 2026-07-27 studio workflow refinement */
  :root {
    --bg: #0B0B0C;
    --bg2: #101011;
    --surface: #171718;
    --surface2: #1E1E20;
    --line: rgba(226, 226, 228, .11);
    --line2: rgba(226, 226, 228, .2);
    --ink: #F3F3F2;
    --dim: #A7A7AA;
    --faint: #858589;
    --accent: #D0D0D2;
    --accent-ink: #262628;
    --accent-dim: rgba(208, 208, 210, .09);
    --nav-h: 68px;
  }
  body {
    background:
      radial-gradient(circle at 72% 4%, rgba(167, 167, 170, .09), transparent 30%),
      var(--bg);
  }
  button:focus-visible, a:focus-visible, input:focus-visible,
  textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .nav {
    height: var(--nav-h);
    padding: 0 28px;
    gap: 28px;
    background: rgba(11, 11, 12, .89);
    border-bottom-color: var(--line);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .brand { font-size: 22px; }
  .brand img { width: 30px; height: 30px; }
  .nav-links a {
    padding: 9px 13px;
    border-radius: 9px;
    font-size: 13px;
  }
  .avatar { width: 33px; height: 33px; }
  main {
    max-width: 1360px;
    padding: 42px 32px 84px;
  }
  .page-head { margin-bottom: 30px; }
  .eyebrow, .step-kicker {
    display: block;
    margin-bottom: 9px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .18em;
    text-transform: uppercase;
  }
  h1 {
    margin-bottom: 12px;
    font-size: clamp(42px, 5vw, 64px);
    font-weight: 500;
    line-height: .98;
    letter-spacing: -.045em;
  }
  .page-head p { font-size: 15px; }
  .segmented {
    padding: 4px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .015);
  }
  .segmented button {
    min-width: 108px;
    min-height: 38px;
    border-radius: 7px;
  }
  .studio-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 16px;
    align-items: stretch;
  }
  .workspace, .library-shell {
    min-width: 0;
    min-height: 650px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
      linear-gradient(145deg, rgba(255, 255, 255, .018), transparent 45%),
      var(--surface);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .035),
      0 22px 70px rgba(0, 0, 0, .21);
  }
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    align-content: start;
    gap: 24px;
    margin: 0;
    padding: 28px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .workspace-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 3px;
  }
  .workspace-head h2, .library-head h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 500;
  }
  .saved-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--faint);
    font-size: 11px;
    white-space: nowrap;
  }
  .saved-state i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #A7A7AA;
  }
  .prompt-column { min-width: 0; }
  .label-row label, .control-label { font-size: 11px; }
  .script-meta { font-size: 11px; }
  textarea {
    min-height: 245px;
    padding: 18px;
    border-radius: 12px;
    background: #101011;
    font: 18px/1.58 var(--serif);
    caret-color: var(--accent);
  }
  textarea:focus {
    border-color: rgba(208, 208, 210, .52);
    box-shadow: 0 0 0 3px rgba(208, 208, 210, .06);
  }
  .side-controls {
    align-content: start;
    gap: 15px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .016);
  }
  .selected-voice {
    min-height: 48px;
    border-radius: 9px;
    background: #171718;
  }
  .selected-initial {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--accent-ink);
  }
  .field, .control-select { border-radius: 8px; background: #171718; }
  .action-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    margin-top: 3px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
  }
  .qty { height: 46px; border-radius: 9px; }
  .generate {
    height: 46px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    border-radius: 9px;
    padding: 0 12px;
    box-shadow: 0 12px 30px rgba(167, 167, 170, .13);
    transition: transform .15s, background .15s, opacity .15s;
  }
  .generate:hover:not(:disabled) { transform: translateY(-1px); }
  .generate-spark { font-size: 14px; }
  .generate kbd {
    padding: 3px 5px;
    border: 1px solid rgba(30, 30, 32, .18);
    border-radius: 5px;
    background: rgba(255, 255, 255, .16);
    font: 9px var(--sans);
  }
  .generate.working .generate-spark { animation: studio-spin 850ms linear infinite; }
  @keyframes studio-spin { to { transform: rotate(360deg); } }
  .library-shell { container-type: inline-size; padding: 24px; overflow: hidden; }
  .library-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 21px;
  }
  .library-meta { color: var(--faint); font-size: 11px; }
  .voice-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px auto;
    gap: 8px;
    margin-bottom: 12px;
  }
  .search { width: 100%; min-width: 0; }
  .provider-select { width: 100%; min-width: 0; padding-right: 24px; }
  .favorite-filter {
    min-width: 46px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #171718;
    color: var(--faint);
    cursor: pointer;
  }
  .favorite-filter span { color: #858589; }
  .favorite-filter[aria-pressed="true"] {
    border-color: rgba(184, 184, 188, .32);
    background: rgba(184, 184, 188, .07);
    color: #D0D0D2;
  }
  .favorite-filter[aria-pressed="true"] span { color: #B8B8BC; }
  @keyframes sample-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
  }
  .favorite-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 32px;
    border: 0;
    background: transparent;
    color: #3A3A3E;
    cursor: pointer;
  }
  .favorite-btn:hover { color: #858589; }
  .favorite-btn.active { color: #B8B8BC; }
  .preset-intro { margin: -2px 0 13px; color: var(--faint); font-size: 12px; }
  .music-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .preset {
    min-height: 72px;
    border-radius: 10px;
    background: #171718;
    color: #D0D0D2;
    text-align: left;
    font-family: var(--serif);
  }
  .preset:hover { color: var(--accent); border-color: rgba(208, 208, 210, .3); }
  .music-controls {
    display: grid;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #171718;
  }
  .music-control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .music-range-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .music-control {
    min-width: 0;
    display: grid;
    gap: 5px;
  }
  .music-control > label,
  .music-control > span:first-child {
    color: var(--faint);
    font-size: 11px;
  }
  .music-control .control-select {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
  }
  .music-range {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .music-readout {
    color: var(--accent);
    font: 600 10.5px var(--mono);
    text-align: left;
  }
  .music-loop {
    width: 100%;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101011;
    color: var(--dim);
    cursor: pointer;
  }
  .music-loop b {
    color: var(--faint);
    font: 600 10px var(--mono);
    text-transform: uppercase;
  }
  .music-loop[aria-checked="true"] {
    border-color: rgba(208, 208, 210, .42);
    background: rgba(208, 208, 210, .07);
    color: var(--accent);
  }
  .music-loop[aria-checked="true"] b { color: var(--accent); }
  .music-mode .side-controls { gap: 10px; padding: 13px; }
  .music-mode .action-row { padding-top: 10px; }
  .history-head {
    align-items: end;
    margin: 56px 0 20px;
  }
  .history-head h2 { font-size: 30px; font-weight: 500; }
  .history-meta { display: block; margin-top: 7px; color: var(--faint); font-size: 11px; }
  .history-grid { grid-template-columns: 1fr; gap: 8px; }
  .audio-item {
    min-height: 86px;
    display: grid;
    grid-template-columns: minmax(280px, 1.2fr) minmax(240px, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 4px 18px;
    padding: 13px 14px;
    border-radius: 11px;
    background: rgba(23, 23, 24, .72);
  }
  .item-head { grid-column: 1; grid-row: 1; min-height: 0; align-items: center; }
  .item-prompt {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    margin: 3px 0 0;
    -webkit-line-clamp: 1;
  }
  .audio-item audio, .item-status {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
  }
  .item-actions {
    grid-column: 3;
    grid-row: 1 / 3;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 168px;
    margin: 0;
  }
  .item-actions .delete { margin-left: 0; }
  .reuse { color: #B8B8BC !important; }
  @media (max-width: 1080px) {
    .studio-shell { grid-template-columns: minmax(0, 1fr) 350px; }
    .workspace { grid-template-columns: 1fr; }
    .workspace-head { grid-column: auto; }
    .side-controls { grid-template-columns: 1fr 1fr; }
    .side-controls .selected-control, .side-controls .action-row, .side-controls .music-controls { grid-column: 1 / -1; }
  }
  @media (max-width: 820px) {
    main { max-width: 700px; padding-top: 34px; }
    .studio-shell { grid-template-columns: 1fr; }
    .workspace, .library-shell { min-height: 0; }
    .audio-item {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-rows: auto auto auto;
    }
    .audio-item audio, .item-status {
      grid-column: 1 / -1;
      grid-row: 3;
      margin-top: 8px;
    }
    .item-actions { grid-column: 2; grid-row: 1 / 3; }
  }
  @media (max-width: 680px) {
    :root { --nav-h: 96px; }
    .nav { height: var(--nav-h); padding: 8px 12px; gap: 7px 10px; }
    main { padding: 24px 14px 72px; }
    .page-head { margin-bottom: 22px; }
    h1 { font-size: 43px; }
    .page-head p { max-width: 330px; font-size: 13px; }
    .workspace, .library-shell { padding: 20px; border-radius: 14px; }
    .workspace-head h2, .library-head h2 { font-size: 21px; }
    textarea { min-height: 190px; font-size: 16px; }
    .side-controls { grid-template-columns: 1fr; }
    .side-controls .selected-control, .side-controls .action-row { grid-column: auto; }
    .music-control-grid { grid-template-columns: 1fr; }
    .music-range-grid { grid-template-columns: 1fr; }
    .voice-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
    .voice-toolbar .search { grid-column: 1 / -1; }
    .provider-select { width: auto; }
    .music-presets { grid-template-columns: 1fr; }
    .history-head { align-items: stretch; margin-top: 44px; }
    .history-head .segmented { width: 100%; }
    .audio-item { display: block; }
    .item-head, .item-prompt, .audio-item audio, .item-status, .item-actions { margin-top: 9px; }
    .item-head { margin-top: 0; }
    .item-actions { max-width: none; justify-content: flex-start; }
    .item-actions .delete { margin-left: auto; }
  }

  /* Canonical Saga navigation: keep page transitions geometrically stable. */
  :root { --nav-h: 54px; }
  .nav {
    height: var(--nav-h);
    min-height: var(--nav-h);
    gap: 10px;
    padding: 0 10px;
    background: rgba(11, 11, 12, .72);
    font: 15px/1.5 var(--sans);
  }
  .brand {
    flex: 0 0 auto;
    gap: 9px;
    font: 600 20px/1 Fraunces, var(--serif);
    letter-spacing: -.01em;
  }
  .brand img { width: auto; height: 24px; }
  .nav-links { align-items: center; gap: 2px; }
  .nav-links a {
    padding: 7px 12px;
    border-radius: 8px;
    font: 500 13.5px var(--sans);
  }
  .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
  }
  .profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--dim);
    font: 500 12.5px var(--sans);
  }
  .avatar {
    width: 26px;
    height: 26px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 700 12px var(--sans);
  }
  @media (max-width: 720px) {
    .nav { gap: 10px; padding: 0 10px; }
    .nav-links a { padding: 6px 8px; font-size: 12.5px; }
  }
  @media (max-width: 640px) {
    :root { --nav-h: 94px; }
    .nav {
      height: var(--nav-h);
      min-height: var(--nav-h);
      padding: 6px 10px 7px;
      row-gap: 4px;
    }
    .nav-links {
      min-width: 0;
      flex: 1 1 0%;
      overflow-x: auto;
      margin-right: 46px;
      scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-right { margin-left: 0; }
    .nav .profile {
      position: absolute;
      top: 8px;
      right: 10px;
      padding: 8px;
    }
    #profileName { display: none; }
  }

  /* 2026-07-27 unified audio workspace */
  main {
    max-width: 1440px;
    padding: 26px 28px 68px;
  }
  .page-head {
    align-items: center;
    margin-bottom: 16px;
  }
  .page-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 18px;
  }
  .page-head h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 550;
    line-height: 1;
    letter-spacing: -.035em;
  }
  .page-head .segmented {
    border-color: rgba(226, 226, 228, .14);
    background: rgba(255, 255, 255, .018);
  }
  .studio-shell {
    grid-template-columns: minmax(0, 1fr) 540px;
    gap: 18px;
    align-items: stretch;
  }
  .workspace, .library-shell {
    min-height: 0;
    border-radius: 18px;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 26px;
  }
  .workspace-head {
    grid-column: auto;
    margin-bottom: 0;
  }
  .workspace-head h2,
  .library-head h2 {
    font-size: 26px;
  }
  .prompt-column {
    display: grid;
  }
  textarea {
    min-height: 290px;
    border-radius: 14px;
    background: #101011;
    font-size: 19px;
  }
  .side-controls {
    grid-template-columns: minmax(0, 1.2fr) minmax(150px, .75fr) minmax(190px, 1fr);
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .02);
  }
  .selected-voice {
    min-height: 58px;
    padding: 7px 10px;
    border-radius: 10px;
  }
  .selected-initial,
  .selected-portrait {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }
  .selected-portrait {
    object-fit: cover;
    object-position: center 36%;
  }
  .selected-copy strong {
    font-size: 13px;
  }
  .action-row {
    grid-column: 1 / -1;
    margin-top: 0;
  }
  body.music-mode .side-controls {
    grid-template-columns: minmax(180px, .42fr) minmax(0, 1fr);
  }
  body.music-mode .music-controls,
  body.music-mode .action-row {
    grid-column: 1 / -1;
  }
  .library-shell {
    padding: 24px;
  }
  .library-head {
    margin-bottom: 18px;
  }
  .voice-toolbar {
    grid-template-columns: minmax(0, 1fr) 136px auto;
    margin-bottom: 14px;
  }
  .voice-toolbar .field,
  .favorite-filter {
    min-height: 42px;
  }
  .favorite-btn {
    width: 24px;
  }
  .history-head {
    margin-top: 34px;
  }
  @media (max-width: 1200px) {
    .studio-shell {
      grid-template-columns: minmax(0, 1fr) 430px;
    }
    .side-controls {
      grid-template-columns: 1fr 1fr;
    }
    .side-controls .selected-control,
    .side-controls .action-row,
    .side-controls .music-controls {
      grid-column: 1 / -1;
    }
    textarea {
      min-height: 270px;
    }
  }
  @media (max-width: 1040px) {
    main {
      max-width: 800px;
      padding-top: 26px;
    }
    .studio-shell {
      grid-template-columns: 1fr;
    }
    .workspace, .library-shell {
      min-height: 0;
    }
  }
  @media (max-width: 680px) {
    main {
      padding: 20px 14px 64px;
    }
    .page-head {
      align-items: stretch;
      flex-direction: column;
      gap: 14px;
      margin-bottom: 16px;
    }
    .page-title {
      align-items: flex-start;
      flex-direction: column;
      gap: 12px;
    }
    .page-head h1 {
      font-size: 34px;
    }
    .page-head .segmented {
      width: 100%;
    }
    .page-head .segmented button {
      min-width: 0;
      min-height: 36px;
      padding: 0 10px;
      font-size: 12px;
    }
    .workspace, .library-shell {
      padding: 18px;
      border-radius: 15px;
    }
    textarea {
      min-height: 220px;
      font-size: 17px;
    }
    .side-controls,
    body.music-mode .side-controls {
      grid-template-columns: 1fr;
    }
    .side-controls .selected-control,
    .side-controls .action-row,
    .side-controls .music-controls {
      grid-column: auto;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
    }
  }
  body.sfx-mode .side-controls {
    grid-template-columns: minmax(180px, .42fr) minmax(0, 1fr);
  }
  body.sfx-mode .sfx-controls,
  body.sfx-mode .action-row {
    grid-column: 1 / -1;
  }
  .sfx-controls {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #171718;
  }
  .sfx-control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .sfx-range {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px;
    align-items: center;
    gap: 9px;
  }
  .sfx-readout {
    color: var(--accent);
    font: 600 10.5px var(--mono);
    text-align: right;
  }
  .sfx-help {
    margin: 0;
    color: var(--faint);
    font-size: 11px;
    line-height: 1.45;
  }
  .sfx-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .sfx-presets .preset {
    min-height: 82px;
    display: grid;
    align-content: center;
    gap: 5px;
  }
  .sfx-presets .preset strong,
  .sfx-presets .preset small {
    display: block;
  }
  .sfx-presets .preset strong {
    color: var(--ink);
    font: 500 14px var(--serif);
  }
  .sfx-presets .preset small {
    color: var(--faint);
    font: 11px/1.35 var(--sans);
  }
  .sfx-presets .preset:hover strong {
    color: var(--accent);
  }
  .music-presets .preset {
    display: grid;
    align-content: center;
    gap: 5px;
  }
  .music-presets .preset strong {
    display: block;
    color: var(--ink);
    font: 500 14px var(--serif);
  }
  .music-presets .preset small {
    display: block;
    color: var(--faint);
    font: 11px/1.35 var(--sans);
  }
  .music-presets .preset:hover strong {
    color: var(--accent);
  }
  /* 2026-08-06 script starters — one-tap performance scripts under the composer */
  .starter-block { margin-top: 2px; }
  .starter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
  }
  .starter-row .preset {
    min-height: 34px;
    padding: 6px 13px;
    border-radius: 999px;
    font: 500 13px var(--serif);
  }
  @media (max-width: 1200px) {
    body.sfx-mode .side-controls {
      grid-template-columns: 1fr 1fr;
    }
    .side-controls .sfx-controls {
      grid-column: 1 / -1;
    }
  }
  @media (max-width: 680px) {
    body.sfx-mode .side-controls,
    .sfx-control-grid {
      grid-template-columns: 1fr;
    }
    .side-controls .sfx-controls {
      grid-column: auto;
    }
    .sfx-presets {
      grid-template-columns: 1fr;
    }
  }

  /* ════════════════════════════════════════════════════════════════════════
     VOICE LIBRARY — portrait-led cards.  ONE definition, deliberately.
     This replaced THREE stacked generations that had accumulated in the old
     inline stylesheet (34px circle with no portrait -> 52px tile -> 70px tile).
     The last one silently won, so the page could not be understood by reading
     any single block, and the actors ended up as 70px thumbnails with a play
     arrow stamped over every face.
     🔴 Edit these rules. Do NOT append a fourth generation below them.
     ════════════════════════════════════════════════════════════════════════ */

  .library-shell { display: flex; flex-direction: column; }
  #speechPanel:not([hidden]) {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
  }
  /* tells the eye there is more below, without covering a card */
  #speechPanel:not([hidden])::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: auto 0 0;
    height: 34px;
    background: linear-gradient(180deg, transparent, var(--surface) 88%);
    pointer-events: none;
  }

  .voice-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* max-content, not auto: an auto row inside a height-constrained grid gets
       sized to FIT the container, which silently squashed every card to 60px
       and clipped the portrait and the whole text body via overflow:hidden. */
    grid-auto-rows: max-content;
    gap: 12px;
    /* bounded so the picker scrolls in place instead of driving the whole row
       taller than the composer beside it — that is what produced the dead space */
    max-height: calc(100vh - 320px);
    min-height: 0;
    /* grid default is align-content:stretch — with a capped height that squashes
       every row to fit instead of scrolling. Rows must keep their natural size. */
    align-content: start;
    padding-right: 4px;
    overflow-y: auto;
    scroll-snap-type: y proximity;
    scrollbar-gutter: stable;
    scrollbar-color: #3A3A3E transparent;
    scrollbar-width: thin;
  }
  @container (min-width: 420px) {
    .voice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  .voice-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    scroll-snap-align: start;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
  }
  .voice-card:hover { border-color: var(--line2); background: var(--surface2); }
  .voice-card.selected {
    border-color: rgba(232, 232, 235, .85);
    background: linear-gradient(180deg, rgba(184, 184, 188, .12), transparent 46%), #1E1E20;
    box-shadow: inset 0 0 0 2px rgba(232, 232, 235, .5);
  }
  /* the old selected state was a tint you had to hunt for; say it outright */
  .voice-card.selected .voice-figure::before {
    content: "Selected";
    position: absolute;
    z-index: 2;
    top: 9px;
    left: 9px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(232, 232, 235, .94);
    color: #101011;
    font: 600 10px/1.4 var(--sans);
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  /* The portrait IS the hero and the SELECT target. Nothing is drawn over the face. */
  .voice-figure {
    position: relative;
    isolation: isolate;
    display: block;
    width: 100%;
    /* The portrait scales to 1.04 on hover. Without this the extra ~3px of
       image escapes this button's bottom border and paints over the card body,
       below the ::after floor that darkens the rest — so it reads as a bright
       line under the face. The card's own overflow:hidden clips the CARD, not
       this button, which is why the spill survived it. */
    overflow: hidden;
    aspect-ratio: 4 / 3;
    /* cap it: in a single-column library (<=1200px, and on mobile) a 4:3 band
       off the full column width made 260px+ portraits and ~4,800px of scroll
       for 13 voices. object-fit:cover keeps the crop correct at the cap. */
    max-height: 210px;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #101011;
  }
  .voice-portrait {
    position: absolute;
    z-index: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 26%;
    transition: transform .3s ease;
  }
  .voice-figure:hover .voice-portrait { transform: scale(1.04); }
  /* a soft floor so the badge stays legible — the face itself is never dimmed */
  .voice-figure::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: auto 0 0;
    height: 44%;
    background: linear-gradient(180deg, transparent, rgba(11, 11, 12, .62));
    pointer-events: none;
  }
  .sample-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

  /* the sample trigger is this badge alone — the rest of the card selects */
  .sample-btn {
    position: absolute;
    z-index: 2;
    right: 9px;
    bottom: 9px;
    display: grid;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(243, 243, 242, .22);
    border-radius: 50%;
    background: rgba(16, 16, 17, .66);
    color: #F3F3F2;
    padding: 0;
    cursor: pointer;
    place-items: center;
    backdrop-filter: blur(3px);
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
  }
  .sample-btn:hover,
  .sample-btn:focus-visible {
    border-color: rgba(208, 208, 210, .8);
    background: rgba(23, 23, 24, .82);
    transform: scale(1.06);
  }
  .sample-btn::before {
    content: "";
    width: 11px;
    height: 12px;
    background: currentColor;
    clip-path: polygon(6% 0, 100% 50%, 6% 100%);
    transform: translateX(1px);
  }
  .sample-btn.playing {
    border-color: rgba(208, 208, 210, .9);
    background: rgba(38, 38, 40, .88);
    color: #D0D0D2;
  }
  .sample-btn.playing::before {
    width: 10px;
    height: 11px;
    clip-path: none;
    background: linear-gradient(90deg, currentColor 0 34%, transparent 34% 66%, currentColor 66%);
    transform: none;
  }
  .sample-btn.loading::before {
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    background: none;
    clip-path: none;
    transform: none;
    animation: badge-spin .7s linear infinite;
  }
  @keyframes badge-spin { to { transform: rotate(360deg); } }

  .voice-body {
    display: flex;
    align-items: start;
    gap: 8px;
    padding: 11px 12px 13px;
  }
  .voice-choice {
    display: grid;
    flex: 1;
    min-width: 0;
    gap: 3px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
  }
  .voice-title {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
  }
  .voice-name {
    overflow: hidden;
    font: 600 15px/1.2 var(--serif);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .voice-provider {
    flex: 0 0 auto;
    color: var(--faint);
    font: 10px/1.4 var(--mono);
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .voice-desc { color: var(--dim); font-size: 12px; line-height: 1.35; }
  .voice-use { color: var(--faint); font-size: 11.5px; line-height: 1.3; }

  @media (max-width: 680px) {
    .voice-grid { gap: 10px; }
    .voice-name { font-size: 14px; }
  }
