:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --text: #243127;
  --muted: #667064;
  --line: #d9ded4;
  --primary: #2f6b4f;
  --primary-dark: #214d39;
  --accent: #b88b4a;
  --danger: #a33b32;
}

/* Design System Foundation v1 (PR #341): opt-in semantic tokens and primitives.
   Existing page-scoped tokens and selectors remain the compatibility layer. */
:root {
  --ds-color-app-background: var(--bg);
  --ds-color-surface: var(--panel);
  --ds-color-surface-elevated: #ffffff;
  --ds-color-border: var(--line);
  --ds-color-text: var(--text);
  --ds-color-text-muted: var(--muted);
  --ds-color-primary: var(--primary);
  --ds-color-primary-hover: var(--primary-dark);
  --ds-color-accent: var(--accent);
  --ds-color-success: #2f6b4f;
  --ds-color-success-surface: #f8faf6;
  --ds-color-success-border: #e2e8de;
  --ds-color-warning: #6f5520;
  --ds-color-warning-surface: #fff9ed;
  --ds-color-warning-border: #e7d7b2;
  --ds-color-info: #2f4f63;
  --ds-color-info-surface: #f3f7fa;
  --ds-color-info-border: #cbdde8;
  --ds-color-danger: var(--danger);
  --ds-color-danger-surface: #fff7f4;
  --ds-color-danger-border: #e4b0a5;
  --ds-color-focus: var(--primary);
  --ds-color-disabled-background: #f0f2ed;
  --ds-color-disabled-text: var(--muted);
  --ds-color-selected-surface: #eaf3e5;
  --ds-color-selected-border: var(--primary);
  --ds-space-xs: 4px;
  --ds-space-sm: 8px;
  --ds-space-md: 12px;
  --ds-space-lg: 16px;
  --ds-space-xl: 24px;
  --ds-radius-control: 8px;
  --ds-radius-surface: 14px;
  --ds-radius-pill: 999px;
  --ds-font-size-page-title: 28px;
  --ds-font-size-section-title: 20px;
  --ds-font-size-card-title: 17px;
  --ds-font-size-body: 16px;
  --ds-font-size-muted: 13px;
  --ds-font-size-label: 12px;
  --ds-font-weight-heading: 800;
  --ds-line-height-body: 1.6;
  --ds-shadow-surface: 0 1px 2px rgba(32, 46, 28, .04);
}
.ds-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ds-space-lg); }
.ds-section { display: grid; gap: var(--ds-space-xl); }
.ds-surface { background: var(--ds-color-surface); border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-surface); box-shadow: var(--ds-shadow-surface); }
.ds-action-row { display: flex; flex-wrap: wrap; gap: var(--ds-space-sm); }
.ds-help-text { margin: var(--ds-space-sm) 0 0; color: var(--ds-color-text-muted); line-height: var(--ds-line-height-body); }
.ds-eyebrow,
.dashboard-eyebrow,
.dashboard-panel-eyebrow { margin: 0 0 var(--ds-space-xs); color: var(--ds-color-primary); font-size: var(--ds-font-size-label); font-weight: var(--ds-font-weight-heading); letter-spacing: .08em; }
.ds-status { border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-control); }
.ds-status--info { background: var(--ds-color-info-surface); border-color: var(--ds-color-info-border); }
.ds-status--success { background: var(--ds-color-success-surface); border-color: var(--ds-color-success-border); }
.ds-status--warning { background: var(--ds-color-warning-surface); border-color: var(--ds-color-warning-border); }
.ds-status--danger { background: var(--ds-color-danger-surface); border-color: var(--ds-color-danger-border); }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}
a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-logo {
  display: block;
  width: auto;
  height: 32px;
  max-width: 160px;
  flex: 0 0 auto;
}
.brand-text { display: inline-block; }
nav { display: flex; flex-wrap: wrap; gap: 10px; }
nav a, .button, button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
button.primary, .button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover, .button.primary:hover { background: var(--primary-dark); }
button.subtle-danger, .button.subtle-danger {
  background: #fff8f4;
  border-color: #e5c8bd;
  color: var(--danger);
}
button.archive-button, .button.archive-button {
  background: #f7f7f4;
  border-color: #d8ded5;
  color: #5f6b5a;
}
.container { max-width: 1180px; margin: 0 auto; padding: 28px; }
.container.container-wide {
  width: 100%;
  max-width: 1600px;
}
.container.container-library {
  width: 100%;
  max-width: none;
  padding: 0;
}

/* Library asset management workspaces are page scoped so their wider cards,
   filter controls, and transparent previews do not alter other Library views. */
.container-library .library-asset-management {
  width: 100%;
  min-width: 0;
}
/* The BGM Library is the only management route allowed to leave the shared
   1600px workspace cap. Keep other Management pages on their existing width. */
.container-library .studio-management-workspace:has(> .library-asset-management--bgm) {
  max-width: none;
}
.container-library .library-asset-management--bgm .library-asset-management__filters--bgm {
  max-width: 1200px;
}
.container-library .library-asset-management__heading {
  font-size: 28px;
  margin: 0 0 18px;
  overflow-wrap: anywhere;
}
.container-library .library-asset-management .page-actions {
  margin: 0 0 16px;
}
.container-library .library-asset-management .field-help {
  color: var(--ds-color-text-muted, var(--muted));
}
.container-library .library-asset-management__toolbar {
  display: grid;
  gap: 14px;
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 12px;
  background: var(--ds-color-surface, var(--panel));
}
.container-library .library-asset-management__filters {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(150px, 1fr) minmax(145px, 1fr) auto;
  gap: 12px;
  align-items: end;
  min-width: 0;
  margin: 0;
}
.container-library .library-asset-management__filters--presentation {
  grid-template-columns: minmax(180px, 2fr) minmax(145px, 1fr) minmax(0, 2fr) auto;
}
.container-library .library-asset-management__filters--visual {
  grid-template-columns: minmax(180px, 2fr) minmax(150px, 1fr) minmax(145px, 1fr) auto;
}
.container-library .library-asset-management__filters > label,
.container-library .library-asset-management__advanced-fields > label {
  min-width: 0;
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management__filters input,
.container-library .library-asset-management__filters select {
  min-width: 0;
  min-height: 44px;
}
.container-library .library-asset-management__advanced-filters {
  min-width: 0;
  align-self: end;
}
.container-library .library-asset-management__advanced-filters summary {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 8px;
  color: var(--ds-color-text, var(--text));
  font-weight: 700;
  cursor: pointer;
}
.container-library .library-asset-management__advanced-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  grid-column: 1 / -1;
  margin-top: 12px;
}
.container-library .library-asset-management__filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.container-library .library-asset-management__filter-actions > * {
  min-height: 44px;
  white-space: nowrap;
}
.container-library .library-asset-management__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.container-library .library-asset-management__chips a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 999px;
  background: var(--ds-color-selected-surface, #eaf3e5);
  color: var(--ds-color-text, var(--text));
  text-decoration: none;
}
.container-library .library-asset-management__chips a:focus-visible,
.container-library .library-asset-management__advanced-filters summary:focus-visible {
  outline: 3px solid var(--ds-color-focus-ring, #25845d);
  outline-offset: 2px;
}
.container-library .library-asset-management__count {
  margin: 0;
  color: var(--ds-color-text-muted, var(--muted));
}
.container-library .library-asset-management__count strong {
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management__empty {
  padding: 24px;
  border: 1px dashed var(--ds-color-border, var(--line));
  border-radius: 12px;
  background: var(--ds-color-surface, var(--panel));
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management__empty h2,
.container-library .library-asset-management__empty p {
  margin-top: 0;
}
.container-library .library-asset-management__grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}
/* 420px leaves about 382px inside the card for a full-width audio player and
   an action row built from two ~120px buttons, a 110px sort field, and gaps. */
.container-library .library-asset-management--bgm .library-asset-management__grid--bgm {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
}
.container-library .library-asset-management__grid--presentation,
.container-library .library-asset-management__grid--visual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.container-library .library-asset-management__card {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 12px;
  background: var(--ds-color-surface, var(--panel));
  color: var(--ds-color-text, var(--text));
  box-shadow: 0 2px 8px rgba(20, 30, 22, .08);
}
.container-library .library-asset-management__card h2 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management__card-heading {
  min-width: 0;
}
.container-library .library-asset-management__metadata,
.container-library .library-asset-management__status {
  margin: 7px 0 0;
  color: var(--ds-color-text-muted, var(--muted));
  overflow-wrap: anywhere;
}
.container-library .library-asset-management__status strong {
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(140px, 1fr);
  grid-template-areas:
    "heading status"
    "audio audio"
    "prompt prompt"
    "actions actions";
  gap: 12px 16px;
  align-content: start;
  align-items: start;
  width: 100%;
  max-width: none;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > .library-asset-management__card-heading {
  grid-area: heading;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > audio,
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > .field-help:not(.library-asset-management__prompt) {
  grid-area: audio;
  min-width: 0;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > .library-asset-management__status {
  grid-area: status;
  min-width: 0;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > .library-asset-management__prompt {
  grid-area: prompt;
  min-width: 0;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm > .library-asset-management__actions {
  grid-area: actions;
  min-width: 0;
}
.container-library .library-asset-management--bgm .library-asset-management__card--bgm audio {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.container-library .library-asset-management__prompt,
.container-library .library-asset-management__card--bgm > .library-asset-management__actions {
  grid-column: 1 / -1;
  min-width: 0;
}
.container-library .library-asset-management__prompt summary {
  min-height: 44px;
  padding: 10px 0;
  font-weight: 700;
  cursor: pointer;
}
.container-library .library-asset-management__prompt textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  margin: 0 0 10px;
}
.container-library .library-asset-management__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, .8fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  min-width: 0;
  margin: 8px 0 0;
}
.container-library .library-asset-management__actions > button {
  min-width: 0;
  min-height: 44px;
  padding-inline: 10px;
  overflow-wrap: anywhere;
}
.container-library .library-asset-management__actions > label {
  min-width: 0;
  color: var(--ds-color-text, var(--text));
}
.container-library .library-asset-management__actions input[type="number"] {
  min-width: 0;
  min-height: 44px;
}
.container-library .library-asset-management--bgm .library-asset-management__actions input[type="number"] {
  width: 100%;
}
.container-library .library-asset-management__preview-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  justify-content: start;
  width: min(100%, 374px);
  margin-top: 14px;
}
.container-library .library-asset-management__preview-pair figure {
  min-width: 0;
  max-width: 180px;
  margin: 0;
}
.container-library .library-asset-management__preview-pair img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 8px;
  background-color: #252a28;
  background-image: linear-gradient(45deg, #414744 25%, transparent 25%), linear-gradient(-45deg, #414744 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #414744 75%), linear-gradient(-45deg, transparent 75%, #414744 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.container-library .library-asset-management__preview-pair figcaption,
.container-library .library-asset-management__visual-preview figcaption {
  margin-top: 6px;
  color: var(--ds-color-text-muted, var(--muted));
  font-size: .9rem;
  text-align: center;
}
.container-library .library-asset-management__visual-preview {
  margin: 14px 0 0;
}
.container-library .library-asset-management__visual-preview-stage {
  width: min(100%, 270px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 10px;
  background-color: #f4f5f2;
  background-image: linear-gradient(45deg, #d8ddd8 25%, transparent 25%), linear-gradient(-45deg, #d8ddd8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d8ddd8 75%), linear-gradient(-45deg, transparent 75%, #d8ddd8 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}
.container-library .library-asset-management__visual-preview-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.container-library .library-asset-management__card--visual .library-asset-management__status {
  margin-top: 14px;
}

@media (min-width: 1700px) {
  .container-library .library-asset-management__grid--presentation,
  .container-library .library-asset-management__grid--visual {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Preserve a maximum of three BGM columns once a fourth 420px track could fit. */
@media (min-width: 2074px) {
  .container-library .library-asset-management--bgm .library-asset-management__grid--bgm {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .container-library .library-asset-management__toolbar {
    padding: 14px;
  }
  .container-library .library-asset-management__filters,
  .container-library .library-asset-management__filters--presentation,
  .container-library .library-asset-management__filters--visual,
  .container-library .library-asset-management__advanced-fields,
  .container-library .library-asset-management__grid--presentation,
  .container-library .library-asset-management__grid--visual {
    grid-template-columns: minmax(0, 1fr);
  }
  .container-library .library-asset-management__advanced-filters,
  .container-library .library-asset-management__filter-actions {
    grid-column: 1 / -1;
  }
  .container-library .library-asset-management__filter-actions > * {
    flex: 1 1 150px;
  }
  .container-library .library-asset-management--bgm .library-asset-management__card--bgm {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "status"
      "audio"
      "prompt"
      "actions";
  }
  .container-library .library-asset-management__preview-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .container-library .library-asset-management__actions {
    grid-template-columns: minmax(0, 1fr);
  }
  .container-library .library-asset-management__actions > button {
    width: 100%;
  }
}
.container-library > .flash {
  margin: 16px clamp(24px, 2.5vw, 48px) 0 calc(250px + clamp(24px, 2.5vw, 48px));
}
@media (max-width: 1100px) {
  .container-library > .flash {
    margin: 16px 24px 0;
  }
}
h1 { font-size: 28px; margin: 0 0 22px; }
h2 { font-size: 18px; margin: 10px 0 6px; }
.auth-panel { max-width: 440px; margin: 60px auto; background: var(--panel); padding: 28px; border: 1px solid var(--line); border-radius: 8px; }
.form { display: grid; gap: 18px; }
.form.wide { max-width: 820px; }
label { display: grid; gap: 7px; font-weight: 700; }
.bulk-apply-mode-options {
  display: grid;
  gap: 10px;
}

.bulk-apply-mode-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  cursor: pointer;
}

.bulk-apply-mode-option input[type="radio"] {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
}

.bulk-apply-mode-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bulk-apply-mode .form-help {
  margin: 12px 0 0;
}

input[type="number"][name="captured_year"], input.my-history-year-input, input[type="text"], input[type="password"], input[type="file"], input[type="search"], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
.form-help {
  margin: -6px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f4;
  color: var(--muted);
  font-size: 0.92rem;
}
.field-help {
  display: block;
  margin-top: 4px;
  margin-bottom: 10px;
  color: #626a60;
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 500;
}
.checkbox-field {
  display: block;
  width: 100%;
  min-width: 0;
}
.checkbox-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  margin: 0;
  padding: 8px 12px;
  background: #eef3ea;
  border-radius: 8px;
  font-weight: 700;
}
.checkbox-main span {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.checkbox-help {
  display: block;
  margin-top: 4px;
  margin-bottom: 10px;
  margin-left: 42px;
  width: calc(100% - 42px);
  max-width: calc(100% - 42px);
  overflow-wrap: anywhere;
  color: #626a60;
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 500;
}
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
legend { font-weight: 700; padding: 0 8px; }
.tag-fieldset {
  display: grid;
  gap: 12px;
}
.tag-group-list {
  display: grid;
  gap: 12px;
}
.tag-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #f7f7f4;
}
.tag-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.tag-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-grid label, .check-row, .select-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  background: #eef3ea;
  border-radius: 8px;
}
input[type="checkbox"] { width: 22px; height: 22px; }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; background: #eef3ea; border: 1px solid var(--line); }
.flash.error { color: var(--danger); background: #fff2ef; }
.flash.success { color: var(--primary-dark); }
.flash.warning { color: #6f5520; background: #fff8df; border-color: #e2c779; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; text-decoration: none; }
.stat strong { display: block; font-size: 34px; color: var(--primary); }
.actions, .list-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0; align-items: center; }

.media-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 16px;
  max-width: 100%;
}
.media-filter-chips__label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}
.media-filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f7f2;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.media-filter-chip:hover,
.media-filter-chip:focus-visible {
  border-color: var(--accent);
  background: #eef6ea;
}
.upload-complete {
  display: grid;
  gap: 14px;
  max-width: 920px;
  margin: 0 0 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.upload-complete h2 {
  margin: 0;
}
.upload-complete p {
  margin: 0;
  color: var(--muted);
}
.upload-complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.upload-complete-actions .action-main {
  font-size: 1.02rem;
  padding-inline: 20px;
}
.uploaded-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.uploaded-preview-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fff;
}
.uploaded-preview-media {
  width: 100%;
  height: 120px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f5f1;
  color: var(--muted);
  font-weight: 800;
}
.uploaded-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.uploaded-preview-name {
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.uploaded-preview-meta {
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}
.uploaded-preview-memo {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}
.upload-preview {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.upload-preview h2 {
  margin: 0;
  font-size: 18px;
}
.upload-preview-empty {
  padding: 18px;
  border-radius: 8px;
  background: #f7f7f4;
  color: var(--muted);
}
.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
  max-width: 100%;
}
.upload-preview-card {
  border: 1px solid #d8ded5;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  box-sizing: border-box;
  max-width: 220px;
}
.upload-preview-media {
  width: 100%;
  height: 120px;
  border-radius: 10px;
  background: #f3f5f1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
  cursor: zoom-in;
}
.upload-preview-media img,
.upload-preview-media video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.upload-preview-media video {
  background: #111;
}
.upload-preview-unavailable {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  box-sizing: border-box;
  color: #5f6b5a;
  font-weight: 700;
  font-size: 0.85rem;
  background: #f3f5f1;
}
.upload-preview-name {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-all;
}
.upload-preview-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #666;
}
.upload-lightbox[hidden] { display: none; }
.upload-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}
.upload-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}
.upload-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: min(88vh, 900px);
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.upload-lightbox-panel h2 {
  margin: 0;
  padding-right: 46px;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.upload-lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 44px;
  padding: 8px 12px;
  font-size: 24px;
  line-height: 1;
}
.upload-lightbox-body {
  display: grid;
  place-items: center;
  min-height: 240px;
  max-height: 80vh;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}
.upload-lightbox-body img,
.upload-lightbox-body video {
  width: 100%;
  height: 100%;
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}
.upload-lightbox-unavailable {
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #fff;
  text-align: center;
  font-weight: 800;
}
body.has-upload-lightbox { overflow: hidden; }
.job-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; align-items: center; }
.job-action-form { display: inline-flex; margin: 0; }
.job-status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}
.reel-mode-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}
.reel-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid #c7d3c8;
  border-radius: 999px;
  background: #f3f7f2;
  color: #31553c;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.reel-mode-before_after {
  border-color: #d8c8a8;
  background: #fff8e8;
  color: #76561e;
}
.reel-mode-time_series {
  border-color: #bfd0df;
  background: #eff6fc;
  color: #315b7d;
}
.reel-mode-unknown {
  border-color: #d6d6d0;
  background: #f7f7f4;
  color: var(--muted);
}
.job-filter-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(150px, 190px)) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.archive-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}
.job-status-chip {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}
.job-status-chip span {
  color: var(--muted);
  font-weight: 800;
}
.job-status-chip strong {
  color: var(--text);
}
.job-status-chip.active {
  border-color: var(--primary);
  background: #eef3ea;
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}
.job-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
}
.job-card-header h2 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.job-state-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f7f4;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.2;
}
.job-state-ready {
  border-color: #d6c58b;
  background: #fff9df;
  color: #7a5a0a;
}
.job-state-processing {
  border-color: #c2d6e8;
  background: #edf6ff;
  color: #285a83;
}
.job-state-done {
  border-color: #bad7c4;
  background: #edf8f0;
  color: var(--primary-dark);
}
.job-state-failed {
  border-color: #e8b8ad;
  background: #fff0ed;
  color: var(--danger);
}
.job-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.job-meta-list div {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  font-size: 0.88rem;
}
.job-meta-list dt {
  color: var(--muted);
  font-weight: 800;
}
.job-meta-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}
.job-result-box,
.job-failure-box {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}
.job-result-box {
  border-color: #bad7c4;
  background: #f4faf5;
}
.job-failure-box {
  border-color: #e8b8ad;
  background: #fff8f6;
}
.job-section-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}
.job-result-actions {
  margin: 0;
}
.job-error-message {
  max-height: 13em;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.job-card.archived {
  background: #fbfaf6;
}
.archive-badge {
  background: #eef3ea;
  color: var(--primary-dark);
}
.job-motion-summary {
  margin: 12px 0;
  padding: 9px 11px;
  border: 1px solid #c9d8e3;
  border-radius: 8px;
  background: #f2f7fa;
  color: #2f4f63;
  font-size: 0.9rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.job-motion-details {
  margin: 8px 0 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f4;
}
.job-motion-details summary {
  cursor: pointer;
  font-weight: 800;
}
.job-motion-details ol {
  margin: 8px 0 0;
  padding-left: 1.6em;
}
.job-motion-details li {
  overflow-wrap: anywhere;
}
.job-review-details {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.job-review-details summary {
  cursor: pointer;
  font-weight: 800;
}
.job-review-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.job-review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.job-review-form textarea {
  min-height: 110px;
}
.job-review-form button {
  justify-self: start;
}
.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}
.completed-videos-pagination {
  align-items: center;
}
.completed-videos-pagination .meta {
  flex: 0 0 auto;
  white-space: nowrap;
}
.bottom-links {
  margin-top: 18px;
}
.completed-video-filter {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(2, minmax(160px, 220px)) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.completed-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.completed-video-card {
  position: relative;
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.completed-video-card.archived {
  background: #fbfaf6;
}
.completed-video-preview {
  width: min(100%, 280px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: 8px;
  background: #111;
  overflow: hidden;
}
.completed-video-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.completed-video-body {
  min-width: 0;
}
.completed-video-path {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7f7f4;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.completed-video-actions {
  align-items: stretch;
}
.status-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef3ea;
  border: 1px solid var(--line);
  font-weight: 700;
}
.status-note.error {
  color: var(--danger);
  background: #fff2ef;
}
.json-help-card,
.json-error-box,
.json-warning-box,
.json-info-box {
  max-width: 820px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f4;
}
.json-help-card h2,
.json-error-box h2,
.json-warning-box h2,
.json-info-box h2 {
  margin: 0 0 8px;
}
.json-help-card ul,
.json-error-box ul,
.json-warning-box ul {
  margin: 0;
  padding-left: 1.3em;
}
.json-help-card code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #fff;
}
.json-error-box {
  border-color: #e5b4ad;
  background: #fff2ef;
  color: var(--danger);
}
.json-warning-box {
  border-color: #e2c779;
  background: #fff8df;
  color: #6f5520;
}
.json-info-box {
  border-color: #c9d8e3;
  background: #f2f7fa;
  color: #2f4f63;
}
.reel-workspace-diagnostic-summary {
  max-width: 980px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f7f4;
}
.reel-workspace-diagnostic-summary-heading { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.reel-workspace-diagnostic-summary-heading h2 { margin: 0; font-size: 15px; }
.reel-workspace-diagnostic-status { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.reel-workspace-diagnostic-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); font-size: 12px; font-weight: 700; }
.reel-workspace-diagnostic-chip.is-warning { border-color: #e2c779; background: #fff8df; color: #6f5520; }
.reel-workspace-diagnostic-chip.is-notice { border-color: #c9d8e3; background: #f2f7fa; color: #2f4f63; }
.reel-workspace-diagnostic-chip.is-error { border-color: #e5b4ad; background: #fff2ef; color: var(--danger); }
.reel-workspace-diagnostics { max-width: 980px; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; overflow-wrap: anywhere; }
.reel-workspace-diagnostics > summary { padding: 10px 12px; color: var(--text); cursor: pointer; font-weight: 800; }
.reel-workspace-diagnostics > summary::marker { color: var(--muted); }
.reel-workspace-diagnostics[open] > summary { border-bottom: 1px solid var(--line); background: #f7f7f4; }
.reel-workspace-diagnostics > :not(summary) { margin-left: 12px; margin-right: 12px; }
.playback-rate-bulk-box {
  max-width: 980px;
}
.playback-rate-bulk-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.playback-rate-bulk-actions button {
  min-height: 48px;
  padding: 10px 14px;
  font-weight: 700;
}
@media (max-width: 640px) {
  .playback-rate-bulk-actions {
    grid-template-columns: 1fr;
  }
}
.motion-summary-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 0;
}
.motion-summary-list div {
  padding: 8px 10px;
  border: 1px solid #d9e5ec;
  border-radius: 8px;
  background: #fff;
}
.motion-summary-list dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}
.motion-summary-list dd {
  margin: 2px 0 0;
  font-size: 1.2rem;
  font-weight: 900;
}
.media-filter-form {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.media-library-context {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 24px;
  padding: 4px 0 20px;
  border-bottom: 1px solid var(--line);
}
.media-library-context h1 {
  margin: 0;
}
.media-library-context__eyebrow,
.media-library-section-heading__eyebrow,
.media-select-bar__eyebrow,
.media-preview-content__eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.media-library-context__copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.media-library-context__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.media-library-browse {
  display: grid;
  gap: 14px;
  margin-bottom: 26px;
}
.media-library-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.media-library-section-heading h2 {
  margin: 0;
  font-size: 20px;
}
.media-library-section-heading__hint {
  max-width: 48em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: right;
}
.media-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
@media (max-width: 1300px) {
  .media-filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}
/* PR #94: 絞り込みの詳細条件折りたたみ（<details>・JSなし）。 */
.media-filter-details {
  margin-top: 12px;
}
.media-filter-details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 2px;
}
.media-filter-details[open] > summary {
  margin-bottom: 10px;
}
.media-filter-details > .media-filter-grid {
  margin-top: 4px;
}
.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #eef3ea;
}
.media-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.media-list-summary {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ea;
  font-weight: 800;
}
.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}
.view-switch-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  font-weight: 800;
}
.media-library-browse .view-switch-link {
  display: grid;
  justify-items: start;
  gap: 2px;
}
.media-library-browse .view-switch-link__label {
  font-weight: 800;
}
.media-library-browse .view-switch-link__hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.view-switch-link.active {
  border-color: var(--primary);
  background: #eef3ea;
  color: var(--primary-dark);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}
.media-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}
/* PR #317 review fix: the selection/action sticky UI lives inside the left
   column so it can never overlap the sticky preview pane in the right column. */
.media-workspace__main {
  min-width: 0;
}
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.media-workspace__main > .media-grid:not(.media-grid-large) {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.media-grid-large {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}
.media-preview-pane {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(42, 51, 42, 0.1);
}
.media-preview-pane__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.media-preview-pane__header h2 {
  margin: 0;
}
.media-preview-pane__eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.media-preview-pane__empty {
  padding: 18px;
  border-radius: 8px;
  background: #f7f7f4;
  color: var(--muted);
  line-height: 1.6;
}
.media-preview-pane__body[hidden],
.media-preview-pane__empty[hidden] {
  display: none;
}
.media-preview-content {
  display: grid;
  gap: 14px;
}
.media-preview-content__media {
  display: grid;
  place-items: center;
  min-height: 180px;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  color: #fff;
  text-align: center;
}
.media-preview-content__media.is-missing {
  background: #eef0ea;
  color: var(--muted);
}
.media-preview-content__media img,
.media-preview-content__media video {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}
.media-preview-content__body {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.media-preview-content__eyebrow {
  margin-bottom: 0;
}
.media-preview-content__body h2,
.media-preview-content__body p {
  margin: 0;
}
.media-preview-content__metadata {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.media-preview-content__body .full {
  margin-top: 4px;
}
.media-card-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.media-card-actions .button {
  width: 100%;
  margin-top: 0;
  text-align: center;
}
.media-card-mobile-actions {
  display: none;
}
.media-card, .job-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.media-card:target {
  scroll-margin-top: 80px;
  outline: 3px solid rgba(47, 107, 79, 0.35);
  outline-offset: 3px;
}
.media-card-large {
  padding: 16px;
}
.media-select-card {
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.media-select-card.selected {
  border-color: var(--primary);
  background: #f0f6ef;
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.18);
}
/* PR #317 review fix: preview focus uses outline only, so it never competes
   with the green selection border/box-shadow and stays visible on a selected
   card. Declared after .selected and .media-card:target to win the cascade. */
.media-select-card.is-preview-focused {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.selected-ribbon {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.media-select-card.selected .selected-ribbon { display: inline-block; }
.media-select-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.media-select-bar__copy {
  min-width: 0;
}
.media-select-bar__copy strong {
  display: block;
  overflow-wrap: anywhere;
}
.selected-count {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 8px;
  background: #eef3ea;
  border: 1px solid var(--line);
  font-weight: 800;
}
.selected-media-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.selected-media-panel h2 {
  margin: 0;
}
.selected-media-empty {
  padding: 12px;
  border-radius: 8px;
  background: #f7f7f4;
  color: var(--muted);
}
.selected-media-empty[hidden] {
  display: none;
}
.selected-media-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}
.selected-media-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f4;
}
.selected-media-thumb {
  width: 112px;
  height: 84px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef0ea;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  font: inherit;
  cursor: zoom-in;
}
.selected-media-thumb:disabled {
  cursor: default;
  opacity: 1;
}
.selected-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
}
.selected-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  background: #111;
}
.selected-media-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.selected-media-body strong,
.selected-media-body span {
  overflow-wrap: anywhere;
}
.selected-media-body strong {
  line-height: 1.35;
}
.selected-media-body span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.selected-media-remove {
  min-height: 40px;
  padding: 8px 10px;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.media-preview-trigger {
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
  text-align: inherit;
}
.media-preview-trigger:disabled {
  cursor: default;
  opacity: 1;
}
.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  background: #eef0ea;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-weight: 800;
}
.media-thumb-large {
  aspect-ratio: auto;
  height: min(520px, 70vh);
}
.media-card-thumb img,
.media-card-thumb .media-preview-image,
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
}
.media-card-video-frame {
  cursor: default;
}
.media-card-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #111;
}
.video-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 18px;
  color: #6f5a37;
  text-align: center;
  line-height: 1.45;
}
.video-preview-placeholder-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e9ddc8;
  color: #5f421c;
  font-weight: 800;
}
.thumb.large { aspect-ratio: 4 / 3; min-width: 320px; }
.media-lightbox[hidden] { display: none; }
.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}
.media-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}
.media-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: 96vh;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.media-lightbox-panel h2 {
  margin: 0;
  padding-right: 46px;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.media-lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 44px;
  padding: 8px 12px;
  font-size: 24px;
  line-height: 1;
}
.media-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 90vh;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}
.media-lightbox-footer[hidden] { display: none; }
.media-lightbox-footer {
  display: grid;
  gap: 8px;
}
.media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-lightbox-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}
.media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-lightbox-body {
  display: block;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  background: #fff;
  color: inherit;
}
.media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-preview-content__media {
  min-height: 160px;
}
.media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-preview-content__media img,
.media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-preview-content__media video {
  max-height: 38vh;
}
.media-lightbox-body img,
.media-lightbox-body video {
  width: auto;
  height: auto;
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  object-position: center center;
  display: block;
}
.media-lightbox-unavailable {
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #fff;
  text-align: center;
  font-weight: 800;
}
body.has-lightbox { overflow: hidden; }
.meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.video-preview-status {
  margin-top: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.45;
}
.video-preview-status.available { color: #2f6b4f; }
.video-preview-status.missing { color: #8a5a16; }

/* Library Browse & Organize: the inspector is a desktop enhancement. Column
   count remains width-driven so the browse surface keeps its density. */
@media (min-width: 1200px) and (max-width: 1799px) {
  .media-workspace {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1499px) {
  .media-workspace {
    display: block;
  }
  .media-preview-pane {
    display: none;
  }
  /* The pane is gone below this breakpoint, so its trigger must go too:
     no dead control, no stray tab stop, no aria-controls to a hidden target. */
  .media-card-actions {
    display: none;
  }
}

/* Library compact grid fallback: Sidebar is hidden at tablet width. */
@media (max-width: 1100px) {
  .media-workspace__main > .media-grid:not(.media-grid-large) {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  .selected-media-list {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
  .selected-media-item {
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 10px;
  }
  .selected-media-thumb {
    width: 96px;
    height: 72px;
  }
}

/* Library density and PC Inspector sizing stay page-scoped. The general
   media grid remains width-driven for other pages and legacy views. */
@media (min-width: 1101px) {
  .container-library .media-workspace__main > .media-grid:not(.media-grid-large) {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
  .container-library .media-select-card {
    display: grid;
    align-content: start;
    gap: 10px;
  }
  .container-library .media-select-card > h2 {
    margin: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .container-library .media-select-card > p {
    margin: 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .container-library .media-select-card > .meta {
    line-height: 1.45;
  }
  .container-library .media-select-card > .media-card-extra-meta,
  .container-library .media-select-card > .video-preview-status,
  .container-library .media-select-card > .media-edit-link,
  .container-library .media-select-card > .media-card-actions {
    margin-top: 0;
  }
}

@media (min-width: 1500px) and (max-width: 1799px) {
  .container-library .media-workspace {
    grid-template-columns: minmax(0, 1fr) 400px;
  }
}

@media (min-width: 1800px) and (max-width: 2299px) {
  .container-library .media-workspace {
    grid-template-columns: minmax(0, 1fr) 600px;
  }
}

@media (min-width: 2300px) {
  .container-library .media-workspace {
    grid-template-columns: minmax(0, 1fr) 640px;
  }
  .container-library .media-workspace__main > .media-grid:not(.media-grid-large) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  .container-library .media-preview-content__media img,
  .container-library .media-preview-content__media video {
    max-height: 640px;
  }
}

.badge { display: inline-block; margin-top: 8px; padding: 4px 9px; border-radius: 999px; background: #efe4d2; color: #5f421c; font-weight: 700; }
.full { display: block; text-align: center; margin-top: 12px; }
.edit-layout { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 24px; align-items: start; }
.media-edit-action-bar {
  position: sticky;
  top: 12px;
  z-index: 30;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(42, 51, 42, 0.12);
  backdrop-filter: blur(8px);
}
.media-edit-action-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.media-edit-action-bar__actions > * {
  flex: 1 1 130px;
  margin: 0;
  text-align: center;
}
.prompt-box { width: 100%; min-height: 560px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.inline-form { display: inline; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #f7f7f4; padding: 14px; border-radius: 8px; }
.table-wrap {
  overflow-x: auto;
}
.debug-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
}
.debug-table th,
.debug-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.debug-table th {
  background: #eef3ea;
}
@media (max-width: 760px) {
  .topbar, .edit-layout { display: block; }
  .brand { font-size: 17px; }
  .brand-logo { height: 28px; max-width: 140px; }
  nav { margin-top: 12px; }
  .container { padding: 18px; }
  .container-library > .flash { margin: 12px 18px 0; }
  .media-library-context,
  .media-library-section-heading { display: block; }
  .media-library-context__actions { justify-content: flex-start; margin-top: 16px; }
  .media-library-section-heading__hint { margin-top: 8px; text-align: left; }
  .media-select-bar { display: block; }
  .stats { grid-template-columns: 1fr; }
  .media-filter-grid { grid-template-columns: 1fr; }
  .media-filter-actions { display: grid; grid-template-columns: 1fr; }
  .media-filter-actions .button,
  .media-filter-actions button {
    width: 100%;
    text-align: center;
  }
  .view-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .view-switch-link {
    width: 100%;
  }
  .filter-check { width: 100%; }
  .completed-video-filter {
    grid-template-columns: 1fr;
  }
  .job-filter-form {
    grid-template-columns: 1fr;
  }
  .filter-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .filter-actions .button,
  .filter-actions button,
  .page-links .button {
    width: 100%;
    text-align: center;
  }
  .completed-videos-pagination {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .completed-videos-pagination .button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }
  .completed-video-grid {
    grid-template-columns: 1fr;
  }
  .completed-video-preview {
    width: min(100%, 260px);
  }
  .media-grid-large {
    grid-template-columns: 1fr;
  }
  .media-thumb-large {
    height: min(460px, 70vh);
  }
  .selected-media-list { grid-template-columns: 1fr; }
  .selected-media-item {
    grid-template-columns: 88px minmax(0, 1fr);
  }
  .selected-media-thumb {
    width: 88px;
    height: 66px;
  }
  .selected-media-remove {
    grid-column: 1 / -1;
    width: 100%;
  }
  .job-status-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reel-mode-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .job-status-chip {
    width: 100%;
    justify-content: space-between;
  }
  .job-actions,
  .job-action-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .job-actions .button,
  .job-actions button {
    width: 100%;
    text-align: center;
  }
  .job-card-header {
    display: grid;
    gap: 8px;
  }
  .job-card-header h2 {
    font-size: 17px;
  }
  .job-state-badge {
    width: fit-content;
  }
  .reel-mode-badge {
    width: fit-content;
  }
  .job-meta-list {
    display: grid;
    grid-template-columns: 1fr;
  }
  .job-meta-list div {
    display: grid;
    grid-template-columns: 5.5em minmax(0, 1fr);
  }
  .job-result-box,
  .job-failure-box {
    padding: 10px;
  }
  .media-select-bar .list-actions { margin: 10px 0 0; }
  .thumb.large { min-width: 0; margin-bottom: 18px; }
  .media-lightbox { padding: 10px; }
  .media-lightbox-panel { max-height: 92vh; padding: 12px; }
  .media-lightbox-body,
  .media-lightbox-body img,
  .media-lightbox-body video { max-height: 86vh; }
  .upload-lightbox { padding: 10px; }
  .upload-lightbox-panel { max-height: 92vh; padding: 12px; }
  .upload-lightbox-body,
  .upload-lightbox-body img,
  .upload-lightbox-body video { max-height: 74vh; }
}
@media (max-width: 600px) {
  .upload-complete-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .upload-complete-actions .button {
    width: 100%;
    text-align: center;
  }
  .upload-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uploaded-preview-grid { grid-template-columns: 1fr; }
  .upload-preview-card { max-width: none; }
  .upload-preview-media { height: 110px; }
}
@media (max-width: 420px) {
  .upload-preview-grid { grid-template-columns: 1fr; }
  .upload-preview-media { height: 150px; }
}

.treatment-adjust-form {
  display: grid;
  gap: 18px;
}

.treatment-summary {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fbfcf8;
}

.treatment-summary-sticky {
  position: sticky;
  top: 10px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 22px rgba(34, 48, 32, 0.12);
  backdrop-filter: blur(8px);
}

.treatment-summary h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.treatment-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.treatment-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #dfe5db;
  border-radius: 8px;
  background: #fff;
}

.treatment-summary-item span {
  color: #566151;
  font-size: 0.9rem;
}

.treatment-summary-item strong {
  color: #2f442b;
  font-size: 1.08rem;
}

.treatment-warning-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.treatment-warning,
.treatment-notice {
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.6;
  font-weight: 700;
}

.treatment-warning {
  border: 1px solid #ead68b;
  background: #fff7d8;
  color: #66530f;
}

.treatment-notice {
  border: 1px solid #c7dcd4;
  background: #eef8f3;
  color: #315447;
}

.treatment-adjust-grid {
  display: grid;
  gap: 16px;
}

.treatment-bulk-duration {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}

.treatment-bulk-duration[hidden],
.treatment-bulk-target-toggle[hidden] {
  display: none;
}

.treatment-bulk-duration h2 {
  margin: 0;
  font-size: 1.05rem;
}

.treatment-bulk-duration > .form-help,
.treatment-bulk-duration-selected-count,
.treatment-bulk-duration-status {
  margin: 0;
}

.treatment-bulk-duration-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.treatment-bulk-duration-controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-weight: 700;
}

.treatment-bulk-duration-controls select {
  width: 100%;
  min-height: 48px;
}

.treatment-bulk-duration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.treatment-bulk-duration-actions button {
  min-height: 48px;
  padding: 10px 14px;
}

.treatment-bulk-duration-selected-count strong {
  font-size: 1.05em;
}

.treatment-bulk-duration-status {
  min-height: 1.5em;
  line-height: 1.5;
}

.treatment-material-selection {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.treatment-material-selection[hidden],
.treatment-selected-materials[hidden] {
  display: none;
}
.treatment-material-selection-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.treatment-material-selection-heading h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.treatment-material-selection-heading .form-help {
  margin: 0;
}
.treatment-material-selection-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}
.treatment-material-selection-actions button {
  min-height: 44px;
  padding: 8px 12px;
}
.treatment-material-selection-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  max-height: 300px;
  min-width: 0;
  overflow: auto;
  padding: 2px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  user-select: none;
}
.treatment-material-selection-item {
  display: grid;
  grid-template-rows: 54px minmax(18px, auto);
  gap: 4px;
  align-content: start;
  min-width: 0;
  min-height: 82px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.treatment-material-selection-item:hover,
.treatment-material-selection-item:focus-visible {
  border-color: var(--primary);
}
.treatment-material-selection-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.treatment-material-selection-item.is-selected,
.treatment-material-selection-item[aria-pressed="true"] {
  border-color: var(--primary);
  background: #e8f3ec;
  box-shadow: inset 0 0 0 1px var(--primary);
}
.treatment-material-selection-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: 54px;
  overflow: hidden;
  border-radius: 5px;
  background: #20282b;
  color: #dce5e1;
  font-size: 11px;
  font-weight: 700;
}
.treatment-material-selection-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.treatment-material-selection-label {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.treatment-selected-materials {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 76px));
  gap: 8px;
  min-width: 0;
  max-height: 180px;
  overflow-y: auto;
  padding: 3px 0 5px;
}
.treatment-selected-material {
  display: grid;
  width: 76px;
  max-width: 100%;
  gap: 4px;
  min-width: 0;
  text-align: center;
}
.treatment-selected-material .treatment-material-selection-thumb {
  height: 48px;
}
.treatment-selected-material-label {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.treatment-selection-marquee {
  position: absolute;
  z-index: 2;
  border: 1px solid #55a879;
  background: rgb(70 160 112 / 18%);
  pointer-events: none;
}

.treatment-bulk-target-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.treatment-bulk-target-toggle input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.order-policy-panel,
.prompt-style-panel {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fff;
}

.order-policy-panel h2,
.prompt-style-panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.order-policy-options {
  display: grid;
  gap: 8px;
}

.order-policy-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #f8faf6;
  cursor: pointer;
}

.order-policy-options input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.prompt-style-options {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fbfcf8;
}

.prompt-style-options legend {
  padding: 0 6px;
  font-weight: 700;
}

.prompt-style-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  margin: 4px 8px 4px 0;
  padding: 7px 10px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.prompt-style-options input {
  width: 18px;
  height: 18px;
}

.duration-preset-options label:has(input:checked) {
  border-color: #2f6f4e;
  background: #e8f3ec;
  color: #1d4d34;
  font-weight: 700;
}

.treatment-adjust-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #fff;
}

.order-controls {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.material-order-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9f1e4;
  color: #31412f;
  font-weight: 800;
}

.order-button {
  min-height: 40px;
  padding: 8px 12px;
}

.treatment-adjust-thumb {
  width: 100%;
  min-height: 150px;
  border-radius: 8px;
  background: #f3f5f1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #5f6b5a;
  font-weight: 700;
}

.treatment-adjust-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.treatment-adjust-video-frame {
  background: #111;
}
.treatment-adjust-video-frame.preview-missing {
  background: #f3f5f1;
}
.treatment-adjust-thumb video {
  width: 100%;
  max-height: 300px;
  display: block;
  object-fit: contain;
  background: #111;
}
.treatment-adjust-video-placeholder {
  min-height: 150px;
}

.treatment-adjust-details {
  display: block;
  min-width: 0;
}

.treatment-adjust-details > summary {
  display: none;
}

.treatment-adjust-details > .treatment-adjust-body,
.treatment-adjust-rail-details > section {
  display: block;
}

.treatment-adjust-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.treatment-adjust-summary::-webkit-details-marker {
  display: none;
}
.treatment-adjust-summary-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.treatment-adjust-summary-title {
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}
.treatment-adjust-summary-detected {
  line-height: 1.5;
}
.treatment-adjust-summary-toggle {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9f1e4;
  color: #31412f;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.treatment-adjust-rail-details {
  display: block;
  min-width: 0;
}

.treatment-adjust-rail-details > summary {
  display: none;
}

.treatment-adjust-body {
  min-width: 0;
}

.treatment-adjust-body h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.treatment-adjust-tags,
.treatment-adjust-memo,
.treatment-adjust-detected {
  margin: 8px 0;
  line-height: 1.6;
}

.treatment-options {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
}

.treatment-options legend {
  padding: 0 6px;
  font-weight: 700;
}

.treatment-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  margin: 4px 8px 4px 0;
  padding: 7px 10px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #f8faf6;
  cursor: pointer;
}

.treatment-options input {
  width: 18px;
  height: 18px;
}

.treatment-note-field {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.treatment-note-field textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}

.treatment-adjust-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

.page-actions-top {
  margin-top: 10px;
  margin-bottom: 18px;
}

.page-actions-bottom {
  margin-top: 22px;
}

.page-actions .button,
.page-actions button,
.page-action-form button,
.btn-primary,
.btn-secondary,
.btn-muted {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.page-action-form {
  margin: 0;
}

.btn-secondary {
  background: #eef3eb;
  border-color: #c8d2c3;
  color: #31412f;
}

.btn-muted {
  background: #f7f8f4;
  border-color: #d8ded5;
  color: #566151;
}

.sticky-action-bar {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 22px rgba(34, 48, 32, 0.12);
  backdrop-filter: blur(8px);
}

.sticky-action-bar[hidden] {
  display: none;
}

.sticky-action-count {
  font-weight: 700;
  color: #31412f;
}

.instagram-post-alert {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #f7f8f4;
}

.instagram-post-alert h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.instagram-post-alert p {
  margin: 0 0 8px;
}

.instagram-post-alert ul {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}

.instagram-post-alert li {
  overflow-wrap: anywhere;
}

.instagram-post-alert-warning {
  border-color: #e3c46e;
  background: #fff8e4;
}

.instagram-post-alert-danger {
  border-color: #d68b8b;
  background: #fff0f0;
}

.instagram-post-prompt-section {
  margin-top: 24px;
}

.instagram-post-prompt-section > h2 {
  margin: 0 0 8px;
}

.instagram-post-prompt-intro {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.instagram-post-pattern-guide {
  margin: 0 0 14px;
  border: 1px solid #d8ded5;
  border-radius: 8px;
  background: #f7f8f4;
}

.instagram-post-pattern-guide summary {
  min-height: 44px;
  padding: 11px 12px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.5;
}

.instagram-post-pattern-guide[open] summary {
  border-bottom: 1px solid #d8ded5;
}

.instagram-post-pattern-guide ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 14px 12px 2rem;
}

.instagram-post-pattern-guide li {
  line-height: 1.55;
}

.instagram-post-prompt-actions {
  margin: 0 0 10px;
}

.instagram-post-copy-status {
  min-height: 1.6em;
  margin: 0 0 12px;
  color: var(--primary-dark);
  line-height: 1.6;
}

.instagram-post-copy-status:not(:empty) {
  padding: 10px 12px;
  border: 1px solid #bad7c4;
  border-radius: 8px;
  background: #edf8f0;
}

.instagram-post-copy-status.is-error {
  border-color: #e8b8ad;
  background: #fff2ef;
  color: var(--danger);
}

.instagram-post-prompt-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.instagram-post-prompt-box {
  min-height: 420px;
  height: min(56vh, 620px);
  max-height: 620px;
  padding: 14px;
  line-height: 1.55;
}

@media (max-width: 768px) {
  .media-select-bar {
    display: none;
  }

  .mobile-hide-action {
    display: none !important;
  }
}

@media (max-width: 700px) {
  .mobile-hide-action {
    display: none !important;
  }

  .media-select-bar {
    display: none;
  }

  .treatment-adjust-card {
    grid-template-columns: 1fr;
  }
  .treatment-adjust-thumb {
    min-height: 210px;
  }
  .treatment-adjust-thumb video {
    max-height: 420px;
  }
  .treatment-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .treatment-options label,
  .prompt-style-options label,
  .treatment-adjust-actions .button,
  .treatment-adjust-actions button {
    width: 100%;
  }

  .order-controls {
    display: grid;
    grid-template-columns: 44px 1fr 1fr;
  }

  .order-controls > .treatment-bulk-target-toggle {
    grid-column: 1 / -1;
  }

  .order-button {
    width: 100%;
  }

  .page-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-actions .button,
  .page-actions button,
  .page-action-form,
  .page-action-form button {
    width: 100%;
  }

  .sticky-action-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 0;
    top: auto;
    display: grid;
    grid-template-columns: 1fr;
    margin: 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .sticky-action-bar button {
    width: 100%;
  }

  .media-grid {
    padding-bottom: 0;
  }

  .has-media-selection .media-grid {
    padding-bottom: 220px;
  }
}

/* PR #333: compact Studio handoff guide. This is display-only; the form and
   route contracts remain unchanged while the active stage stays visible. */
.reel-studio-flow {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf8;
}
.reel-studio-flow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.reel-studio-flow-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid #e0e3dc;
  border-radius: 999px;
  background: #f2f3ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.reel-studio-flow-step.is-complete {
  border-color: #c5d7c9;
  background: #edf5ee;
  color: #356247;
}
.reel-studio-flow-step.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.reel-studio-flow-index {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  background: rgba(36, 49, 39, .1);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.reel-studio-flow-step.is-active .reel-studio-flow-index {
  background: rgba(255, 255, 255, .2);
}
.reel-studio-flow-next {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.reel-studio-flow-next strong { color: var(--primary-dark); }

/* PR #311: large-screen Reel editing workspace. The DOM remains one column
   below the breakpoint so existing storyboard controls and form names stay
   unchanged on phones and tablets. */
.reel-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 24px;
  align-items: start;
}
.reel-workspace-editor { min-width: 0; }
.reel-workspace-preview {
  position: sticky;
  top: 18px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(35, 49, 39, .08);
}
.reel-workspace-preview h2 { margin-top: 0; }
.reel-preview-frame {
  position: relative;
  width: min(100%, 280px);
  aspect-ratio: 9 / 16;
  margin: 12px auto;
  overflow: hidden;
  border: 1px solid #324238;
  border-radius: 12px;
  background: linear-gradient(150deg, #314338, #17231d);
  color: #fff;
}
.reel-preview-safe-zone {
  position: absolute;
  inset: 12% 9% 24%;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255,255,255,.45);
  color: rgba(255,255,255,.7);
  font-size: 12px;
}
.reel-preview-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.reel-preview-text {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 20%;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,.35);
  text-align: center;
  font-size: 12px;
}
.reel-preview-text[hidden], .reel-preview-frame img[hidden] { display: none; }
.reel-preview-layer-list { margin: 0; padding-left: 22px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.visual-asset-card { margin-bottom: 1rem; }
.visual-asset-thumbnail { width: 135px; aspect-ratio: 9 / 16; object-fit: contain; background: #222; border-radius: 8px; }
.visual-asset-actions { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }

/* Studio Workflow structure: the form stays the POST boundary while the
   material comparison plane and overall-condition rail use the available
   desktop width. Card DOM order remains the submitted order. */
.treatment-adjust-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  grid-template-areas: "main rail" "actions rail";
  gap: 24px;
  align-items: start;
}
.treatment-adjust-main {
  grid-area: main;
  min-width: 0;
  container-name: treatment-main;
  container-type: inline-size;
}
.treatment-adjust-rail {
  grid-area: rail;
  min-width: 0;
}
.treatment-adjust-main .treatment-adjust-grid {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.studio-production .treatment-adjust-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  min-width: 0;
}
.studio-production .treatment-adjust-info-grid > * {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.treatment-adjust-actions {
  grid-area: actions;
  margin-top: 18px;
}
/* Material cards use the live main-pane width and never exceed three columns. */
@container treatment-main (min-width: 560px) {
  .studio-production .treatment-adjust-main .treatment-adjust-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container treatment-main (min-width: 1100px) {
  .studio-production .treatment-adjust-main .treatment-adjust-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@container treatment-main (min-width: 560px) {
  .studio-production .treatment-adjust-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-adjust-thumb {
    min-height: 0;
    max-height: 220px;
    aspect-ratio: 16 / 9;
  }
  .studio-production .treatment-adjust-thumb img,
  .studio-production .treatment-adjust-thumb video {
    width: 100%;
    height: 100%;
    max-height: 100%;
  }
  .studio-production .treatment-adjust-body,
  .studio-production .treatment-adjust-details[open] > .treatment-adjust-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .studio-production .treatment-adjust-detail-intro,
  .studio-production .treatment-note-field {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .studio-production .treatment-adjust-info-grid > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .studio-production .treatment-adjust-tags,
  .studio-production .treatment-adjust-memo,
  .studio-production .treatment-adjust-detected {
    overflow-wrap: anywhere;
  }
}
.prompt-mode-switch {
  display: inline-flex;
  gap: 4px;
  margin: 16px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.prompt-mode-switch button {
  min-height: 40px;
  padding: 8px 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
}
.prompt-mode-switch button[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
}
.prompt-mode-panel {
  min-width: 0;
}
.prompt-mode-panel[hidden] { display: none; }
.prompt-project-label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  font-weight: 700;
}
.prompt-project-box { min-height: 180px; }
.studio-edit-json-primary {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.studio-edit-json-primary h2 { margin: 0 0 8px; }
.studio-edit-json-primary label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  font-weight: 700;
}
.studio-edit-json-primary textarea {
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .treatment-adjust-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .treatment-adjust-rail > .treatment-summary {
    margin-top: 18px;
  }
  .treatment-adjust-actions {
    width: 100%;
    margin-top: 18px;
  }
  .treatment-adjust-main .treatment-adjust-grid { grid-template-columns: 1fr; }
  .treatment-adjust-thumb {
    grid-column: 1 / -1;
  }
  .treatment-adjust-details {
    display: block;
    grid-column: 1 / -1;
  }
  .treatment-adjust-details > summary {
    display: flex;
  }
  .treatment-adjust-details:not([open]) > .treatment-adjust-body {
    display: none;
  }
  .treatment-adjust-details[open] > .treatment-adjust-body {
    display: block;
  }
  .treatment-adjust-details[open] .treatment-adjust-body {
    padding-top: 12px;
  }
  .treatment-adjust-rail-details {
    display: block;
    margin: 12px 0 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
  }
  .treatment-adjust-rail-details > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    list-style-position: inside;
  }
  .treatment-adjust-rail-details[open] > summary {
    border-bottom: 1px solid var(--line);
  }
  .treatment-adjust-rail-details:not([open]) > section {
    display: none;
  }
  .treatment-adjust-rail-details[open] > section {
    display: block;
  }
  .treatment-adjust-rail-details > .prompt-style-panel,
  .treatment-adjust-rail-details > .order-policy-panel {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .treatment-adjust-rail-details > section > h2 {
    display: none;
  }
  .treatment-summary-sticky {
    position: static;
    box-shadow: none;
    backdrop-filter: none;
  }
}

@media (max-width: 900px) {
  .reel-workspace { grid-template-columns: 1fr; }
  .reel-workspace-preview { position: static; }
  .reel-preview-frame { margin-left: 0; }
}

@media (max-width: 640px) {
  .instagram-post-prompt-box {
    min-height: 300px;
    height: 48vh;
    max-height: 440px;
    font-size: 16px;
  }

  .prompt-copy-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .prompt-copy-actions > button,
  .prompt-copy-actions > .inline-form,
  .prompt-copy-actions > .inline-form button {
    width: 100%;
  }

  .prompt-copy-actions > .inline-form {
    display: block;
  }

  .prompt-copy-actions button {
    min-height: 56px;
    font-size: 16px;
  }
}

/* PR #72: 素材一覧カードの撮影年月・分類メタ表示（小さく控えめに、既存デザインは変えない） */
.media-card-extra-meta {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #666;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 6px;
}
.media-card-extra-meta .extra-meta-line {
  overflow-wrap: anywhere;
}
.media-card-extra-meta .extra-meta-fav {
  color: #c9851f;
  font-weight: 600;
}

.btn-before-after {
  border-color: #8d4b36;
  color: #8d4b36;
}

.before-after-selection-help {
  flex-basis: 100%;
  color: #8d4b36;
  font-size: 0.9rem;
}

.before-after-adjust-form {
  max-width: 980px;
  margin: 0 auto;
}

.before-after-preview-panel {
  display: grid;
  gap: 18px;
  margin: 24px 0;
}

.before-after-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.before-after-card {
  padding: 18px;
  border: 1px solid #d8cfc8;
  border-radius: 14px;
  background: #fffaf6;
}

.before-after-card-label {
  margin-bottom: 10px;
  color: #8d4b36;
  font-size: 1.05rem;
  font-weight: 700;
}

.before-after-card-preview {
  display: grid;
  min-height: 180px;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #f0ebe7;
}

.before-after-card-preview img,
.before-after-card-preview video {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.before-after-card h2 {
  margin: 14px 0 4px;
  font-size: 1rem;
}

.before-after-swap-button {
  justify-self: center;
  min-width: 260px;
  min-height: 52px;
  padding: 12px 20px;
  border: 1px solid #8d4b36;
  border-radius: 999px;
  background: #fff;
  color: #8d4b36;
  font-weight: 700;
  cursor: pointer;
}

.before-after-duration-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  border: 1px solid #d8cfc8;
  border-radius: 12px;
}

.before-after-duration-options legend {
  width: 100%;
  font-weight: 700;
}

.before-after-duration-options label {
  min-width: 92px;
  padding: 12px 16px;
  border: 1px solid #d8cfc8;
  border-radius: 10px;
  text-align: center;
}

.before-after-adjust-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 700px) {
  .before-after-card-grid {
    grid-template-columns: 1fr;
  }

  .before-after-swap-button,
  .before-after-adjust-actions > * {
    width: 100%;
  }
}

/* PR #245: server-side creation drafts. */
.draft-title-field { max-width: 520px; margin: 12px 0; }
.draft-table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.draft-table { width: 100%; min-width: 860px; border-collapse: collapse; }
.draft-table th, .draft-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.draft-table th { background: #f7f8f4; white-space: nowrap; font-size: 13px; }
.draft-table tbody tr:last-child td { border-bottom: 0; }
.draft-actions, .draft-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.draft-actions form, .draft-card-actions form { margin: 0; }
.draft-card-list { display: none; }
.draft-empty, .draft-warning, .draft-resume-summary, .draft-resume-form, .draft-resume-media { margin: 18px 0; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.draft-empty h2, .draft-warning h2, .draft-resume-summary h2, .draft-resume-media h2 { margin-top: 0; }
.draft-error { border-color: #e5c8bd; background: #fff8f4; }
.draft-warning { border-color: #dfc992; background: #fffaf0; }
.draft-resume-summary { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.draft-resume-kicker { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.draft-resume-summary h2 { margin-bottom: 4px; }
.draft-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.draft-media-card { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; align-items: center; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcf8; }
.draft-media-card h3 { margin: 0 0 4px; overflow-wrap: anywhere; font-size: 15px; }
.draft-media-preview { display: grid; width: 88px; height: 88px; place-items: center; overflow: hidden; border-radius: 7px; background: #edf0ea; color: var(--muted); font-size: 12px; text-align: center; }
.draft-media-preview img, .draft-media-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.draft-media-preview.is-missing { border: 1px dashed #c7cec2; }
.draft-resume-form { display: grid; gap: 12px; }
.draft-resume-form button { width: fit-content; min-width: 220px; }
.draft-confirm-text { margin: 0; color: #78591f; font-weight: 700; }
.draft-status { display: inline-flex; padding: 3px 8px; border-radius: 999px; background: #edf8f0; color: var(--primary-dark); font-size: 12px; font-weight: 700; white-space: nowrap; }
.draft-status.is-converted { background: #f1f1ec; color: #626b5c; }
.draft-card-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0 0 14px; }
.draft-card-meta div { min-width: 0; }
.draft-card-meta dt { color: var(--muted); font-size: 12px; }
.draft-card-meta dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .draft-table-wrap { display: none; }
  .draft-card-list { display: grid; gap: 12px; margin: 18px 0; }
  .draft-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  .draft-card-header { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
  .draft-card-header h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; }
  .draft-card-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 0.45fr); }
  .draft-card-actions .button, .draft-card-actions button { width: 100%; min-height: 52px; }
  .draft-resume-summary { display: grid; align-items: stretch; }
  .draft-resume-summary .button, .draft-resume-form button { width: 100%; min-height: 52px; }
  .draft-media-grid { grid-template-columns: 1fr; }
}

/* PR #246: metadata-based reel candidate recommendations. */
.recommendation-panel {
  margin: 22px 0 26px;
  padding: 20px;
  border: 1px solid #d8cfc8;
  border-radius: 14px;
  background: #fffaf6;
}
.recommendation-panel__header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.recommendation-panel__header h2 { margin: 0; font-size: 1.2rem; }
.recommendation-panel__eyebrow { margin: 0 0 4px; color: #8d4b36; font-size: 12px; font-weight: 700; }
.recommendation-panel__note { margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
.recommendation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.recommendation-card {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8cfc8;
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.recommendation-card.is-selected {
  border-color: #8d4b36;
  box-shadow: 0 0 0 2px rgba(141, 75, 54, .12);
}
.recommendation-card__media {
  display: grid;
  min-height: 112px;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: #f0ebe7;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.recommendation-card__media img,
.recommendation-card__media video { display: block; width: 100%; height: 100%; min-height: 112px; object-fit: cover; }
.recommendation-card__body { display: flex; min-width: 0; flex-direction: column; align-items: stretch; }
.recommendation-card__body h3 { margin: 0 0 4px; overflow-wrap: anywhere; font-size: 1rem; }
.recommendation-card__meta { margin: 0; color: var(--muted); font-size: 12px; }
.recommendation-card__reasons,
.recommendation-card__warnings { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 0; padding: 0; list-style: none; }
.recommendation-card__reasons li,
.recommendation-card__warnings li { padding: 3px 7px; border-radius: 999px; font-size: 12px; line-height: 1.35; }
.recommendation-card__reasons li { background: #f2ece7; color: #704333; }
.recommendation-card__warnings li { background: #fff3d8; color: #765719; }
.recommendation-card__add { width: 100%; min-height: 44px; margin-top: auto; padding: 9px 12px; }
.recommendation-card__add:disabled { cursor: default; opacity: .72; }
.recommendation-empty { margin: 0; color: var(--muted); }

@media (max-width: 760px) {
  .recommendation-panel { padding: 16px; }
  .recommendation-panel__header { display: block; }
  .recommendation-panel__note { margin-top: 6px; text-align: left; }
  .recommendation-list { grid-template-columns: 1fr; }
  .recommendation-card { grid-template-columns: 112px minmax(0, 1fr); }
  .recommendation-card__add { min-height: 52px; margin-top: 12px; }
}

/* PR #251: server-side Normal reel storyboard confirmation. */
.reel-storyboard {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid #d8cfc8;
  border-radius: 14px;
  background: #fffaf6;
}
.reel-storyboard-heading {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.reel-storyboard-heading h2 { margin: 0; font-size: 1.25rem; }
.reel-storyboard-eyebrow { margin: 0 0 4px; color: #8d4b36; font-size: 12px; font-weight: 700; }
.reel-storyboard-note { margin: 4px 0 0; color: var(--muted); font-size: 13px; text-align: right; }
.reel-storyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}
.reel-storyboard-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d8cfc8;
  border-radius: 12px;
  background: #fff;
}
.reel-storyboard-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px 0;
}
.reel-storyboard-clip-number { color: #8d4b36; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.reel-storyboard-move-controls { display: grid; grid-template-columns: repeat(2, minmax(72px, auto)); gap: 7px; }
.reel-storyboard-move-button {
  min-width: 72px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #c99e8e;
  border-radius: 8px;
  background: #fff6f0;
  color: #704333;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.reel-storyboard-move-button:hover:not(:disabled) { background: #f8e8df; }
.reel-storyboard-move-button:disabled { cursor: default; opacity: .45; }
.reel-storyboard-move-down { background: #8d4b36; color: #fff; }
.reel-storyboard-move-down:hover:not(:disabled) { background: #704333; }
.reel-storyboard-preview {
  display: grid;
  aspect-ratio: 16 / 9;
  min-height: 150px;
  margin: 10px 14px 0;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: #f0ebe7;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.reel-storyboard-preview img,
.reel-storyboard-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.reel-storyboard-placeholder { display: grid; gap: 3px; padding: 16px; }
.reel-storyboard-card-body { display: grid; gap: 8px; min-width: 0; padding: 14px; }
.reel-storyboard-basic-fields,
.reel-storyboard-effects-fields { display: grid; gap: 10px; }
.reel-storyboard-basic-fields { grid-template-columns: minmax(0, 1fr) minmax(120px, 160px); }
.reel-storyboard-basic-fields label,
.reel-storyboard-effects-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.reel-storyboard-basic-fields textarea,
.reel-storyboard-basic-fields input,
.reel-storyboard-effects-fields select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font: inherit; }
.reel-storyboard-basic-fields textarea { min-height: 78px; resize: vertical; line-height: 1.45; }
.reel-storyboard-effects { padding-top: 4px; border-top: 1px solid #ece7e1; }
.reel-storyboard-effects summary { cursor: pointer; color: #704333; font-size: 13px; font-weight: 800; }
.reel-storyboard-effects-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 10px; }
.reel-storyboard-clip-errors { padding: 8px 10px; border: 1px solid #e2a39b; border-radius: 8px; background: #fff0ee; color: var(--danger); font-size: 13px; }
.reel-storyboard-clip-errors ul { margin: 0; padding-left: 18px; }
.storyboard-duration-match { margin: 4px 0; color: var(--primary); font-size: 13px; font-weight: 700; }
.reel-storyboard-type,
.reel-storyboard-unresolved { width: fit-content; padding: 3px 8px; border-radius: 999px; background: #f2ece7; color: #704333; font-size: 12px; font-weight: 700; }
.reel-storyboard-unresolved { background: #fff3d8; color: #765719; }
.reel-storyboard-original-name,
.reel-storyboard-duration,
.reel-storyboard-caption { margin: 0; overflow-wrap: anywhere; }
.reel-storyboard-original-name { display: grid; gap: 2px; }
.reel-storyboard-original-name span,
.reel-storyboard-caption span { color: var(--muted); font-size: 12px; }
.reel-storyboard-original-name strong { font-size: 14px; }
.reel-storyboard-duration { color: var(--muted); font-size: 13px; }
.reel-storyboard-caption { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; min-height: 2.7em; line-height: 1.35; }
.reel-storyboard-caption span { display: block; margin-bottom: 2px; }
.reel-storyboard-treatments { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.reel-storyboard-treatments li { padding: 3px 7px; border-radius: 999px; background: #f4f5f1; color: #566052; font-size: 12px; line-height: 1.35; }
.reel-storyboard-treatments li span { margin-right: 4px; color: var(--muted); }
.reel-storyboard-card-disabled { opacity: .52; filter: grayscale(.2); }
.reel-storyboard-usage-status { margin: 0; color: #704333; font-size: 13px; font-weight: 700; }
.reel-storyboard-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.reel-storyboard-toggle-button { flex: 0 0 auto; min-width: 8em; min-height: 44px; padding: 8px 12px; border: 1px solid #c99e8e; border-radius: 8px; background: #fff6f0; color: #704333; font-weight: 700; white-space: nowrap; }
.reel-storyboard-toggle-button:hover { background: #f8e8df; }
.reel-storyboard-submit-note { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.reel-storyboard-card-heading { display: grid; gap: 3px; min-width: 0; }
.reel-storyboard-card-meta { color: var(--muted); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.reel-storyboard-disabled-note { margin: 0 0 12px; padding: 8px 10px; border-left: 3px solid #c99e8e; background: #fff8f2; color: #704333; font-size: 13px; }
.reel-storyboard-duration-summary { margin: -12px 0 24px; padding: 14px 16px; border: 1px solid #d8cfc8; border-radius: 10px; background: #fff; color: var(--muted); }
.reel-storyboard-duration-summary h3 { margin: 0 0 8px; color: var(--text); font-size: 15px; }
.reel-storyboard-duration-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin: 0; }
.reel-storyboard-duration-summary dl div { display: flex; justify-content: space-between; gap: 12px; }
.reel-storyboard-duration-summary dt { font-size: 13px; }
.reel-storyboard-duration-summary dd { margin: 0; color: var(--text); font-weight: 800; }
.reel-storyboard-duration-summary p { margin: 8px 0 0; }

@media (max-width: 700px) {
  .reel-storyboard { padding: 16px; }
  .reel-storyboard-heading { display: block; }
  .reel-storyboard-note { margin-top: 6px; text-align: left; }
  .reel-storyboard-grid { grid-template-columns: 1fr; }
  .reel-storyboard-card-header { grid-template-columns: 1fr; }
  .reel-storyboard-move-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reel-storyboard-move-button { width: 100%; min-height: 48px; }
  .reel-storyboard-preview { min-height: 170px; }
  .reel-storyboard-toggle { align-items: stretch; }
  .reel-storyboard-usage-status { flex: 1 1 100%; }
  .reel-storyboard-toggle-button { width: 100%; }
  .reel-storyboard-duration-summary dl { grid-template-columns: 1fr; }
  .reel-storyboard-basic-fields,
  .reel-storyboard-effects-fields { grid-template-columns: 1fr; }
}

/* PR #261: project-reference 9:16 Reel layout guide. */
.reel-storyboard-layout-guide {
  display: grid;
  gap: 14px;
  margin: 18px 0 20px;
  padding: 16px;
  border: 1px solid #d8cfc8;
  border-radius: 12px;
  background: #fff;
}
.reel-storyboard-layout-guide-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}
.reel-storyboard-layout-guide-heading h3 { margin: 0; font-size: 1.05rem; }
.reel-storyboard-layout-guide-eyebrow {
  margin: 0 0 4px;
  color: #8d4b36;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.reel-storyboard-layout-guide-note,
.reel-storyboard-layout-guide-warning,
.reel-storyboard-layout-guide-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.reel-storyboard-layout-guide-note { max-width: 360px; text-align: right; }
.reel-storyboard-layout-guide-warning {
  padding: 10px 12px;
  border: 1px solid #e0c58c;
  border-radius: 8px;
  background: #fff9e9;
  color: #6f551c;
}
.reel-storyboard-layout-guide-body {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.reel-storyboard-layout-frame {
  position: relative;
  width: min(100%, 280px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #bca99e;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(141, 75, 54, .12), transparent 48%),
    linear-gradient(325deg, rgba(91, 121, 111, .14), transparent 54%),
    #f6f3ef;
  color: #5f5048;
  isolation: isolate;
}
.reel-storyboard-layout-safe-zone,
.reel-storyboard-layout-text-zone {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
.reel-storyboard-layout-safe-zone {
  top: var(--reel-guide-safe-top);
  right: var(--reel-guide-safe-right);
  bottom: var(--reel-guide-safe-bottom);
  left: 0;
  border: 1px solid rgba(141, 75, 54, .72);
  border-left: 0;
  border-radius: 0 4px 4px 0;
}
.reel-storyboard-layout-text-zone {
  top: var(--reel-guide-safe-top);
  right: var(--reel-guide-text-right);
  bottom: var(--reel-guide-safe-bottom);
  left: var(--reel-guide-text-left);
  border: 1px dashed rgba(91, 121, 111, .8);
  border-radius: 4px;
}
.reel-storyboard-layout-safe-label,
.reel-storyboard-layout-caption-marker,
.reel-storyboard-layout-ending-marker,
.reel-storyboard-layout-brand-marker {
  position: absolute;
  z-index: 3;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .84);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}
.reel-storyboard-layout-safe-label {
  top: calc(var(--reel-guide-safe-top) + 4px);
  left: 4px;
  color: #8d4b36;
}
.reel-storyboard-layout-caption-anchor,
.reel-storyboard-layout-ending-anchor {
  position: absolute;
  z-index: 2;
  right: var(--reel-guide-text-right);
  left: var(--reel-guide-text-left);
  height: 0;
  border-top: 1px dashed;
  pointer-events: none;
}
.reel-storyboard-layout-caption-anchor {
  bottom: var(--reel-guide-caption-margin-v);
  border-top-color: rgba(72, 105, 93, .72);
}
.reel-storyboard-layout-ending-anchor {
  bottom: var(--reel-guide-ending-margin-v);
  border-top-color: rgba(111, 85, 28, .72);
}
.reel-storyboard-layout-caption-marker {
  top: 0;
  right: 0;
  transform: translateY(-50%);
  color: #48695d;
}
.reel-storyboard-layout-ending-marker {
  top: 0;
  right: 0;
  transform: translateY(calc(-50% - 6px));
  color: #6f551c;
}
.reel-storyboard-layout-brand-marker {
  top: calc(var(--reel-guide-safe-top) + 4px);
  right: var(--reel-guide-safe-right);
  color: #704333;
}
.reel-storyboard-layout-opening-marker {
  position: absolute;
  z-index: 2;
  top: var(--reel-opening-y);
  right: 8%;
  left: 8%;
  height: 0;
  border-top: 1px dashed rgba(141, 75, 54, .55);
  color: #704333;
  font-size: 9px;
  line-height: 1;
}
.reel-storyboard-layout-opening-marker span {
  position: absolute;
  top: -1px;
  left: 50%;
  padding: 2px 4px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(141, 75, 54, .44);
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  white-space: nowrap;
}
.reel-storyboard-layout-opening-marker small { font-size: 8px; font-weight: 600; }
.reel-storyboard-layout-opening-marker[data-active="true"] {
  border-top-color: #8d4b36;
  border-top-width: 2px;
}
.reel-storyboard-layout-opening-marker[data-active="true"] span {
  background: #8d4b36;
  color: #fff;
}
.reel-storyboard-layout-guide-details {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
  padding: 4px 0;
}
.reel-storyboard-layout-guide-details p { margin: 0; overflow-wrap: anywhere; }
.reel-storyboard-layout-guide-details [data-reel-opening-title] {
  display: inline-block;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.reel-storyboard-layout-reference-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 700px) {
  .reel-storyboard-layout-guide { padding: 14px; }
  .reel-storyboard-layout-guide-heading { display: block; }
  .reel-storyboard-layout-guide-note { margin-top: 6px; text-align: left; }
  .reel-storyboard-layout-guide-body { grid-template-columns: 1fr; gap: 12px; }
  .reel-storyboard-layout-frame { width: min(100%, 260px); }
  .reel-storyboard-layout-guide-details { padding: 0; }
}

/* Presentation Template candidate review (PR #306) */
.pt-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
}
.pt-preview-toolbar-label {
  font-size: 13px;
  color: var(--muted);
}
.pt-preview-toolbar .button.is-active {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 1px;
}
.pt-candidate-section {
  margin: 24px 0;
}
/* Candidates are inspected, not skimmed: the track maximum is bounded so a
   single candidate cannot stretch to the full form width and become taller
   than the viewport, and auto-fit keeps empty tracks from shrinking the rest. */
.pt-candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 400px));
  justify-content: center;
  gap: 20px;
}
.pt-candidate-card {
  display: block;
  border: 2px solid rgba(127, 127, 127, 0.35);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}
.pt-candidate-card:focus-within {
  border-color: var(--accent, #3b82f6);
}
.pt-candidate-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 6px;
}
.pt-candidate-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.pt-bg-checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #c8c8c8 25%, transparent 25%, transparent 75%, #c8c8c8 75%),
    linear-gradient(45deg, #c8c8c8 25%, transparent 25%, transparent 75%, #c8c8c8 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}
.pt-bg-white { background-color: #ffffff; }
.pt-bg-black { background-color: #000000; }
.pt-guide {
  position: absolute;
  pointer-events: none;
  border: 1px dashed rgba(255, 64, 129, 0.75);
  background: rgba(255, 64, 129, 0.08);
  font-size: 10px;
  line-height: 1.2;
  color: #b3004f;
}
.pt-guide span {
  position: absolute;
  top: 2px;
  left: 4px;
  background: rgba(255, 255, 255, 0.75);
  padding: 0 3px;
  border-radius: 2px;
  white-space: nowrap;
}
.pt-guide-ui-top { top: 0; left: 0; right: 0; }
.pt-guide-ui-bottom { bottom: 0; left: 0; right: 0; }
.pt-guide-ui-right { right: 0; }
.pt-guide-brand {
  border-color: rgba(0, 128, 255, 0.75);
  background: rgba(0, 128, 255, 0.1);
  color: #004a99;
  width: 34%;
}
.pt-guide-text {
  border-color: rgba(0, 160, 90, 0.8);
  background: rgba(0, 160, 90, 0.1);
  color: #005c33;
}
.pt-guide-opening {
  top: 50%;
  transform: translateY(-50%);
}
.pt-candidate-body {
  margin-top: 10px;
}
.pt-quality {
  margin: 0 0 6px;
  font-size: 14px;
}
.pt-quality-ok strong { color: #067647; }
.pt-quality-caution strong { color: #a15c00; }
.pt-quality-review strong,
.pt-quality-unknown strong { color: #b42318; }
.pt-quality-flags {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.pt-candidate-choose {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.12);
  font-size: 15px;
  font-weight: 600;
}
.pt-candidate-choose input[type="radio"] {
  width: 22px;
  height: 22px;
}

@media (max-width: 700px) {
  .pt-candidate-grid { grid-template-columns: min(100%, 400px); gap: 16px; }
  .pt-candidate-card { padding: 8px; }
  .pt-candidate-choose { min-height: 56px; font-size: 16px; }
}

/* PR #312: PC reel editor uses one broad editing plane and a narrow preview.
   Storyboard details are relocated by presentation-only JavaScript; the
   original form inputs stay in the same form and retain their POST names.

   The shared .container caps every other page at 1180px. Only this screen
   opts out, through the page-scoped modifier class render_header() adds, so
   the editing plane can use the full window without a horizontal scrollbar.
   The 16px gutter here is what makes the plane 1948px wide at 1980px. */
.container.container-reel-editor {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

/* App Shell / Navigation Foundation v1. Desktop owns the shared Sidebar;
   tablet/mobile keep the existing server-rendered topbar fallback. The shared
   shell owns geometry and navigation focus only; workspaces remain page-owned. */
/* Dashboard-only Reel Studio Sidebar pilot (PR #321). The shared topbar and
   container remain the default for every other page until a later shell
   migration. */
.container.container-dashboard {
  width: 100%;
  max-width: none;
  padding: 0;
}
.container.container-management {
  width: 100%;
  max-width: none;
  padding: 0;
}
.container-management > .flash {
  margin: 16px clamp(24px, 2.5vw, 48px) 0 calc(250px + clamp(24px, 2.5vw, 48px));
}
@media (max-width: 1100px) {
  .container-management > .flash {
    margin: 16px 24px 0;
  }
}
@media (max-width: 760px) {
  .container-management > .flash {
    margin: 12px 18px 0;
  }
}
/* Sidebar-aligned session flash for the Dashboard and Production Studio
   shells (App Theme Foundation v1): the same gutters as Management instead of
   spanning the Sidebar column. */
.container-dashboard > .flash,
.container-studio > .flash {
  margin: 16px clamp(24px, 2.5vw, 48px) 0 calc(250px + clamp(24px, 2.5vw, 48px));
}
@media (max-width: 1100px) {
  .container-dashboard > .flash,
  .container-studio > .flash {
    margin: 16px 24px 0;
  }
}
@media (max-width: 760px) {
  .container-dashboard > .flash,
  .container-studio > .flash {
    margin: 12px 18px 0;
  }
}
@media (min-width: 1101px) {
  .reel-studio-dashboard-topbar { display: none; }
}
@media (min-width: 1101px) {
  .reel-studio-library-topbar { display: none; }
}
@media (min-width: 1101px) {
  .reel-studio-management-topbar { display: none; }
}
.reel-studio-shell {
  display: grid;
  grid-template-columns: minmax(220px, 250px) minmax(0, 1fr);
  min-height: 100vh;
  color: var(--ds-color-text);
  background: var(--ds-color-app-background);
}
.reel-studio-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  height: 100vh;
  padding: 16px;
  background: var(--ds-color-surface);
  border-right: 1px solid var(--ds-color-border);
}
.reel-studio-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}
.reel-studio-sidebar__brand img { width: 34px; height: 34px; }
.reel-studio-sidebar__brand span { display: grid; gap: 2px; min-width: 0; }
.reel-studio-sidebar__brand strong { font-size: 15px; }
.reel-studio-sidebar__brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.reel-studio-sidebar__nav { display: grid; gap: 14px; margin: 0; }
.reel-studio-sidebar__group { display: grid; gap: 2px; }
.reel-studio-sidebar__group-label { margin: 0 8px 1px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.reel-studio-sidebar__link,
.reel-studio-sidebar__logout {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--text);
  border-radius: 8px;
  text-decoration: none;
}
.reel-studio-sidebar__link:hover,
.reel-studio-sidebar__logout:hover { background: #f2f6ef; }
.reel-studio-sidebar__link.is-active { color: var(--primary-dark); background: #eaf3e5; font-weight: 800; }
.reel-studio-sidebar__brand:focus-visible,
.reel-studio-sidebar__link:focus-visible,
.reel-studio-sidebar__logout:focus-visible {
  outline: 3px solid var(--ds-color-focus);
  outline-offset: 2px;
}
.reel-studio-sidebar__account { display: grid; gap: 4px; margin-top: auto; }
.reel-studio-shell__workspace { min-width: 0; padding: 28px clamp(24px, 3vw, 48px) 44px; }
.studio-management-workspace { width: 100%; max-width: 1600px; margin: 0 auto; }
/* Studio Management header and toolbar (App Theme Foundation v1): the header
   reuses the shared ds-page-header layout, and the toolbar groups the existing
   view scope, filter form, and facet rows without changing any form, link,
   or query contract. */
.studio-management-header { margin: 0 0 var(--ds-space-xl); }
.studio-management-header h1 { margin: 0; }
.studio-management-header .page-actions { margin: 0; }
.studio-management-toolbar {
  display: grid;
  gap: var(--ds-space-lg);
  margin: 0 0 var(--ds-space-xl);
  padding: var(--ds-space-lg);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-surface);
  background: var(--ds-color-surface);
}
.studio-management-toolbar > .archive-toggle { margin: 0; }
.studio-management-toolbar > .job-filter-form {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.studio-management-facets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: var(--ds-space-lg) var(--ds-space-xl);
}
.studio-management-facet { display: grid; align-content: start; gap: var(--ds-space-sm); min-width: 0; }
.studio-management-facet > .job-section-title,
.studio-management-facet > .job-status-summary,
.studio-management-facet > .reel-mode-summary { margin: 0; }
@media (max-width: 760px) {
  .studio-management-header { display: block; }
  .studio-management-header .page-actions { margin-top: var(--ds-space-lg); }
  .studio-management-toolbar { padding: var(--ds-space-md); }
}

/* Dashboard Workspace (PR #320): page-scoped layout only. Shared page widths,
   scroll ownership, and existing workspace layouts remain unchanged. */
.dashboard-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dashboard-toolbar { padding: 4px 0 0; }
.dashboard-toolbar h1,
.dashboard-panel h2,
.dashboard-assets h2,
.dashboard-asset-card h3 { margin: 0; }
.dashboard-toolbar h1 { font-size: var(--ds-font-size-page-title); }
.dashboard-asset-card p { margin: var(--ds-space-sm) 0 0; color: var(--ds-color-text-muted); line-height: var(--ds-line-height-body); }
.dashboard-toolbar-actions,
.dashboard-asset-actions { justify-content: flex-end; }
.dashboard-toolbar-actions { margin: 0; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: var(--ds-space-md); }
.dashboard-kpi { display: grid; gap: var(--ds-space-sm); min-width: 0; padding: var(--ds-space-lg); color: var(--ds-color-text); text-decoration: none; background: var(--ds-color-surface); border: 1px solid var(--ds-color-border); border-radius: 12px; box-shadow: var(--ds-shadow-surface); }
.dashboard-kpi:hover { border-color: var(--ds-color-primary); }
.dashboard-kpi span { color: var(--ds-color-text-muted); font-size: var(--ds-font-size-muted); font-weight: 700; }
.dashboard-kpi strong { color: var(--ds-color-primary); font-size: 30px; line-height: 1; }
.dashboard-kpi.is-alert { border-color: var(--ds-color-danger-border); background: var(--ds-color-danger-surface); }
.dashboard-kpi.is-alert strong { color: var(--ds-color-danger); }
.dashboard-main-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.dashboard-activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.dashboard-panel { min-width: 0; padding: 22px; }
.dashboard-asset-card { min-width: 0; padding: 22px; background: var(--ds-color-surface); border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-surface); box-shadow: var(--ds-shadow-surface); }
.dashboard-panel-heading h2,
.dashboard-assets h2 { font-size: var(--ds-font-size-section-title); }
.dashboard-text-link { align-self: center; color: var(--ds-color-primary-hover); font-size: 14px; font-weight: var(--ds-font-weight-heading); text-decoration: none; }
.dashboard-text-link:hover { text-decoration: underline; }
.dashboard-status-list { display: grid; gap: 10px; margin-top: 18px; }
.dashboard-status-row { display: grid; grid-template-columns: minmax(130px, max-content) auto minmax(0, 1fr); align-items: center; gap: var(--ds-space-lg); padding: 15px 16px; color: var(--ds-color-text); text-decoration: none; }
.dashboard-status-row.ds-status--info strong { color: var(--ds-color-info); }
.dashboard-status-row:hover { border-color: var(--ds-color-primary); }
.dashboard-status-row strong { color: var(--ds-color-success); white-space: nowrap; }
.dashboard-status-row > span:last-child { color: var(--ds-color-text-muted); font-size: var(--ds-font-size-muted); text-align: right; white-space: nowrap; }
.dashboard-status-row.is-alert strong,
.dashboard-status-row.is-alert > span:last-child { color: var(--ds-color-danger); }
.dashboard-quick-actions { display: grid; align-content: start; gap: 16px; }
.dashboard-quick-action-list { display: grid; gap: 10px; }
.dashboard-quick-action { display: grid; gap: 4px; min-height: 58px; padding: 12px 14px; color: var(--ds-color-text); text-decoration: none; border: 1px solid var(--ds-color-border); border-radius: 10px; }
.dashboard-quick-action:hover { border-color: var(--ds-color-primary); background: var(--ds-color-control-hover, var(--ds-color-success-surface)); }
.dashboard-quick-action span { font-weight: 800; }
.dashboard-quick-action small { color: var(--ds-color-text-muted); }
.dashboard-activity-list { display: grid; gap: 2px; margin: 16px 0 0; padding: 0; list-style: none; }
.dashboard-activity-list a { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; color: var(--ds-color-text); text-decoration: none; border-bottom: 1px solid var(--ds-color-border); }
.dashboard-activity-list li:last-child a { border-bottom: 0; }
.dashboard-activity-list a:hover strong { color: var(--ds-color-primary-hover); text-decoration: underline; }
.dashboard-activity-main { display: grid; min-width: 0; gap: 3px; }
.dashboard-activity-main strong { overflow-wrap: anywhere; }
.dashboard-activity-main small,
.dashboard-activity-list time { color: var(--ds-color-text-muted); font-size: var(--ds-font-size-label); }
.dashboard-activity-list time { flex: 0 0 auto; white-space: nowrap; }
.dashboard-empty-state { margin: 18px 0 0; color: var(--ds-color-text-muted); line-height: var(--ds-line-height-body); }
.dashboard-assets { display: grid; grid-template-columns: minmax(210px, .72fr) repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; padding: 22px; background: var(--ds-color-surface-inset, var(--ds-color-success-surface)); border: 1px solid var(--ds-color-border); border-radius: 14px; }
.dashboard-assets-heading { display: block; padding: 4px 4px 0 0; }
.dashboard-asset-card { display: flex; flex-direction: column; justify-content: space-between; }
.dashboard-asset-card h3 { font-size: var(--ds-font-size-card-title); }
.dashboard-asset-actions { margin-top: 18px; justify-content: flex-start; }

@media (max-width: 1100px) {
  .dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-main-grid { grid-template-columns: 1fr; }
  .dashboard-assets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-assets-heading { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .dashboard-workspace { gap: 18px; }
  .dashboard-toolbar,
  .dashboard-panel-heading { display: block; }
  .dashboard-toolbar-actions { justify-content: flex-start; margin-top: 16px; }
  .dashboard-panel-heading .dashboard-text-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 10px; }
  .dashboard-activity-grid,
  .dashboard-assets { grid-template-columns: 1fr; }
  .dashboard-assets-heading { grid-column: auto; }
  .dashboard-panel,
  .dashboard-asset-card,
  .dashboard-assets { padding: 18px; }
  .dashboard-status-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; }
  .dashboard-status-row > span:last-child { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-kpi { padding: 14px; }
  .dashboard-kpi strong { font-size: 26px; }
  .dashboard-toolbar-actions,
  .dashboard-asset-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .dashboard-toolbar-actions .button,
  .dashboard-asset-actions .button { width: 100%; text-align: center; }
  .dashboard-activity-list a { display: grid; gap: 6px; }
}

/* PR #321 Dashboard shell breakpoint: tablet uses the existing topbar. */
@media (max-width: 1100px) {
  .reel-studio-shell { display: block; min-height: 0; }
  .reel-studio-sidebar { display: none; }
  .reel-studio-shell__workspace { padding: 24px; }
}
@media (max-width: 760px) {
  .reel-studio-shell__workspace { padding: 18px; }
}
.reel-editor-page {
  width: 100%;
  max-width: 1980px;
  margin: 0 auto;
}
.reel-editor-page .reel-workspace {
  grid-template-columns: minmax(0, 1fr) clamp(360px, 20vw, 420px);
  gap: 20px;
}
.reel-workspace-editor .form.wide { max-width: none; }
.reel-workspace-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7f4f1;
}
.reel-workspace-tabs button {
  min-height: 42px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
}
.reel-workspace-tabs button:hover { background: #eee7e1; }
.reel-workspace-tabs button.is-active,
.reel-workspace-tabs button[aria-selected="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(35, 49, 39, .12); }
.reel-workspace-panel { min-width: 0; }
.reel-workspace-panel[hidden] { display: none; }
.reel-workspace-panel > .reel-storyboard:first-child { margin-top: 0; }
.reel-edit-json-advanced {
  margin: 18px 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf8;
}
.reel-edit-json-advanced summary { cursor: pointer; color: var(--text); font-weight: 800; }
.reel-edit-json-advanced label { display: grid; gap: 7px; margin-top: 12px; }
.reel-edit-json-advanced textarea { min-height: 320px; }
.reel-storyboard { padding: 16px; }
.reel-storyboard-selected-pane {
  display: none;
  margin: 14px 0;
  border: 1px solid #cdbdaf;
  border-radius: 12px;
  background: #fff;
}
[data-workspace-enhanced="true"] .reel-storyboard-selected-pane { display: block; }
.reel-storyboard-selected-pane-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 14px 16px 0;
}
.reel-storyboard-selected-pane-heading h3 { margin: 0; font-size: 1.05rem; }
.reel-storyboard-selected-pane-heading .field-help { margin: 4px 0 0; text-align: right; }
.reel-storyboard-selected-pane-content {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  outline: none;
}
.reel-storyboard-selected-pane-content .reel-storyboard-card-body {
  display: grid;
  gap: 12px;
  padding: 0;
}
.reel-storyboard-selected-pane-content .reel-storyboard-preview {
  max-width: 420px;
  margin: 0;
}
.reel-storyboard-selected-pane-content .reel-storyboard-basic-fields {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}
.reel-storyboard-selected-pane-content .reel-storyboard-basic-fields label:first-child { grid-column: 1 / -1; }
.reel-storyboard-selected-pane-content .reel-storyboard-effects-fields { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.reel-storyboard-selected-pane-content .workspace-clip-extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 6px 12px;
  padding: 12px;
  border: 1px solid #e5ddd7;
  border-radius: 9px;
  background: #fcfbf9;
}
.reel-storyboard-selected-pane-content .workspace-clip-extra > strong,
.reel-storyboard-selected-pane-content .workspace-clip-extra > .workspace-clip-extra-title,
.reel-storyboard-selected-pane-content .workspace-clip-extra > .field-help { grid-column: 1 / -1; }
.workspace-clip-extra-title { color: #704333; font-size: 13px; font-weight: 800; }
.reel-storyboard-selected-pane-content .workspace-clip-extra select { width: 100%; min-height: 42px; }
[data-workspace-enhanced="true"] .workspace-clip-extra-bank { display: none; }
.reel-storyboard-grid[data-storyboard-navigator] { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.reel-storyboard-select {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.reel-storyboard-select:focus-visible { outline: 3px solid #6d9f8b; outline-offset: 3px; }
[data-workspace-enhanced="true"] .reel-storyboard-card { overflow: visible; }
[data-workspace-enhanced="true"] .reel-storyboard-card-header { padding: 10px 12px; }
[data-workspace-enhanced="true"] .reel-storyboard-card[data-storyboard-selected] { border-color: #6d9f8b; box-shadow: 0 0 0 2px rgba(109, 159, 139, .18); }
[data-workspace-enhanced="true"] .reel-storyboard-card .reel-storyboard-preview,
[data-workspace-enhanced="true"] .reel-storyboard-card .reel-storyboard-card-body { display: none; }
[data-workspace-enhanced="true"] .reel-storyboard-move-controls { grid-template-columns: repeat(2, minmax(40px, auto)); gap: 4px; }
[data-workspace-enhanced="true"] .reel-storyboard-move-button { min-width: 0; min-height: 36px; padding: 6px 8px; font-size: 12px; }
.visual-asset-editor-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #ece7e1;
  font-size: 13px;
}
.visual-asset-editor-links button { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text); font: inherit; font-size: 13px; }
.reel-workspace-preview { padding: 14px; }
.reel-preview-mode-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.reel-preview-mode-controls button { min-height: 36px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; }
.reel-preview-mode-controls button.is-active { border-color: #6d9f8b; background: #edf6f0; color: #254f3d; }
.reel-preview-text-controls { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.reel-preview-text-controls-label { margin-right: 2px; color: var(--muted); font-size: 12px; font-weight: 700; }
.reel-preview-text-controls button { min-height: 36px; min-width: 48px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; }
.reel-preview-text-controls button.is-active { border-color: #6d9f8b; background: #edf6f0; color: #254f3d; }
.reel-preview-mode-status { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.reel-preview-frame { width: min(100%, 320px); }
.reel-preview-text { white-space: pre-line; }
.reel-preview-text-off,
.reel-preview-legacy-brand { position: absolute; z-index: 3; color: #fff; font-weight: 800; text-shadow: 0 1px 3px #000; }
.reel-preview-text-off[hidden],
.reel-preview-legacy-brand[hidden] { display: none; }
.reel-preview-text-off { left: 12%; right: 12%; bottom: 20%; padding: 8px; border-radius: 6px; background: rgba(0,0,0,.45); text-align: center; font-size: 12px; }
.reel-preview-legacy-brand { display: grid; top: 8%; right: 9%; font-size: 14px; line-height: 1.2; text-align: right; }
.reel-preview-legacy-brand span:first-child { font-size: 10px; }
.reel-preview-frame [data-preview-material] { z-index: 0; object-fit: cover; }
.reel-preview-frame [data-preview-material][hidden],
.reel-preview-frame [data-preview-base][hidden] { display: none; }
.reel-preview-frame [data-preview-presentation] { z-index: 1; }
.reel-preview-frame [data-preview-overlay] { z-index: 2; }
.reel-preview-frame [data-preview-text],
.reel-preview-frame [data-preview-text-off] { z-index: 3; }
.reel-preview-frame [data-preview-brand],
.reel-preview-frame [data-preview-legacy-brand] { z-index: 4; }

@media (min-width: 1351px) and (max-width: 1799px) {
  .reel-editor-page .reel-workspace { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (min-width: 1101px) and (max-width: 1350px) {
  .reel-editor-page .reel-workspace { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 1100px) {
  .reel-editor-page .reel-workspace { grid-template-columns: 1fr; }
  .reel-editor-page .reel-workspace-preview { position: static; }
}

@media (max-width: 700px) {
  .reel-studio-flow-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reel-studio-flow-step {
    border-radius: 8px;
    align-items: flex-start;
  }
  .reel-studio-flow-step:last-child { grid-column: 1 / -1; }
  .reel-studio-flow-label { overflow-wrap: anywhere; }

  .container.container-reel-editor { padding-left: 12px; padding-right: 12px; }
  .reel-workspace-tabs { overflow-x: auto; }
  .reel-workspace-tabs button { flex: 1 0 max-content; }
  .reel-storyboard-selected-pane-heading { display: block; }
  .reel-storyboard-selected-pane-heading .field-help { text-align: left; }
  .reel-storyboard-selected-pane-content .reel-storyboard-basic-fields,
  .reel-storyboard-selected-pane-content .reel-storyboard-effects-fields,
  .reel-storyboard-selected-pane-content .workspace-clip-extra { grid-template-columns: 1fr; }
  .reel-storyboard-selected-pane-content .workspace-clip-extra > strong,
  .reel-storyboard-selected-pane-content .workspace-clip-extra > .workspace-clip-extra-title,
  .reel-storyboard-selected-pane-content .workspace-clip-extra > .field-help { grid-column: auto; }
}

/* Library asset category links. This view only owns its own navigation row. */
.library-asset-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.library-asset-navigation a {
  display: flex;
  flex: 1 1 190px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--ds-color-text);
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.library-asset-navigation a:hover {
  background: var(--ds-color-control-hover, var(--ds-color-success-surface));
}
.library-asset-navigation a:focus-visible {
  outline: 3px solid var(--ds-color-focus);
  outline-offset: 2px;
}
.library-asset-navigation a[aria-current="page"] {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-accent);
  font-weight: 800;
}
@media (max-width: 760px) {
  .library-asset-navigation a {
    flex-basis: calc(50% - 4px);
    padding-inline: 8px;
  }
}

/* The same Library header and category navigation render on every route.
   Each route keeps its existing content workspace and responsive padding. */
.container-library .library-asset-shell__column {
  min-width: 0;
}
.container-library .library-asset-shell__navigation {
  display: flow-root;
  padding: 24px clamp(24px, 2.5vw, 48px) 0;
}
.container-library .library-asset-shell__header {
  display: flow-root;
}
.container-library .reel-studio-shell__workspace.library-asset-shell__content,
.container-library .reel-studio-shell__workspace.library-asset-shell__media-content {
  padding-top: 0;
}
@media (min-width: 761px) and (max-width: 1100px) {
  .container-library .library-asset-shell__navigation {
    padding: 24px 24px 0;
  }
}
@media (max-width: 760px) {
  .container-library .library-asset-shell__navigation {
    padding: 18px 18px 0;
  }
}

/* Library First workspace: the browse controls stay opaque and sticky while
   the grid remains the page's primary, width-driven surface. */
html:has(.container-library) {
  scrollbar-gutter: stable;
}
.container-library {
  --library-controls-height: 0px;
}
.container-library .media-library-controls {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 40;
  margin: 0 0 8px;
  padding: 6px 0 4px;
  background: var(--bg);
  box-shadow: 0 8px 18px rgba(34, 48, 32, 0.08);
}
.container-library .media-filter-form {
  gap: 6px;
  margin: 0;
  padding: 8px 10px;
  background: var(--panel);
}
.container-library .media-filter-form > .media-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.container-library .media-filter-form label {
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
}
.container-library .media-filter-form input[type="number"],
.container-library .media-filter-form input[type="text"],
.container-library .media-filter-form select {
  min-height: 38px;
  padding: 7px 8px;
  font-size: 13px;
}
.container-library .media-filter-details {
  margin-top: 0;
  border-top: 1px solid var(--line);
}
.container-library .media-filter-details > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 6px 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
.container-library .media-filter-details[open] > summary {
  margin-bottom: 4px;
}
.container-library .media-filter-mega {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.container-library .media-filter-group {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.container-library .media-filter-group h3 {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 12px;
  line-height: 1.2;
}
.container-library .media-filter-group__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  align-items: end;
}
.container-library .media-filter-group__fields label {
  display: grid;
  gap: 3px;
}
.container-library .media-filter-group__fields .filter-check {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 8px;
  background: #eef3ea;
}
.container-library .media-filter-group__fields .filter-check input {
  flex: 0 0 auto;
}
.container-library .media-filter-actions {
  gap: 8px;
}
.container-library .media-filter-actions > * {
  min-height: 40px;
}
.container-library .media-filter-chips {
  gap: 6px;
  margin: 0;
  padding: 4px 0;
}
.container-library .media-filter-chip {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}
.container-library .media-list-summary {
  min-height: 40px;
  margin: 4px 0 0;
  padding: 8px 10px;
}
.container-library .media-workspace {
  display: block;
}
.container-library .media-workspace__main > .media-grid:not(.media-grid-large) {
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}
.container-library .media-select-card {
  min-width: 0;
}
.container-library .media-card-actions {
  display: grid;
  gap: 8px;
  margin-top: 0;
}
.container-library .sticky-action-bar {
  top: calc(var(--library-controls-height) + 10px);
  z-index: 35;
  justify-content: flex-start;
  gap: 8px;
  margin: 12px 0;
  padding: 8px;
  background: var(--panel);
}
.container-library .sticky-action-count {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.container-library .sticky-action-bar button {
  flex: 0 1 auto;
  min-height: 44px;
}
.container-library .media-preview-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 22, 17, 0.44);
}
.container-library .media-preview-drawer-backdrop[hidden],
.container-library .media-preview-pane[hidden] {
  display: none !important;
}
.container-library .media-preview-pane {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 91;
  width: min(400px, calc(100vw - 32px));
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(16, 25, 18, 0.28);
}
.container-library .media-preview-pane__header {
  min-height: 72px;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.container-library .media-preview-pane__header h2 {
  font-size: 18px;
}
.container-library .media-preview-pane__body {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}
.container-library .media-preview-pane__empty {
  margin: 16px;
}
.container-library .media-preview-pane__footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.container-library .media-preview-pane__footer[hidden] {
  display: none;
}
.container-library .media-preview-pane__footer .full {
  margin-top: 0;
}
.container-library .media-preview-content {
  gap: 12px;
}
.container-library .media-preview-content__media {
  min-height: 160px;
}
.container-library .media-preview-content__body {
  gap: 8px;
}
.container-library .media-preview-content__body > p {
  overflow-wrap: anywhere;
}
.container-library .media-preview-content__metadata {
  overflow-wrap: anywhere;
}
.container-library .library-scroll-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
  border-color: var(--primary);
  background: var(--panel);
  color: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(34, 48, 32, 0.16);
}
.container-library .library-scroll-top[hidden] {
  display: none;
}

@media (min-width: 1400px) and (max-width: 1599px) {
  .container-library .media-filter-form > .media-filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .container-library .media-filter-group__fields {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
}

@media (min-width: 1600px) {
  .container-library .media-filter-form > .media-filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }
}

@media (max-width: 1399px) and (min-width: 1101px) {
  .container-library .media-filter-form > .media-filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .container-library .media-filter-mega {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .container-library .media-filter-group__fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .container-library .media-preview-drawer-backdrop,
  .container-library .media-preview-pane,
  .container-library .media-card-actions,
  .container-library .library-scroll-top {
    display: none !important;
  }
  .container-library .media-card-mobile-actions {
    display: grid;
    gap: 8px;
    margin-top: 0;
  }
  .container-library .media-card-mobile-actions .button {
    width: 100%;
    margin-top: 0;
    text-align: center;
  }
  .container-library .media-workspace__main > .media-grid:not(.media-grid-large) {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  .container-library .media-filter-mega {
    grid-template-columns: 1fr;
  }
  .container-library .media-filter-group__fields {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (min-width: 1101px) {
  body.has-media-preview-drawer {
    overflow: hidden;
  }
}

@media (max-width: 760px) {
  .container-library .media-library-controls {
    position: static;
    box-shadow: none;
  }
  .container-library .media-filter-form > .media-filter-grid,
  .container-library .media-filter-mega {
    grid-template-columns: 1fr;
  }
  .container-library .media-filter-group__fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .container-library .sticky-action-bar {
    top: auto;
  }
}

/* Prototype Layout Alignment: keep Library's natural page flow while making
   the Browse surface denser and giving the material Grid visual priority.
   This is deliberately Library-scoped; the shared shell and mobile layout
   remain unchanged. */
.container-library .media-card-usage-state {
  display: none;
}
.container-library .media-card-desktop-identify,
.container-library .media-card-favorite-indicator {
  display: none;
}

/* PR #340: Mobile Library Selection Workspace. The compact state keeps the
   two primary destinations reachable while the secondary actions remain in
   the same form and expand without changing selection payloads. */
@media (max-width: 1100px) {
  .container-library .selection-workspace[hidden] {
    display: none !important;
  }

  .container-library .selection-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
  }

  .container-library .selection-workspace__header,
  .container-library .selection-workspace__primary,
  .container-library .selection-workspace__persistent,
  .container-library .selection-workspace__secondary {
    min-width: 0;
  }

  .container-library .selection-workspace__header {
    display: grid;
  }

  .container-library .selection-workspace__primary {
    display: grid;
  }

  .container-library .selection-workspace__persistent,
  .container-library .selection-workspace__secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .container-library .selection-workspace__secondary {
    grid-column: 1 / -1;
    max-height: min(220px, calc(100svh - 200px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
  }

  .container-library .selection-workspace__secondary[hidden] {
    display: none !important;
  }

  .container-library .selection-workspace__secondary-action {
    display: grid;
    min-width: 0;
  }

  .container-library .selection-workspace__secondary-action > button,
  .container-library .selection-workspace__primary > button,
  .container-library .selection-workspace__persistent > button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .container-library .selection-workspace__contextual-action {
    min-width: 0;
  }

  .container-library .selection-workspace__contextual-action > [hidden] {
    display: none !important;
  }

  .container-library .selection-workspace__contextual-action > .time-series-selection-help,
  .container-library .selection-workspace__contextual-action > .before-after-selection-help {
    display: flex;
    min-height: 44px;
    align-items: center;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .container-library .selection-workspace__contextual-action > .before-after-selection-help {
    color: #8d4b36;
  }

  .container-library .selection-workspace__status {
    grid-column: 1 / -1;
    min-width: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 700px) {
  .container-library form[data-media-select-form].has-media-selection {
    --selection-workspace-fallback-clearance: calc(184px + env(safe-area-inset-bottom, 0px));
    --selection-workspace-clearance: var(--selection-workspace-measured-height, var(--selection-workspace-fallback-clearance));
  }

  .container-library form[data-media-select-form].has-media-selection[data-selection-workspace-state="expanded"] {
    --selection-workspace-fallback-clearance: calc(380px + env(safe-area-inset-bottom, 0px));
  }

  .container-library form[data-media-select-form].has-media-selection .media-grid {
    padding-bottom: var(--selection-workspace-clearance);
  }

  .container-library .selection-workspace {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .container-library .selection-workspace__secondary {
    max-height: min(220px, calc(100svh - 200px));
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .container-library .selection-workspace {
    overflow: visible;
  }

  .container-library .selection-workspace__secondary {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (min-width: 1101px) {
  .container-library .selection-workspace__header,
  .container-library .selection-workspace__primary,
  .container-library .selection-workspace__persistent,
  .container-library .selection-workspace__secondary,
  .container-library .selection-workspace__secondary-action,
  .container-library .selection-workspace__contextual-action {
    display: contents;
  }

  .container-library .selection-workspace__secondary[hidden] {
    display: contents !important;
  }

  .container-library .selection-workspace__toggle {
    display: none;
  }

  .container-library .selection-workspace__status {
    order: 10;
  }

  .container-library .selection-workspace__header .sticky-action-count {
    order: 1;
  }

  .container-library .selection-workspace__primary > button {
    order: 3;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-draft] > button {
    order: 2;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-time-series] > button {
    order: 4;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-time-series] > .time-series-selection-help {
    order: 5;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-before-after] > button {
    order: 6;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-before-after] > .before-after-selection-help {
    order: 7;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-bulk] > button {
    order: 8;
  }

  .container-library .selection-workspace__persistent > [data-instagram-post-prompt-button] {
    order: 9;
  }

  .container-library .selection-workspace__secondary > [data-selection-workspace-clear] > button {
    order: 11;
  }

}

.container-library .selection-workspace__label-desktop {
  display: none;
}

@media (min-width: 1101px) {
  .container-library .selection-workspace__label-mobile {
    display: none;
  }

  .container-library .selection-workspace__label-desktop {
    display: inline;
  }
}

@media (min-width: 1101px) {
  .container-library .reel-studio-shell__workspace {
    padding: 24px clamp(24px, 2.5vw, 48px) 40px;
  }

  .container-library .media-library-context {
    gap: 18px;
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .container-library .media-library-context h1 {
    font-size: clamp(24px, 2vw, 30px);
  }

  .container-library .media-library-context__copy {
    margin-top: 6px;
  }

  .container-library .media-library-context__actions {
    gap: 8px;
  }

  .container-library .media-library-browse {
    gap: 10px;
    margin-bottom: 20px;
  }

  .container-library .media-library-section-heading {
    gap: 14px;
  }

  .container-library .media-library-section-heading h2 {
    font-size: 18px;
  }

  .container-library .media-library-section-heading__hint {
    font-size: 12px;
  }

  .container-library .recommendation-panel {
    margin: 0;
    padding: 12px 14px;
    border-radius: 10px;
  }

  .container-library .recommendation-panel__header {
    margin-bottom: 10px;
  }

  .container-library .recommendation-panel__header h2 {
    font-size: 16px;
  }

  .container-library .recommendation-list {
    gap: 10px;
  }

  .container-library .recommendation-card {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
  }

  .container-library .recommendation-card__media,
  .container-library .recommendation-card__media img,
  .container-library .recommendation-card__media video {
    min-height: 84px;
  }

  .container-library .recommendation-card__body h3 {
    font-size: 14px;
  }

  .container-library .recommendation-card__reasons,
  .container-library .recommendation-card__warnings {
    gap: 4px;
    margin-top: 6px;
  }

  .container-library .recommendation-card__add {
    min-height: 40px;
    padding: 7px 10px;
  }

  .container-library .page-actions-top {
    margin-top: 8px;
    margin-bottom: 10px;
  }

  .container-library .view-switch {
    gap: 8px;
    margin-bottom: 12px;
  }

  .container-library .view-switch-link {
    min-height: 40px;
    padding: 8px 12px;
  }

  .container-library .media-select-bar {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .container-library .selected-media-panel {
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
  }

  .container-library .selected-media-panel h2 {
    font-size: 16px;
  }

  .container-library .media-select-card {
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
  }

  .container-library .media-select-card:not(.media-card-large) .media-card-thumb {
    aspect-ratio: 3 / 2;
  }

  .container-library .media-select-card > h2 {
    font-size: 16px;
  }

  .container-library .media-select-card > p {
    font-size: 14px;
  }

  .container-library .media-select-card > .meta {
    font-size: 12px;
  }

  .container-library .media-card-extra-meta {
    margin-top: 0;
    padding: 5px 7px;
    font-size: 11px;
    line-height: 1.4;
  }

  .container-library .video-preview-status {
    margin-top: 0;
    font-size: 12px;
  }

  .container-library .media-select-card > .media-edit-link,
  .container-library .media-card-actions .button {
    min-height: 40px;
    padding: 8px 10px;
  }

  /* Desktop Browse cards keep selection-critical context visible while the
     Inspector Drawer owns the verbose metadata. Mobile card content remains
     unchanged because this rule is scoped to desktop widths only. */
  .container-library .media-select-card > .media-card-memo,
  .container-library .media-select-card > .media-card-detail-meta,
  .container-library .media-select-card .media-card-usage-detail {
    display: none;
  }

  .container-library .media-select-card .media-card-legacy-scene,
  .container-library .media-select-card .media-card-tags {
    display: none;
  }

  .container-library .media-select-card > .media-card-identify-meta {
    display: none;
  }

  .container-library .media-select-card > .media-card-desktop-identify {
    display: grid;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
  }

  .container-library .media-select-card > .media-card-desktop-identify .extra-meta-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .container-library .media-select-card .media-card-favorite-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.8em;
  }

  .container-library .media-select-card .media-card-usage-state {
    display: inline;
  }
}

/* Overlay Prompt options: compact rows and native disclosure, page scope only. */
.visual-prompt-options-management {
  width: 100%;
  min-width: 0;
  color: var(--ds-color-text, var(--text));
}
.visual-prompt-options-management .vpo-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin-bottom: .6rem;
}
.visual-prompt-options-management .vpo-heading h1 { margin: 0; }
.visual-prompt-options-management .vpo-heading .page-actions { margin: 0; }
.visual-prompt-options-management > .field-help { margin: .5rem 0 .8rem; }
.visual-prompt-options-management .vpo-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.visual-prompt-options-management .vpo-tabs .button { padding: .45rem .7rem; }
.visual-prompt-options-management .vpo-overview {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .4rem 1.2rem;
  margin: .7rem 0;
  padding: .6rem .8rem;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 8px;
  background: var(--ds-color-surface, #fff);
  overflow-wrap: anywhere;
  font-size: .9rem;
}
.visual-prompt-options-management .vpo-overview h2 { margin: 0; font-size: .95rem; }
.visual-prompt-options-management .vpo-candidate-list {
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 8px;
}
.visual-prompt-options-management .vpo-list-heading,
.visual-prompt-options-management .vpo-candidate-summary {
  display: grid;
  grid-template-columns: 4rem minmax(7rem, 1.4fr) minmax(8rem, 2.5fr) 4rem 4.5rem 3rem;
  gap: .65rem;
  align-items: center;
  padding: .65rem .8rem;
  min-width: 0;
  font-size: .9rem;
}
.visual-prompt-options-management .vpo-list-heading {
  color: var(--ds-color-text-muted, var(--muted));
  font-size: .8rem;
}
.visual-prompt-options-management .vpo-candidate { border-top: 1px solid var(--ds-color-border, var(--line)); }
.visual-prompt-options-management .vpo-candidate-summary { cursor: pointer; list-style: none; }
.visual-prompt-options-management .vpo-candidate-summary::-webkit-details-marker { display: none; }
.visual-prompt-options-management .vpo-candidate-summary:hover,
.visual-prompt-options-management .vpo-candidate[open] > summary {
  background: var(--ds-color-surface-inset, #f4f5f3);
}
.visual-prompt-options-management summary:focus-visible {
  outline: 2px solid var(--ds-color-accent, #2c775e);
  outline-offset: -2px;
}
.visual-prompt-options-management .vpo-name,
.visual-prompt-options-management .vpo-prompt-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.visual-prompt-options-management .vpo-prompt-preview,
.visual-prompt-options-management .vpo-order { color: var(--ds-color-text-muted, var(--muted)); }
.visual-prompt-options-management .vpo-order { font-variant-numeric: tabular-nums; }
.visual-prompt-options-management .vpo-badge {
  justify-self: start;
  padding: .15rem .4rem;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 5px;
  color: var(--ds-color-text-muted, var(--muted));
  font-size: .75rem;
  white-space: nowrap;
}
.visual-prompt-options-management .vpo-badge-active,
.visual-prompt-options-management .vpo-badge-default { color: var(--ds-color-text, var(--text)); }
.visual-prompt-options-management .vpo-toggle { font-size: .8rem; text-align: right; }
.visual-prompt-options-management .vpo-mobile-label,
.visual-prompt-options-management .vpo-toggle-close { display: none; }
.visual-prompt-options-management .vpo-candidate[open] .vpo-toggle-edit { display: none; }
.visual-prompt-options-management .vpo-candidate[open] .vpo-toggle-close { display: inline; }
.visual-prompt-options-management .vpo-candidate-editor,
.visual-prompt-options-management .vpo-add-editor {
  padding: .8rem;
  border-top: 1px solid var(--ds-color-border, var(--line));
  overflow-wrap: anywhere;
}
.visual-prompt-options-management .vpo-candidate-editor > p { margin: 0 0 .6rem; font-size: .85rem; }
.visual-prompt-options-management .vpo-edit-form,
.visual-prompt-options-management .vpo-add-form {
  width: 100%;
  max-width: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  align-items: end;
  gap: .65rem;
}
.visual-prompt-options-management .vpo-edit-form label,
.visual-prompt-options-management .vpo-add-form label { min-width: 0; }
.visual-prompt-options-management .vpo-edit-form input,
.visual-prompt-options-management .vpo-add-form input { width: 100%; min-width: 0; }
.visual-prompt-options-management .form-actions { margin: 0; }
.visual-prompt-options-management button { padding: .5rem .7rem; }
.visual-prompt-options-management .vpo-state-actions { margin: .7rem 0; gap: .4rem; }
.visual-prompt-options-management .vpo-sort-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: .65rem;
  max-width: none;
}
.visual-prompt-options-management .vpo-sort-form input { width: 7rem; }
.visual-prompt-options-management .vpo-add,
.visual-prompt-options-management .vpo-full-preview {
  margin-top: .8rem;
  border: 1px solid var(--ds-color-border, var(--line));
  border-radius: 8px;
}
.visual-prompt-options-management .vpo-add > summary,
.visual-prompt-options-management .vpo-full-preview > summary { padding: .6rem .8rem; cursor: pointer; }
.visual-prompt-options-management .vpo-add-form > .field-help { grid-column: 1 / -1; margin: 0; }
.visual-prompt-options-management .vpo-add-form > .form-actions { grid-column: 3; grid-row: 1; }
.visual-prompt-options-management .vpo-full-preview > p { margin: .6rem .8rem; font-size: .85rem; }
.visual-prompt-options-management .vpo-full-preview textarea { width: 100%; min-width: 0; }
@media (max-width: 1000px) {
  .visual-prompt-options-management .vpo-list-heading { display: none; }
  .visual-prompt-options-management .vpo-candidate:first-of-type { border-top: 0; }
  .visual-prompt-options-management .vpo-candidate-summary {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "name name toggle" "order state default-state" "prompt prompt prompt";
    gap: .4rem .65rem;
  }
  .visual-prompt-options-management .vpo-name { grid-area: name; white-space: normal; overflow-wrap: anywhere; }
  .visual-prompt-options-management .vpo-order { grid-area: order; }
  .visual-prompt-options-management .vpo-prompt-preview { grid-area: prompt; }
  .visual-prompt-options-management .vpo-badge { grid-area: state; }
  .visual-prompt-options-management .vpo-badge + .vpo-badge { grid-area: default-state; }
  .visual-prompt-options-management .vpo-toggle { grid-area: toggle; }
  .visual-prompt-options-management .vpo-mobile-label { display: inline; }
  .visual-prompt-options-management .vpo-edit-form,
  .visual-prompt-options-management .vpo-add-form { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .visual-prompt-options-management .vpo-add-form > .form-actions { grid-column: auto; grid-row: auto; }
}

/* BGM Prompt Builder and single-template preview. */
.bgm-prompt-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.bgm-prompt-examples[hidden] { display: none; }
.bgm-prompt-examples > span,
.bgm-prompt-examples > p { flex-basis: 100%; margin: 0; }
.bgm-prompt-examples > button { max-width: 100%; white-space: normal; }
.bgm-manual-assist[hidden] { display: none; }
.bgm-manual-assist { margin-top: 1.5rem; max-width: 100%; }
.bgm-manual-assist textarea { width: 100%; max-width: 100%; box-sizing: border-box; }
.bgm-manual-assist .form-actions { flex-wrap: wrap; }
.bgm-manual-assist [data-manual-import][aria-disabled="true"] { background: var(--ds-color-disabled-background); border: 1px dashed currentColor; color: var(--ds-color-text); cursor: progress; }
.bgm-manual-import-result[hidden] { display: none; }
.bgm-manual-import-result { box-sizing: border-box; max-width: 100%; margin: .75rem 0 1rem; padding: .75rem; border: 1px solid currentColor; border-inline-start-width: .3rem; border-radius: .35rem; overflow-wrap: anywhere; }
.bgm-manual-stale-questions[hidden] { display: none; }
.bgm-manual-stale-questions { box-sizing: border-box; max-width: 100%; margin: .75rem 0 1rem; padding: .75rem; border: 1px solid currentColor; border-inline-start-width: .3rem; border-radius: .35rem; overflow-wrap: anywhere; }
.bgm-manual-import-result > :first-child { margin-top: 0; }
.bgm-manual-import-result > :last-child { margin-bottom: 0; }
.bgm-manual-import-result ol { padding-inline-start: 1.5rem; }
.bgm-manual-import-result li + li { margin-top: .5rem; }
.bgm-manual-stale-questions > :first-child { margin-top: 0; }
.bgm-manual-stale-questions > :last-child { margin-bottom: 0; }
.bgm-manual-stale-questions ol { padding-inline-start: 1.5rem; }
.bgm-manual-stale-questions li + li { margin-top: .5rem; }
.bgm-manual-stale-questions button { margin-block-start: .75rem; }
.bgm-prompt-details {
  border: 1px solid currentColor;
  border-radius: .5rem;
  margin-block: 1rem;
  padding: .75rem;
}
.bgm-prompt-details > summary {
  cursor: pointer;
  font-weight: 700;
}
.bgm-prompt-details__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  margin-block: .75rem;
}
.bgm-prompt-details__grid label {
  min-width: 0;
}
.bgm-prompt-arrangement {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-block: .75rem;
}
.bgm-prompt-arrangement p {
  margin: 0;
}
.bgm-prompt-details [hidden],
.bgm-prompt-arrangement [hidden],
.bgm-template-preview [hidden] {
  display: none !important;
}
.bgm-template-preview {
  border: 1px solid currentColor;
  border-radius: .5rem;
  display: grid;
  gap: .5rem;
  margin-block-start: 1rem;
  max-width: 42rem;
  padding: .75rem;
}
.bgm-template-preview h3,
.bgm-template-preview p {
  margin: 0;
}
.bgm-template-preview audio {
  max-width: 100%;
  width: 100%;
}
@media (max-width: 600px) {
  .bgm-prompt-details__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .bgm-prompt-arrangement {
    align-items: stretch;
    flex-direction: column;
  }
  .bgm-prompt-arrangement button {
    width: 100%;
  }
}

/* App Theme Foundation v1: the single Dark palette for the allowlisted App
   Shell pages.
   render_header() adds html[data-theme="dark"] only for those main variants,
   so Light pages never match this block. The token root keeps its full
   specificity so it wins over the Light :root tokens; every component rule is
   wrapped in :where() so it only fills in where the Studio-only overrides in
   the final block do not. .studio-production is listed next to the hook so
   Studio stays Dark even while the hook is absent (deploy and rollback). */
html[data-theme="dark"],
.studio-production {
  color-scheme: dark;
  --ds-color-app-background: #0d1317;
  --ds-color-surface: #1b252b;
  --ds-color-surface-elevated: #141c21;
  --ds-color-surface-inset: #11191e;
  --ds-color-border: #304047;
  --ds-color-border-strong: #4c646d;
  --ds-color-border-field: #81918d;
  --ds-color-text: #edf4f1;
  --ds-color-text-muted: #a9b8b3;
  --ds-color-accent: #70d1a0;
  --ds-color-primary: var(--ds-color-accent);
  --ds-color-primary-hover: var(--ds-color-accent);
  --ds-color-primary-fill: #2f9b6b;
  --ds-color-on-primary: #07150e;
  --ds-color-control-hover: #263941;
  --ds-color-success: #8ed6ad;
  --ds-color-success-surface: #1c3028;
  --ds-color-success-border: #365948;
  --ds-color-warning: #e5bd67;
  --ds-color-warning-surface: #392f1f;
  --ds-color-warning-border: #6f5a35;
  --ds-color-info: #8db9d8;
  --ds-color-info-surface: #20313d;
  --ds-color-info-border: #466171;
  --ds-color-danger: #f08c84;
  --ds-color-danger-surface: #3b2423;
  --ds-color-danger-border: #6a4542;
  --ds-color-focus: var(--ds-color-accent);
  --ds-color-disabled-background: var(--ds-color-surface-inset);
  --ds-color-disabled-text: var(--ds-color-text-muted);
  --ds-color-selected-surface: #20392f;
  --ds-color-selected-border: var(--ds-color-accent);
}

/* Page base and the tablet/mobile topbar fallback. */
:where(html[data-theme="dark"]) body {
  background: var(--ds-color-app-background);
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"]) .topbar {
  background: var(--ds-color-surface-inset);
  border-bottom-color: var(--ds-color-border);
  color: var(--ds-color-text);
}

/* Controls. The Light global nav a / .button / button rule stays untouched;
   Dark pages re-skin it here with the same specificity. Filled primary
   controls use primary-fill with on-primary text, never white text. */
:where(html[data-theme="dark"]) :is(nav a, .button, button) {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"]) :where(nav a, a.button, button:not(:disabled)):hover {
  background: var(--ds-color-control-hover);
}
:where(html[data-theme="dark"]) .button[aria-current="page"] {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-accent);
}
:where(html[data-theme="dark"]) button.primary,
:where(html[data-theme="dark"]) .button.primary {
  background: var(--ds-color-primary-fill);
  border-color: var(--ds-color-primary-fill);
  color: var(--ds-color-on-primary);
}
:where(html[data-theme="dark"]) button.primary:hover,
:where(html[data-theme="dark"]) .button.primary:hover {
  background: var(--ds-color-accent);
  border-color: var(--ds-color-accent);
}
:where(html[data-theme="dark"]) button.subtle-danger,
:where(html[data-theme="dark"]) .button.subtle-danger {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
  color: var(--ds-color-danger);
}
:where(html[data-theme="dark"]) button.archive-button,
:where(html[data-theme="dark"]) .button.archive-button {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}

/* Fields. border-field is the normal field boundary only; disabled and
   read-only fields keep the quieter strong border, and focus stays on the
   shared focus outline. */
:where(html[data-theme="dark"]) :is(input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="file"], select, textarea) {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"]) :is(input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="file"], select, textarea):where(:not(:disabled):not([readonly])) {
  border-color: var(--ds-color-border-field);
}
:where(html[data-theme="dark"]) :is(input, select, textarea):disabled {
  background: var(--ds-color-disabled-background);
  color: var(--ds-color-disabled-text);
}
:where(html[data-theme="dark"]) :is(input, textarea)::placeholder {
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) :is(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--ds-color-accent);
}
:where(html[data-theme="dark"]) fieldset {
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--ds-color-focus);
  outline-offset: 2px;
}
:where(html[data-theme="dark"]) pre {
  background: var(--ds-color-surface-inset);
}
:where(html[data-theme="dark"]) .meta {
  color: var(--ds-color-text-muted);
}

/* Sidebar: one implementation for every Dark shell page, Studio included.
   The Light global nav a rule would paint these links as framed buttons, so
   the default state is transparent with a reserved 1px border; only hover,
   active, focus, and disabled states draw a surface. The topbar links are not
   Sidebar links and never match these rules. */
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar {
  background: var(--ds-color-surface-inset);
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__brand,
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__link,
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__logout {
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__group-label,
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__brand small {
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__link,
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__logout {
  border: 1px solid transparent;
  background: transparent;
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__link:hover,
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__logout:hover {
  background: var(--ds-color-control-hover);
  border-color: var(--ds-color-border-strong);
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__link.is-active {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-accent);
}
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__link[aria-disabled="true"],
:where(html[data-theme="dark"], .studio-production) .reel-studio-sidebar__logout[aria-disabled="true"] {
  background: var(--ds-color-disabled-background);
  border-color: var(--ds-color-border);
  color: var(--ds-color-disabled-text);
  opacity: .62;
}

/* Feedback: session flash, status notes, and badges. The in-page Studio
   flashes keep their Studio-only overrides, which outrank these rules. */
:where(html[data-theme="dark"]) .flash {
  background: var(--ds-color-success-surface);
  border-color: var(--ds-color-success-border);
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"]) .flash.success {
  color: var(--ds-color-success);
}
:where(html[data-theme="dark"]) .flash.error {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
  color: var(--ds-color-danger);
}
:where(html[data-theme="dark"]) .flash.warning {
  background: var(--ds-color-warning-surface);
  border-color: var(--ds-color-warning-border);
  color: var(--ds-color-warning);
}
:where(html[data-theme="dark"]) .status-note {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .status-note.error {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
  color: var(--ds-color-danger);
}
:where(html[data-theme="dark"]) .badge {
  background: var(--ds-color-warning-surface);
  color: var(--ds-color-warning);
}
:where(html[data-theme="dark"]) .archive-badge {
  background: var(--ds-color-selected-surface);
  color: var(--ds-color-accent);
}

/* Jobs: filter panel, facet chips, cards, and state/mode badges. */
:where(html[data-theme="dark"]) .job-filter-form,
:where(html[data-theme="dark"]) .job-status-chip,
:where(html[data-theme="dark"]) .job-card {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .job-status-chip span,
:where(html[data-theme="dark"]) .job-section-title,
:where(html[data-theme="dark"]) .job-meta-list dt {
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) .job-status-chip strong,
:where(html[data-theme="dark"]) .job-meta-list dd {
  color: var(--ds-color-text);
}
:where(html[data-theme="dark"]) .job-status-chip.active {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  box-shadow: none;
}
:where(html[data-theme="dark"]) .job-card.archived,
:where(html[data-theme="dark"]) .job-meta-list div,
:where(html[data-theme="dark"]) .job-motion-details,
:where(html[data-theme="dark"]) .job-review-details {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .job-state-badge {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) .reel-mode-badge,
:where(html[data-theme="dark"]) .job-state-done {
  background: var(--ds-color-success-surface);
  border-color: var(--ds-color-success-border);
  color: var(--ds-color-success);
}
:where(html[data-theme="dark"]) .job-state-ready,
:where(html[data-theme="dark"]) .reel-mode-before_after {
  background: var(--ds-color-warning-surface);
  border-color: var(--ds-color-warning-border);
  color: var(--ds-color-warning);
}
:where(html[data-theme="dark"]) .job-state-processing,
:where(html[data-theme="dark"]) .reel-mode-time_series,
:where(html[data-theme="dark"]) .job-motion-summary {
  background: var(--ds-color-info-surface);
  border-color: var(--ds-color-info-border);
  color: var(--ds-color-info);
}
:where(html[data-theme="dark"]) .job-state-failed {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
  color: var(--ds-color-danger);
}
:where(html[data-theme="dark"]) .reel-mode-unknown {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) .job-result-box {
  background: var(--ds-color-success-surface);
  border-color: var(--ds-color-success-border);
}
:where(html[data-theme="dark"]) .job-failure-box {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
}

/* Drafts: table, mobile cards, resume panels, and status. */
:where(html[data-theme="dark"]) .draft-table-wrap,
:where(html[data-theme="dark"]) .draft-card,
:where(html[data-theme="dark"]) .draft-empty,
:where(html[data-theme="dark"]) .draft-warning,
:where(html[data-theme="dark"]) .draft-resume-summary,
:where(html[data-theme="dark"]) .draft-resume-form,
:where(html[data-theme="dark"]) .draft-resume-media {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .draft-table th,
:where(html[data-theme="dark"]) .draft-table td {
  border-bottom-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .draft-table th {
  background: var(--ds-color-surface-inset);
}
:where(html[data-theme="dark"]) .draft-error {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
}
:where(html[data-theme="dark"]) .draft-warning {
  background: var(--ds-color-warning-surface);
  border-color: var(--ds-color-warning-border);
}
:where(html[data-theme="dark"]) .draft-resume-kicker,
:where(html[data-theme="dark"]) .draft-card-meta dt {
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) .draft-media-card {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
:where(html[data-theme="dark"]) .draft-media-preview {
  background: var(--ds-color-app-background);
  color: var(--ds-color-text-muted);
}
:where(html[data-theme="dark"]) .draft-media-preview.is-missing {
  border-color: var(--ds-color-border-strong);
}
:where(html[data-theme="dark"]) .draft-confirm-text {
  color: var(--ds-color-warning);
}
:where(html[data-theme="dark"]) .draft-status {
  background: var(--ds-color-success-surface);
  color: var(--ds-color-success);
}
:where(html[data-theme="dark"]) .draft-status.is-converted {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
/* End App Theme Foundation v1. */

/* Library Dark: media-list.php joins the App Theme Foundation through the
   closed container-library variant. Every rule is scoped to
   html[data-theme="dark"] .container-library, reads only Foundation semantic
   tokens, and changes color only: layout, sticky offsets, z-index, overflow,
   and breakpoints stay with the Library rules above, and the intentional
   black media stages and overlay backdrops are not overridden. Selectors
   mirror the Light rules they replace so each override outranks them. */
html[data-theme="dark"] .container-library .media-library-context {
  border-bottom-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-library-context__eyebrow,
html[data-theme="dark"] .container-library .media-library-section-heading__eyebrow,
html[data-theme="dark"] .container-library .media-select-bar__eyebrow,
html[data-theme="dark"] .container-library .media-preview-content__eyebrow,
html[data-theme="dark"] .container-library .media-filter-group h3 {
  color: var(--ds-color-primary);
}
html[data-theme="dark"] .container-library .media-library-context__copy,
html[data-theme="dark"] .container-library .media-library-section-heading__hint,
html[data-theme="dark"] .container-library .media-filter-chips__label,
html[data-theme="dark"] .container-library .media-library-browse .view-switch-link__hint,
html[data-theme="dark"] .container-library .media-preview-pane__eyebrow,
html[data-theme="dark"] .container-library .recommendation-panel__note,
html[data-theme="dark"] .container-library .recommendation-card__meta,
html[data-theme="dark"] .container-library .recommendation-empty,
html[data-theme="dark"] .container-library .selected-media-body span,
html[data-theme="dark"] .container-library .before-after-selection-help,
html[data-theme="dark"] .container-library .video-preview-placeholder {
  color: var(--ds-color-text-muted);
}

/* New Reel flow guidance: the same stage treatment as Production Studio. */
html[data-theme="dark"] .container-library .reel-studio-flow {
  background: var(--ds-color-surface-elevated);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .reel-studio-flow-step {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .reel-studio-flow-step.is-active {
  background: var(--ds-color-primary-fill);
  border-color: var(--ds-color-accent);
  color: var(--ds-color-on-primary);
}
html[data-theme="dark"] .container-library .reel-studio-flow-next,
html[data-theme="dark"] .container-library .reel-studio-flow-next strong {
  color: var(--ds-color-text);
}

/* Recommendations: the warm #8d4b36 family is mapped by meaning. The
   suggestion eyebrow and reasons use the accent, a selected card uses the
   selection border, and only the real review warnings use warning tokens. */
html[data-theme="dark"] .container-library .recommendation-panel {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .recommendation-panel__eyebrow {
  color: var(--ds-color-accent);
}
html[data-theme="dark"] .container-library .recommendation-card {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .recommendation-card.is-selected {
  border-color: var(--ds-color-selected-border);
  box-shadow: 0 0 0 1px var(--ds-color-selected-border);
}
html[data-theme="dark"] .container-library .recommendation-card__media {
  background: var(--ds-color-app-background);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .recommendation-card__reasons li {
  background: var(--ds-color-selected-surface);
  color: var(--ds-color-accent);
}
html[data-theme="dark"] .container-library .recommendation-card__warnings li {
  background: var(--ds-color-warning-surface);
  color: var(--ds-color-warning);
}

/* Browse controls: the sticky band stays opaque on the Dark canvas. */
html[data-theme="dark"] .container-library .media-library-controls {
  background: var(--ds-color-app-background);
}
html[data-theme="dark"] .container-library .media-filter-form {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-filter-details {
  border-top-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-filter-details > summary {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .media-filter-group {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .filter-check,
html[data-theme="dark"] .container-library .media-filter-group__fields .filter-check {
  background: var(--ds-color-surface);
}
/* The Light captured-year field rule outranks the Foundation field rule. */
html[data-theme="dark"] .container-library input[type="number"][name="captured_year"] {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border-field);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .media-filter-chip {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .media-filter-chip:hover,
html[data-theme="dark"] .container-library .media-filter-chip:focus-visible {
  background: var(--ds-color-control-hover);
  border-color: var(--ds-color-accent);
}
html[data-theme="dark"] .container-library .media-list-summary {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .view-switch-link {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .view-switch-link.active {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-accent);
  box-shadow: none;
}

/* Reel Setup and form help keep their position; only the surfaces change. */
html[data-theme="dark"] .container-library .prompt-style-options {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .prompt-style-options label {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .duration-preset-options label:has(input:checked) {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .form-help {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}

/* Selection Workspace surfaces; the sticky / fixed placement stays above. */
html[data-theme="dark"] .container-library .media-select-bar,
html[data-theme="dark"] .container-library .selected-media-panel {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .selected-media-empty {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .selected-media-item {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .selected-media-thumb {
  background: var(--ds-color-app-background);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .sticky-action-bar {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
}
html[data-theme="dark"] .container-library .sticky-action-count {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-library .btn-before-after {
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
@media (max-width: 1100px) {
  html[data-theme="dark"] .container-library .selection-workspace__contextual-action > .time-series-selection-help,
  html[data-theme="dark"] .container-library .selection-workspace__contextual-action > .before-after-selection-help {
    background: var(--ds-color-app-background);
    border-color: var(--ds-color-border);
    color: var(--ds-color-text-muted);
  }
  html[data-theme="dark"] .container-library .selection-workspace__status {
    color: var(--ds-color-text-muted);
  }
}

/* Browse cards and their selection, focus, and status states. */
html[data-theme="dark"] .container-library .media-card {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-card:target {
  outline-color: var(--ds-color-focus);
}
html[data-theme="dark"] .container-library .media-select-card.selected {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  box-shadow: 0 0 0 1px var(--ds-color-selected-border);
}
html[data-theme="dark"] .container-library .media-select-card.is-preview-focused {
  outline-color: var(--ds-color-focus);
}
html[data-theme="dark"] .container-library .selected-ribbon {
  background: var(--ds-color-primary-fill);
  color: var(--ds-color-on-primary);
}
html[data-theme="dark"] .container-library .select-box {
  background: var(--ds-color-surface-inset);
}
html[data-theme="dark"] .container-library .thumb {
  background: var(--ds-color-app-background);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .video-preview-placeholder-label {
  background: var(--ds-color-surface);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .media-card-extra-meta {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .media-card-extra-meta .extra-meta-fav {
  color: var(--ds-color-accent);
}
html[data-theme="dark"] .container-library .video-preview-status.available {
  color: var(--ds-color-success);
}
html[data-theme="dark"] .container-library .video-preview-status.missing {
  color: var(--ds-color-warning);
}
html[data-theme="dark"] .container-library .media-card .badge {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-accent);
}

/* Desktop Drawer and Lightbox chrome; the backdrops and black media stages keep their meaning. */
html[data-theme="dark"] .container-library .media-preview-pane {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
}
html[data-theme="dark"] .container-library .media-preview-pane__header,
html[data-theme="dark"] .container-library .media-preview-pane__footer {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-preview-pane__empty,
html[data-theme="dark"] .container-library .media-preview-content__media.is-missing {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-library .media-preview-content__metadata {
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-library .media-lightbox-panel,
html[data-theme="dark"] .container-library .media-lightbox[data-media-lightbox-mode="mobile-inspector"] .media-lightbox-body {
  background: var(--ds-color-surface);
}
html[data-theme="dark"] .container-library .library-scroll-top {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-primary);
  color: var(--ds-color-primary);
}
/* End Library Dark. */

/* Production Studio Dark: the canonical shell is shared with Dashboard and
   Library, so every visual override stays below this page-only namespace.
   Existing form names, workspace layout, and responsive shell rules remain
   owned by the selectors above. The Dark palette itself is owned by the App
   Theme Foundation; the Studio tokens below only alias it. */
.container.container-studio {
  width: 100%;
  max-width: none;
  padding: 0;
}
.studio-production {
  --studio-bg: var(--ds-color-app-background);
  --studio-surface: var(--ds-color-surface-elevated);
  --studio-panel: var(--ds-color-surface);
  --studio-panel-inset: var(--ds-color-surface-inset);
  --studio-line: var(--ds-color-border);
  --studio-line-strong: var(--ds-color-border-strong);
  --studio-text: var(--ds-color-text);
  --studio-muted: var(--ds-color-text-muted);
  --studio-accent: var(--ds-color-accent);
  --studio-accent-strong: var(--ds-color-primary-fill);
  --studio-success: var(--ds-color-success);
  --studio-warning: var(--ds-color-warning);
  --studio-danger: var(--ds-color-danger);
  background: var(--studio-bg);
  color: var(--studio-text);
}
.reel-studio-production-topbar {
  background: #11191e;
  border-bottom-color: #304047;
  color: #edf4f1;
}
.reel-studio-production-topbar nav a {
  background: #1c292f;
  border-color: #4c646d;
  color: #edf4f1;
}
@media (min-width: 1101px) {
  .reel-studio-production-topbar { display: none; }
}
@media (max-width: 1100px) {
  .studio-production .reel-studio-shell { min-height: 100vh; }
}
.studio-production .reel-studio-shell {
  background: var(--studio-bg);
  color: var(--studio-text);
}
.studio-production .reel-studio-shell__workspace {
  background: var(--studio-bg);
}
.studio-production h1,
.studio-production h2,
.studio-production h3,
.studio-production strong,
.studio-production legend {
  color: var(--studio-text);
}
.studio-production .lead,
.studio-production .meta,
.studio-production .field-help,
.studio-production .form-help,
.studio-production .video-preview-status,
.studio-production .reel-storyboard-note,
.studio-production .reel-storyboard-duration,
.studio-production .reel-storyboard-caption span,
.studio-production .reel-preview-mode-status,
.studio-production .reel-preview-layer-list {
  color: var(--studio-muted);
}
.studio-production .form-help,
.studio-production .json-info-box,
.studio-production .reel-workspace-diagnostic-summary,
.studio-production .reel-workspace-diagnostics,
.studio-production .treatment-summary,
.studio-production .treatment-adjust-rail-details,
.studio-production .treatment-adjust-summary,
.studio-production .treatment-bulk-duration,
.studio-production .prompt-style-panel,
.studio-production .order-policy-panel,
.studio-production .treatment-adjust-card,
.studio-production .before-after-card,
.studio-production .before-after-preview-panel,
.studio-production .reel-storyboard,
.studio-production .reel-storyboard-selected-pane,
.studio-production .reel-workspace-preview {
  background: var(--studio-panel);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .treatment-summary-sticky {
  background: rgba(20, 28, 33, .96);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
}
.studio-production .treatment-summary-item,
.studio-production .prompt-style-options,
.studio-production .order-policy-options label,
.studio-production .treatment-options label,
.studio-production .before-after-duration-options label,
.studio-production .treatment-material-selection-item {
  background: var(--studio-panel-inset);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .treatment-material-selection-item.is-selected,
.studio-production .treatment-material-selection-item[aria-pressed="true"] {
  background: #1d4637;
  border-color: #55a879;
  color: #f3faf6;
}
.studio-production .treatment-material-selection-grid {
  color: var(--studio-text);
}
.studio-production .treatment-material-selection-thumb {
  background: #10171b;
  color: #dce5e1;
}
.studio-production .treatment-summary-item span,
.studio-production .treatment-summary-item strong {
  color: var(--studio-text);
}
.studio-production .treatment-warning,
.studio-production .json-warning-box,
.studio-production .reel-workspace-diagnostic-chip.is-warning {
  background: #332b18;
  border-color: #80662b;
  color: var(--studio-warning);
}
.studio-production .treatment-notice,
.studio-production .json-info-box,
.studio-production .reel-workspace-diagnostic-chip.is-notice {
  background: #162c2a;
  border-color: #35645b;
  color: #a5ded0;
}
.studio-production .json-error-box,
.studio-production .reel-workspace-diagnostic-chip.is-error {
  background: #351d20;
  border-color: #884b50;
  color: var(--studio-danger);
}
.studio-production input[type="text"],
.studio-production input[type="number"],
.studio-production input[type="search"],
.studio-production input[type="password"],
.studio-production input[type="file"],
.studio-production select,
.studio-production textarea {
  background: #0f171b;
  border-color: var(--ds-color-border-field);
  color: var(--studio-text);
}
.studio-production input:disabled,
.studio-production select:disabled,
.studio-production textarea:disabled,
.studio-production input[readonly],
.studio-production textarea[readonly] {
  border-color: var(--studio-line-strong);
}
.studio-production input::placeholder,
.studio-production textarea::placeholder {
  color: #81918d;
}
.studio-production input[type="checkbox"],
.studio-production input[type="radio"] {
  accent-color: var(--studio-accent);
}
.studio-production fieldset {
  border-color: var(--studio-line);
}
.studio-production .button,
.studio-production button {
  background: #1c292f;
  border-color: var(--studio-line-strong);
  color: var(--studio-text);
}
.studio-production .button:hover,
.studio-production button:hover {
  background: #263941;
}
.studio-production button.primary,
.studio-production .button.primary {
  background: var(--studio-accent-strong);
  border-color: var(--studio-accent-strong);
  color: #07150e;
}
.studio-production button.primary:hover,
.studio-production .button.primary:hover {
  background: var(--studio-accent);
  border-color: var(--studio-accent);
}
.studio-production .btn-secondary,
.studio-production .btn-muted {
  background: #1c292f;
  border-color: var(--studio-line-strong);
  color: var(--studio-text);
}
.studio-production a:focus-visible,
.studio-production button:focus-visible,
.studio-production input:focus-visible,
.studio-production select:focus-visible,
.studio-production textarea:focus-visible {
  outline: 3px solid var(--studio-accent);
  outline-offset: 2px;
}
.studio-production .flash {
  background: #162c2a;
  border-color: #35645b;
  color: var(--studio-success);
}
.studio-production .flash.warning {
  background: #332b18;
  border-color: #80662b;
  color: var(--studio-warning);
}
.studio-production .flash.error {
  background: #351d20;
  border-color: #884b50;
  color: var(--studio-danger);
}
.studio-production .reel-studio-flow {
  background: var(--studio-surface);
  border-color: var(--studio-line);
}
.studio-production .reel-studio-flow-step {
  background: #1c292f;
  border-color: var(--studio-line);
  color: var(--studio-muted);
}
.studio-production .reel-studio-flow-step.is-complete {
  background: #173629;
  border-color: #356c50;
  color: var(--studio-success);
}
.studio-production .reel-studio-flow-step.is-active {
  background: var(--studio-accent-strong);
  border-color: var(--studio-accent);
  color: #07150e;
}
.studio-production .reel-studio-flow-next,
.studio-production .reel-studio-flow-next strong {
  color: var(--studio-text);
}
.studio-production .treatment-adjust-thumb,
.studio-production .before-after-card-preview,
.studio-production .reel-storyboard-preview {
  background: #0b1013;
  border-color: var(--studio-line);
}
.studio-production .material-order-number {
  background: #214334;
  color: var(--studio-success);
}
.studio-production .video-preview-status.available { color: var(--studio-success); }
.studio-production .video-preview-status.missing { color: var(--studio-warning); }
.studio-production .reel-workspace-tabs {
  background: var(--studio-surface);
}
.studio-production .reel-workspace-tabs button {
  background: transparent;
  border-color: transparent;
  color: var(--studio-muted);
}
.studio-production .reel-workspace-tabs button:hover,
.studio-production .reel-workspace-tabs button[aria-selected="true"] {
  background: #24353b;
  color: var(--studio-text);
}
.studio-production .reel-preview-mode-controls button.is-active,
.studio-production .reel-preview-text-controls button.is-active {
  background: var(--studio-accent-strong);
  border-color: var(--studio-accent);
  color: #07150e;
  box-shadow: 0 0 0 1px rgba(112, 209, 160, .24);
}
.studio-production .reel-edit-json-advanced textarea {
  background: #0a1115;
  border-color: var(--studio-line-strong);
  color: #e5f3ed;
  caret-color: var(--studio-accent);
}
.studio-production .prompt-mode-switch {
  background: var(--studio-surface);
  border-color: var(--studio-line);
}
.studio-production .prompt-mode-switch button {
  color: var(--studio-muted);
}
.studio-production .prompt-mode-switch button[aria-selected="true"] {
  background: var(--studio-accent-strong);
  color: #07150e;
}
.studio-production .prompt-project-label,
.studio-production .studio-edit-json-primary {
  color: var(--studio-text);
}
.studio-production .studio-edit-json-primary {
  background: var(--studio-panel);
  border-color: var(--studio-line);
}
.studio-production .studio-edit-json-primary textarea,
.studio-production .prompt-project-box {
  background: #0a1115;
  border-color: var(--studio-line-strong);
  color: #e5f3ed;
  caret-color: var(--studio-accent);
}
.studio-production .prompt-box {
  background: #0a1115;
  border-color: var(--studio-line-strong);
  color: #e5f3ed;
  caret-color: var(--studio-accent);
}
.studio-production .reel-storyboard-card {
  background: #172126;
  border-color: var(--studio-line);
}
.studio-production .reel-storyboard-card[data-storyboard-selected] {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 2px rgba(112, 209, 160, .18);
}
.studio-production .reel-storyboard-toggle-button {
  background: #33251d;
  border-color: #856348;
  color: #f0bd91;
}
.studio-production .reel-storyboard-toggle-button:hover {
  background: #453024;
}
.studio-production .reel-workspace-diagnostics > summary,
.studio-production .reel-edit-json-advanced summary {
  color: var(--studio-text);
}
.studio-production .reel-workspace-diagnostics[open] > summary {
  background: #182329;
  border-bottom-color: var(--studio-line);
}
.studio-production .storyboard-duration-match {
  color: var(--studio-success);
}

/* Contrast hardening for the three Production Studio workflow pages. Keep
   every override below the Studio namespace so the existing light UI keeps
   its original palette and interaction contract. The shared Sidebar is owned
   by the App Theme Foundation. */
.studio-production .prompt-style-options label,
.studio-production .order-policy-options label,
.studio-production .treatment-options label {
  background: var(--studio-panel-inset);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .prompt-style-options label:hover,
.studio-production .prompt-style-options label:focus-within,
.studio-production .order-policy-options label:hover,
.studio-production .order-policy-options label:focus-within,
.studio-production .treatment-options label:hover,
.studio-production .treatment-options label:focus-within {
  background: #1c292f;
  border-color: var(--studio-line-strong);
  color: var(--studio-text);
}
.studio-production .prompt-style-options label:has(input:checked),
.studio-production .order-policy-options label:has(input:checked),
.studio-production .treatment-options label:has(input:checked) {
  background: #173629;
  border-color: var(--studio-accent);
  color: var(--studio-text);
  box-shadow: 0 0 0 1px rgba(112, 209, 160, .18);
}
.studio-production .prompt-style-options label:has(input:disabled),
.studio-production .order-policy-options label:has(input:disabled),
.studio-production .treatment-options label:has(input:disabled) {
  background: #151d22;
  border-color: #2a363d;
  color: var(--studio-muted);
  cursor: not-allowed;
  opacity: .58;
}
.studio-production .treatment-bulk-target-toggle {
  background: var(--studio-panel-inset);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .prompt-style-options label small {
  color: var(--studio-muted);
}

.studio-production .treatment-adjust-rail-details > summary {
  color: var(--studio-text);
}
.studio-production .treatment-adjust-rail-details > summary:hover {
  background: #202e34;
  color: var(--studio-text);
}
.studio-production .treatment-adjust-rail-details > summary:focus-visible,
.studio-production .treatment-adjust-summary:focus-visible {
  outline: 3px solid var(--studio-accent);
  outline-offset: 2px;
}
.studio-production .treatment-adjust-summary:hover {
  background: #202e34;
  border-color: var(--studio-line-strong);
  color: var(--studio-text);
}
.studio-production .treatment-adjust-summary-toggle {
  background: #1c292f;
  border: 1px solid var(--studio-line-strong);
  color: var(--studio-muted);
}
.studio-production .treatment-adjust-details:not([open]) > .treatment-adjust-summary .treatment-adjust-summary-toggle {
  background: #1c292f;
  border: 1px solid var(--studio-line-strong);
  color: var(--studio-muted);
}
.studio-production .treatment-adjust-details[open] > .treatment-adjust-summary .treatment-adjust-summary-toggle {
  background: #214334;
  border: 1px solid #356c50;
  color: var(--studio-success);
}
.studio-production .treatment-adjust-summary:hover .treatment-adjust-summary-toggle,
.studio-production .treatment-adjust-summary:focus-visible .treatment-adjust-summary-toggle {
  border-color: var(--studio-accent);
}

.studio-production .json-help-card {
  background: var(--studio-panel);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .json-help-card code {
  background: #0f171b;
  border: 1px solid var(--studio-line);
  color: var(--studio-success);
}
.studio-production .reel-workspace-diagnostic-chip:not(.is-warning):not(.is-notice):not(.is-error) {
  background: var(--studio-panel-inset);
  border-color: var(--studio-line);
  color: var(--studio-text);
}

.studio-production .reel-storyboard-layout-guide {
  background: var(--studio-panel);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .reel-storyboard-layout-guide-eyebrow {
  color: var(--studio-accent);
}
.studio-production .reel-storyboard-layout-guide-note,
.studio-production .reel-storyboard-layout-guide-help,
.studio-production .reel-storyboard-layout-reference-list {
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-layout-guide-warning {
  background: #332b18;
  border-color: #80662b;
  color: var(--studio-warning);
}
.studio-production .reel-storyboard-layout-guide-warning strong {
  color: var(--studio-warning);
}

.studio-production .reel-storyboard-eyebrow,
.studio-production .reel-storyboard-clip-number,
.studio-production .workspace-clip-extra-title {
  color: var(--studio-accent);
}
.studio-production .reel-storyboard-card-meta,
.studio-production .reel-storyboard-submit-note,
.studio-production .reel-storyboard-basic-fields label,
.studio-production .reel-storyboard-effects-fields label,
.studio-production .reel-storyboard-original-name span,
.studio-production .reel-storyboard-usage-status {
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-effects {
  border-top-color: var(--studio-line);
}
.studio-production .reel-storyboard-effects summary {
  color: var(--studio-accent);
}
.studio-production .reel-storyboard-type {
  background: #202c31;
  border: 1px solid var(--studio-line);
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-unresolved {
  background: #332b18;
  border: 1px solid #80662b;
  color: var(--studio-warning);
}
.studio-production .reel-storyboard-treatments li {
  background: #202c31;
  border: 1px solid var(--studio-line);
  color: var(--studio-text);
}
.studio-production .reel-storyboard-treatments li span {
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-card.reel-storyboard-card-disabled {
  background: #151d22;
  border-color: #2a363d;
  opacity: .72;
}
.studio-production .reel-storyboard-disabled-note {
  border: 1px solid var(--studio-line);
  border-left: 3px solid var(--studio-line-strong);
  background: #151d22;
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-duration-summary {
  background: var(--studio-panel);
  border-color: var(--studio-line);
  color: var(--studio-muted);
}
.studio-production .reel-storyboard-duration-summary h3,
.studio-production .reel-storyboard-duration-summary dd {
  color: var(--studio-text);
}
.studio-production .reel-storyboard-clip-errors {
  background: #351d20;
  border-color: #884b50;
  color: var(--studio-danger);
}
.studio-production .workspace-clip-extra {
  background: var(--studio-panel-inset);
  border-color: var(--studio-line);
  color: var(--studio-text);
}
.studio-production .workspace-clip-extra:hover,
.studio-production .workspace-clip-extra:focus-within {
  background: #1c292f;
  border-color: var(--studio-line-strong);
}
.studio-production .workspace-clip-extra:has(select:disabled) {
  background: #151d22;
  border-color: #2a363d;
  color: var(--studio-muted);
  opacity: .62;
}
.studio-production .reel-preview-text-controls-label {
  color: var(--studio-muted);
}

/* On phone-sized Adjustment screens the material comparison must consume the
   full workspace width. Keep the desktop/container-query card rules intact. */
@media screen and (max-width: 700px) {
  .studio-production .treatment-adjust-layout,
  .studio-production .treatment-adjust-main,
  .studio-production .treatment-adjust-main .treatment-adjust-grid {
    width: 100%;
    min-width: 0;
  }
  .studio-production .treatment-adjust-main .treatment-adjust-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-adjust-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-adjust-thumb {
    width: 100%;
    min-height: 220px;
    max-height: 420px;
    aspect-ratio: 16 / 9;
  }
  .studio-production .treatment-adjust-thumb img,
  .studio-production .treatment-adjust-thumb video {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .studio-production .treatment-bulk-duration-controls {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-bulk-duration-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-bulk-duration-actions button {
    width: 100%;
  }
  .studio-production .treatment-adjust-main .treatment-adjust-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-adjust-body,
  .studio-production .treatment-adjust-details[open] > .treatment-adjust-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-adjust-info-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-material-selection-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .studio-production .treatment-material-selection-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .studio-production .treatment-material-selection-actions button {
    width: 100%;
  }
  .studio-production .treatment-material-selection-grid {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    max-height: 260px;
  }
}
/* End Production Studio Dark. */

/* History Dark / Management shell. History owns its readable content width and
   presentation overrides so the shared Browse selectors remain unchanged. */
.history-page {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  color: var(--ds-color-text);
  overflow-wrap: anywhere;
}
.history-page > .studio-management-header {
  align-items: flex-start;
}
.history-page > .studio-management-header h1 {
  margin: 0;
  font-size: var(--ds-font-size-page-title);
}
.history-page > .studio-management-header .ds-help-text {
  margin-bottom: 0;
}
.history-page .media-filter-form,
.history-page .completed-video-filter {
  color: var(--ds-color-text);
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
}
.history-page .media-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ds-space-md);
}
.history-page .media-filter-details > .media-filter-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.history-page .completed-video-filter {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ds-space-md);
  align-items: end;
}
.history-page .completed-video-filter > label:nth-of-type(3) {
  grid-column: span 2;
}
.history-page .completed-video-filter .filter-actions,
.history-page .media-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-sm);
  align-items: center;
}
.history-page .filter-actions > *,
.history-page .media-filter-actions > * {
  min-height: 44px;
}
.history-page .completed-video-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--ds-space-lg);
}
.history-page .filter-check {
  background: var(--ds-color-surface-inset);
}
.history-page details {
  border-top: 1px solid var(--ds-color-border);
}
.history-page details > summary {
  min-height: 44px;
  padding: 8px 2px;
  color: var(--ds-color-primary);
  cursor: pointer;
}
.history-page .media-filter-details > summary {
  color: var(--ds-color-text);
}
.history-page .view-switch-link {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border-strong);
  color: var(--ds-color-text);
}
.history-page .view-switch-link:hover {
  background: var(--ds-color-control-hover);
  border-color: var(--ds-color-border-strong);
}
.history-page .view-switch-link.active {
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
  color: var(--ds-color-accent);
  box-shadow: none;
}
.history-page .media-list-summary {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text);
}
.history-page .media-card,
.history-page .completed-video-card {
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
  box-shadow: var(--ds-shadow-surface);
}
.history-page .thumb {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
  color: var(--ds-color-text-muted);
}
.history-page .media-card-extra-meta {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
.history-page .video-preview-placeholder {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
.history-page .media-lightbox-unavailable {
  background: var(--ds-color-warning-surface);
  color: var(--ds-color-warning);
}
.history-page .completed-video-body > .button {
  display: inline-block;
}
@media (min-width: 1400px) {
  .history-page .media-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .history-page .completed-video-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .history-page .completed-video-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 761px) and (max-width: 800px) {
  .history-page .media-filter-form > .media-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .history-page .media-filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-page .media-filter-details > .media-filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-page .completed-video-filter {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-page .completed-video-filter > label:nth-of-type(3) {
    grid-column: auto;
  }
  .history-page .completed-video-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* End History Dark / Management shell. */

/* Completed Output page: keep the shared History selectors unchanged and
   compose the video preview, decision details, and primary actions here. */
.completed-output-page {
  display: grid;
  gap: var(--ds-space-xl);
  min-width: 0;
  color: var(--ds-color-text);
}
.completed-output-page .completed-output-header {
  align-items: center;
}
.completed-output-page .completed-output-header h1 {
  margin: 0;
  font-size: var(--ds-font-size-page-title);
}
.completed-output-page .completed-output-header .ds-help-text {
  margin-bottom: 0;
}
.completed-output-page .page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--ds-space-sm);
  margin: 0;
}
.completed-output-page .page-actions .button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.completed-output-page .completed-output-toolbar {
  gap: var(--ds-space-md);
  margin: 0;
  background: var(--ds-color-surface);
}
.completed-output-page .archive-toggle {
  gap: var(--ds-space-sm);
  margin: 0;
}
.completed-output-page .archive-toggle .job-status-chip,
.completed-output-page .reel-mode-summary .job-status-chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-sm);
  padding: 8px 14px;
  color: var(--ds-color-text);
  background: var(--ds-color-surface-inset);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-control);
  text-decoration: none;
}
.completed-output-page .archive-toggle .job-status-chip.active,
.completed-output-page .reel-mode-summary .job-status-chip.active {
  color: var(--ds-color-accent);
  background: var(--ds-color-selected-surface);
  border-color: var(--ds-color-selected-border);
}
.completed-output-page .archive-toggle .job-status-chip:hover,
.completed-output-page .reel-mode-summary .job-status-chip:hover {
  background: var(--ds-color-control-hover);
  border-color: var(--ds-color-border-strong);
}
.completed-output-page .completed-video-filter {
  grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(120px, .72fr)) auto;
  gap: var(--ds-space-md);
  align-items: end;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.completed-output-page .completed-video-filter label {
  min-width: 0;
  color: var(--ds-color-text-muted);
}
.completed-output-page .completed-video-filter input,
.completed-output-page .completed-video-filter select {
  width: 100%;
  min-height: 44px;
}
.completed-output-page .completed-video-filter .filter-actions {
  gap: var(--ds-space-sm);
  align-items: center;
}
.completed-output-page .completed-video-filter .filter-actions > * {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.completed-output-page .completed-output-count {
  margin: 0;
  padding: var(--ds-space-sm) var(--ds-space-md);
  color: var(--ds-color-text);
  background: var(--ds-color-surface-inset);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-control);
}
.completed-output-page .completed-output-empty {
  margin: 0;
  padding: var(--ds-space-lg);
  color: var(--ds-color-text-muted);
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-surface);
}
.completed-output-page .reel-mode-summary {
  gap: var(--ds-space-sm);
  margin: 0;
}
.completed-output-page .reel-mode-summary .job-status-chip {
  min-height: 48px;
}
.completed-output-page .reel-mode-summary .job-status-chip strong {
  color: inherit;
}
.completed-output-page .page-links.completed-videos-pagination {
  justify-content: flex-start;
  gap: var(--ds-space-sm);
  margin: 0;
}
.completed-output-page .completed-videos-pagination .button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.completed-output-page .completed-videos-pagination .meta {
  align-self: center;
  color: var(--ds-color-text-muted);
}
.completed-output-page .completed-video-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: var(--ds-space-lg);
  align-items: start;
}
.completed-output-page .completed-video-card {
  container-type: inline-size;
  min-width: 0;
  padding: var(--ds-space-md);
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
  border-radius: var(--ds-radius-surface);
  box-shadow: var(--ds-shadow-surface);
}
.completed-output-page .archive-badge {
  width: fit-content;
  margin: 0 0 var(--ds-space-sm);
}
.completed-output-page .completed-video-content {
  display: grid;
  grid-template-columns: minmax(136px, .62fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--ds-space-lg);
  min-width: 0;
}
.completed-output-page .completed-video-preview {
  width: min(100%, 190px);
  margin: 0 auto;
  overflow: visible;
  background: var(--ds-color-surface-inset);
}
.completed-output-page .completed-video-preview video {
  border-radius: var(--ds-radius-control);
}
.completed-output-page .completed-video-body {
  display: grid;
  align-content: start;
  gap: var(--ds-space-sm);
  min-width: 0;
}
.completed-output-page .completed-video-body h2 {
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-card-title);
  overflow-wrap: anywhere;
}
.completed-output-page .completed-video-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ds-space-xs) var(--ds-space-md);
}
.completed-output-page .completed-video-meta .meta {
  min-width: 0;
  color: var(--ds-color-text-muted);
  overflow-wrap: anywhere;
}
.completed-output-page .completed-video-path {
  margin: 0;
  padding: var(--ds-space-sm) var(--ds-space-md);
  color: var(--ds-color-text-muted);
  background: var(--ds-color-surface-inset);
  border: 1px solid var(--ds-color-border);
  overflow-wrap: anywhere;
}
.completed-output-page .completed-video-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(11.5em, 100%), 1fr));
  gap: var(--ds-space-sm);
  margin: var(--ds-space-sm) 0;
}
.completed-output-page .completed-video-actions > .button,
.completed-output-page .completed-video-actions > .job-action-form,
.completed-output-page .completed-video-actions > .job-action-form button {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}
.completed-output-page .completed-video-actions > .button,
.completed-output-page .completed-video-actions > .job-action-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.completed-output-page .completed-video-secondary-actions {
  display: flex;
  margin-top: var(--ds-space-xs);
}
.completed-output-page .completed-video-secondary-actions .job-action-form {
  width: min(100%, 320px);
}
.completed-output-page .completed-video-secondary-actions .job-action-form button {
  width: 100%;
  min-height: 44px;
  color: var(--ds-color-text-muted);
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border);
}
.completed-output-page .completed-video-secondary-actions .job-action-form button:hover {
  color: var(--ds-color-text);
  background: var(--ds-color-control-hover);
  border-color: var(--ds-color-border-strong);
}
.completed-output-page .completed-video-body .completed-output-details {
  min-width: 0;
  border-top: 1px solid var(--ds-color-border);
}
.completed-output-page .completed-output-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--ds-color-primary);
  cursor: pointer;
}
.completed-output-page .completed-output-details ul {
  padding-inline-start: 1.25rem;
}
.completed-output-page .completed-output-details .job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-sm);
  margin: 0 0 var(--ds-space-sm);
}
.completed-output-page .completed-output-details .job-action-form {
  width: min(100%, 360px);
}
.completed-output-page .completed-output-details .job-action-form button {
  width: 100%;
  min-height: 44px;
}
.completed-output-page .completed-output-details li,
.completed-output-page .completed-output-details a {
  overflow-wrap: anywhere;
}
.completed-output-page .completed-output-details pre {
  color: var(--ds-color-text);
  background: var(--ds-color-surface-inset);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.completed-output-page .media-lightbox-unavailable {
  display: grid;
  place-items: center;
  padding: var(--ds-space-md);
  color: var(--ds-color-warning);
  background: var(--ds-color-warning-surface);
  text-align: center;
}
.completed-output-page .bottom-links {
  margin-top: 0;
}
@media (max-width: 900px) {
  .completed-output-page .completed-video-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@container (max-width: 360px) {
  .completed-output-page .completed-video-content {
    grid-template-columns: minmax(0, 1fr);
  }
  .completed-output-page .completed-video-preview {
    width: min(100%, 190px);
  }
}
@media (max-width: 760px) {
  .completed-output-page .completed-output-header {
    display: block;
  }
  .completed-output-page .page-actions {
    justify-content: flex-start;
    margin-top: var(--ds-space-md);
  }
  .completed-output-page .completed-output-toolbar {
    padding: var(--ds-space-md);
  }
  .completed-output-page .completed-video-filter {
    grid-template-columns: minmax(0, 1fr);
  }
  .completed-output-page .completed-video-filter .filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .completed-output-page .completed-video-filter .filter-actions > * {
    width: 100%;
  }
  .completed-output-page .completed-video-content {
    grid-template-columns: minmax(0, 1fr);
  }
  .completed-output-page .completed-video-preview {
    width: min(100%, 260px);
  }
  .completed-output-page .completed-videos-pagination {
    flex-wrap: wrap;
    overflow: visible;
  }
  .completed-output-page .completed-videos-pagination .button {
    width: auto;
    white-space: nowrap;
  }
}
@media (max-width: 560px) {
  .completed-output-page .page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .completed-output-page .page-actions .button {
    justify-content: center;
    text-align: center;
  }
}
/* End Completed Output page. */

/* Navigation v2: global places, one sticky workspace switch, page-owned actions. */
.app-navigation-toggle,
.app-navigation-toggle-label { display: none; }
.reel-studio-sidebar { overflow-y: auto; z-index: 80; }
.reel-studio-sidebar__group > summary {
  cursor: pointer;
  min-height: 44px;
  padding: 12px 8px;
  color: var(--ds-color-text);
  font-size: 13px;
  letter-spacing: normal;
}
.reel-studio-sidebar__group.is-active > summary { font-weight: 800; }
.reel-studio-sidebar__group > summary:focus-visible,
.workspace-navigation a:focus-visible {
  outline: 3px solid var(--ds-color-focus);
  outline-offset: -3px;
}
.reel-studio-sidebar__link.app-navigation-create {
  border: 1px solid var(--ds-color-border);
  background: var(--ds-color-selected-surface);
  font-weight: 800;
}
.workspace-list,
.workspace-editor,
.workspace-detail,
.workspace-flow {
  width: 100%;
  min-width: 0;
  margin-inline: auto;
  padding: 24px clamp(24px, 2vw, 32px) 40px;
}
.reel-studio-shell .workspace-list { max-width: 2400px; }
.reel-studio-shell .workspace-editor { max-width: 2000px; }
.reel-studio-shell .workspace-detail { max-width: 1800px; }
.reel-studio-shell .workspace-flow { max-width: 2200px; }
.workspace-header { position: static; margin: 0 0 16px; }
.workspace-header h1 { margin-top: 0; }
.workspace-header .page-actions { margin-bottom: 0; }
.workspace-navigation {
  position: sticky;
  top: 0;
  z-index: 60;
  min-width: 0;
  margin-bottom: 20px;
  padding: 8px 0;
  background: var(--ds-color-app-background);
  border-bottom: 1px solid var(--ds-color-border);
}
.workspace-navigation__tabs,
.visual-prompt-options-management .workspace-navigation__fields {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
}
.workspace-navigation__tabs a,
.workspace-navigation__fields a {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 14px;
  white-space: nowrap;
  border: 1px solid var(--ds-color-border);
  border-radius: 8px;
  color: var(--ds-color-text);
  text-decoration: none;
}
.workspace-navigation a[aria-current] {
  background: var(--ds-color-selected-surface);
  border-bottom: 3px solid var(--ds-color-focus);
  font-weight: 800;
}
html[data-theme="dark"] .workspace-navigation a[aria-current] { color: var(--ds-color-text); }
.library-asset-shell__column {
  /* One tab row: active link line/borders, tab padding, nav padding/border. */
  --library-workspace-navigation-height: calc(max(44px, 1.6em + 20px) + 21px);
  --library-workspace-navigation-top: 0px;
  width: 100%; max-width: 2400px; margin-inline: auto;
}
.library-asset-shell__header.workspace-header { padding: 24px clamp(24px, 2vw, 32px) 0; }
.library-asset-shell__column > .workspace-navigation { margin-inline: clamp(24px, 2vw, 32px); }
.library-asset-shell__column .workspace-list { padding-top: 0; }
@media (min-width: 701px) {
  .container-library .library-asset-shell__column .media-library-controls {
    top: calc(var(--library-workspace-navigation-top) + var(--library-workspace-navigation-height));
  }
  .container-library .library-asset-shell__column .sticky-action-bar {
    top: calc(var(--library-workspace-navigation-top) + var(--library-workspace-navigation-height) + var(--library-controls-height) + 10px);
  }
}
.workspace-editor-columns {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}
.workspace-editor-columns > .form.wide { max-width: none; }
.workspace-editor-columns > *,
.workspace-editor-support textarea { min-width: 0; width: 100%; }
.workspace-editor-support {
  padding: 20px;
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border);
  border-radius: 12px;
  overflow-wrap: anywhere;
}
/* Only the three Prompt Builder workspaces use this viewport-bound inspector. */
.prompt-inspector-workspace { --prompt-inspector-top: 84px; }
.prompt-inspector-workspace > .prompt-inspector {
  position: sticky;
  top: var(--prompt-inspector-top);
  max-height: min(calc(100dvh - var(--prompt-inspector-top) - 24px), var(--prompt-inspector-height, 100dvh));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.prompt-inspector__header { flex: 0 0 auto; padding: 16px 20px 12px; border-bottom: 1px solid var(--ds-color-border); }
.prompt-inspector__header h2 { margin: 0 0 10px; font-size: 1.15rem; }
.prompt-inspector__count { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.prompt-inspector__count h3 { margin: 0; font-size: 1rem; }
.prompt-inspector__count span { font-variant-numeric: tabular-nums; white-space: nowrap; }
.prompt-inspector__status { margin: 8px 0 0; min-height: 1.6em; font-size: .85rem; color: var(--ds-color-text-muted); }
.prompt-inspector__body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 20px 20px; }
.prompt-inspector__body:focus-visible { outline: 2px solid var(--ds-color-focus); outline-offset: -2px; }
.prompt-inspector__current { margin: 0 0 20px; display: grid; gap: 12px; }
.prompt-inspector__current dt { font-weight: 700; font-size: .85rem; }
.prompt-inspector__current dd { margin: 4px 0 0; white-space: pre-wrap; }
.prompt-inspector__current small { display: block; margin-top: 3px; font-size: .78rem; font-weight: 400; color: var(--ds-color-text-muted); }
.prompt-inspector__current dt small { display: inline; margin-left: 8px; }
.prompt-inspector__current .is-unspecified { color: var(--ds-color-text-muted); }
.prompt-inspector__output + .prompt-inspector__output { margin-top: 20px; }
.prompt-inspector__output h3 { margin: 0 0 8px; font-size: 1rem; }
.prompt-inspector__output details { margin-top: 10px; border-top: 1px solid var(--ds-color-border); padding-top: 10px; }
.prompt-inspector__output summary { cursor: pointer; min-height: 32px; font-weight: 700; }
.prompt-inspector__textarea-label { display: block; margin: 6px 0; font-size: .85rem; }
.prompt-inspector__output textarea { width: 100%; resize: vertical; max-height: 45dvh; margin-bottom: 8px; }
.prompt-inspector__japanese { white-space: pre-wrap; line-height: 1.7; }
.prompt-inspector__registration { margin: 20px 0 0; }
.prompt-inspector__analysis { margin-block: 0 20px; border-block: 1px solid var(--ds-color-border); padding-block: .65rem; }
.prompt-inspector__analysis > summary { cursor: pointer; min-height: 32px; font-weight: 700; }
.bgm-diagnostics { min-width: 0; margin-block-end: 1rem; padding-block-end: 1rem; border-bottom: 1px solid var(--ds-color-border); overflow-wrap: anywhere; }
.bgm-diagnostics > h3 { margin: 0 0 .5rem; font-size: 1rem; }
.bgm-diagnostics__availability { margin: 0 0 .75rem; font-weight: 700; }
.bgm-diagnostics__selections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .75rem; margin: 0 0 .75rem; }
.bgm-diagnostics__selections > div { min-width: 0; }
.bgm-diagnostics__selections dt { font-size: .8rem; font-weight: 700; color: var(--ds-color-text-muted); }
.bgm-diagnostics__selections dd { margin: .15rem 0 0; overflow-wrap: anywhere; }
.bgm-diagnostics__items { display: grid; gap: .65rem; }
.bgm-diagnostic { min-width: 0; padding: .65rem; border: 1px solid var(--ds-color-border); border-inline-start-width: .3rem; border-radius: .35rem; overflow-wrap: anywhere; }
.bgm-diagnostic--error { border-inline-start-color: var(--ds-color-danger, currentColor); }
.bgm-diagnostic--warning { border-inline-start-color: var(--ds-color-warning, currentColor); }
.bgm-diagnostic--info { border-inline-start-color: var(--ds-color-focus, currentColor); }
.bgm-diagnostic h4 { margin: 0 0 .35rem; font-size: .95rem; }
.bgm-diagnostic h4 span { font-size: .75rem; letter-spacing: .03em; }
.bgm-diagnostic p { margin: .35rem 0; }
.bgm-diagnostic button { max-width: 100%; white-space: normal; }
.bgm-diagnostics__truncated { margin: .5rem 0; font-weight: 700; }
.bgm-diagnostics__log { min-width: 0; margin-block-start: .75rem; padding-block-start: .65rem; border-top: 1px solid var(--ds-color-border); }
.bgm-diagnostics__log > summary { cursor: pointer; min-height: 36px; font-weight: 700; }
.bgm-diagnostics__log > p { margin: .4rem 0; }
.bgm-diagnostics__log > label { display: block; margin-block: .45rem; font-weight: 700; }
.bgm-diagnostics__log textarea { box-sizing: border-box; display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 12rem; resize: vertical; white-space: pre-wrap; overflow-wrap: anywhere; }
.bgm-diagnostics__confirm { display: flex !important; align-items: flex-start; gap: .5rem; }
.bgm-diagnostics__confirm input { flex: 0 0 auto; margin-block-start: .25rem; }
.bgm-diagnostics__log button { max-width: 100%; white-space: normal; }
[data-bgm-diagnostics-copy-status] { min-height: 1.4em; }
@media (max-width: 420px) {
  .bgm-diagnostics__selections { grid-template-columns: minmax(0, 1fr); }
  .bgm-diagnostics { padding-inline: 0; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .prompt-inspector-workspace { --prompt-inspector-top: 140px; }
}
@media (max-width: 760px) {
  .prompt-inspector-workspace > .prompt-inspector { position: static; max-height: none; }
  .prompt-inspector-workspace .prompt-inspector__body { overflow: visible; }
}
.reel-studio-shell :is(a, button, input, select, textarea, summary) { scroll-margin-top: 150px; }
@media (max-width: 1100px) {
  .reel-studio-dashboard-topbar,
  .reel-studio-library-topbar,
  .reel-studio-management-topbar,
  .reel-studio-production-topbar { display: none; }
  .app-navigation-toggle {
    display: block;
    position: fixed;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    z-index: 110;
  }
  .app-navigation-toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
    padding: 12px 18px;
    background: var(--ds-color-surface);
    border-bottom: 1px solid var(--ds-color-border);
    cursor: pointer;
  }
  .app-navigation-toggle:focus-visible + .app-navigation-toggle-label {
    outline: 3px solid var(--ds-color-focus);
    outline-offset: -3px;
  }
  .app-navigation-toggle:checked ~ .reel-studio-sidebar {
    display: flex;
    position: fixed;
    top: 56px;
    left: 0;
    width: min(88vw, 320px);
    height: calc(100dvh - 56px);
    z-index: 90;
    box-shadow: 12px 0 30px var(--ds-color-app-background);
  }
  .workspace-navigation { top: 56px; }
  .library-asset-shell__column { --library-workspace-navigation-top: 56px; }
}
@media (max-width: 760px) {
  .reel-studio-shell :is(.workspace-list, .workspace-editor, .workspace-detail, .workspace-flow) { padding: 18px; }
  /* The legacy mobile nav margin adds 12px to the single tab row. */
  .library-asset-shell__column { --library-workspace-navigation-height: calc(max(44px, 1.6em + 20px) + 33px); }
  .library-asset-shell__header.workspace-header { padding: 18px 18px 0; }
  .library-asset-shell__column > .workspace-navigation { margin-inline: 18px; }
  .library-asset-shell__column .workspace-list { padding-top: 0; }
  .workspace-editor-columns { grid-template-columns: minmax(0, 1fr); }
  .workspace-editor-support { padding: 16px; }
  .workspace-header h1 { overflow-wrap: anywhere; }
}

/* App-wide Dark completion for the remaining first-party screens. Page
   structure stays owned by each route; these selectors only map legacy
   surfaces and feedback onto the existing App Theme Foundation tokens. */
html[data-theme="dark"] .container-auth .auth-panel {
  color: var(--ds-color-text);
  background: var(--ds-color-surface);
  border-color: var(--ds-color-border);
  box-shadow: var(--ds-shadow-surface);
}
html[data-theme="dark"] .container-auth .auth-panel h1 {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-auth input:-webkit-autofill,
html[data-theme="dark"] .container-auth input:-webkit-autofill:hover,
html[data-theme="dark"] .container-auth input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ds-color-text);
  box-shadow: 0 0 0 1000px var(--ds-color-surface-inset) inset;
  caret-color: var(--ds-color-text);
}
html[data-theme="dark"] .container-auth input:-moz-autofill {
  box-shadow: 0 0 0 1000px var(--ds-color-surface-inset) inset;
  filter: none;
}

html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :is(h1, h2, h3, legend) {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration details {
  border-color: var(--ds-color-border);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration details > summary {
  border-radius: var(--ds-radius-control);
  color: var(--ds-color-text);
  cursor: pointer;
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration details > summary:hover,
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration details[open] > summary {
  color: var(--ds-color-primary);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration details > summary:focus-visible {
  outline: 2px solid var(--ds-color-focus);
  outline-offset: 2px;
}
/* Keep the compatibility mapping opt-in to these 13 legacy migration routes.
   Semantic feedback classes stay out of this neutral surface list so their
   danger/warning/info palette cannot be flattened by :is() specificity. */
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.form-help, .json-help-card, .upload-complete, .upload-preview, .upload-preview-card, .uploaded-preview-card, .pt-candidate-card, .instagram-post-pattern-guide, .media-edit-ai, .media-edit-action-bar, .bulk-apply-mode, .treatment-notice, .edit-layout > .thumb.large) {
  border-color: var(--ds-color-border);
  background: var(--ds-color-surface);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.json-info-box) {
  border-color: var(--ds-color-info-border);
  background: var(--ds-color-info-surface);
  color: var(--ds-color-info);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.json-error-box, .instagram-post-alert-danger) {
  border-color: var(--ds-color-danger-border);
  background: var(--ds-color-danger-surface);
  color: var(--ds-color-danger);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.json-warning-box, .instagram-post-alert-warning) {
  border-color: var(--ds-color-warning-border);
  background: var(--ds-color-warning-surface);
  color: var(--ds-color-warning);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.field-help, .checkbox-help, .form-help, .upload-complete p, .uploaded-preview-meta, .uploaded-preview-memo, .upload-preview-meta, .upload-preview-empty, .pt-quality-flags, .pt-preview-toolbar-label, .instagram-post-prompt-intro, .media-edit-ai__notice, .media-edit-ai__status, .media-edit-ai__candidate p, .media-edit-action-bar__hint) {
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.checkbox-main, .tag-group, .tag-grid label, .check-row, .select-box, .bulk-apply-mode-option, .upload-preview-empty, .uploaded-preview-media, .media-edit-ai__candidate, .media-edit-action-bar__actions) {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.checkbox-main, .tag-group, .tag-grid label, .check-row, .select-box, .bulk-apply-mode, .media-edit-ai, .media-edit-ai__candidate, .media-edit-action-bar, .media-edit-action-bar__actions, .upload-preview-card, .uploaded-preview-card, .pt-candidate-card, .instagram-post-pattern-guide) {
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .tag-group h3 {
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .motion-summary-list div {
  border-color: var(--ds-color-border);
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .motion-summary-list dt {
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .motion-summary-list dd {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration input[type="number"][name="captured_year"] {
  background: var(--ds-color-surface-inset);
  border-color: var(--ds-color-border-field);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration input[type="number"][name="captured_year"]:focus {
  border-color: var(--ds-color-accent);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration input[type="number"][name="captured_year"]:disabled {
  background: var(--ds-color-disabled-background);
  color: var(--ds-color-disabled-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.instagram-post-pattern-guide[open] summary, .media-edit-ai__candidate) {
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.instagram-post-copy-status:not(:empty), .instagram-post-copy-status.is-error) {
  background: var(--ds-color-success-surface);
  border-color: var(--ds-color-success-border);
  color: var(--ds-color-success);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .instagram-post-copy-status.is-error {
  background: var(--ds-color-danger-surface);
  border-color: var(--ds-color-danger-border);
  color: var(--ds-color-danger);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .instagram-post-copy-status {
  color: var(--ds-color-success);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-preview-media {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-preview-media video,
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-lightbox-body {
  background: #111;
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-preview-unavailable {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .video-preview-placeholder {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .video-preview-placeholder-label {
  background: var(--ds-color-surface);
  color: var(--ds-color-text-muted);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-lightbox-panel {
  background: var(--ds-color-surface);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .upload-lightbox-unavailable {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .media-edit-action-bar {
  background: var(--ds-color-surface);
  box-shadow: 0 -8px 22px rgba(0, 0, 0, .24);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .pt-candidate-card:focus-within {
  border-color: var(--ds-color-accent);
  box-shadow: 0 0 0 2px var(--ds-color-focus);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .pt-candidate-choose {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .pt-quality-ok strong {
  color: var(--ds-color-success);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .pt-quality-caution strong {
  color: var(--ds-color-warning);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :is(.pt-quality-review strong, .pt-quality-unknown strong) {
  color: var(--ds-color-danger);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .media-edit-ai__status.is-error {
  color: var(--ds-color-danger);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .media-edit-ai__candidate {
  background: var(--ds-color-surface-inset);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.media-edit-ai__candidate, .media-edit-action-bar, .upload-preview-card, .uploaded-preview-card, .pt-candidate-card, .instagram-post-pattern-guide, .bulk-apply-mode) {
  box-shadow: var(--ds-shadow-surface);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration table,
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration th,
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration td {
  border-color: var(--ds-color-border);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration th {
  background: var(--ds-color-surface-inset);
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration :where(.page-actions, .actions, .form-actions, .upload-complete-actions, .media-edit-action-bar__actions, .filter-actions) {
  gap: var(--ds-space-sm);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration .reel-studio-shell__workspace {
  color: var(--ds-color-text);
}
html[data-theme="dark"] .container-management .reel-studio-shell--dark-migration audio {
  color-scheme: dark;
}
/* End App-wide Dark completion. */
