:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #101010;
  --panel-2: #171717;
  --text: #f7f7f7;
  --muted: #b7b7b7;
  --line: rgba(255, 255, 255, 0.14);
  --red: #ff0719;
  --good: #39d98a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1;
  --panel: #ffffff;
  --panel-2: #ecece7;
  --text: #111;
  --muted: #5d5d5d;
  --line: rgba(0, 0, 0, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.portal-login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 7, 25, 0.18), transparent 34%),
    #030303;
}

.login-shell {
  width: min(460px, 100%);
}

.login-panel,
.portal-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.login-panel {
  padding: 34px;
}

.login-panel img {
  width: 190px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  line-height: 1.06;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.15rem, 1.9vw, 1.65rem);
  line-height: 1.14;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 700;
}

.login-field {
  margin-bottom: 16px;
}

.login-field > label {
  margin-bottom: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  border-radius: 0;
}

textarea {
  resize: vertical;
}

.password-wrap {
  display: grid;
  grid-template-columns: 1fr 48px;
}

.password-wrap input {
  border-right: 0;
}

.eye-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.eye-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.portal-button,
.mode-toggle {
  border: 1px solid var(--red);
  background: var(--red);
  color: white;
  padding: 12px 16px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.portal-inline-button {
  display: inline-flex;
  margin-top: 4px;
  text-decoration: none;
}

.form-error,
.notice {
  border-left: 4px solid var(--red);
  padding: 12px;
  background: rgba(255, 7, 25, 0.1);
}

.notice-success {
  border-left-color: var(--good);
  background: rgba(57, 217, 138, 0.09);
}

.login-help {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.portal-app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100svh;
}

.control-bar {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  text-decoration: none;
}

.portal-brand img {
  width: 66px;
}

.control-bar nav {
  display: grid;
  gap: 10px;
  overflow-y: auto;
}

.control-bar nav a,
.bar-bottom a {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  text-decoration: none;
}

.control-bar nav a.active {
  border-color: rgba(255, 7, 25, 0.46);
  background: rgba(255, 7, 25, 0.11);
  color: var(--text);
}

.control-bar nav a.active::before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 3px;
  background: var(--red);
  content: "";
}

.main-site-link {
  border-color: var(--red) !important;
  background: var(--red);
  color: white;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.bar-bottom {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.portal-main {
  min-width: 0;
  padding: clamp(28px, 5vw, 64px);
}

.portal-top {
  margin-bottom: 34px;
}

.stat-grid,
.team-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-grid article,
.portal-card {
  padding: 24px;
}

.stat-grid span,
.portal-card p,
td {
  color: var(--muted);
}

.stat-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 2.1rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.pill {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid var(--line);
}

.pill.real {
  color: var(--good);
}

.pill.bot,
.text-danger {
  color: var(--red);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.portal-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.portal-card-heading h2,
.portal-card-heading p {
  margin-bottom: 0;
}

.portal-card-heading > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.user-create-card,
.user-database-card {
  margin-bottom: 20px;
}

.user-create-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.35fr) 150px minmax(190px, 1fr) minmax(190px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.user-create-form label {
  min-width: 0;
  margin: 0;
  font-size: 0.78rem;
}

.user-create-form .portal-button {
  min-height: 47px;
  white-space: nowrap;
}

.user-table {
  min-width: 860px;
}

.user-table td > strong,
.user-table td > small {
  display: block;
}

.user-table td > small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-secondary-button,
.portal-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 11px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.portal-text-button {
  border-color: transparent;
  color: var(--muted);
}

.portal-secondary-button:hover,
.portal-secondary-button:focus-visible,
.portal-text-button:hover,
.portal-text-button:focus-visible {
  border-color: var(--red);
  color: var(--text);
}

.portal-dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.portal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.portal-dialog > form > header,
.portal-dialog > form > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.portal-dialog > form > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.portal-dialog h2 {
  margin: 0;
  font-size: 1.05rem;
}

.portal-dialog header > button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.portal-dialog-body {
  padding: 20px 18px;
}

.portal-dialog-body p {
  color: var(--muted);
  line-height: 1.55;
}

.account-layout,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(380px, 1.3fr);
  gap: 20px;
  align-items: start;
}

.account-summary dl,
.ai-status-card dl {
  margin: 24px 0 0;
}

.account-summary dl div,
.ai-status-card dl div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.account-summary dt,
.ai-status-card dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.account-summary dd,
.ai-status-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.account-password-card form,
.ai-key-card form {
  max-width: 620px;
}

.settings-layout {
  grid-template-columns: minmax(260px, 0.75fr) minmax(380px, 1.25fr);
}

.ai-scope-card {
  grid-column: 1 / -1;
}

.ai-connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 18px;
}

.ai-connection-status i {
  width: 10px;
  height: 10px;
  background: #e5aa27;
  border-radius: 50%;
}

.ai-connection-status.connected i {
  background: var(--good);
}

.ai-key-card code {
  padding: 2px 5px;
  background: var(--panel-2);
  color: var(--text);
}

.ai-remove-form {
  margin-top: 18px;
}

.ai-access-check {
  margin-top: 12px;
}

/* Studio */
.portal-studio-page {
  --studio-red: #ff202c;
  --studio-green: #3ac474;
  --studio-amber: #e5aa27;
  --studio-line: rgba(255, 255, 255, 0.13);
  font-size: 14px;
}

[data-theme="light"] .portal-studio-page,
[data-theme="light"] body.portal-studio-page {
  --studio-line: rgba(0, 0, 0, 0.16);
}

.portal-studio-page .control-bar {
  gap: 20px;
  padding: 18px 16px;
}

.portal-studio-page .portal-brand img {
  width: 52px;
}

.portal-studio-page .control-bar nav {
  gap: 6px;
}

.portal-studio-page .control-bar nav a,
.portal-studio-page .bar-bottom a {
  padding: 10px 11px;
  font-size: 0.86rem;
}

.portal-studio-page .bar-bottom {
  gap: 8px;
}

.portal-studio-page .bar-bottom p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.portal-studio-page .mode-toggle {
  padding: 10px 11px;
  border-color: var(--studio-line);
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  text-align: left;
}

.portal-studio-page .portal-main {
  min-width: 0;
  padding: 0;
  overflow: clip;
}

.studio-shell {
  min-height: 100svh;
  background: var(--bg);
}

.studio-toolbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-toolbar h1 {
  flex: 0 0 auto;
  margin: 0 12px 0 0;
  font-size: 1.35rem;
  line-height: 1;
  text-transform: none;
}

.studio-project-switch {
  width: min(350px, 36vw);
}

.studio-project-switch label {
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.studio-project-switch select {
  height: 40px;
  padding: 0 36px 0 12px;
  border-color: var(--studio-line);
  background: var(--bg);
  font-size: 0.9rem;
}

.studio-icon-command {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid var(--studio-line);
  background: transparent;
  color: var(--studio-red);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.studio-icon-command:hover,
.studio-icon-command:focus-visible {
  border-color: var(--studio-red);
}

.studio-toolbar-spacer {
  flex: 1;
}

.studio-mode-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}

.studio-mode-status i {
  width: 7px;
  height: 7px;
  background: var(--studio-amber);
  border-radius: 50%;
}

.studio-mode-status.connected i {
  background: var(--studio-green);
}

.studio-save-status {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.studio-save-status.unsaved {
  color: var(--studio-amber);
  font-weight: 800;
}

.studio-toolbar .portal-button {
  min-height: 40px;
  padding: 0 16px;
  font-size: 0.78rem;
}

.studio-stage-tabs {
  min-height: 53px;
  display: grid;
  grid-template-columns: repeat(6, minmax(104px, 1fr));
  padding: 0 16px;
  border-bottom: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-stage-tabs a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.studio-stage-tabs a::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: transparent;
  content: "";
}

.studio-stage-tabs a.active {
  color: var(--studio-red);
}

.studio-stage-tabs a.active::after {
  background: var(--studio-red);
}

.studio-stage-tabs a span,
.studio-review-panel h2 span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  background: rgba(255, 32, 44, 0.2);
  color: var(--studio-red);
  border-radius: 50%;
  font-size: 0.7rem;
}

.studio-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  padding: 9px 18px;
  border-bottom: 1px solid rgba(58, 196, 116, 0.35);
  background: rgba(58, 196, 116, 0.09);
  color: var(--text);
  font-size: 0.84rem;
}

.studio-notice.error {
  border-color: rgba(255, 32, 44, 0.45);
  background: rgba(255, 32, 44, 0.09);
}

.studio-notice button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.studio-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.studio-canvas {
  min-width: 0;
  min-height: calc(100svh - 115px);
  padding: 16px;
  border-right: 1px solid var(--studio-line);
}

.studio-project-summary {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 104px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-summary-mark {
  width: 86px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 32, 44, 0.42);
  background: #070707;
  color: var(--studio-red);
  font-size: 1.4rem;
  font-weight: 900;
}

.studio-summary-image {
  width: 86px;
  height: 82px;
  border: 1px solid var(--studio-line);
  object-fit: cover;
}

.studio-project-summary h2,
.studio-section-heading h2,
.studio-inspector h2,
.studio-dialog h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  text-transform: none;
}

.studio-project-summary p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.studio-project-summary p strong {
  color: var(--studio-red);
}

.studio-project-meta {
  display: flex;
  gap: 0;
}

.studio-project-meta span + span::before {
  margin: 0 10px;
  color: var(--line);
  content: "|";
}

.studio-table-wrap {
  border: 1px solid var(--studio-line);
  background: var(--panel);
  overflow-x: auto;
}

.studio-shot-table {
  min-width: 880px;
  table-layout: fixed;
}

.studio-shot-table th,
.studio-shot-table td {
  padding: 10px 9px;
  border-color: var(--studio-line);
  color: var(--muted);
  font-size: 0.77rem;
}

.studio-shot-table thead th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.studio-shot-table th:nth-child(1) { width: 74px; }
.studio-shot-table th:nth-child(2) { width: 60px; }
.studio-shot-table th:nth-child(4) { width: 74px; }
.studio-shot-table th:nth-child(5) { width: 98px; }
.studio-shot-table th:nth-child(6) { width: 70px; }
.studio-shot-table th:nth-child(7) { width: 112px; }

.studio-shot-table tbody tr {
  cursor: pointer;
}

.studio-shot-table tbody tr:hover td,
.studio-shot-table tbody tr:hover th,
.studio-shot-table tbody tr.selected td,
.studio-shot-table tbody tr.selected th {
  background: rgba(255, 32, 44, 0.055);
}

.studio-shot-table tbody tr.selected td,
.studio-shot-table tbody tr.selected th {
  border-top-color: var(--studio-red);
  border-bottom-color: var(--studio-red);
}

.studio-shot-table tbody tr.selected td:first-of-type,
.studio-shot-table tbody tr.selected th:first-child {
  border-left: 1px solid var(--studio-red);
}

.studio-shot-table tbody tr.selected td:last-child {
  border-right: 1px solid var(--studio-red);
}

.studio-shot-table td:nth-child(2),
.studio-shot-table td strong {
  color: var(--text);
}

.studio-scene-cell {
  background: var(--bg);
  color: var(--text) !important;
  text-align: center;
}

.studio-scene-cell strong,
.studio-scene-cell span {
  display: block;
}

.studio-scene-cell strong {
  font-size: 1.1rem;
}

.studio-scene-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
}

.studio-shot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.studio-shot-status i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  background: var(--muted);
  border-radius: 50%;
}

.studio-shot-status.approved i { background: var(--studio-green); }
.studio-shot-status.review i { background: var(--studio-amber); }
.studio-shot-status.planned i { background: #8c8c8c; }

.studio-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.studio-text-command,
.studio-track-command {
  border: 0;
  background: transparent;
  color: var(--studio-red);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.studio-empty-row {
  height: 160px;
  color: var(--muted) !important;
  text-align: center;
}

.studio-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 6px 0 17px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-section-heading p {
  max-width: 650px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.studio-brief-form {
  max-width: 920px;
}

.studio-brief-form label,
.studio-dialog label {
  margin-bottom: 15px;
  color: var(--muted);
  font-size: 0.78rem;
}

.studio-brief-form input,
.studio-brief-form textarea,
.studio-brief-form select,
.studio-dialog input,
.studio-dialog textarea,
.studio-dialog select {
  min-height: 42px;
  padding: 10px 12px;
  border-color: var(--studio-line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.88rem;
}

.studio-brief-form textarea,
.studio-dialog textarea {
  line-height: 1.55;
}

.studio-story-input {
  min-height: 430px;
  max-height: 75svh;
}

.studio-music-field {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-music-field.is-hidden {
  display: none;
}

.studio-music-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.studio-music-heading strong,
.studio-music-heading small {
  display: block;
}

.studio-music-heading small,
.studio-music-field > p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.studio-music-heading output {
  color: var(--studio-red);
  font-weight: 900;
}

.studio-music-field audio {
  width: 100%;
  height: 42px;
  margin-bottom: 8px;
}

.studio-music-field label {
  margin: 13px 0 0;
}

.studio-columns.studio-columns-chat {
  grid-template-columns: minmax(0, 1fr);
}

.studio-columns.studio-columns-wide {
  grid-template-columns: minmax(0, 1fr);
}

.studio-columns-wide .studio-canvas {
  border-right: 0;
}

.studio-columns-chat .studio-canvas {
  padding: 0;
  border-right: 0;
}

.studio-director-workspace {
  height: calc(100svh - 130px);
  min-height: 540px;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  background: var(--panel);
  overflow: hidden;
}

.studio-notice + .studio-columns .studio-director-workspace {
  height: calc(100svh - 172px);
}

.studio-director-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-director-header h2 {
  margin: 2px 0 5px;
  font-size: 1.35rem;
  text-transform: none;
}

.studio-director-header p {
  margin: 0;
  color: var(--muted);
}

.studio-director-kicker {
  color: var(--studio-red) !important;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.studio-director-context {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.studio-director-context span,
.studio-director-context a {
  font-size: 0.76rem;
  font-weight: 800;
}

.studio-director-context span {
  color: var(--studio-green);
}

.studio-director-context a {
  color: var(--text);
}

.studio-generate-workspace {
  width: min(1460px, 100%);
  margin: 0 auto;
}

.studio-generate-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-generate-header h2 {
  margin: 2px 0 5px;
  font-size: 1.35rem;
  text-transform: none;
}

.studio-generate-header p {
  margin: 0;
  color: var(--muted);
}

.studio-generator-status,
.studio-refreshing,
.studio-render-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.studio-generator-status {
  margin-top: 7px;
  color: var(--muted);
}

.studio-generator-status i,
.studio-render-state i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--studio-amber);
}

.studio-generator-status.connected {
  color: var(--studio-green);
}

.studio-generator-status.connected i,
.studio-render-item.completed .studio-render-state i {
  background: var(--studio-green);
}

.studio-provider-alert {
  margin: 14px 0;
  padding: 11px 13px;
  border-left: 3px solid var(--studio-amber);
  background: rgba(229, 170, 39, 0.08);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.studio-provider-alert strong {
  color: var(--text);
}

.studio-generator-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(480px, 1.22fr);
  gap: 14px;
  align-items: start;
}

.studio-generator-panel,
.studio-render-panel {
  border: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-generator-panel > header,
.studio-render-panel > header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--studio-line);
  background: var(--panel-2);
}

.studio-generator-panel h3,
.studio-render-panel h3 {
  margin: 0;
  font-size: 0.95rem;
}

.studio-generator-panel header p,
.studio-render-panel header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.studio-generator-panel > header > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.studio-generator-form {
  padding: 15px;
}

.studio-generator-form > label {
  margin-bottom: 15px;
  color: var(--muted);
  font-size: 0.78rem;
}

.studio-generator-form textarea {
  min-height: 230px;
  max-height: 48svh;
  padding: 11px 12px;
  border-color: var(--studio-line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.55;
}

.studio-duration-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.studio-duration-control legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.studio-duration-control label {
  margin: 0;
  cursor: pointer;
}

.studio-duration-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.studio-duration-control span {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--studio-line);
  background: var(--panel-2);
}

.studio-duration-control strong,
.studio-duration-control small {
  display: block;
}

.studio-duration-control strong {
  color: var(--text);
  font-size: 0.84rem;
}

.studio-duration-control small {
  color: var(--muted);
  font-size: 0.7rem;
}

.studio-duration-control input:checked + span {
  border-color: var(--studio-red);
  box-shadow: inset 3px 0 0 var(--studio-red);
}

.studio-duration-control input:focus-visible + span {
  outline: 2px solid var(--studio-red);
  outline-offset: 2px;
}

.studio-render-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 13px;
  border: 1px solid var(--studio-line);
}

.studio-render-facts div {
  min-width: 0;
  padding: 9px 10px;
}

.studio-render-facts div + div {
  border-left: 1px solid var(--studio-line);
}

.studio-render-facts dt,
.studio-render-facts dd {
  margin: 0;
}

.studio-render-facts dt {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.studio-render-facts dd {
  margin-top: 4px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.studio-generator-limit {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.studio-paid-confirm {
  display: flex !important;
  align-items: flex-start;
  gap: 9px !important;
  margin-bottom: 13px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.studio-paid-confirm input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin-top: 1px;
  accent-color: var(--studio-red);
}

.studio-paid-confirm span {
  line-height: 1.45;
}

.studio-generate-button {
  width: 100%;
}

.studio-generate-button:disabled {
  border-color: var(--studio-line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: not-allowed;
}

.studio-refreshing {
  color: var(--studio-amber);
}

.studio-refreshing i {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: studio-spin 0.9s linear infinite;
}

@keyframes studio-spin {
  to { transform: rotate(360deg); }
}

.studio-render-empty {
  min-height: 240px;
  display: grid;
  place-content: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.studio-render-empty strong {
  color: var(--text);
}

.studio-render-empty p {
  max-width: 360px;
  margin: 7px 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
}

.studio-render-list {
  display: grid;
}

.studio-render-item {
  padding: 14px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-render-item:last-child {
  border-bottom: 0;
}

.studio-render-item > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 11px;
}

.studio-render-item > header > div {
  display: grid;
  gap: 4px;
}

.studio-render-item > header time,
.studio-render-item > header > strong {
  color: var(--muted);
  font-size: 0.69rem;
}

.studio-render-item.failed .studio-render-state {
  color: var(--studio-red);
}

.studio-render-item.failed .studio-render-state i {
  background: var(--studio-red);
}

.studio-render-item video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--studio-line);
  background: #000;
  object-fit: contain;
}

.studio-render-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
}

.studio-render-progress progress {
  width: 100%;
  height: 8px;
  border: 0;
  background: var(--panel-2);
  accent-color: var(--studio-red);
}

.studio-render-progress progress::-webkit-progress-bar { background: var(--panel-2); }
.studio-render-progress progress::-webkit-progress-value { background: var(--studio-red); }
.studio-render-progress progress::-moz-progress-bar { background: var(--studio-red); }

.studio-render-progress span {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
}

.studio-render-wait,
.studio-render-error {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.studio-render-error {
  padding: 10px;
  border-left: 3px solid var(--studio-red);
  background: rgba(255, 32, 44, 0.07);
}

.studio-download-button {
  display: inline-flex;
  margin-top: 10px;
  text-decoration: none;
}

.studio-render-prompt {
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.72rem;
}

.studio-render-prompt summary {
  width: max-content;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.studio-render-prompt p {
  margin: 9px 0 0;
  padding: 10px;
  background: var(--panel-2);
  line-height: 1.5;
}

.studio-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.studio-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 8px;
}

.studio-form-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.studio-form-actions .portal-button,
.studio-section-heading .portal-button {
  font-size: 0.75rem;
}

.studio-continuity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 33%);
  border: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-continuity-list {
  min-width: 0;
  border-right: 1px solid var(--studio-line);
}

.studio-filter-row {
  display: flex;
  gap: 2px;
  padding: 10px;
  border-bottom: 1px solid var(--studio-line);
  overflow-x: auto;
}

.studio-filter-row button,
.studio-inspector-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}

.studio-filter-row button.active,
.studio-inspector-tabs button.active {
  border-bottom-color: var(--studio-red);
  color: var(--text);
}

.studio-library-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--studio-line);
  text-decoration: none;
}

.studio-library-row:hover,
.studio-library-row.selected {
  background: rgba(255, 32, 44, 0.055);
}

.studio-library-row.selected {
  box-shadow: inset 3px 0 var(--studio-red);
}

.studio-library-row img,
.studio-reference-placeholder,
.studio-inspector-asset > img,
.studio-inspector-asset > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  object-fit: cover;
  border: 1px solid var(--studio-line);
  background: var(--panel-2);
  color: var(--studio-red);
  font-size: 0.72rem;
  font-weight: 900;
}

.studio-library-row > span:nth-child(2) {
  min-width: 0;
}

.studio-library-row strong,
.studio-library-row small {
  display: block;
}

.studio-library-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-library-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
}

.studio-library-row em {
  color: var(--studio-red);
  font-size: 0.69rem;
  font-style: normal;
  white-space: nowrap;
}

.studio-library-row em.approved {
  color: var(--studio-green);
}

.studio-asset-detail {
  padding: 18px;
}

.studio-detail-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  object-fit: cover;
  border: 1px solid var(--studio-line);
  background: var(--bg);
}

.studio-detail-image.placeholder {
  align-content: center;
  gap: 7px;
  color: var(--studio-red);
  font-size: 1.4rem;
  font-weight: 900;
}

.studio-detail-image.placeholder small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.studio-detail-type {
  margin: 17px 0 4px;
  color: var(--studio-red);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.studio-asset-detail h3 {
  margin: 0;
  font-size: 1.05rem;
}

.studio-asset-detail > p:not(.studio-detail-type) {
  margin: 10px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.studio-asset-detail dl {
  margin: 0 0 18px;
  border-top: 1px solid var(--studio-line);
}

.studio-asset-detail dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--studio-line);
}

.studio-asset-detail dt,
.studio-asset-detail dd {
  margin: 0;
  font-size: 0.73rem;
}

.studio-asset-detail dt { color: var(--muted); }
.studio-asset-detail dd { color: var(--text); text-align: right; }

.studio-secondary-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--studio-line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.studio-secondary-button:hover,
.studio-secondary-button:focus-visible {
  border-color: var(--studio-red);
}

.studio-review-count {
  color: var(--studio-red);
  font-size: 0.82rem;
}

.studio-review-list {
  border: 1px solid var(--studio-line);
  background: var(--panel);
}

.studio-review-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-review-row:last-child { border-bottom: 0; }
.studio-review-row.resolved { opacity: 0.58; }

.studio-issue-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--studio-red);
  color: var(--studio-red);
  border-radius: 50%;
  font-size: 0.76rem;
  font-weight: 900;
}

.studio-review-row h3,
.studio-review-row p {
  margin: 0;
}

.studio-review-row h3 { font-size: 0.86rem; }
.studio-review-row p { margin-top: 5px; color: var(--muted); font-size: 0.72rem; }
.studio-resolved-label { color: var(--studio-green); font-size: 0.75rem; font-weight: 800; }

.studio-empty-state {
  margin: 0;
  padding: 40px 20px;
  color: var(--muted);
  line-height: 1.55;
  text-align: center;
}

.studio-empty-state.compact {
  padding: 18px 12px;
  font-size: 0.76rem;
}

.studio-inspector {
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  background: var(--panel);
}

.studio-inspector-section {
  border-bottom: 1px solid var(--studio-line);
}

.studio-inspector-section > header {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}

.studio-inspector-section > header h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.83rem;
}

.studio-inspector-section > header > button {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--studio-red);
  font-size: 1.25rem;
  cursor: pointer;
}

.studio-inspector-section > header > a,
.studio-inspector-section > header > span {
  color: var(--muted);
  font-size: 0.69rem;
  text-decoration: none;
}

.studio-inspector-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--studio-line);
  border-bottom: 1px solid var(--studio-line);
}

.studio-inspector-tabs button {
  min-width: 0;
  padding-inline: 3px;
}

.studio-inspector-assets {
  max-height: 222px;
  overflow-y: auto;
}

.studio-inspector-asset {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--studio-line);
  text-decoration: none;
}

.studio-inspector-asset:hover,
.studio-inspector-asset.selected {
  background: rgba(255, 32, 44, 0.055);
}

.studio-inspector-asset.selected {
  box-shadow: inset 2px 0 var(--studio-red);
}

.studio-inspector-asset > img,
.studio-inspector-asset > span {
  width: 36px;
  height: 36px;
  font-size: 0.64rem;
}

.studio-inspector-asset strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-inspector-asset small {
  color: var(--studio-red);
  font-size: 0.64rem;
  white-space: nowrap;
}

.studio-inspector-asset small.approved { color: var(--studio-green); }

.studio-track-command {
  width: 100%;
  min-height: 40px;
  border-top: 1px solid var(--studio-line);
  font-size: 0.75rem;
}

.studio-inspector-issue {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 12px;
  border-top: 1px solid var(--studio-line);
  text-decoration: none;
}

.studio-inspector-issue > span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--studio-red);
  color: var(--studio-red);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 900;
}

.studio-inspector-issue strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.69rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-inspector-issue small {
  color: var(--muted);
  font-size: 0.62rem;
  white-space: nowrap;
}

.studio-chat-messages {
  max-height: 360px;
  padding: 0 10px 8px;
  overflow-y: auto;
}

.studio-chat-messages-full {
  width: min(980px, calc(100% - 48px));
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 0 auto;
  padding: 18px 0 28px;
}

.studio-chat-message {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--studio-line);
  background: var(--bg);
}

.studio-chat-message.assistant {
  border-left-color: var(--studio-red);
}

.studio-chat-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--studio-line);
  background: var(--panel-2);
  color: var(--studio-red);
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 900;
}

.studio-chat-message header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.studio-chat-message strong,
.studio-chat-message time {
  font-size: 0.67rem;
}

.studio-chat-message time {
  color: var(--muted);
}

.studio-chat-message p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.studio-chat-messages-full .studio-chat-message {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 13px;
  margin-top: 14px;
  padding: 16px;
}

.studio-chat-messages-full .studio-chat-message.user {
  width: min(82%, 760px);
  margin-left: auto;
  background: var(--panel-2);
}

.studio-chat-messages-full .studio-chat-message.assistant {
  width: min(88%, 840px);
}

.studio-chat-messages-full .studio-chat-avatar {
  width: 38px;
  height: 38px;
}

.studio-chat-messages-full .studio-chat-message strong,
.studio-chat-messages-full .studio-chat-message time {
  font-size: 0.76rem;
}

.studio-chat-messages-full .studio-chat-message p {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.65;
}

.studio-chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.studio-chat-header-actions small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
}

.studio-chat-header-actions a {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--studio-line);
  color: var(--text);
}

.studio-chat-header-actions svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.studio-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: end;
  gap: 0;
  padding: 10px;
  border-top: 1px solid var(--studio-line);
}

.studio-chat-form textarea {
  min-height: 72px;
  max-height: 240px;
  min-width: 0;
  padding: 11px 12px;
  border-color: var(--studio-line);
  background: var(--bg);
  font-size: 0.73rem;
  line-height: 1.5;
  resize: vertical;
}

.studio-chat-form button {
  width: 46px;
  height: 72px;
  border: 1px solid var(--studio-red);
  background: var(--studio-red);
  color: white;
  cursor: pointer;
}

.studio-chat-form-full {
  width: min(980px, calc(100% - 48px));
  grid-template-columns: minmax(0, 1fr) 58px;
  margin: 0 auto;
  padding: 18px 0 24px;
  border-top: 1px solid var(--studio-line);
}

.studio-chat-form-full textarea {
  min-height: 96px;
  max-height: 340px;
  padding: 15px 16px;
  background: var(--bg);
  font-size: 0.9rem;
}

.studio-chat-form-full button {
  width: 58px;
  height: 96px;
}

.studio-chat-form svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.studio-dialog {
  width: min(570px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
  overflow-y: auto;
}

[data-theme="light"] .studio-dialog {
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.studio-small-dialog { width: min(520px, calc(100vw - 32px)); }

.studio-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.studio-dialog > form > header,
.studio-dialog > form > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--studio-line);
}

.studio-dialog > form > header button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.35rem;
  cursor: pointer;
}

.studio-dialog-body {
  padding: 18px 16px 5px;
}

.studio-dialog > form > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--studio-line);
  border-bottom: 0;
}

.studio-dialog > form > footer .portal-button {
  font-size: 0.75rem;
}

.studio-dialog-cancel {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.studio-segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 15px;
  padding: 0;
  border: 1px solid var(--studio-line);
}

.studio-segmented-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.studio-segmented-control label {
  margin: 0;
}

.studio-segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.studio-segmented-control span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--studio-line);
  color: var(--muted);
  font-size: 0.73rem;
  cursor: pointer;
}

.studio-segmented-control label:last-child span { border-right: 0; }
.studio-segmented-control input:checked + span { background: var(--studio-red); color: white; }
.studio-segmented-control input:focus-visible + span { outline: 2px solid white; outline-offset: -3px; }

.studio-upload-control {
  position: relative;
  min-height: 78px;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

[data-theme="light"] .studio-upload-control { border-color: rgba(0, 0, 0, 0.3); }

.studio-upload-preview {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--studio-red);
  font-weight: 900;
  object-fit: cover;
}

.studio-upload-control strong,
.studio-upload-control small {
  display: block;
}

.studio-upload-control strong { color: var(--studio-red); font-size: 0.78rem; }
.studio-upload-control small { margin-top: 5px; color: var(--muted); font-size: 0.68rem; }

.studio-upload-control input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.studio-checkbox {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.studio-checkbox input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--studio-red);
}

.is-filtered-out {
  display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--studio-red);
  outline-offset: 2px;
}

@media (max-width: 1320px) {
  .studio-columns {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .studio-shot-table {
    min-width: 650px;
  }

  .studio-shot-table .studio-col-location,
  .studio-shot-table .studio-col-time {
    display: none;
  }

  .studio-shot-table th:nth-child(3) { width: auto; }
  .studio-shot-table th:nth-child(7) { width: 108px; }

  .studio-continuity-layout {
    grid-template-columns: 1fr;
  }

  .studio-continuity-list {
    border-right: 0;
    border-bottom: 1px solid var(--studio-line);
  }

  .studio-asset-detail {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    column-gap: 18px;
  }

  .studio-detail-image {
    grid-row: 1 / span 7;
  }
}

@media (max-width: 1040px) {
  .studio-columns {
    grid-template-columns: 1fr;
  }

  .studio-canvas {
    min-height: auto;
    border-right: 0;
  }

  .studio-inspector {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--studio-line);
  }

  .studio-chat-panel {
    grid-column: 1 / -1;
  }

  .studio-generator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .portal-studio-page .control-bar {
    position: relative;
    height: auto;
    min-width: 0;
    max-width: 100vw;
    padding: 12px;
  }

  .portal-studio-page .control-bar nav {
    display: flex;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .portal-studio-page .control-bar nav a {
    flex: 0 0 auto;
  }

  .portal-studio-page .bar-bottom {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    min-width: 0;
    max-width: 100%;
  }

  .portal-studio-page .bar-bottom p {
    text-align: center;
  }

  .studio-project-switch {
    width: min(310px, 46vw);
  }
}

@media (max-width: 640px) {
  .portal-studio-page .portal-brand img { width: 44px; }

  .portal-studio-page .bar-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .studio-toolbar {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .studio-toolbar h1 {
    flex: 1;
  }

  .studio-project-switch {
    order: 3;
    width: calc(100% - 52px);
  }

  .studio-toolbar-spacer,
  .studio-mode-status,
  .studio-save-status {
    display: none;
  }

  .studio-stage-tabs {
    grid-template-columns: repeat(6, minmax(96px, 1fr));
    padding: 0;
    overflow-x: auto;
  }

  .studio-stage-tabs a {
    min-height: 48px;
    padding: 0 10px;
  }

  .studio-canvas {
    padding: 12px;
  }

  .studio-project-summary {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 11px;
  }

  .studio-summary-mark {
    width: 58px;
    height: 68px;
    font-size: 1rem;
  }

  .studio-summary-image {
    width: 58px;
    height: 68px;
  }

  .studio-section-heading {
    align-items: flex-start;
  }

  .studio-generate-header {
    display: grid;
    gap: 10px;
  }

  .studio-generator-status {
    margin-top: 0;
  }

  .studio-render-facts {
    grid-template-columns: 1fr;
  }

  .studio-render-facts div + div {
    border-top: 1px solid var(--studio-line);
    border-left: 0;
  }

  .studio-generator-panel > header,
  .studio-render-panel > header,
  .studio-render-item > header {
    align-items: flex-start;
  }

  .studio-story-input {
    min-height: 340px;
  }

  .studio-director-workspace {
    height: calc(100svh - 170px);
    min-height: 520px;
    grid-template-rows: auto minmax(220px, 1fr) auto;
  }

  .studio-director-header {
    display: grid;
    padding: 18px 16px 14px;
  }

  .studio-chat-messages-full,
  .studio-chat-form-full {
    width: calc(100% - 24px);
  }

  .studio-chat-messages-full .studio-chat-message.user,
  .studio-chat-messages-full .studio-chat-message.assistant {
    width: 100%;
  }

  .studio-chat-form-full {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .studio-chat-form-full button {
    width: 52px;
  }

  .studio-field-row,
  .studio-inspector {
    grid-template-columns: 1fr;
  }

  .studio-chat-panel {
    grid-column: auto;
  }

  .studio-asset-detail {
    display: block;
  }

  .studio-detail-image {
    max-height: 240px;
  }

  .studio-library-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .studio-library-row em {
    grid-column: 2;
  }

  .studio-review-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .studio-review-row form,
  .studio-resolved-label {
    grid-column: 2;
    justify-self: start;
  }

  .studio-segmented-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .studio-segmented-control label:nth-child(2) span,
  .studio-segmented-control label:nth-child(3) span {
    border-bottom: 1px solid var(--studio-line);
  }
}

.editor-form {
  display: grid;
  gap: 6px;
}

.team-editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.team-thumb {
  width: min(220px, 100%);
  aspect-ratio: 1;
  object-fit: cover;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}

.text-danger {
  margin-top: 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

@media (max-width: 900px) {
  .portal-app {
    grid-template-columns: 1fr;
  }

  .control-bar {
    position: relative;
    height: auto;
    min-width: 0;
    max-width: 100vw;
  }

  .stat-grid,
  .team-editor-grid {
    grid-template-columns: 1fr;
  }

  .user-create-form,
  .account-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .ai-scope-card {
    grid-column: auto;
  }
}

@media (max-width: 1280px) and (min-width: 901px) {
  .user-create-form {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .user-create-form .portal-button {
    justify-self: start;
  }
}
