:root {
  color-scheme: light;
  --background: #DEDDD7;
  --ink: #594333;
  --muted: #AAA596;
  --olive: #646247;
  --copper: #B65E3D;
  --aubergine: #733D58;
  --surface: #F1F0ED;
  --button-text: #FFFFFF;
  --error: var(--aubergine);
  --wallpaper: url('/voice-studio-stone-olive.svg');
  font-family: "Avenir Next", Avenir, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--background);
  background-image: var(--wallpaper);
  background-repeat: repeat;
  background-size: 1200px 1200px;
  background-position: 0 0;
  min-height: 100%;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #382B24;
  --ink: #D4C8AE;
  --muted: #786750;
  --olive: #A3A078;
  --copper: #D58A63;
  --aubergine: #A25F86;
  --surface: #3E3028;
  --button-text: #382B24;
  --error: var(--copper);
  --wallpaper: url('/voice-studio-walnut.svg');
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --background: #382B24;
    --ink: #D4C8AE;
    --muted: #786750;
    --olive: #A3A078;
    --copper: #D58A63;
    --aubergine: #A25F86;
    --surface: #3E3028;
    --button-text: #382B24;
    --error: var(--copper);
    --wallpaper: url('/voice-studio-walnut.svg');
  }
}

:root {
  --reading-font: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --generation: #646247;
  --recording: #AD453F;
  --secondary-ink: #685F4C;
  --line: color-mix(in srgb, var(--ink) 25%, transparent);
  --layer: color-mix(in srgb, var(--surface) 90%, transparent);
  --avatar-lightness: 38%;
  --text-halo: 0 0 2px var(--background), 0 0 4px var(--background),
    0 0 4px var(--background), 0 0 8px var(--surface), 0 0 8px var(--surface),
    0 0 16px var(--surface), 0 0 24px var(--surface);
  --motion: 350ms;
}
:root[data-theme="dark"] { --generation: #7D885B; --recording: #C96358; --secondary-ink: #B8AD96; --avatar-lightness: 66%; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --generation: #7D885B; --recording: #C96358; --secondary-ink: #B8AD96; --avatar-lightness: 66%; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
.studio-layout { width: min(1380px, calc(100% - 80px)); margin: 64px auto 40px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 48px; }
main { min-width: 0; }
.studio-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
h1 { font: 500 clamp(34px, 3.3vw, 46px)/1.1 var(--reading-font); letter-spacing: -1px; margin: 0; }
h2 { margin: 0; font: 500 27px/1.2 var(--reading-font); }
h3 { font-size: 14px; font-weight: 500; }
.intro { color: var(--secondary-ink); margin: 10px 0 0; font-size: 16px; }
#workspace > .studio-header h1, #workspace > .studio-header .intro, #primary-label, .record-time, #record-status,
.speech-metrics, #estimate-note, #generation-hint, #status, footer { text-shadow: var(--text-halo); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button { border: 1px solid transparent; border-radius: 9px; padding: 11px 17px; font-size: 14px; font-weight: 600; background: var(--olive); color: var(--button-text); }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.quiet-control { background: transparent; color: var(--olive); padding-inline: 8px; }
a { color: var(--olive); text-underline-offset: 4px; }
.settings-link { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--olive); border-radius: 50%; border: 1px solid var(--line); background: var(--layer); }
.settings-link svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.setup-anchor { position: relative; }
.setup-highlight { outline: 2px solid var(--aubergine); outline-offset: 5px; }
.setup-callout { display: flex; align-items: flex-start; gap: 8px; padding: 10px 10px 10px 14px; border: 1px solid var(--aubergine); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 5px 18px #00000020; font-size: 13px; line-height: 1.5; }
.setup-callout p { margin: 0; }
.setup-callout button { flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; margin: -6px; background: transparent; color: var(--ink); font-size: 22px; }
.config-anchor .setup-callout { position: absolute; z-index: 2; top: calc(100% + 14px); right: 0; width: min(260px, calc(100vw - 32px)); }
.setup-callout::before { content: ""; position: absolute; width: 10px; height: 10px; border-top: 1px solid var(--aubergine); border-left: 1px solid var(--aubergine); background: var(--surface); transform: rotate(45deg); }
.config-anchor .setup-callout::before { top: -6px; right: 16px; }
.download-anchor .setup-callout { position: relative; margin-top: 16px; }
.download-anchor .setup-callout::before { top: -6px; left: 24px; }
.primary-control { display: flex; flex-direction: column; align-items: center; margin: 50px 0 30px auto; max-width: 760px; min-height: 196px; }
.primary-action { --action-color: var(--generation); position: relative; display: grid; place-items: center; width: 132px; height: 132px; padding: 0; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 75%, white); color: #FFF8E9; background: radial-gradient(circle at 35% 25%, #FFFFFF24, transparent 75%) var(--action-color); box-shadow: 0 0 0 17px color-mix(in srgb, var(--action-color) 16%, transparent), 0 0 0 34px color-mix(in srgb, var(--action-color) 8%, transparent), inset 0 1px 4px #FFFFFF30; transition: background-color 400ms ease-in-out, box-shadow 400ms ease-in-out, scale 160ms ease; }
.primary-action:hover { filter: none; scale: 1.025; }
.primary-action:active { scale: .98; }
.primary-action:disabled { opacity: .65; scale: 1; }
.primary-action svg:not([hidden]) { animation: action-icon-in 250ms ease-in-out; }
@keyframes action-icon-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.primary-action svg { grid-area: 1 / 1; width: 48px; height: 48px; fill: currentColor; }
#generate-icon { fill: none; stroke: currentColor; stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; }
#microphone-icon path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
#workspace[data-mode="recording-open"] .primary-action { --action-color: var(--recording); }
#primary-label { font-size: 15px; margin: 29px 0 0; }
.record-time { font-size: 19px; font-variant-numeric: tabular-nums; margin: 28px 0 0; }
#record-status { text-align: center; max-width: 52ch; margin: 4px 0 0; }
.voice-workspace, .composer, .result, #status, footer { width: 100%; max-width: 760px; margin-left: auto; margin-right: 0; }
.voice-workspace { border-block: 1px solid var(--line); background: var(--layer); border-radius: 12px 12px 3px 3px; }
.voice-selector, .new-voice, .voice-row { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; background: transparent; color: var(--ink); border: 0; border-radius: 0; font-weight: 500; padding: 17px 22px; min-height: 82px; }
.voice-selector { border-radius: 12px 12px 0 0; }
.voice-copy { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.voice-copy > span:first-child { overflow-wrap: anywhere; font-size: 16px; }
.voice-meta { font-size: 13px; color: var(--secondary-ink); font-weight: 400; }
.voice-avatar { display: grid; place-items: center; flex: 0 0 46px; height: 46px; border-radius: 50%; background: color-mix(in srgb, var(--olive) 70%, var(--surface)); color: var(--background); font-size: 25px; }
.voice-avatar.voice-color { background: hsl(var(--voice-hue) 30% var(--avatar-lightness)); }
.voice-avatar[data-voice-hue="0"] { --voice-hue: 0; }
.voice-avatar[data-voice-hue="30"] { --voice-hue: 30; }
.voice-avatar[data-voice-hue="60"] { --voice-hue: 60; }
.voice-avatar[data-voice-hue="90"] { --voice-hue: 90; }
.voice-avatar[data-voice-hue="120"] { --voice-hue: 120; }
.voice-avatar[data-voice-hue="150"] { --voice-hue: 150; }
.voice-avatar[data-voice-hue="180"] { --voice-hue: 180; }
.voice-avatar[data-voice-hue="210"] { --voice-hue: 210; }
.voice-avatar[data-voice-hue="240"] { --voice-hue: 240; }
.voice-avatar[data-voice-hue="270"] { --voice-hue: 270; }
.voice-avatar[data-voice-hue="300"] { --voice-hue: 300; }
.voice-avatar[data-voice-hue="330"] { --voice-hue: 330; }
.voice-avatar svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; fill: none; }
.new-avatar { font-size: 32px; font-weight: 400; }
.disclosure { flex: 0 0 22px; width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.7; fill: none; transition: transform var(--motion) ease-in-out; }
.voice-selector[aria-expanded="true"] .disclosure, .new-voice[aria-expanded="true"] .disclosure { transform: rotate(180deg); }
.voice-drawer { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--motion) ease-in-out; }
#workspace:not([data-mode="generator-closed"]) .voice-drawer { grid-template-rows: 1fr; }
.drawer-content { min-height: 0; overflow: hidden; }
.new-voice { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--olive) 6%, transparent); }
.new-voice[aria-expanded="true"] { background: color-mix(in srgb, var(--olive) 10%, transparent); }
.voice-layers { display: grid; position: relative; isolation: isolate; }
.voice-list, .script-sheet { grid-area: 1 / 1; min-width: 0; }
.voice-list { max-height: 420px; overflow-y: auto; scrollbar-width: thin; }
.voice-row { border-top: 1px solid var(--line); }
.voice-row[aria-pressed="true"] { background: color-mix(in srgb, var(--olive) 10%, transparent); }
.voice-row:hover { background: color-mix(in srgb, var(--olive) 8%, transparent); }
.voice-check { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--olive); color: var(--button-text); }
.voice-empty { padding: 20px 22px; margin: 0; color: var(--secondary-ink); font-size: 14px; }
.script-sheet { z-index: 1; display: grid; grid-template-rows: 0fr; align-self: start; box-shadow: 0 12px 18px -14px #00000080; visibility: hidden; transition: grid-template-rows 440ms cubic-bezier(.4, 0, .2, 1), visibility 440ms; }
#workspace[data-mode="recording-open"] .script-sheet { grid-template-rows: 1fr; visibility: visible; }
.script-sheet-clip { min-height: 0; overflow: hidden; }
.script-sheet-content { padding: 24px; background: var(--surface); border-top: 1px solid var(--line); }
.script-navigation { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px; font-size: 14px; }
#script-position { margin-right: auto; }
.round-control { display: grid; place-items: center; padding: 0; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 30px; line-height: 1; font-weight: 400; }
.script-dots { display: flex; gap: 0; }
.script-dots button { padding: 0; width: 28px; height: 44px; background: transparent; display: grid; place-items: center; }
.script-dots button::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 30%, transparent); }
.script-dots button[aria-current="true"]::after { background: var(--olive); }
.script-dots .custom-script-indicator::after { content: none; }
.custom-script-indicator svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.script-dots .custom-script-indicator { color: color-mix(in srgb, var(--ink) 45%, transparent); }
.script-dots .custom-script-indicator[aria-current="true"] { color: var(--olive); }
.script-reading { touch-action: pan-y; }
.script-pages { display: grid; position: relative; }
#script-text, .script-measure, #custom-script { font: 400 clamp(23px, 2.15vw, 29px)/1.5 var(--reading-font); margin: 0; max-width: 64ch; }
#script-text, .script-measure { grid-area: 1 / 1; }
.script-measure { visibility: hidden; pointer-events: none; }
#custom-script { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; resize: none; }
.script-duration { display: block; text-align: right; color: var(--secondary-ink); font-size: 13px; margin-top: 16px; }
.record-guidance { margin-top: 20px; max-width: 68ch; }
.recording-review { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 4px; }
.upload-options { margin-top: 18px; }
summary { cursor: pointer; min-height: 44px; padding: 12px 0; color: var(--olive); font-size: 14px; }
label { display: block; font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); accent-color: var(--olive); }
textarea { resize: vertical; line-height: 1.65; }
input::placeholder, textarea::placeholder { color: var(--secondary-ink); opacity: 1; }
.composer { display: grid; grid-template-rows: 1fr; margin-top: 20px; opacity: 1; transition: grid-template-rows 400ms ease-in-out, margin-top 400ms ease-in-out, opacity 200ms ease-in-out; }
.composer-content { overflow: hidden; min-height: 0; }
#workspace[data-mode="recording-open"] .composer { grid-template-rows: 0fr; margin-top: 0; opacity: 0; }
.primary-action[data-generation="pending"], .primary-action[data-generation="running"] { border-style: dashed; }
#speech { background: var(--layer); min-height: 230px; padding: 20px 22px; font-size: 17px; border-radius: 3px 3px 12px 12px; }
.speech-metrics { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 14px; margin-top: 12px; }
.speech-metrics strong { font-weight: 500; color: var(--ink); }
.hint, footer, #status, #voice-status, #config-status { color: var(--secondary-ink); font-size: 13px; line-height: 1.6; }
#estimate-note, #generation-hint { margin: 5px 0; }
#status { min-height: 21px; margin-top: 14px; }
#voice-status:empty { display: none; }
.error { color: var(--error) !important; }
.actions, .dialog-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.actions { margin-top: 16px; }
.dialog-header { justify-content: space-between; }
audio { width: 100%; display: block; margin: 16px 0; }
.result { background: var(--layer); padding: 12px 20px 20px; border-radius: 10px; margin-top: 16px; }
footer { text-align: center; margin-top: 30px; }
dialog { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; padding: 28px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 80px #00000033; max-height: calc(100dvh - 40px); }
dialog::backdrop { background: #00000066; }
button.icon { background: transparent; color: var(--ink); font-size: 26px; padding: 0 6px; min-width: 44px; min-height: 44px; }
:focus-visible { outline: 3px solid var(--olive); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#queue-panel { position: sticky; top: 28px; width: 100%; background: var(--layer); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 14px 35px #00000017; }
.queue-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 18px; gap: 12px; }
.queue-header button { min-height: 30px; padding: 4px 12px; font-size: 13px; }
#queue-count { font: 400 13px/1.2 "Avenir Next", system-ui, sans-serif; color: var(--secondary-ink); }
#queue-body { padding: 0 18px 16px; max-height: calc(100dvh - 170px); overflow-y: auto; }
#queue-panel.collapsed #queue-body, #queue-panel.collapsed #selection-toolbar { display: none; }
#queue-body h3 { margin: 16px 0 8px; color: var(--ink); }
#queue-body h3 span { float: right; color: var(--secondary-ink); }
.job-card { padding: 13px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.job-card p { margin: 0 0 5px; }
.job-title { font-size: 13px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job-detail, .job-status { font-size: 12px; color: var(--secondary-ink); line-height: 1.5; }
.job-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 12px; }
.job-actions button { font-size: 12px; padding: 5px 12px; min-height: 44px; }
.job-actions .job-play { min-height: 30px; padding-block: 3px; }
.job-card progress { width: 100%; height: 5px; accent-color: var(--olive); }
#more-jobs, #recent-jobs { margin-top: 12px; }
#selection-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, auto); align-items: center; gap: 6px; padding: 0 18px; }
#selection-toolbar button { padding: 8px; font-size: 12px; min-height: 44px; }
#selection-count { font-size: 12px; }
#selection-toolbar svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#selection-hint { grid-column: 1 / -1; margin: 0; }
#selection-hint:empty { display: none; }
.job-card.selectable { user-select: none; cursor: pointer; border-radius: 6px; }
.job-card.selected { background: color-mix(in srgb, var(--olive) 10%, transparent); box-shadow: inset 3px 0 var(--olive); padding-left: 10px; }
@media (max-width: 1129px) {
  .studio-layout { max-width: 820px; width: calc(100% - 48px); grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 32px; }
  #queue-panel { position: static; }
  #queue-body { max-height: 65dvh; }
}
@media (max-width: 540px) {
  .studio-layout { width: calc(100% - 32px); margin-top: 26px; }
  .studio-header { gap: 12px; align-items: flex-start; }
  .intro { font-size: 14px; max-width: 28ch; }
  .primary-control { margin-top: 48px; }
  .voice-selector, .new-voice, .voice-row { padding: 15px 14px; gap: 12px; }
  .script-sheet-content { padding-inline: 18px; }
  .script-navigation { gap: 4px; flex-wrap: wrap; }
  #script-position { font-size: 13px; }
  #script-text, .script-measure, #custom-script { font-size: 24px; line-height: 1.45; }
  .script-dots button { width: 24px; }
  .speech-metrics { justify-content: flex-start; }
  #speech { padding: 17px; }
  dialog { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
