﻿/* ==========================================================================
   HAMSTER 画面別スタイル (screens.css)
   ==========================================================================
   GAS版の画面別CSS (css-home, css-main, css-storyboard, css-gallery,
   css-imagedb, css-usage, css-videogallery, css-responsive) を統合。
   各画面固有のコンポーネントスタイルを定義。
   ========================================================================== */

/* ---------------------------------------------------------------------------
   画像生成ギャラリー 指示メニュー
   GAS版 css-gallery.html を Firebase テーマ変数で再現。
   --------------------------------------------------------------------------- */

/* 各画面のテーマカラー（画面別アクセント）を画面全体で統一する。
   生成パネル、カード、バッジ、タブなど全要素で画面テーマカラーのみを使用する。 */

.gallery-layout {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  min-height: 560px;
  isolation: isolate;
}

.gallery-layout .media-gallery-results {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.gallery-layout.is-generation-unavailable .media-gallery-results,
.gallery-layout.is-generation-unavailable.is-collapsed .media-gallery-results,
.gallery-layout.is-generation-unavailable.is-panel-left .media-gallery-results,
.gallery-layout.is-generation-unavailable.is-collapsed.is-panel-left .media-gallery-results {
  max-width: none;
}

.gallery-layout.is-generation-unavailable .gallery-generate-panel {
  display: none;
}

.gallery-generate-panel {
  /* ギャラリー内のサイドタブとして配置し、画像一覧の上には重ねない。 */
  --gallery-panel-accent: var(--color-gallery);
  --gallery-panel-accent-dark: var(--color-gallery-dark);
  --gallery-panel-accent-rgb: var(--color-gallery-rgb);
  order: 2;
  flex: 0 0 390px;
  position: sticky;
  top: calc(var(--header-height) + 24px);
  width: 390px;
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
  padding: 18px;
  background: var(--surface-glass);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.16);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px) saturate(1.08);
  z-index: var(--z-content);
  transition: flex-basis 0.2s ease, width 0.2s ease, padding 0.2s ease, border-radius 0.2s ease;
}

.gallery-generate-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.07), transparent 160px);
}

.gallery-layout.is-panel-left .gallery-generate-panel {
  order: 1;
}

.gallery-layout.is-panel-left .media-gallery-results {
  order: 2;
}

.gallery-layout.is-collapsed .gallery-generate-panel {
  position: fixed;
  top: max(calc(50% + var(--header-height) / 2), calc(var(--header-height) + 24px));
  right: 0;
  left: auto;
  flex-basis: auto;
  width: 44px;
  min-height: 172px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  overflow: visible;
  pointer-events: none;
  transform: translateY(-50%);
  z-index: var(--z-floating-panel);
}

.gallery-layout.is-collapsed.is-panel-left .gallery-generate-panel {
  right: auto;
  left: 0;
}

.gallery-layout.is-collapsed .gallery-generate-panel::before {
  display: none;
}

.gallery-layout.is-collapsed .generation-panel-controls {
  pointer-events: auto;
}

.gallery-layout.is-collapsed .gallery-generator-body {
  display: none;
}

.generation-panel-controls {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  min-width: 0;
  pointer-events: auto;
}

.gallery-panel-toggle {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.08);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.gallery-panel-toggle:hover,
.generation-panel-position-select:hover {
  color: var(--gallery-panel-accent);
  background: rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.18);
}

.gallery-toggle-icon {
  display: inline-flex;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #fff;
  background: var(--gallery-panel-accent);
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.gallery-layout.is-collapsed .gallery-panel-toggle {
  width: 44px;
  height: 160px;
  margin-bottom: 0;
  padding: 10px 8px;
  flex-direction: column;
  border-radius: 20px 0 0 20px;
}

.gallery-layout.is-collapsed.is-panel-left .gallery-panel-toggle {
  border-radius: 0 20px 20px 0;
}

.gallery-layout.is-collapsed .generation-panel-controls {
  margin-bottom: 0;
}

.gallery-layout.is-collapsed .generation-panel-position-select {
  display: none;
}

.gallery-layout.is-collapsed .gallery-toggle-icon {
  transform: rotate(180deg);
}

.gallery-layout.is-collapsed .gallery-toggle-text {
  writing-mode: vertical-rl;
  letter-spacing: 0.08em;
}

.gallery-toggle-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.generation-panel-position-select {
  box-sizing: border-box;
  flex: 0 0 76px;
  width: 76px;
  height: 38px;
  padding: 0 24px 0 12px;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 38px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.gallery-generate-panel .generation-panel-position-select {
  width: 76px;
  padding: 0 24px 0 12px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.08);
  border-color: transparent;
  border-radius: 999px;
  font-size: var(--text-sm);
  line-height: 38px;
}

.gallery-generator-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
}

.gallery-generate-panel h2 {
  margin-bottom: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.gallery-db-hint,
.gallery-db-empty {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.gallery-generate-panel textarea,
.gallery-generate-panel select {
  width: 100%;
  padding: 10px 12px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.14);
  border-radius: 14px;
  font: inherit;
}

.gallery-generate-panel textarea {
  /* サイドタブ内では本文入力が大きく見えすぎるため、読みやすさを保つ範囲で少し詰める。 */
  font-size: var(--text-sm);
  line-height: 1.55;
  min-height: 132px;
  background: linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.05), rgba(255, 255, 255, 0.94));
}

.gallery-generate-panel textarea:focus,
.gallery-generate-panel select:focus {
  outline: none;
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.5);
}

.gallery-db-section,
.gallery-reference-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
}

.gallery-reference-label,
.gallery-db-label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gallery-reference-section,
.gallery-db-section {
  /* 小さな枠の連続を避け、余白と薄い下線で入力群を区切る。 */
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-radius: 0;
}

.gallery-reference-header,
.gallery-db-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gallery-ref-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  margin-bottom: 12px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.06);
  border: 1px dashed rgba(var(--gallery-panel-accent-rgb), 0.28);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.gallery-ref-drop-zone:hover,
.gallery-ref-drop-zone.is-dragover,
.gallery-ref-drop-zone:focus-visible,
#galleryRefImageInput:focus-visible + .gallery-ref-drop-zone {
  background: rgba(var(--gallery-panel-accent-rgb), 0.1);
  border-color: var(--gallery-panel-accent);
  outline: 3px solid rgba(var(--gallery-panel-accent-rgb), 0.14);
  outline-offset: 2px;
}

.gallery-ref-drop-icon {
  color: var(--gallery-panel-accent);
}

.gallery-ref-drop-text {
  font-size: 13px;
  font-weight: 600;
}

.gallery-ref-drop-hint {
  font-size: 11px;
}

.gallery-ref-preview-list,
.gallery-db-image-list,
.gallery-selected-db-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-selected-db-images:empty {
  display: none;
}

.gallery-db-image-list {
  max-height: 180px;
  overflow-y: auto;
}

.gallery-db-image-item {
  width: 60px;
  height: 60px;
  padding: 3px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.gallery-db-image-item:hover,
.gallery-db-image-item.selected {
  border-color: var(--color-gallery);
  transform: translateY(-1px);
}

.gallery-db-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 7px;
}

.gallery-ref-preview-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gallery-ref-preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.gallery-ref-preview-thumb:hover {
  border-color: var(--color-danger);
}

.gallery-ref-preview-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-gallery);
}

.gallery-selected-db-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px 4px 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.gallery-selected-db-order {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--color-gallery);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.gallery-selected-db-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 999px;
}

.gallery-selected-db-name {
  max-width: 170px;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   GAS版 モデル設定パネル
   --------------------------------------------------------------------------- */
.image-gen-config-panel {
  /* 実寸サイズ表示が長いため、size列だけ広げて横圧迫を吸収する。 */
  display: grid;
  grid-template-columns: minmax(112px, 1.35fr) minmax(58px, 0.6fr) minmax(108px, 0.95fr) minmax(54px, 0.6fr);
  gap: 6px;
  margin-bottom: 0;
  padding: 12px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-radius: 0;
}

.image-gen-config-panel > .model-selector {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 0;
  padding: 0;
  background: none;
  border: none;
  border-bottom: 0;
  border-radius: 0;
}

.image-gen-config-panel > .model-selector label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.image-gen-config-panel > .model-selector select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.14);
  border-radius: 14px;
  font-size: 13px;
}

.image-settings-panel {
  display: contents;
}

.image-setting-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.image-setting-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.image-setting-field select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.gallery-anima-instructions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}

.gallery-anima-instructions[hidden] {
  display: none;
}

.gallery-anima-instructions > label,
.gallery-anima-settings label {
  font-size: 12px;
  font-weight: 700;
}

.gallery-anima-instructions textarea,
.gallery-anima-instructions input,
.gallery-anima-instructions select {
  width: 100%;
}

.gallery-anima-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 0.8fr);
  gap: 10px;
}

@media (max-width: 700px) {
  .gallery-anima-settings {
    grid-template-columns: 1fr;
  }
}

.image-setting-field--size select {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  padding-right: 4px;
}

@media (max-width: 480px) {
  .image-gen-config-panel {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }

  .image-setting-field--size {
    grid-column: span 2;
  }
}

/* ---------------------------------------------------------------------------
   GAS版 ローカル参照画像アップロードリスト
   --------------------------------------------------------------------------- */
.gallery-ref-upload-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------------------------------------------------------------------------
   GAS版 参照画像解析ボタン
   --------------------------------------------------------------------------- */
.gallery-ref-analyze-btn {
  padding: 2px 8px;
  color: var(--color-gallery);
  font-size: 10px;
  font-weight: 700;
  background: rgba(var(--color-gallery-rgb), 0.08);
  border: 1px solid rgba(var(--color-gallery-rgb), 0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  line-height: 1.3;
}

.gallery-ref-analyze-btn:hover:not(:disabled) {
  background: rgba(var(--color-gallery-rgb), 0.16);
  border-color: rgba(var(--color-gallery-rgb), 0.4);
}

.gallery-ref-analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gallery-ref-analyze-btn.analyzed {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
}

/* ---------------------------------------------------------------------------
   GAS版 選択済み画像統合表示
   --------------------------------------------------------------------------- */
.gallery-combined-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  min-height: 36px;
  padding: 10px;
  background: rgba(var(--gallery-panel-accent-rgb), 0.04);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-radius: 16px;
}

.gallery-combined-selected:empty {
  display: none;
}

.gallery-combined-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.gallery-combined-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 2px solid var(--color-border);
  border-radius: 5px;
  transition: border-color 0.2s ease;
}

.gallery-combined-item:hover img {
  border-color: var(--color-danger);
}

.gallery-combined-order {
  padding: 1px 6px;
  color: var(--color-gallery);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  background: rgba(var(--color-gallery-rgb), 0.1);
  border-radius: 3px;
}

/* ---------------------------------------------------------------------------
   GAS版 自動追記テキストエリア
   --------------------------------------------------------------------------- */
.gallery-auto-append-input {
  min-height: 56px;
  padding: 10px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.5;
  background: rgba(var(--color-gallery-rgb), 0.04);
  border: 1px dashed rgba(var(--color-gallery-rgb), 0.22);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.gallery-auto-append-input:focus {
  color: var(--color-text);
  background: rgba(var(--color-gallery-rgb), 0.08);
  border-color: rgba(var(--color-gallery-rgb), 0.42);
  outline: none;
}

.gallery-auto-append-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.gallery-generate-btn {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   ギャラリーグリッド（画像/動画の一覧表示を共有）
   --------------------------------------------------------------------------- */
.media-gallery-scope {
  --media-scope-accent-rgb: var(--color-gallery-rgb);
  display: inline-flex;
  gap: 3px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(var(--media-scope-accent-rgb), 0.08);
  border: 1px solid rgba(var(--media-scope-accent-rgb), 0.16);
  border-radius: 999px;
}

.media-gallery-scope--video {
  --media-scope-accent-rgb: var(--color-video-rgb);
}

.media-gallery-scope-btn {
  min-width: 72px;
  padding: 7px 15px;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.media-gallery-scope-btn:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.7);
}

.media-gallery-scope-btn.is-active {
  color: rgb(var(--media-scope-accent-rgb));
  background: #fff;
  box-shadow: 0 2px 8px rgba(var(--media-scope-accent-rgb), 0.16);
}

.media-gallery-scope-btn:focus-visible {
  outline: 2px solid rgba(var(--media-scope-accent-rgb), 0.42);
  outline-offset: 2px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.gallery-grid > .hint,
.gallery-grid > .placeholder-text {
  grid-column: 1 / -1;
}

/* 完了した画像/動画を含むギャラリー用カードは .image-card をベースとし、
   カード内レイアウト・文字サイズ・余白を動画・画像DBと共通化する。 */
.media-gallery-card {
  /* .image-card の position / overflow / border-radius 等に委ねる。 */
  --media-card-accent: var(--color-gallery);
  --media-card-accent-dark: var(--color-gallery-dark);
  --media-card-accent-rgb: var(--color-gallery-rgb);
}

.media-card-visual {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-surface-hover);
}

.media-card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card-download-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.58);
  cursor: pointer;
  opacity: 0.92;
  transition: opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.media-card-download-btn:hover {
  background: var(--color-gallery);
  border-color: rgba(255, 255, 255, 0.78);
  transform: translateY(-1px);
  opacity: 1;
}

.video-card-download-btn:hover {
  background: var(--color-video);
}

.audio-card-download-btn:hover {
  background: var(--modal-spec-tools-accent);
}

.media-card-download-btn:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.media-card-title {
  height: 2.9em;
  font-weight: 700;
  color: var(--color-text);
}

.media-card-title-text {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.media-gallery-card .card-prompt.media-card-title {
  display: -webkit-box;
  -webkit-line-clamp: unset;
}

.video-gallery-card .card-prompt.media-card-title {
  display: -webkit-box;
  -webkit-line-clamp: unset;
}

.media-gallery-card .card-prompt {
  -webkit-line-clamp: 1;
}

.video-gallery-card .card-prompt {
  -webkit-line-clamp: 2;
}

/* ---------------------------------------------------------------------------
   ギャラリー画像モーダル（GAS版 gallery-image-modal 相当）
   --------------------------------------------------------------------------- */
.gallery-image-modal-overlay {
  --modal-accent: var(--modal-spec-default-accent);
  --modal-accent-rgb: var(--modal-spec-default-accent-rgb);
  --modal-accent-dark: var(--modal-spec-default-accent-dark);
  --modal-accent-soft: var(--modal-spec-default-accent-soft);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 50% 12%, rgba(var(--modal-accent-rgb), 0.18), transparent 36rem),
    rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
  cursor: zoom-out;
  animation: fadeIn 0.15s ease;
}

/* 画像詳細の表示元カテゴリをクラスで表し、JSからの色指定を不要にする。 */
.gallery-image-modal-overlay.modal-accent-gallery {
  --modal-accent: var(--modal-spec-gallery-accent);
  --modal-accent-rgb: var(--modal-spec-gallery-accent-rgb);
  --modal-accent-dark: var(--modal-spec-gallery-accent-dark);
  --modal-accent-soft: var(--modal-spec-gallery-accent-soft);
}

.gallery-image-modal-overlay.modal-accent-imagedb {
  --modal-accent: var(--modal-spec-imagedb-accent);
  --modal-accent-rgb: var(--modal-spec-imagedb-accent-rgb);
  --modal-accent-dark: var(--modal-spec-imagedb-accent-dark);
  --modal-accent-soft: var(--modal-spec-imagedb-accent-soft);
}

.gallery-image-modal-overlay.modal-accent-video {
  --modal-accent: var(--modal-spec-video-accent);
  --modal-accent-rgb: var(--modal-spec-video-accent-rgb);
  --modal-accent-dark: var(--modal-spec-video-accent-dark);
  --modal-accent-soft: var(--modal-spec-video-accent-soft);
}

.gallery-image-modal-overlay.modal-accent-tools {
  --modal-accent: var(--modal-spec-tools-accent);
  --modal-accent-rgb: var(--modal-spec-tools-accent-rgb);
  --modal-accent-dark: var(--modal-spec-tools-accent-dark);
  --modal-accent-soft: var(--modal-spec-tools-accent-soft);
}

.gallery-image-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.gallery-image-modal-img-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-image-modal-img-wrapper.is-image-loading {
  width: min(80vw, 720px);
  min-height: min(70vh, 520px);
}

.gallery-image-modal-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  cursor: default;
}

.gallery-image-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.gallery-image-modal-close:hover {
  background: rgba(var(--modal-accent-rgb), 0.28);
  border-color: rgba(var(--modal-accent-rgb), 0.56);
}

.gallery-image-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.gallery-image-modal-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.gallery-image-modal-metadata {
  width: min(100%, 760px);
  padding: 14px 16px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.28);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.gallery-image-modal-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.gallery-image-modal-field span {
  color: rgba(255, 255, 255, 0.62);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-image-modal-field input,
.gallery-image-modal-field textarea {
  width: 100%;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--text-sm);
  line-height: 1.6;
}

.gallery-image-modal-field textarea {
  max-height: 9.5em;
  resize: vertical;
}

.gallery-image-modal-metadata-actions {
  display: flex;
  justify-content: flex-end;
}

.gallery-image-modal-save-metadata-btn {
  min-height: 38px;
  padding: 8px 16px;
  color: #fff;
  background: var(--modal-accent-dark);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  font-weight: 800;
  cursor: pointer;
}

.gallery-image-modal-save-metadata-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.gallery-model-badge,
.gallery-model-settings {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: var(--line-ui);
}

.gallery-model-badge {
  color: #fff;
  background: var(--modal-accent, var(--modal-spec-default-accent));
}

.gallery-model-settings {
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.2);
}

.gallery-image-modal-use-btn,
.gallery-image-modal-download-btn,
.gallery-image-modal-copy-url-btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  border: none;
}

.gallery-image-modal-download-btn {
  background: var(--modal-accent, var(--modal-spec-default-accent));
  color: #fff;
}

.gallery-image-modal-download-btn:hover {
  background: var(--modal-accent-dark, var(--modal-spec-default-accent-dark));
  transform: translateY(-1px);
}

.gallery-image-modal-use-btn {
  background: var(--modal-accent, var(--modal-spec-default-accent));
  color: #fff;
  border: 1px solid var(--modal-accent, var(--modal-spec-default-accent));
}

.gallery-image-modal-use-btn:hover {
  background: var(--modal-accent-dark, var(--modal-spec-default-accent-dark));
  border-color: var(--modal-accent-dark, var(--modal-spec-default-accent-dark));
}

.gallery-image-modal-copy-url-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.gallery-image-modal-copy-url-btn:hover {
  background: rgba(var(--modal-accent-rgb), 0.18);
  border-color: rgba(var(--modal-accent-rgb), 0.42);
  color: #fff;
}

.gallery-image-modal-use-btn:focus-visible,
.gallery-image-modal-download-btn:focus-visible,
.gallery-image-modal-copy-url-btn:focus-visible,
.gallery-image-modal-close:focus-visible {
  outline: 3px solid rgba(var(--modal-accent-rgb), 0.36);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  .gallery-layout {
    display: block;
  }

  .gallery-layout .media-gallery-results,
  .gallery-layout.is-collapsed .media-gallery-results,
  .gallery-layout.is-panel-left .media-gallery-results,
  .gallery-layout.is-collapsed.is-panel-left .media-gallery-results {
    max-width: none;
    margin-right: 0;
    margin-left: 0;
  }

  .gallery-generate-panel,
  .gallery-layout.is-panel-left .gallery-generate-panel {
    position: static;
    flex-basis: auto;
    width: auto;
    max-height: none;
    margin-bottom: 18px;
    overflow: visible;
  }

  .gallery-layout.is-collapsed .gallery-generate-panel {
    position: fixed;
    top: max(calc(50% + var(--header-height) / 2), calc(var(--header-height) + 24px));
    right: 0;
    left: auto;
    width: 44px;
    min-height: 172px;
    margin-bottom: 0;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
  }

  .gallery-layout.is-collapsed.is-panel-left .gallery-generate-panel {
    right: auto;
    left: 0;
  }

  .gallery-layout.is-collapsed .gallery-panel-toggle {
    width: 44px;
    height: 160px;
    flex-direction: column;
    border-radius: 20px 0 0 20px;
  }

  .gallery-layout.is-collapsed.is-panel-left .gallery-panel-toggle {
    border-radius: 0 20px 20px 0;
  }

  .gallery-layout.is-collapsed .gallery-toggle-text {
    writing-mode: vertical-rl;
  }

  .gallery-image-modal-content {
    max-width: 95vw;
    max-height: 95vh;
  }

  .gallery-image-modal-img {
    max-height: 60vh;
  }
}

/* ---------------------------------------------------------------------------
   動画生成ギャラリー 指示メニュー
   GAS版 css-videogallery.html を Firebase テーマ変数で再現。
   --------------------------------------------------------------------------- */

.videogallery-layout {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  min-height: 560px;
  isolation: isolate;
}

.videogallery-layout.is-generation-unavailable .media-gallery-results,
.videogallery-layout.is-generation-unavailable.is-collapsed .media-gallery-results,
.videogallery-layout.is-generation-unavailable.is-panel-left .media-gallery-results,
.videogallery-layout.is-generation-unavailable.is-collapsed.is-panel-left .media-gallery-results {
  max-width: none;
}

.videogallery-layout.is-generation-unavailable .videogallery-generate-panel {
  display: none;
}

.videogallery-layout .media-gallery-results {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.videogallery-generate-panel {
  /* ギャラリー内のサイドタブとして配置し、動画一覧の上には重ねない。 */
  --gallery-panel-accent: var(--color-video);
  --gallery-panel-accent-dark: var(--color-video-dark);
  --gallery-panel-accent-rgb: var(--color-video-rgb);
  order: 2;
  flex: 0 0 390px;
  position: sticky;
  top: calc(var(--header-height) + 24px);
  width: 390px;
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
  padding: 18px;
  background: var(--surface-glass);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.16);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px) saturate(1.08);
  z-index: var(--z-content);
  transition: flex-basis 0.2s ease, width 0.2s ease, padding 0.2s ease, border-radius 0.2s ease;
}

.videogallery-generate-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.07), transparent 160px);
}

.videogallery-layout.is-panel-left .videogallery-generate-panel {
  order: 1;
}

.videogallery-layout.is-panel-left .media-gallery-results {
  order: 2;
}

.videogallery-layout.is-collapsed .videogallery-generate-panel {
  position: fixed;
  top: max(calc(50% + var(--header-height) / 2), calc(var(--header-height) + 24px));
  right: 0;
  left: auto;
  flex-basis: auto;
  width: 44px;
  min-height: 172px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  overflow: visible;
  pointer-events: none;
  transform: translateY(-50%);
  z-index: var(--z-floating-panel);
}

.videogallery-layout.is-collapsed.is-panel-left .videogallery-generate-panel {
  right: auto;
  left: 0;
}

.videogallery-layout.is-collapsed .videogallery-generate-panel::before {
  display: none;
}

.videogallery-layout.is-collapsed .generation-panel-controls {
  pointer-events: auto;
}

.videogallery-layout.is-collapsed .videogallery-generator-body {
  display: none;
}

.videogallery-panel-toggle {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.08);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.videogallery-panel-toggle:hover,
.generation-panel-position-select:hover {
  color: var(--gallery-panel-accent);
  background: rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.18);
}

.videogallery-toggle-icon {
  display: inline-flex;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #fff;
  background: var(--gallery-panel-accent);
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.videogallery-layout.is-collapsed .videogallery-panel-toggle {
  width: 44px;
  height: 160px;
  margin-bottom: 0;
  padding: 10px 8px;
  flex-direction: column;
  border-radius: 20px 0 0 20px;
}

.videogallery-layout.is-collapsed.is-panel-left .videogallery-panel-toggle {
  border-radius: 0 20px 20px 0;
}

.videogallery-layout.is-collapsed .generation-panel-controls {
  margin-bottom: 0;
}

.videogallery-layout.is-collapsed .generation-panel-position-select {
  display: none;
}

.videogallery-layout.is-collapsed .videogallery-toggle-icon {
  transform: rotate(180deg);
}

.videogallery-layout.is-collapsed .videogallery-toggle-text {
  writing-mode: vertical-rl;
  letter-spacing: 0.08em;
}

.videogallery-toggle-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.videogallery-generate-panel .generation-panel-position-select {
  width: 76px;
  padding: 0 24px 0 12px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.08);
  border-color: transparent;
  border-radius: 999px;
  font-size: 13px;
  line-height: 38px;
}

.videogallery-generator-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
}

.videogallery-generate-panel h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.videogallery-generate-panel textarea,
.videogallery-generate-panel select,
.videogallery-generate-panel input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.14);
  border-radius: 14px;
  font: inherit;
}

.videogallery-generate-panel textarea:focus,
.videogallery-generate-panel select:focus,
.videogallery-generate-panel input[type="number"]:focus {
  outline: none;
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.5);
}

.videogallery-generate-panel textarea {
  min-height: 132px;
  font-size: var(--text-sm);
  line-height: 1.55;
  background: linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.05), rgba(255, 255, 255, 0.94));
}

.videogallery-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.videogallery-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-video);
}

.videogallery-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.videogallery-menu-section,
.videogallery-reference-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
}

.videogallery-menu-section {
  background: transparent;
  border: none;
}

.videogallery-menu-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.videogallery-menu-section-label,
.videogallery-reference-label {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.videogallery-reference-section,
.videogallery-menu-section {
  /* 動画生成メニューも画像側と同じく、枠ではなく余白と下線で構造を見せる。 */
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-radius: 0;
}

.videogallery-reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.videogallery-ref-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  color: var(--color-text-muted);
  background: rgba(var(--gallery-panel-accent-rgb), 0.06);
  border: 1px dashed rgba(var(--gallery-panel-accent-rgb), 0.28);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.videogallery-ref-drop-zone:hover,
.videogallery-ref-drop-zone.is-dragover,
.videogallery-ref-drop-zone:focus-visible,
#video-ref-file-input:focus-visible + .videogallery-ref-drop-zone {
  background: rgba(var(--gallery-panel-accent-rgb), 0.1);
  border-color: var(--gallery-panel-accent);
  outline: 3px solid rgba(var(--gallery-panel-accent-rgb), 0.14);
  outline-offset: 2px;
}

.videogallery-ref-drop-zone.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.videogallery-ref-drop-icon {
  color: var(--gallery-panel-accent);
}

.videogallery-ref-drop-text {
  font-size: 13px;
  font-weight: 600;
}

.videogallery-ref-drop-hint {
  font-size: 11px;
}

.videogallery-ref-preview-list,
.videogallery-db-image-list,
.videogallery-selected-db-images,
.videogallery-ref-upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.videogallery-selected-db-images:empty {
  display: none;
}

.videogallery-db-image-list {
  max-height: 180px;
  overflow-y: auto;
}

.videogallery-db-image-item {
  width: 60px;
  height: 60px;
  padding: 3px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.videogallery-db-image-item:hover,
.videogallery-db-image-item.selected {
  border-color: var(--color-video);
  transform: translateY(-1px);
}

.videogallery-db-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 7px;
}

.videogallery-ref-preview-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.videogallery-ref-preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.videogallery-ref-preview-thumb:hover {
  border-color: var(--color-danger);
}

.videogallery-ref-preview-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-video);
}

.videogallery-selected-db-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px 4px 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.videogallery-selected-db-order {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--color-video);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.videogallery-selected-db-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 999px;
}

.videogallery-selected-db-name {
  max-width: 170px;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.videogallery-ref-upload-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.videogallery-ref-upload-item video {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
}

.videogallery-ref-upload-info {
  flex: 1;
  min-width: 0;
}

.videogallery-ref-upload-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.videogallery-ref-upload-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

.videogallery-ref-upload-remove {
  width: 24px;
  height: 24px;
  background: var(--color-error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 50%;
  color: var(--color-error);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.videogallery-seedance-gen-btn {
  width: 100%;
  padding: 10px;
  background: rgba(var(--gallery-panel-accent-rgb), 0.08);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.18);
  border-radius: 14px;
  color: var(--gallery-panel-accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.videogallery-seedance-gen-btn:hover {
  background: rgba(var(--gallery-panel-accent-rgb), 0.14);
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.36);
}

.videogallery-generate-btn {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   生成タブ共通UI（画像/動画）
   ---------------------------------------------------------------------------
   モデル選択、プロンプト、参照画像などの操作密度を揃え、
   画像生成と動画生成を同じパネル部品として扱える見た目にする。
   --------------------------------------------------------------------------- */

.gallery-generate-panel,
.videogallery-generate-panel {
  scrollbar-gutter: stable;
}

.gallery-generator-body,
.videogallery-generator-body {
  gap: 16px;
}

/* 生成指示は設定、プロンプト、参照素材、実行の順に読み進められる構造へ統一する。 */
.generation-prompt-section,
.generation-source-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
}

.generation-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.generation-section-label,
.generation-selected-label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
}

.generation-source-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.generation-source-tab {
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.generation-source-tab.active {
  color: var(--gallery-panel-accent-dark);
  background: var(--color-surface);
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.28);
}

.generation-source-tab:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.image-restoration-mode-tabs {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-restoration-mode-tab {
  display: grid;
  gap: 4px;
  min-height: 48px;
  padding: 8px;
  white-space: normal;
  text-align: left;
}

.image-restoration-mode-tab.active {
  color: var(--modal-accent-dark);
  background: linear-gradient(180deg, #FFFFFF, rgba(var(--modal-accent-rgb), 0.08));
  border-color: rgba(var(--modal-accent-rgb), 0.32);
  box-shadow: 0 8px 18px rgba(var(--modal-accent-rgb), 0.08);
}

.image-restoration-mode-name {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.image-restoration-mode-badge {
  justify-self: start;
  padding: 2px 7px;
  color: var(--modal-accent-dark);
  background: rgba(var(--modal-accent-rgb), 0.1);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.18);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.image-restoration-mode-tab.active .image-restoration-mode-badge {
  color: #FFFFFF;
  background: var(--modal-accent-dark);
  border-color: var(--modal-accent-dark);
}

.generation-source-pane[hidden] {
  display: none;
}

.generation-source-section > .generation-source-pane {
  padding: 4px 0 0;
  border: 0;
}

.generation-selected-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.generation-selected-summary:has(.gallery-combined-selected:empty) {
  display: none;
}

.generation-submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 0 2px;
  background: var(--color-surface);
  border-top: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.18);
}

.generation-submit-bar .btn {
  width: 100%;
  white-space: nowrap;
}

.videogallery-model-section {
  order: 1;
}

.videogallery-settings-section {
  order: 2;
}

.videogallery-prompt-section {
  order: 3;
}

.videogallery-source-section {
  order: 4;
}

.videogallery-submit-bar {
  order: 5;
}

.videogallery-settings-section > .videogallery-settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.videogallery-source-section > .generation-source-pane {
  padding: 4px 0 0;
  border: 0;
}

.generation-prompt-section .videogallery-seedance-gen-btn {
  width: auto;
  padding: 7px 10px;
  white-space: nowrap;
}

.generation-advanced-menu {
  margin-top: 10px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.generation-advanced-menu summary {
  width: max-content;
  padding: 5px 0;
  font-weight: 700;
  cursor: pointer;
}

.generation-advanced-menu > .settings-grid {
  margin-top: 8px;
}

@media (max-width: 480px) {
  .videogallery-settings-section > .videogallery-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

.gallery-generate-panel h2,
.videogallery-generate-panel h2 {
  font-size: var(--text-lg);
}

.gallery-db-hint,
.gallery-db-empty {
  font-size: var(--text-xs);
  line-height: var(--line-body);
}

.gallery-db-section,
.gallery-reference-section,
.image-gen-config-panel,
.videogallery-menu-section,
.videogallery-reference-section {
  padding: 14px 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
}

.videogallery-menu-section:first-of-type {
  padding-top: 0;
}

.gallery-reference-label,
.gallery-db-label,
.videogallery-menu-section-label,
.videogallery-reference-label,
.image-gen-config-panel > .model-selector label,
.image-setting-field label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
}

.gallery-generate-panel textarea,
.gallery-generate-panel select,
.videogallery-generate-panel textarea,
.videogallery-generate-panel select,
.videogallery-generate-panel input[type="number"] {
  min-height: 42px;
  padding: 10px 12px;
  font-size: var(--text-sm);
  line-height: var(--line-ui);
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.16);
  border-radius: 14px;
}

.gallery-generate-panel textarea,
.videogallery-generate-panel textarea {
  min-height: 148px;
  color: var(--color-text);
  background:
    linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.06), rgba(255, 255, 255, 0.94));
  resize: vertical;
}

.gallery-generate-panel textarea::placeholder,
.videogallery-generate-panel textarea::placeholder {
  color: rgba(100, 116, 139, 0.78);
}

.gallery-ref-drop-zone,
.videogallery-ref-drop-zone {
  min-height: 96px;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, rgba(var(--gallery-panel-accent-rgb), 0.08), rgba(var(--gallery-panel-accent-rgb), 0.035));
  border: 1px dashed rgba(var(--gallery-panel-accent-rgb), 0.34);
  border-radius: 18px;
}

.videogallery-image-source-tabs {
  margin-top: 2px;
}

.videogallery-image-source-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.videogallery-image-source-pane[hidden] {
  display: none;
}

/* 「生成に使用する素材」は参照素材タブの直後・生成ボタンの手前へ常時表示する（DOM順で参照素材セクションの後ろに置く前提）。 */
.videogallery-combined-section {
  order: 4;
}

/* 空のリストは非表示にし、セクション内の余分なgapを作らない。 */
.videogallery-combined-section > :empty {
  display: none;
}

.videogallery-combined-empty {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* いずれかの素材（画像DB・ローカル画像・動画・音声）が選択されたら未選択メッセージを隠す。 */
.videogallery-combined-section:has(.videogallery-selected-db-images > *) .videogallery-combined-empty,
.videogallery-combined-section:has(.videogallery-ref-preview-list > *) .videogallery-combined-empty,
.videogallery-combined-section:has(.videogallery-ref-upload-list > *) .videogallery-combined-empty {
  display: none;
}

.videogallery-ref-upload-item {
  align-items: flex-start;
}

.videogallery-ref-upload-info {
  min-width: 0;
  flex: 1;
}

.media-playback-preview {
  display: block;
  width: 100%;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.88);
}

video.media-playback-preview {
  width: 100%;
  height: auto;
  object-fit: contain;
}

audio.media-playback-preview {
  max-height: none;
  background: transparent;
}

.videogallery-ref-upload-preview {
  max-height: 160px;
  margin-top: 8px;
}

.durable-tool-input-preview {
  margin-top: 8px;
  pointer-events: auto;
}

.gallery-ref-drop-text,
.videogallery-ref-drop-text {
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.gallery-ref-drop-hint,
.videogallery-ref-drop-hint {
  font-size: var(--text-xs);
  line-height: var(--line-ui);
}

.gallery-selected-db-item,
.videogallery-selected-db-item {
  max-width: 100%;
  padding: 5px 8px 5px 5px;
  border-color: rgba(var(--gallery-panel-accent-rgb), 0.16);
  background: rgba(var(--gallery-panel-accent-rgb), 0.05);
}

.gallery-selected-db-order,
.videogallery-selected-db-order {
  background: var(--gallery-panel-accent);
  font-size: var(--text-xs);
}

.gallery-selected-db-name,
.videogallery-selected-db-name {
  font-size: var(--text-xs);
  color: var(--color-text);
}

.gallery-generate-panel .btn-primary,
.videogallery-generate-panel .btn-primary,
.videogallery-seedance-gen-btn {
  min-height: 42px;
  border-radius: 14px;
  font-size: var(--text-sm);
  font-weight: 800;
}

.video-preview-content {
  width: min(92vw, 1120px);
}

.video-preview-container {
  overflow: hidden;
  width: 100%;
  max-height: 72vh;
  border-radius: var(--radius-lg);
  background: #020617;
  cursor: default;
}

.video-preview-player {
  display: block;
  width: 100%;
  max-height: 72vh;
  background: #020617;
}

.video-preview-toolbar {
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(92vw, 1120px);
}

.video-preview-prompt {
  width: min(92vw, 860px);
  max-height: 140px;
  padding: 12px 14px;
  overflow-y: auto;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.28);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(var(--modal-accent-rgb), 0.12), rgba(15, 23, 42, 0.72));
  color: #fff;
}

.video-preview-section-label {
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.video-preview-prompt p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.65;
}

.video-preview-actions .gallery-image-modal-use-btn,
.video-preview-actions .gallery-image-modal-download-btn {
  background: var(--modal-accent, var(--modal-spec-video-accent));
  border-color: var(--modal-accent, var(--modal-spec-video-accent));
}

.video-preview-actions .gallery-image-modal-use-btn:hover,
.video-preview-actions .gallery-image-modal-download-btn:hover {
  background: var(--modal-accent-dark, var(--modal-spec-video-accent-dark));
  border-color: var(--modal-accent-dark, var(--modal-spec-video-accent-dark));
}

@media (max-width: 1100px) {
  .videogallery-layout {
    display: block;
  }

  .videogallery-layout .media-gallery-results,
  .videogallery-layout.is-collapsed .media-gallery-results,
  .videogallery-layout.is-panel-left .media-gallery-results,
  .videogallery-layout.is-collapsed.is-panel-left .media-gallery-results {
    max-width: none;
    margin-right: 0;
    margin-left: 0;
  }

  .videogallery-generate-panel,
  .videogallery-layout.is-panel-left .videogallery-generate-panel {
    position: static;
    flex-basis: auto;
    width: auto;
    max-height: none;
    margin-bottom: 18px;
    overflow: visible;
  }

  .videogallery-layout.is-collapsed .videogallery-generate-panel {
    position: fixed;
    top: max(calc(50% + var(--header-height) / 2), calc(var(--header-height) + 24px));
    right: 0;
    left: auto;
    width: 44px;
    min-height: 172px;
    margin-bottom: 0;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
  }

  .videogallery-layout.is-collapsed.is-panel-left .videogallery-generate-panel {
    right: auto;
    left: 0;
  }

  .videogallery-layout.is-collapsed .videogallery-panel-toggle {
    width: 44px;
    height: 160px;
    flex-direction: column;
    border-radius: 20px 0 0 20px;
  }

  .videogallery-layout.is-collapsed.is-panel-left .videogallery-panel-toggle {
    border-radius: 0 20px 20px 0;
  }

  .videogallery-layout.is-collapsed .videogallery-toggle-text {
    writing-mode: vertical-rl;
  }
}

/* ---------------------------------------------------------------------------
   ギャラリーカード（画像表示用共通）
   --------------------------------------------------------------------------- */

/* 画像グリッドカード（GAS版のギャラリーカード/画像DBカード共通デザイン） */
.image-card {
  position: relative;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.image-card:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-1px);
}

.image-card .card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--color-surface-hover);
}

.image-card .card-info {
  padding: 8px 10px 9px;
}

.image-card .card-info .card-prompt {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: var(--line-ui);
}

.image-card .card-info .card-meta {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.image-card .card-info .card-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card .card-info .card-settings {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-card .card-info .media-card-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: var(--line-ui);
  white-space: nowrap;
  height: 1.45em;
  overflow: hidden;
}

.image-card .card-info .media-card-summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-card .card-info .media-card-summary span {
  flex: 0 1 auto;
}

.image-card .card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.image-card .card-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  font-size: var(--text-xs);
  padding: 5px 7px;
  min-height: 28px;
}

/* 共通カードJSは配置を持たず、アイコンと代替サムネイルの寸法はCSSで管理する。 */
.media-reuse-icon {
  flex-shrink: 0;
  margin-right: 4px;
}

.video-card-fallback-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card-preview-unavailable {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.image-card .card-prompt-full {
  margin-top: 10px;
  padding: 10px 11px;
  background: rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.06);
  border: 1px solid rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.14);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--line-body);
  white-space: pre-wrap;
  word-break: break-word;
  height: 160px;
  max-height: 160px;
  overflow-y: auto;
}

.job-progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  appearance: none;
  background: rgba(148, 163, 184, 0.22);
  border: 0;
  border-radius: 999px;
}

.job-progress::-webkit-progress-bar {
  background: rgba(148, 163, 184, 0.22);
  border-radius: inherit;
}

.job-progress::-webkit-progress-value {
  background: var(--pending-job-accent, var(--color-primary));
  border-radius: inherit;
}

.job-progress::-moz-progress-bar {
  background: var(--pending-job-accent, var(--color-primary));
  border-radius: inherit;
}

.image-card .card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
}

/* ソースタイプ別バッジ色 */
.badge-imagedb { background: var(--color-imagedb); }
.badge-storyboard { background: var(--color-script); }
.badge-gallery { background: var(--color-gallery); }

/* メディアカードの画面別アクセントはCSS変数だけを切り替え、部品の見た目は共通化する。 */
.video-gallery-card {
  --media-card-accent: var(--color-video);
  --media-card-accent-dark: var(--color-video-dark);
  --media-card-accent-rgb: var(--color-video-rgb);
}

.audio-gallery-card {
  --media-card-accent: var(--modal-spec-tools-accent);
  --media-card-accent-dark: var(--modal-spec-tools-accent-dark);
  --media-card-accent-rgb: var(--modal-spec-tools-accent-rgb);
}

/* 画像・動画ともモデル名はサムネイル左下へ重ね、本文の情報構造を共通化する。 */
.media-card-model-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  max-width: 72%;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.34);
  line-height: var(--line-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.video-card-thumb .media-card-model-badge {
  max-width: calc(100% - 76px);
}

.media-use-settings-btn {
  color: var(--media-card-accent, var(--color-gallery));
  background: rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.06);
  border-color: rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.16);
}

.media-use-settings-btn:hover {
  color: var(--media-card-accent-dark, var(--color-gallery-dark));
  background: rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.12);
  border-color: rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.28);
}

.media-prompt-btn {
  color: var(--color-text);
  background: var(--color-surface-hover);
  border-color: rgba(148, 163, 184, 0.22);
}

.media-prompt-btn:hover {
  background: #FFFFFF;
  border-color: rgba(148, 163, 184, 0.34);
}

.media-prompt-btn:focus-visible,
.media-use-settings-btn:focus-visible {
  outline: 3px solid rgba(var(--media-card-accent-rgb, var(--color-gallery-rgb)), 0.18);
  outline-offset: 2px;
}

/* ギャラリー系画面の文字サイズを共通トークンへ寄せ、カード間の大小差を抑える。 */
.gallery-generate-panel h2,
.videogallery-generate-panel h2 {
  font-size: var(--text-lg);
}

.gallery-panel-toggle,
.generation-panel-position-select,
.gallery-generate-panel .generation-panel-position-select,
.gallery-generate-panel textarea,
.gallery-generate-panel select,
.image-card .card-info .card-prompt,
.image-card .card-prompt-full {
  font-size: var(--text-sm);
  line-height: var(--line-ui);
}

.gallery-db-hint,
.gallery-db-empty,
.gallery-reference-label,
.gallery-db-label,
.gallery-ref-drop-hint,
.gallery-ref-preview-label,
.gallery-selected-db-order,
.gallery-selected-db-name,
.image-gen-config-panel > .model-selector label,
.image-setting-field label,
.gallery-ref-analyze-btn,
.gallery-combined-order,
.gallery-auto-append-input,
.image-card .card-info .card-meta,
.image-card .card-info .card-settings,
.image-card .card-actions .btn,
.image-card .card-badge {
  font-size: var(--text-xs);
  line-height: var(--line-ui);
}

/* 動画カード用 */
.video-card-thumb {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

.audio-gallery-card .media-card-visual {
  background:
    radial-gradient(circle at 18% 22%, rgba(var(--modal-spec-tools-accent-rgb), 0.28), transparent 34%),
    linear-gradient(135deg, rgba(var(--modal-spec-tools-accent-rgb), 0.2), rgba(15, 23, 42, 0.08));
}

.audio-card-preview-shell {
  position: relative;
  display: grid;
  align-content: end;
  width: 100%;
  height: 100%;
  padding: 18px 14px;
}

.audio-card-wave {
  position: absolute;
  inset: 18px 16px 62px;
  opacity: 0.72;
  background:
    linear-gradient(90deg, transparent 0 5%, rgba(var(--modal-spec-tools-accent-rgb), 0.7) 5% 7%, transparent 7% 12%, rgba(var(--modal-spec-tools-accent-rgb), 0.38) 12% 14%, transparent 14% 20%, rgba(var(--modal-spec-tools-accent-rgb), 0.82) 20% 22%, transparent 22% 30%),
    linear-gradient(180deg, transparent 42%, rgba(15, 23, 42, 0.22) 42% 58%, transparent 58%);
  border-radius: var(--radius-md);
}

.audio-card-preview {
  position: relative;
  z-index: 1;
  width: 100%;
}

.audio-card-preview-unavailable {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--color-text-muted);
  font-weight: 800;
}

.video-card-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.video-card-preview.is-ready {
  opacity: 1;
  transform: scale(1);
}

.video-card-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(15, 23, 42, 0.52);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
  pointer-events: none;
}

.video-card-thumb:hover .video-card-play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  background: rgba(15, 23, 42, 0.72);
}

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.gallery-load-more {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 8px 0 20px;
}

/* ---------------------------------------------------------------------------
   プロジェクト作成モーダル
   --------------------------------------------------------------------------- */
.project-create-modal {
  --modal-accent: var(--modal-spec-admin-accent);
  --modal-accent-dark: var(--modal-spec-admin-accent-dark);
  --modal-accent-rgb: var(--modal-spec-admin-accent-rgb);
  --modal-accent-soft: var(--modal-spec-admin-accent-soft);
}

.project-modal-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------------------------------------------------------------------------
   画像DB アップロードエリア
   --------------------------------------------------------------------------- */
.upload-zone {
  padding: 40px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-imagedb);
  background: var(--color-primary-bg);
}

.upload-zone .upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-zone .upload-hint {
  color: var(--color-text-muted);
  font-size: 13px;
}

.upload-zone input[type="file"] {
  display: none;
}

/* ---------------------------------------------------------------------------
   台本アップロード後の抽出進捗
   --------------------------------------------------------------------------- */
.storyboard-work-status-list--compact {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.script-extract-status {
  --script-status-accent: var(--color-script);
  --script-status-accent-rgb: var(--color-script-rgb);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--script-status-accent-rgb), 0.18);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.script-extract-status-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(var(--script-status-accent-rgb), 0.2), transparent 52%),
    rgba(var(--script-status-accent-rgb), 0.08);
}

.script-extract-status-icon::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(var(--script-status-accent-rgb), 0.24);
  border-top-color: var(--script-status-accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.script-extract-status.is-terminal .script-extract-status-icon {
  color: #fff;
  background: var(--color-error);
  font-weight: 900;
}

.script-extract-status.is-terminal .script-extract-status-icon::before {
  display: none;
}

.script-extract-status-main {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.script-extract-status-head {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.script-extract-status-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-extract-status-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--color-script-dark);
  background: rgba(var(--script-status-accent-rgb), 0.1);
  font-size: var(--text-xs);
  font-weight: 700;
}

.script-extract-status-message {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-extract-progress {
  height: 5px;
  margin-top: 0;
}

.script-extract-status-meta {
  display: grid;
  gap: 2px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-align: right;
  white-space: nowrap;
}

.script-extract-status-meta strong {
  color: var(--color-script-dark);
  font-size: var(--text-sm);
}

@media (max-width: 640px) {
  .script-extract-status {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .script-extract-status-meta {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    text-align: left;
  }
}

/* ---------------------------------------------------------------------------
   Feature画面共通サーフェス
   --------------------------------------------------------------------------- */

.feature-page-shell {
  position: relative;
}

.feature-hero {
  isolation: isolate;
}

.feature-hero-copy h2 {
  letter-spacing: -0.04em;
}

.feature-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.feature-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 11px;
  color: var(--feature-accent-dark, var(--color-primary));
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(var(--feature-accent-rgb, 68, 80, 102), 0.2);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(var(--feature-accent-rgb, 68, 80, 102), 0.08);
  font-size: var(--text-xs);
  font-weight: 800;
  backdrop-filter: blur(10px);
}

.feature-stat-pill strong {
  font-size: var(--text-md);
  line-height: 1;
}

.feature-action-card {
  outline-offset: 4px;
}

.feature-hero--tools {
  --feature-accent: var(--modal-spec-tools-accent);
  --feature-accent-dark: var(--modal-spec-tools-accent-dark);
  --feature-accent-rgb: var(--modal-spec-tools-accent-rgb);
}

/* ---------------------------------------------------------------------------
   キャラクターDB インラインワークスペース
   --------------------------------------------------------------------------- */
#screen-imagedb {
  --imagedb-accent: var(--color-imagedb);
  --imagedb-accent-dark: var(--color-imagedb-dark);
  --imagedb-accent-rgb: var(--color-imagedb-rgb);
  --imagedb-accent-soft: var(--color-imagedb-soft);
  --feature-accent: var(--imagedb-accent);
  --feature-accent-dark: var(--imagedb-accent-dark);
  --feature-accent-rgb: var(--imagedb-accent-rgb);
}

#screen-imagedb.screen-content--surface {
  background:
    radial-gradient(circle at 8% 2%, rgba(var(--imagedb-accent-rgb), 0.16), transparent 28rem),
    radial-gradient(circle at 94% 18%, rgba(255, 255, 255, 0.9), transparent 22rem),
    linear-gradient(180deg, rgba(var(--imagedb-accent-rgb), 0.055), rgba(255, 255, 255, 0) 26rem);
}

.imagedb-library {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.imagedb-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 28px;
  align-items: center;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
  background:
    radial-gradient(circle at 86% 8%, rgba(var(--imagedb-accent-rgb), 0.34), transparent 17rem),
    radial-gradient(circle at 18% 105%, rgba(255, 255, 255, 0.82), transparent 18rem),
    linear-gradient(135deg, rgba(var(--imagedb-accent-rgb), 0.2), rgba(255, 255, 255, 0.94) 68%);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.26);
  border-radius: calc(var(--radius-lg) + 8px);
  box-shadow: 0 24px 70px rgba(var(--imagedb-accent-rgb), 0.16), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.imagedb-hero::after {
  content: '';
  position: absolute;
  top: -72px;
  right: -54px;
  width: 210px;
  height: 210px;
  border: 34px solid rgba(var(--imagedb-accent-rgb), 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.imagedb-hero::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: calc(var(--radius-lg) + 2px);
  pointer-events: none;
}

.imagedb-hero-copy,
.imagedb-intake {
  position: relative;
  z-index: 1;
}

.imagedb-kicker,
.imagedb-section-label {
  margin: 0 0 6px;
  color: var(--imagedb-accent-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.imagedb-hero h2 {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(1.75rem, 3.2vw, 2.75rem);
  line-height: 1.16;
}

.imagedb-hero-copy > p:last-child {
  max-width: 44rem;
  margin: 14px 0 0;
  color: var(--color-text-muted);
  font-weight: 500;
  line-height: 1.75;
}

.imagedb-intake {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 112px;
  padding: 20px;
  color: var(--color-text);
  text-align: left;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(var(--imagedb-accent-rgb), 0.08)),
    rgba(255, 255, 255, 0.82);
  border: 2px dashed rgba(var(--imagedb-accent-rgb), 0.48);
  border-radius: calc(var(--radius-lg) + 4px);
  box-shadow: 0 18px 44px rgba(var(--imagedb-accent-rgb), 0.13), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s, background 0.2s;
}

.imagedb-intake:hover,
.imagedb-intake:focus-visible,
.imagedb-intake.is-drag-over {
  background: #FFFFFF;
  border-color: var(--imagedb-accent);
  box-shadow: 0 16px 36px rgba(var(--imagedb-accent-rgb), 0.2);
  outline: none;
  transform: translateY(-2px);
}

.imagedb-intake:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.imagedb-intake-mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  color: #FFFFFF;
  background: var(--imagedb-accent-dark);
  border-radius: 50%;
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}

.imagedb-intake-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.imagedb-intake-copy strong {
  font-size: 1rem;
  font-weight: 900;
}

.imagedb-intake-copy small {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.imagedb-upload-workspace {
  overflow: hidden;
  background: linear-gradient(145deg, rgba(var(--imagedb-accent-rgb), 0.08), #FFFFFF 38%);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.32);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px rgba(var(--imagedb-accent-rgb), 0.1);
  scroll-margin-top: 20px;
}

.imagedb-upload-workspace.is-uploading {
  border-color: var(--imagedb-accent);
}

.imagedb-upload-workspace.is-complete {
  box-shadow: 0 18px 44px rgba(var(--imagedb-accent-rgb), 0.16);
}

.imagedb-upload-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid rgba(var(--imagedb-accent-rgb), 0.18);
}

.imagedb-upload-header h3,
.imagedb-library-header h3 {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-xl);
}

.imagedb-upload-header > div > p:last-child {
  margin: 8px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.imagedb-upload-count {
  flex: 0 0 auto;
  padding: 7px 11px;
  color: var(--imagedb-accent-dark);
  background: var(--imagedb-accent-soft);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.25);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.imagedb-upload-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 14px;
  padding: 20px 24px;
}

.imagedb-upload-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.2);
  border-radius: var(--radius-lg);
}

.imagedb-upload-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--imagedb-accent-soft);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.2);
  flex-shrink: 0;
}

.imagedb-upload-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.imagedb-upload-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 800;
}

.imagedb-upload-label input,
.imagedb-upload-label textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  font-size: var(--text-md);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
}

.imagedb-upload-label input:focus-visible,
.imagedb-upload-label textarea:focus-visible {
  outline: none;
  border-color: var(--imagedb-accent);
  box-shadow: 0 0 0 3px rgba(var(--imagedb-accent-rgb), 0.12);
}

.imagedb-upload-status {
  font-size: 12px;
}

.imagedb-upload-status .status-uploading {
  color: var(--color-text-muted);
}

.imagedb-upload-status .status-success {
  color: var(--color-success, #10B981);
}

.imagedb-upload-status .status-error {
  color: var(--color-error, #EF4444);
}

.imagedb-upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px 22px;
  background: rgba(var(--imagedb-accent-rgb), 0.06);
  border-top: 1px solid rgba(var(--imagedb-accent-rgb), 0.18);
}

.imagedb-upload-actions > p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.imagedb-upload-actions > div {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.imagedb-upload-actions .btn {
  min-height: 44px;
}

.imagedb-upload-actions .btn-primary {
  color: #FFFFFF;
  background: var(--imagedb-accent-dark);
  border-color: var(--imagedb-accent-dark);
}

.imagedb-upload-actions .btn-primary:hover:not(:disabled) {
  background: var(--imagedb-accent);
  border-color: var(--imagedb-accent);
}

.imagedb-library-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(var(--imagedb-accent-rgb), 0.16);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(14px);
}

.imagedb-library-header > p {
  max-width: 34rem;
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: right;
}

#screen-imagedb .imagedb-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

#screen-imagedb .imagedb-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.9)),
    var(--color-surface);
  border-color: rgba(var(--imagedb-accent-rgb), 0.16);
  border-radius: calc(var(--radius-lg) + 2px);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

#screen-imagedb .imagedb-card .card-thumb {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 50% 35%, rgba(var(--imagedb-accent-rgb), 0.16), transparent 44%),
    var(--color-surface-hover);
  transition: transform 0.35s ease, filter 0.35s ease;
}

#screen-imagedb .imagedb-card:hover .card-thumb {
  transform: scale(1.035);
  filter: saturate(1.04) contrast(1.02);
}

#screen-imagedb .imagedb-card .card-info {
  padding: 13px 14px 14px;
}

#screen-imagedb .imagedb-card .card-title {
  margin-bottom: 6px;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

#screen-imagedb .imagedb-card .card-prompt {
  color: var(--color-text-muted);
  font-weight: 600;
  line-height: 1.58;
  -webkit-line-clamp: 3;
}

#screen-imagedb .imagedb-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(var(--imagedb-accent-rgb), 0.12);
}

#screen-imagedb .imagedb-card-actions .btn {
  min-height: 30px;
  border-radius: 999px;
}

#screen-imagedb .badge-imagedb {
  color: #fff;
  background: linear-gradient(135deg, var(--imagedb-accent-dark), var(--imagedb-accent));
  box-shadow: 0 10px 22px rgba(var(--imagedb-accent-rgb), 0.22);
}

@media (max-width: 640px) {
  .imagedb-hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 22px 18px;
  }

  .imagedb-intake {
    min-height: 96px;
    padding: 16px;
  }

  .imagedb-upload-header,
  .imagedb-upload-actions,
  .imagedb-library-header {
    align-items: stretch;
    flex-direction: column;
  }

  .imagedb-upload-header,
  .imagedb-upload-list,
  .imagedb-upload-actions {
    padding-right: 16px;
    padding-left: 16px;
  }

  .imagedb-upload-count {
    align-self: flex-start;
  }

  .imagedb-upload-item {
    flex-direction: column;
    gap: 12px;
  }

  .imagedb-upload-thumb {
    width: 100%;
    height: 160px;
  }

  .imagedb-upload-actions > div {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .imagedb-upload-actions .btn {
    width: 100%;
  }

  .imagedb-library-header > p {
    text-align: left;
  }

  #screen-imagedb .imagedb-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
    gap: 14px;
  }
}

/* ---------------------------------------------------------------------------
   画像DB カード管理UI
   --------------------------------------------------------------------------- */
.imagedb-card {
  position: relative;
}

.imagedb-card .card-thumb {
  cursor: pointer;
}

.imagedb-card .card-badge {
  z-index: 2;
}

.imagedb-card .badge-done {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--color-success, #10B981);
}

.imagedb-card .badge-pending {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--color-warning, #F59E0B);
}

.imagedb-card .card-info {
  gap: 6px;
}

.imagedb-name-view {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}

.imagedb-name-edit {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
}

.imagedb-name-edit:focus {
  outline: none;
  border-color: var(--color-imagedb);
}

.imagedb-desc-edit {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  resize: vertical;
}

.imagedb-desc-edit:focus {
  outline: none;
  border-color: var(--color-imagedb);
}

.imagedb-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.imagedb-card-actions .btn {
  padding: 4px 8px;
  font-size: 11px;
}

/* ---------------------------------------------------------------------------
   台本→絵コンテ キャラクターDBタブ
   --------------------------------------------------------------------------- */
.storyboard-characterdb .imagedb-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.storyboard-characterdb .imagedb-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.9)),
    var(--color-surface);
  border-color: rgba(var(--imagedb-accent-rgb), 0.16);
  border-radius: calc(var(--radius-lg) + 2px);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.storyboard-characterdb .imagedb-card .card-thumb {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 50% 35%, rgba(var(--imagedb-accent-rgb), 0.16), transparent 44%),
    var(--color-surface-hover);
  transition: transform 0.35s ease, filter 0.35s ease;
}

.storyboard-characterdb .imagedb-card:hover .card-thumb {
  transform: scale(1.035);
  filter: saturate(1.04) contrast(1.02);
}

.storyboard-characterdb .imagedb-card .card-info {
  padding: 13px 14px 14px;
}

.storyboard-characterdb .imagedb-card .card-title {
  margin-bottom: 6px;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.storyboard-characterdb .imagedb-card .card-prompt {
  color: var(--color-text-muted);
  font-weight: 600;
  line-height: 1.58;
  -webkit-line-clamp: 3;
}

.storyboard-characterdb .imagedb-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(var(--imagedb-accent-rgb), 0.12);
}

.storyboard-characterdb .imagedb-card-actions .btn {
  min-height: 30px;
  border-radius: 999px;
}

.storyboard-characterdb .badge-imagedb {
  color: #fff;
  background: linear-gradient(135deg, var(--imagedb-accent-dark), var(--imagedb-accent));
  box-shadow: 0 10px 22px rgba(var(--imagedb-accent-rgb), 0.22);
}

.storyboard-characterdb-header {
  align-items: center;
}

@media (max-width: 640px) {
  .storyboard-characterdb .imagedb-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
    gap: 14px;
  }

  .storyboard-characterdb-header {
    align-items: stretch;
    flex-direction: column;
  }

  .storyboard-characterdb-header > p {
    text-align: left;
  }
}

.storyboard-image-card .card-info {
  gap: 6px;
}

.storyboard-image-card .storyboard-image-name-view {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}

.storyboard-image-card .storyboard-image-name-edit {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
}

.storyboard-image-card .storyboard-image-name-edit:focus {
  outline: none;
  border-color: var(--color-imagedb);
}

.storyboard-image-card .storyboard-image-desc-edit {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  resize: vertical;
}

.storyboard-image-card .storyboard-image-desc-edit:focus {
  outline: none;
  border-color: var(--color-imagedb);
}

.storyboard-image-card .storyboard-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.storyboard-image-card .storyboard-image-actions .btn {
  padding: 4px 8px;
  font-size: 11px;
}

/* ---------------------------------------------------------------------------
   画像DBの一覧テーブル（GAS版 画像DB画面相当）
   --------------------------------------------------------------------------- */
.imagedb-table {
  width: 100%;
  border-collapse: collapse;
}

.imagedb-table th {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: left;
  background: var(--color-surface-hover);
}

.imagedb-table td {
  padding: 8px 12px;
  font-size: 13px;
  border-top: 1px solid var(--color-border);
  vertical-align: middle;
}

.imagedb-table .char-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-hover);
}

/* ---------------------------------------------------------------------------
   絵コンテビューア（GAS版 絵コンテ閲覧タブ相当）
   --------------------------------------------------------------------------- */
.storyboard-viewer {
  display: grid;
  gap: 18px;
}

.storyboard-viewer-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(var(--color-script-rgb), 0.12), rgba(255, 255, 255, 0.82)),
    var(--color-surface);
  border: 1px solid rgba(var(--color-script-rgb), 0.18);
  border-radius: 24px;
}

.storyboard-viewer-kicker {
  margin: 0 0 4px;
  color: var(--color-script-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.storyboard-viewer-hero h3,
.storyboard-viewer-hero p {
  margin: 0;
}

.storyboard-viewer-controls {
  display: grid;
  gap: 10px;
  min-width: min(320px, 100%);
}

.storyboard-run-select-label {
  display: grid;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.storyboard-run-select-label select {
  width: 100%;
}

.storyboard-download-all-btn {
  width: 100%;
  justify-content: center;
}

.storyboard-viewer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.storyboard-viewer-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(var(--color-script-rgb), 0.14);
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

.storyboard-viewer-summary strong {
  color: var(--color-text);
  font-size: 1rem;
}

.storyboard-sheet {
  display: grid;
  gap: 16px;
}

.storyboard-cut-card {
  display: grid;
  grid-template-columns: 54px minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  gap: 16px;
  align-items: stretch;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(var(--color-script-rgb), 0.16);
  border-radius: 22px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.06);
}

.storyboard-cut-number {
  display: grid;
  place-items: center;
  align-self: start;
  width: 46px;
  height: 46px;
  color: #fff;
  background: var(--color-script);
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.storyboard-cut-image {
  min-height: 180px;
  overflow: hidden;
  background: var(--color-surface-hover);
  border: 1px solid rgba(var(--color-script-rgb), 0.12);
  border-radius: 18px;
}

.storyboard-cut-image img,
.storyboard-cut-image .empty-thumb {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.storyboard-cut-image .empty-thumb {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--color-text-muted);
}

.storyboard-cut-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.storyboard-cut-headline {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.storyboard-cut-label {
  display: block;
  margin-bottom: 4px;
  color: var(--color-script-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.storyboard-cut-headline h4 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.45;
}

.storyboard-cut-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: var(--color-text-muted);
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.storyboard-cut-status--completed {
  color: #047857;
  background: rgba(16, 185, 129, 0.12);
}

.storyboard-cut-status--failed,
.storyboard-cut-status--timeout {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.storyboard-cut-text {
  margin: 0;
  color: var(--color-text);
  font-size: 0.92rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.storyboard-cut-references {
  display: grid;
  gap: 7px;
}

.storyboard-cut-reference-title {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.storyboard-cut-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.storyboard-cut-reference-chip {
  max-width: 180px;
  overflow: hidden;
  padding: 5px 9px;
  color: var(--color-script-dark);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(var(--color-script-rgb), 0.1);
  border: 1px solid rgba(var(--color-script-rgb), 0.16);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.storyboard-cut-no-reference {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.84rem;
}

@media (max-width: 980px) {
  .storyboard-viewer-hero,
  .storyboard-cut-card {
    grid-template-columns: 1fr;
  }

  .storyboard-viewer-controls {
    width: 100%;
    min-width: 0;
  }

  .storyboard-cut-number {
    width: auto;
    height: auto;
    padding: 8px 12px;
    justify-self: start;
    border-radius: 999px;
  }
}

/* ---------------------------------------------------------------------------
   マッチング済み画像表示
   --------------------------------------------------------------------------- */
.matched-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.matched-image-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.matched-image-thumb.selected {
  border-color: var(--color-script);
}

/* ---------------------------------------------------------------------------
   生成設定パネル（GAS版 各画面の生成設定パネル相当）
   --------------------------------------------------------------------------- */
.generate-panel {
  padding: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.generate-panel h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.generate-panel .settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   プログレスバー（ジョブ状態表示用）
   --------------------------------------------------------------------------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-surface-hover);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-bar.indeterminate .progress-fill {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ---------------------------------------------------------------------------
   pendingカード（生成中表示）
   --------------------------------------------------------------------------- */
.pending-card {
  --pending-job-accent: var(--color-gallery);
  --pending-job-soft: var(--color-gallery-soft);
  opacity: 0.7;
  position: relative;
}

.pending-card[data-media-type="video"] {
  --pending-job-accent: var(--color-video);
  --pending-job-soft: var(--color-video-soft);
}

.pending-card-thumb {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--pending-job-soft), var(--color-surface));
}

.pending-card-spinner {
  border-top-color: var(--pending-job-accent);
}

.pending-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pending-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.4) 50%,
    transparent 100%
  );
  animation: pending-shimmer 2s infinite;
  pointer-events: none;
}

@keyframes pending-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.pending-card .pending-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 10px;
  background: var(--color-warning);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  z-index: 1;
}

.pending-card.failed-card {
  opacity: 1;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.pending-card.failed-card::after {
  display: none;
}

.pending-card.failed-card .pending-badge {
  background: var(--color-error);
}

.pending-card.failed-card .card-thumb {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(251, 191, 36, 0.45)) !important;
}

.failed-card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.pending-error-report {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 9px 10px;
  color: #991B1B;
  background: rgba(254, 226, 226, 0.72);
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
}

.pending-error-report strong {
  font-size: 11px;
}

.pending-error-action {
  padding-top: 4px;
  border-top: 1px solid rgba(127, 29, 29, 0.14);
}

.pending-recovery-report {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 9px 10px;
  color: #78350F;
  background: rgba(254, 243, 199, 0.78);
  border: 1px solid rgba(217, 119, 6, 0.24);
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
}

.pending-error-report code {
  width: fit-content;
  padding: 2px 6px;
  color: #7F1D1D;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.pending-error-id-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pending-copy-id-btn {
  width: fit-content;
  padding: 2px 7px;
  color: #7F1D1D;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(127, 29, 29, 0.16);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}

.pending-copy-id-btn:hover {
  background: #fff;
  border-color: rgba(127, 29, 29, 0.32);
}

/* ---------------------------------------------------------------------------
   削除済み表示
   --------------------------------------------------------------------------- */
.deleted-badge {
  padding: 2px 8px;
  background: var(--color-error);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   404 / エラー画面
   --------------------------------------------------------------------------- */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px;
  text-align: center;
}

.error-screen .error-code {
  font-size: 72px;
  font-weight: 900;
  color: var(--color-primary);
  opacity: 0.2;
}

.error-screen .error-message {
  margin-top: 16px;
  font-size: 16px;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   内部画面リデザイン
   ---------------------------------------------------------------------------
   ホームは入口のランディングとして残し、ログイン後の作業画面だけを
   「制作コンソール」として見せる。構造は変えず、共通CSSの上書きで
   画面間の階層、作業領域、操作パネルの区別を強める。
   --------------------------------------------------------------------------- */

#screen-app:not(.is-home) {
  --internal-ink: var(--color-ink-strong);
  --internal-ink-soft: #334155;
  --internal-panel: rgba(255, 255, 255, 0.92);
  --internal-panel-strong: var(--color-surface-strong);
  --internal-line: rgba(100, 116, 139, 0.2);
  color: var(--internal-ink);
}

#screen-app:not(.is-home) .app-header {
  height: 72px;
  padding: 10px 22px;
  color: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.92)),
    radial-gradient(circle at 18% 0%, rgba(var(--accent-rgb), 0.34), transparent 26rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px) saturate(1.2);
}

#screen-app:not(.is-home) .app-title {
  color: var(--color-ink-inverse);
  letter-spacing: 0.16em;
}

#screen-app:not(.is-home) .app-title:hover,
#screen-app:not(.is-home) .btn-text:hover {
  background: rgba(255, 255, 255, 0.1);
}

#screen-app:not(.is-home) .usage-admin-table .btn-text,
#screen-app:not(.is-home) .usage-admin-table .btn-text:hover {
  color: var(--color-text-muted);
  background: transparent;
}

#screen-app:not(.is-home) .header-breadcrumb {
  border-left-color: rgba(255, 255, 255, 0.14);
  color: rgba(226, 232, 240, 0.72);
}

#screen-app:not(.is-home) .breadcrumb-separator {
  color: rgba(148, 163, 184, 0.7);
}

#screen-app:not(.is-home) .breadcrumb-current,
#screen-app:not(.is-home) .user-email,
#screen-app:not(.is-home) .btn-text {
  color: rgba(255, 255, 255, 0.86);
}

#screen-app:not(.is-home) .project-tabs {
  width: min(780px, 100%);
  padding: 5px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
}

#screen-app:not(.is-home) .project-item {
  min-width: 140px;
  padding: 7px 14px;
  color: rgba(226, 232, 240, 0.78);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
}

#screen-app:not(.is-home) .project-item:hover {
  background: rgba(255, 255, 255, 0.11);
}

#screen-app:not(.is-home) .project-item.active {
  color: var(--color-ink-strong);
  background: linear-gradient(135deg, var(--color-surface-strong), var(--color-surface-selected));
  border-color: rgba(255, 255, 255, 0.7);
}

#screen-app:not(.is-home) .project-count {
  color: inherit;
  opacity: 0.64;
}

#screen-app:not(.is-home) .project-empty {
  color: rgba(226, 232, 240, 0.7);
}

#screen-app:not(.is-home) .main-content {
  width: min(1800px, 100%);
  margin: 72px auto 0;
  padding: clamp(18px, 2.4vw, 34px);
}

#screen-app:not(.is-home) .btn {
  border-radius: var(--radius-pill);
  font-weight: 800;
  letter-spacing: 0.01em;
}

#screen-app:not(.is-home) .btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border-color: transparent;
}

#screen-app:not(.is-home) .btn-primary:hover {
  transform: translateY(-1px);
}

#screen-app:not(.is-home) input[type="text"],
#screen-app:not(.is-home) input[type="email"],
#screen-app:not(.is-home) input[type="password"],
#screen-app:not(.is-home) input[type="number"],
#screen-app:not(.is-home) textarea,
#screen-app:not(.is-home) select {
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(100, 116, 139, 0.24);
  border-radius: 16px;
}

#screen-app:not(.is-home) input:focus,
#screen-app:not(.is-home) textarea:focus,
#screen-app:not(.is-home) select:focus {
  border-color: rgba(var(--accent-rgb), 0.62);
}

/* 台本ワークスペースは工程タブを大きめのセグメントにし、現在工程を明確にする。 */
#screen-app:not(.is-home) .workspace-tabs {
  gap: 8px;
  padding: 8px;
  margin-bottom: 22px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--internal-line);
  border-radius: 999px;
}

#screen-app:not(.is-home) .ws-tab {
  flex: 1 1 0;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
}

#screen-app:not(.is-home) .ws-tab.active {
  color: var(--color-ink-inverse);
  background: linear-gradient(135deg, var(--color-script), var(--color-primary));
  border-color: rgba(255, 255, 255, 0.45);
}

#screen-app:not(.is-home) .workspace-content,
#screen-app:not(.is-home) .usage-admin-panel,
#screen-app:not(.is-home) .usage-table-container {
  background: var(--internal-panel);
  border: 1px solid var(--internal-line);
  border-radius: 28px;
}

#screen-app:not(.is-home) .workspace-content {
  padding: clamp(14px, 1.6vw, 22px);
}

#screen-app:not(.is-home) .gallery-layout,
#screen-app:not(.is-home) .videogallery-layout {
  gap: clamp(16px, 1.8vw, 28px);
}

/* 生成指示パネルと結果一覧は兄弟とし、結果一覧には外側のサーフェスを持たせない。 */
#screen-app:not(.is-home) .media-gallery-results {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

/* 台本→絵コンテは中央上の作業タブと作業面だけで構成する。 */
#screen-app:not(.is-home) #screen-storyboard {
  padding: 0;
  background: transparent;
  border: 0;
}

#screen-app:not(.is-home) #screen-storyboard .storyboard-layout {
  --gallery-panel-accent: var(--color-script);
  --gallery-panel-accent-dark: var(--color-script-dark);
  --gallery-panel-accent-rgb: var(--color-script-rgb);
  position: relative;
  display: block;
  min-height: 560px;
  isolation: isolate;
}

#screen-app:not(.is-home) #screen-storyboard .storyboard-results {
  min-width: 0;
  display: grid;
  gap: 14px;
}

#screen-app:not(.is-home) #screen-storyboard .storyboard-workspace-tabs {
  margin: 0;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.16);
  border-radius: 18px;
}

#screen-app:not(.is-home) #screen-storyboard .storyboard-workspace-tabs .ws-tab {
  min-height: 44px;
}

#screen-app:not(.is-home) #screen-storyboard .workspace-content {
  min-height: 560px;
  padding: clamp(16px, 1.8vw, 24px);
  background: var(--internal-panel);
  border: 1px solid var(--internal-line);
  border-radius: 28px;
}

#screen-app:not(.is-home) .gallery-generate-panel,
#screen-app:not(.is-home) .videogallery-generate-panel {
  top: 96px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    radial-gradient(circle at 12% 0%, rgba(var(--gallery-panel-accent-rgb), 0.16), transparent 16rem);
  border: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.16);
  border-radius: 24px;
}

#screen-app:not(.is-home) .gallery-layout.is-collapsed .gallery-generate-panel,
#screen-app:not(.is-home) .videogallery-layout.is-collapsed .videogallery-generate-panel {
  background: transparent;
  border: 0;
}

#screen-app:not(.is-home) .generation-panel-controls,
#screen-app:not(.is-home) .gallery-reference-section,
#screen-app:not(.is-home) .gallery-db-section,
#screen-app:not(.is-home) .videogallery-reference-section,
#screen-app:not(.is-home) .videogallery-menu-section,
#screen-app:not(.is-home) .image-gen-config-panel {
  position: relative;
  z-index: 1;
  padding: 14px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(var(--gallery-panel-accent-rgb), 0.12);
  border-radius: 0;
}

#screen-app:not(.is-home) .generation-panel-controls {
  padding: 0;
  background: transparent;
  border: 0;
}

#screen-app:not(.is-home) .gallery-grid,
#screen-app:not(.is-home) .video-grid,
#screen-app:not(.is-home) .imagedb-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

/* ギャラリー本体は生成タブの開閉状態でカード最小幅を変え、レスポンシブのまま密度を調整する。 */
#screen-app:not(.is-home) .gallery-layout:not(.is-collapsed) .gallery-grid,
#screen-app:not(.is-home) .videogallery-layout:not(.is-collapsed) .video-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

#screen-app:not(.is-home) .gallery-layout.is-collapsed .gallery-grid,
#screen-app:not(.is-home) .videogallery-layout.is-collapsed .video-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* 画像ギャラリーは緑、動画ギャラリーは青を生成系UIの唯一のアクセントにする。 */
#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .btn-primary,
#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .gallery-enhance-btn:hover,
#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .gallery-enhance-btn.is-active {
  color: var(--color-ink-inverse);
  background: var(--color-gallery);
  border-color: var(--color-gallery);
}

#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .btn-primary:hover {
  background: var(--color-gallery-dark);
  border-color: var(--color-gallery-dark);
}

#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .btn-ghost {
  color: var(--color-gallery);
  background: rgba(var(--color-gallery-rgb), 0.06);
  border-color: rgba(var(--color-gallery-rgb), 0.16);
}

#screen-app:not(.is-home) #screen-imagegallery .gallery-generate-panel .btn-ghost:hover {
  color: var(--color-gallery-dark);
  background: rgba(var(--color-gallery-rgb), 0.12);
  border-color: rgba(var(--color-gallery-rgb), 0.28);
}

#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-primary,
#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .videogallery-seedance-gen-btn:hover {
  color: var(--color-ink-inverse);
  background: var(--color-video);
  border-color: var(--color-video);
}

#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-primary:hover {
  background: var(--color-video-dark);
  border-color: var(--color-video-dark);
}

#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-ghost,
#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-secondary,
#screen-app:not(.is-home) #screen-videogallery .videogallery-seedance-gen-btn {
  color: var(--color-video);
  background: rgba(var(--color-video-rgb), 0.06);
  border-color: rgba(var(--color-video-rgb), 0.16);
}

#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-ghost:hover,
#screen-app:not(.is-home) #screen-videogallery .videogallery-generate-panel .btn-secondary:hover {
  color: var(--color-video-dark);
  background: rgba(var(--color-video-rgb), 0.12);
  border-color: rgba(var(--color-video-rgb), 0.28);
}

#screen-app:not(.is-home) .usage-header {
  margin-bottom: 18px;
}

#screen-app:not(.is-home) .usage-admin-panel {
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(100, 116, 139, 0.16);
  border-radius: 28px;
}

#screen-app:not(.is-home) .usage-history-section .usage-admin-panel {
  background: transparent;
  border: 0;
}

#screen-app:not(.is-home) .usage-month-selector {
  padding: 8px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--internal-line);
  border-radius: 999px;
}

#screen-app:not(.is-home) .usage-project-tabs {
  margin: 0 0 14px;
  padding: 4px 0 8px;
}

#screen-app:not(.is-home) .usage-project-tab {
  min-width: 0;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(100, 116, 139, 0.18);
  border-radius: 20px;
}

#screen-app:not(.is-home) .usage-project-tab.is-active {
  color: var(--color-text);
  background: var(--color-usage-soft);
  border-color: rgba(var(--color-usage-rgb), 0.45);
}

#screen-app:not(.is-home) .usage-project-tab.is-active .usage-project-tab-meta {
  color: var(--text-secondary);
}

/* 管理・全体履歴タブはadmin専用のため、利用履歴テーマ色で通常タブと区別する。 */
#screen-app:not(.is-home) .usage-project-tab.is-admin-tab {
  color: var(--color-usage-dark);
  background: rgba(var(--color-usage-rgb), 0.08);
  border-color: rgba(var(--color-usage-rgb), 0.28);
}

#screen-app:not(.is-home) .usage-project-tab.is-admin-tab.is-active {
  color: var(--color-usage-dark);
  background: var(--color-usage-soft);
  border-color: var(--color-usage);
}

#screen-app:not(.is-home) .usage-project-tab.is-admin-tab.is-active .usage-project-tab-meta {
  color: var(--color-usage-dark);
}

#screen-app:not(.is-home) .usage-summary-card,
#screen-app:not(.is-home) .usage-admin-card {
  background: linear-gradient(180deg, #FFFFFF, #F8FAFC);
  border-color: rgba(100, 116, 139, 0.16);
  border-radius: 22px;
}

#screen-app:not(.is-home) .usage-summary-card {
  padding: 18px;
}

#screen-app:not(.is-home) .usage-summary-card .value {
  margin-top: 4px;
  letter-spacing: -0.03em;
}

@media (max-width: 760px) {
  #screen-app:not(.is-home) .usage-section-header,
  #screen-app:not(.is-home) .usage-admin-panel-header,
  #screen-app:not(.is-home) .usage-selected-project-card {
    flex-direction: column;
    align-items: stretch;
  }

  #screen-app:not(.is-home) .usage-admin-project-layout {
    grid-template-columns: 1fr;
  }
}

#screen-app:not(.is-home) .usage-table-container {
  padding: 8px;
}

#screen-app:not(.is-home) .usage-table {
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

#screen-app:not(.is-home) .usage-table th {
  background: rgba(15, 23, 42, 0.05);
  border-bottom: 1px solid rgba(100, 116, 139, 0.14);
}

#screen-app:not(.is-home) .usage-table th:first-child {
  border-top-left-radius: 18px;
}

#screen-app:not(.is-home) .usage-table th:last-child {
  border-top-right-radius: 18px;
}

#screen-app:not(.is-home) .usage-table td {
  border-top: 1px solid rgba(100, 116, 139, 0.12);
}

#screen-app:not(.is-home) .placeholder-text,
#screen-app:not(.is-home) .empty-state {
  border: 1px dashed rgba(100, 116, 139, 0.28);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.52);
}

@media (max-width: 980px) {
  #screen-app:not(.is-home) .app-header {
    height: auto;
    padding: 10px 14px;
  }

  #screen-app:not(.is-home) .main-content {
    margin-top: 156px;
    padding: 16px;
  }

}

/* ========================================================================== */
/* 高画質化: 画像比較を主役にした復元ラボ                                  */
/* ========================================================================== */

.image-restoration-workspace {
  --feature-accent: var(--modal-spec-tools-accent);
  --feature-accent-dark: var(--modal-spec-tools-accent-dark);
  --feature-accent-rgb: var(--modal-spec-tools-accent-rgb);
  padding: 0;
}

#screen-imagerestoration.screen-content--surface {
  background:
    radial-gradient(circle at 12% 4%, rgba(var(--modal-accent-rgb), 0.15), transparent 28rem),
    radial-gradient(circle at 90% 18%, rgba(255, 255, 255, 0.92), transparent 24rem),
    linear-gradient(180deg, rgba(var(--modal-accent-rgb), 0.055), rgba(255, 255, 255, 0) 28rem);
}

.image-restoration-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.image-restoration-stage,
.image-restoration-controls {
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.08), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  backdrop-filter: blur(14px);
}

.image-restoration-stage {
  position: relative;
  min-width: 0;
  padding: clamp(18px, 2vw, 24px);
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 0%, rgba(var(--modal-accent-rgb), 0.18), transparent 18rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(var(--modal-accent-rgb), 0.075));
  border-radius: calc(var(--radius-lg) + 8px);
}

.image-restoration-stage::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: calc(var(--radius-lg) + 2px);
  pointer-events: none;
}

.image-restoration-stage::after {
  content: '';
  position: absolute;
  right: -68px;
  bottom: -92px;
  width: 230px;
  height: 230px;
  border: 34px solid rgba(var(--modal-accent-rgb), 0.07);
  border-radius: 50%;
  pointer-events: none;
}

.image-restoration-stage-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.image-restoration-stage-header h2 {
  margin: 3px 0 0;
  color: var(--color-text);
  font-size: clamp(1.85rem, 3.1vw, 2.65rem);
  font-weight: 900;
  letter-spacing: -0.045em;
}

.image-restoration-stage-header > div:first-child > p:last-child {
  margin: 7px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.image-restoration-kicker {
  margin: 0;
  color: var(--modal-accent-dark);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.image-restoration-status {
  position: relative;
  z-index: 1;
  padding: 8px 14px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.28);
  border-radius: 999px;
  color: var(--modal-accent-dark);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(var(--modal-accent-rgb), 0.08);
  font-size: 0.92rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.image-restoration-status.is-ready {
  border-color: color-mix(in srgb, var(--color-success) 38%, transparent);
  color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 10%, #FFFFFF);
}

.image-restoration-status.is-stopped {
  border-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
  color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 10%, #FFFFFF);
}

.image-restoration-status.is-error {
  border-color: color-mix(in srgb, var(--color-error) 32%, transparent);
  color: var(--color-error);
  background: var(--color-error-bg);
}

.image-restoration-drop-zone {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  border: 2px dashed rgba(var(--modal-accent-rgb), 0.38);
  border-radius: calc(var(--radius-lg) + 4px);
  background-color: rgba(255, 255, 255, 0.72);
  background-image:
    radial-gradient(circle at 50% 35%, rgba(var(--modal-accent-rgb), 0.16), transparent 32%),
    linear-gradient(rgba(var(--modal-accent-rgb), 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--modal-accent-rgb), 0.07) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  box-shadow: 0 20px 52px rgba(var(--modal-accent-rgb), 0.1) inset;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.image-restoration-drop-zone:hover,
.image-restoration-drop-zone.dragover,
.image-restoration-drop-zone:focus-visible {
  border-color: var(--modal-accent-dark);
  background-color: #FFFFFF;
  box-shadow: 0 20px 58px rgba(var(--modal-accent-rgb), 0.16) inset, 0 14px 34px rgba(var(--modal-accent-rgb), 0.12);
  transform: translateY(-1px);
}

.image-restoration-drop-zone.has-image {
  border-style: solid;
  border-color: rgba(var(--modal-accent-rgb), 0.3);
  background: var(--color-surface);
}

.image-restoration-placeholder {
  max-width: 25rem;
  padding: 28px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.18);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-muted);
  text-align: center;
  pointer-events: auto;
}

.image-restoration-placeholder strong {
  color: var(--modal-accent-dark);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
}

.image-restoration-upload-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  place-items: center;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--modal-accent-dark), var(--modal-accent));
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1;
}

.image-restoration-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 18px;
}

.image-restoration-controls {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: clamp(20px, 2vw, 26px);
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--modal-accent-rgb), 0.16), transparent 14rem),
    linear-gradient(145deg, rgba(var(--modal-accent-rgb), 0.12), #FFFFFF 58%);
  border-radius: calc(var(--radius-lg) + 6px);
}

.image-restoration-model-heading {
  display: grid;
  gap: 3px;
}

.image-restoration-model-heading h3 {
  margin: 0;
  color: var(--modal-accent-dark);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
}

.image-restoration-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--modal-accent-rgb), 0.18);
}

.image-restoration-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.34);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.image-restoration-field select:focus {
  border-color: var(--modal-accent-dark);
  box-shadow: 0 0 0 3px rgba(var(--modal-accent-rgb), 0.14);
}

.image-restoration-model-description {
  min-height: 42px;
  margin: -8px 0 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.image-restoration-spec {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(var(--modal-accent-rgb), 0.06);
}

.image-restoration-spec strong {
  color: var(--modal-accent-dark);
}

.image-restoration-spec span,
.image-restoration-spec small {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.55;
}

#imageRestorationInputSupport {
  display: inline-flex;
  width: fit-content;
  padding: 3px 8px;
  color: var(--modal-accent-dark);
  background: rgba(var(--modal-accent-rgb), 0.08);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.16);
  border-radius: 999px;
  font-weight: 800;
}

.image-restoration-result {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.image-restoration-result:empty {
  display: none;
}

#audioSeparatorResult {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr));
  align-items: start;
}

/* 音声分離の履歴カードは動画プレビュー、stemチェック、DL操作を同時に持つため、
   通常ギャラリーカードより広い表示領域を確保する。 */
#screen-app:not(.is-home) #audioSeparatorResult.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr));
}

.image-restoration-sample {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: clamp(14px, 2vw, 18px);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--modal-accent-rgb), 0.13), transparent 14rem),
    rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.07);
}

.image-restoration-sample.hidden {
  display: none;
}

.image-restoration-sample-copy {
  display: grid;
  gap: 5px;
}

.image-restoration-sample-copy h3,
.image-restoration-sample-copy p {
  margin: 0;
}

.image-restoration-sample-copy h3 {
  color: var(--modal-accent-dark);
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.9vw, 1.35rem);
  font-weight: 900;
}

.image-restoration-sample-copy p:last-child {
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.image-restoration-sample-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.image-restoration-sample figure {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.22);
  border-radius: var(--radius-md);
  background: rgba(var(--modal-accent-rgb), 0.055);
}

.image-restoration-sample figure span {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 4px 9px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.25);
  border-radius: 999px;
  color: var(--modal-accent-dark);
  background: rgba(255, 255, 255, 0.84);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.image-restoration-sample img,
.image-restoration-sample-video-player {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.image-restoration-sample-video-slot {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--color-text-muted);
  font-size: 12px;
}

.image-restoration-sample-video small {
  display: block;
  padding: 10px 14px 14px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.image-restoration-submit {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--modal-accent-rgb), 0.18);
}

.image-restoration-submit p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

#screen-imagerestoration .btn-primary {
  min-height: 48px;
  color: #FFFFFF;
  background: var(--modal-accent-dark);
  border-color: var(--modal-accent-dark);
}

#screen-imagerestoration .btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--modal-accent-dark) 88%, #000000);
  border-color: color-mix(in srgb, var(--modal-accent-dark) 88%, #000000);
}

.image-restoration-progress,
.image-restoration-error {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.3);
  border-radius: var(--radius-md);
  background: var(--modal-accent-soft);
  color: var(--text-secondary);
  font-size: 13px;
}

.image-restoration-progress span {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid rgba(var(--modal-accent-rgb), 0.32);
  border-top-color: var(--modal-accent-dark);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.image-restoration-error {
  border-color: color-mix(in srgb, var(--color-error) 30%, transparent);
  color: var(--color-error);
  background: var(--color-error-bg);
}

.image-restoration-result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: clamp(18px, 2vw, 24px);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.3);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}

.image-restoration-result-card img {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-md);
  background: rgba(var(--modal-accent-rgb), 0.045);
}

.audio-separator-result {
  display: grid;
  gap: 10px;
  width: 100%;
}

.audio-separator-work-result {
  align-content: start;
  grid-template-columns: 1fr;
  min-width: 0;
  padding: 14px;
}

.audio-separator-result audio {
  width: 100%;
}

.audio-separator-result-console {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(320px, 1fr);
  gap: 14px;
  align-items: start;
}

.audio-separator-result-preview {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.22);
  border-radius: var(--radius-md);
  background: rgba(var(--modal-accent-rgb), 0.045);
}

.audio-separator-result-preview--video {
  justify-items: center;
}

.audio-separator-result-preview--video span {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 4px 9px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.25);
  border-radius: 999px;
  color: var(--modal-accent-dark);
  background: rgba(255, 255, 255, 0.84);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.audio-separator-result-preview--audio {
  align-content: center;
  min-height: 132px;
}

.audio-separator-result-preview small,
.audio-separator-result-preview--audio small {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.audio-separator-result-video {
  display: block;
  width: auto;
  max-width: min(100%, 204px);
  max-height: 300px;
  height: auto;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-md);
  background: #050816;
  cursor: pointer;
  object-fit: contain;
}

.audio-separator-result-video:focus-visible {
  outline: 3px solid rgba(var(--modal-accent-rgb), 0.48);
  outline-offset: 3px;
}

.audio-separator-result-mixer {
  align-content: start;
  gap: 10px;
  padding: 10px;
}

.audio-separator-result-header,
.audio-separator-merge-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: space-between;
}

.audio-separator-result-header strong {
  color: var(--modal-accent-dark);
  font-size: 0.94rem;
}

.audio-separator-result-header span,
.audio-separator-merge-panel span {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.audio-separator-result-stems {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.audio-separator-result-stem-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 6px;
  align-items: stretch;
}

.audio-separator-result-stem {
  min-width: 0;
  min-height: 40px;
  padding: 8px 9px;
  font-size: 0.88rem;
}

.audio-separator-result-stem-row .btn-small {
  min-height: 40px;
  padding-inline: 8px;
}

.audio-separator-result-actions {
  gap: 8px;
}

.audio-separator-result-actions span {
  flex-basis: 100%;
}

.audio-separator-sample-player {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.audio-separator-sample-video {
  min-width: 0;
  justify-self: center;
  width: min(100%, 220px);
}

.audio-separator-sample-video .image-restoration-sample-video-player {
  aspect-ratio: 9 / 16;
  background: #050816;
  cursor: pointer;
  object-fit: contain;
}

.audio-separator-sample-video .image-restoration-sample-video-player:focus-visible {
  outline: 3px solid rgba(var(--modal-accent-rgb), 0.48);
  outline-offset: 3px;
}

.audio-separator-sample-mixer {
  display: grid;
  gap: 14px;
  padding: clamp(14px, 2vw, 18px);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.22);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(var(--modal-accent-rgb), 0.11), rgba(255, 255, 255, 0.76)),
    rgba(255, 255, 255, 0.82);
}

.audio-separator-sample-stems {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.audio-separator-sample-stem {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.22);
  border-radius: var(--radius-md);
  color: var(--modal-accent-dark);
  background: rgba(255, 255, 255, 0.68);
  font-weight: 900;
}

.audio-separator-sample-stem input {
  width: 18px;
  height: 18px;
  accent-color: var(--modal-accent-dark);
}

.audio-separator-sample-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.audio-separator-sample-actions span {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.image-restoration-result-actions {
  display: flex;
  align-items: stretch;
  align-self: start;
  flex-direction: column-reverse;
  justify-content: space-between;
  gap: 10px;
  height: 100%;
  color: var(--color-text-muted);
  font-size: 11px;
}

.image-restoration-result-actions span {
  font-family: var(--font-mono);
}

@media (max-width: 980px) {
  .image-restoration-workspace {
    padding: 0;
  }

  .image-restoration-layout {
    grid-template-columns: 1fr;
  }

  .image-restoration-stage-header {
    align-items: stretch;
    flex-direction: column;
  }

  .image-restoration-status {
    align-self: flex-start;
  }

  .audio-separator-sample-player {
    grid-template-columns: 1fr;
  }

  .audio-separator-result-console {
    grid-template-columns: 1fr;
  }

  .audio-separator-result-preview--video {
    justify-self: center;
    width: min(100%, 220px);
  }

  .audio-separator-result-video {
    max-width: min(100%, 204px);
    max-height: 300px;
  }

  .image-restoration-drop-zone {
    min-height: 220px;
  }
}

@media (max-width: 640px) {
  .image-restoration-stage,
  .image-restoration-controls {
    padding: 16px;
  }

  .image-restoration-drop-zone {
    min-height: 200px;
  }

  .image-restoration-result-card {
    grid-template-columns: 1fr;
  }

  .image-restoration-sample-grid {
    grid-template-columns: 1fr;
  }

  .audio-separator-sample-stems {
    grid-template-columns: 1fr;
  }

  #audioSeparatorResult {
    grid-template-columns: 1fr;
  }

  .audio-separator-result-stems {
    grid-template-columns: 1fr;
  }

  .image-restoration-result-actions .btn {
    width: 100%;
  }
}

@media (max-width: 768px) {
  #screen-app:not(.is-home) .main-content {
    margin-top: 172px;
    padding: 12px;
  }

  #screen-app:not(.is-home) .workspace-tabs {
    align-items: stretch;
    overflow-x: auto;
    border-radius: 22px;
  }

  #screen-app:not(.is-home) .ws-tab {
    flex: 0 0 150px;
  }

  #screen-app:not(.is-home) .gallery-grid,
  #screen-app:not(.is-home) .video-grid,
  #screen-app:not(.is-home) .imagedb-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  #screen-app:not(.is-home) .usage-project-tab {
    min-width: 0;
  }

  #screen-app:not(.is-home) .usage-project-tab-wrap {
    flex-basis: 136px;
  }

}

/* ---------------------------------------------------------------------------
   共通濃色ヘッダー
   ---------------------------------------------------------------------------
   ホームを含むログイン後画面すべてで同じヘッダーを使う。
   ホームだけヘッダーを消すと、プロジェクト境界・ログアウト・現在地確認の導線が
   画面によって変わるため、入口画面でも同じ操作体系に揃える。
   --------------------------------------------------------------------------- */

#screen-app .app-header,
#screen-app.is-home .app-header {
  display: flex;
  height: 72px;
  padding: 10px 22px;
  color: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.92)),
    radial-gradient(circle at 18% 0%, rgba(99, 102, 241, 0.34), transparent 26rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px) saturate(1.2);
}

#screen-app .app-title,
#screen-app.is-home .app-title {
  color: var(--color-ink-inverse);
  letter-spacing: 0.16em;
}

#screen-app .app-title:hover,
#screen-app .btn-text:hover,
#screen-app.is-home .app-title:hover,
#screen-app.is-home .btn-text:hover {
  background: rgba(255, 255, 255, 0.1);
}

#screen-app .usage-admin-table .btn-text,
#screen-app .usage-admin-table .btn-text:hover,
#screen-app.is-home .usage-admin-table .btn-text,
#screen-app.is-home .usage-admin-table .btn-text:hover {
  color: var(--color-text-muted);
  background: transparent;
}

#screen-app .header-breadcrumb,
#screen-app.is-home .header-breadcrumb {
  border-left-color: rgba(255, 255, 255, 0.14);
  color: rgba(226, 232, 240, 0.72);
}

#screen-app .breadcrumb-separator,
#screen-app.is-home .breadcrumb-separator {
  color: rgba(148, 163, 184, 0.7);
}

#screen-app .breadcrumb-current,
#screen-app .user-email,
#screen-app .btn-text,
#screen-app.is-home .breadcrumb-current,
#screen-app.is-home .user-email,
#screen-app.is-home .btn-text {
  color: rgba(255, 255, 255, 0.86);
}

#screen-app .usage-admin-table .btn-text,
#screen-app.is-home .usage-admin-table .btn-text {
  color: var(--color-text-muted);
}

#screen-app .usage-admin-table .btn-text:hover,
#screen-app.is-home .usage-admin-table .btn-text:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

#screen-app .project-tabs,
#screen-app.is-home .project-tabs {
  width: min(780px, 100%);
  padding: 5px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
}

#screen-app .project-item,
#screen-app.is-home .project-item {
  min-width: 140px;
  padding: 7px 14px;
  color: rgba(226, 232, 240, 0.78);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
}

#screen-app .project-item:hover,
#screen-app.is-home .project-item:hover {
  background: rgba(255, 255, 255, 0.11);
}

#screen-app .project-item.active,
#screen-app.is-home .project-item.active {
  color: var(--color-ink-strong);
  background: linear-gradient(135deg, var(--color-surface-strong), var(--color-surface-selected));
  border-color: rgba(255, 255, 255, 0.7);
}

#screen-app .project-count,
#screen-app.is-home .project-count {
  color: inherit;
  opacity: 0.64;
}

#screen-app .project-new-btn,
#screen-app.is-home .project-new-btn {
  color: var(--color-ink-inverse);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

#screen-app .project-new-btn:hover,
#screen-app.is-home .project-new-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.32);
}

#screen-app .project-empty,
#screen-app.is-home .project-empty {
  color: rgba(226, 232, 240, 0.7);
}

#screen-app.is-home .main-content {
  margin-top: 72px;
  padding: 0;
  min-height: calc(100vh - 72px);
}

#screen-app.is-home #screen-home.home-launch {
  min-height: calc(100vh - 72px);
  padding-top: 48px;
}

@media (max-width: 980px) {
  #screen-app .app-header,
  #screen-app.is-home .app-header {
    height: auto;
    min-height: 72px;
    padding: 10px 14px;
  }

  #screen-app.is-home .main-content {
    margin-top: 156px;
  }

  #screen-app.is-home #screen-home.home-launch {
    min-height: calc(100vh - 156px);
    padding-top: 36px;
  }
}

@media (max-width: 640px) {
  #screen-app.is-home .main-content {
    margin-top: 172px;
  }

  #screen-app.is-home #screen-home.home-launch {
    min-height: calc(100vh - 172px);
    padding-top: 28px;
  }
}

/* ==========================================================================
   画像角度修正ツール
   ========================================================================== */

.imageedit-angle-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.imageedit-angle-stage {
  position: relative;
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: clamp(18px, 2vw, 24px);
  overflow: hidden;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: calc(var(--radius-lg) + 8px);
  background:
    radial-gradient(circle at 92% 0%, rgba(var(--modal-accent-rgb), 0.18), transparent 18rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(var(--modal-accent-rgb), 0.075));
}

.imageedit-angle-stage-header {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0;
}

.imageedit-angle-stage-header h2,
.imageedit-angle-controls-header h3 {
  margin: 3px 0 0;
  color: var(--color-text);
  font-weight: 900;
}

.imageedit-angle-stage-header h2 {
  font-size: clamp(1.85rem, 3.1vw, 2.65rem);
  letter-spacing: -0.045em;
}

.imageedit-angle-controls-header h3 {
  color: var(--modal-accent-dark);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.imageedit-angle-stage-header > div:first-child > p:last-child {
  margin: 7px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.imageedit-angle-kicker {
  margin: 0;
  color: var(--modal-accent-dark);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.imageedit-angle-status {
  position: relative;
  z-index: 1;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--modal-accent-dark);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.28);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(var(--modal-accent-rgb), 0.08);
  backdrop-filter: blur(10px);
}

.imageedit-angle-status.is-ready {
  color: var(--color-success);
  background: rgba(var(--color-success-rgb), 0.12);
  border-color: rgba(var(--color-success-rgb), 0.32);
}

.imageedit-angle-status.is-stopped {
  color: var(--color-warning);
  background: rgba(var(--color-warning-rgb), 0.14);
  border-color: rgba(var(--color-warning-rgb), 0.36);
}

.imageedit-angle-status.is-error {
  color: var(--color-error);
  background: rgba(var(--color-error-rgb), 0.1);
  border-color: rgba(var(--color-error-rgb), 0.28);
}

#screen-imageeditangle .imageedit-angle-composer {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: clamp(420px, 52vw, 590px);
  border: 2px dashed rgba(var(--modal-accent-rgb), 0.42);
  border-radius: calc(var(--radius-lg) + 4px);
  background:
    radial-gradient(ellipse at 50% 58%, rgba(var(--modal-accent-rgb), 0.22), transparent 42%),
    linear-gradient(180deg, color-mix(in srgb, var(--modal-accent-dark) 17%, #101827), #07101e 72%);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28) inset;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

#screen-imageeditangle .imageedit-angle-composer:hover,
#screen-imageeditangle .imageedit-angle-composer.dragover,
#screen-imageeditangle .imageedit-angle-composer:focus-visible {
  border-color: var(--modal-accent-dark);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.36) inset, 0 14px 34px rgba(var(--modal-accent-rgb), 0.12);
  transform: translateY(-1px);
}

#screen-imageeditangle .imageedit-angle-composer.has-image {
  border-style: solid;
  border-color: rgba(var(--modal-accent-rgb), 0.3);
  cursor: default;
}

#screen-imageeditangle .imageedit-angle-composer.is-camera-dragging {
  user-select: none;
}

.imageedit-angle-placeholder {
  position: relative;
  z-index: 10;
  max-width: 25rem;
  padding: 28px;
  color: rgba(226, 232, 240, 0.76);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.32);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: rgba(226, 232, 240, 0.76);
  pointer-events: none;
}

.imageedit-angle-placeholder strong {
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
}

.imageedit-angle-placeholder small {
  font-size: var(--text-xs);
}

.imageedit-angle-upload-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  place-items: center;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--modal-accent-dark), var(--modal-accent));
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}

.imageedit-angle-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.imageedit-angle-camera-scene {
  --scene-grid-rotate-x: 63deg;
  --scene-grid-rotate-z: 0deg;
  --scene-grid-scale: 1;
  --scene-orbit-rotate-x: 0deg;
  --scene-orbit-rotate-z: 0deg;
  --scene-axis-rotate-z: 0deg;
  --scene-axis-tilt: 63deg;
  --subject-scale: 1;
  --subject-depth: 34px;
  position: absolute;
  inset: 0;
  display: none;
  perspective: 760px;
  perspective-origin: 50% 48%;
  pointer-events: none;
}

.imageedit-angle-composer.has-image .imageedit-angle-camera-scene {
  display: block;
}

.imageedit-angle-space-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0 0 44%;
  opacity: 0.55;
  background:
    linear-gradient(rgba(var(--modal-accent-rgb), 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--modal-accent-rgb), 0.1) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 82%, transparent);
  transform: rotateZ(var(--scene-orbit-rotate-z));
  transform-origin: 50% 80%;
  transition: transform 140ms ease-out;
}

/* 水平・垂直・ズームを同一原点から伸びる直交軸として表示する。 */
.imageedit-angle-world-axes {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 55%;
  width: min(58vw, 520px);
  height: min(42vw, 360px);
  transform: translate(-50%, -50%) rotateZ(var(--scene-grid-rotate-z));
  transform-style: preserve-3d;
  transition: transform 140ms ease-out;
}

.imageedit-angle-world-axis {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 1px;
  color: rgba(226, 232, 240, 0.56);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-indent: calc(100% + 8px);
  white-space: nowrap;
  transform-origin: 0 50%;
}

.imageedit-angle-world-axis::before,
.imageedit-angle-world-axis::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 1px;
  background: currentColor;
}

.imageedit-angle-world-axis::before {
  width: 100%;
  box-shadow: 0 0 12px rgba(var(--modal-accent-rgb), 0.34);
}

.imageedit-angle-world-axis::after {
  left: calc(100% - 8px);
  width: 8px;
  transform: rotate(32deg);
  transform-origin: 100% 50%;
}

.imageedit-angle-world-axis--horizontal {
  color: rgba(255, 255, 255, 0.72);
  transform: translateY(-50%);
}

.imageedit-angle-world-axis--vertical {
  color: rgba(var(--modal-accent-rgb), 0.82);
  transform: translateY(-50%) rotate(-90deg);
}

.imageedit-angle-world-axis--zoom {
  color: rgba(226, 232, 240, 0.46);
  transform: translateY(-50%) rotate(90deg) rotateX(var(--scene-axis-tilt));
}

.imageedit-angle-world-axis--horizontal::before,
.imageedit-angle-world-axis--horizontal::after,
.imageedit-angle-world-axis--vertical::before,
.imageedit-angle-world-axis--vertical::after,
.imageedit-angle-world-axis--zoom::before,
.imageedit-angle-world-axis--zoom::after {
  pointer-events: none;
}

.imageedit-angle-floor-grid {
  position: absolute;
  z-index: 0;
  left: -18%;
  right: -18%;
  bottom: -33%;
  height: 84%;
  transform: rotateX(var(--scene-grid-rotate-x)) rotateZ(var(--scene-grid-rotate-z)) scale(var(--scene-grid-scale));
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  background:
    linear-gradient(rgba(var(--modal-accent-rgb), 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--modal-accent-rgb), 0.28) 1px, transparent 1px);
  background-size: 54px 46px;
  box-shadow: 0 -1px 0 rgba(var(--modal-accent-rgb), 0.5);
  mask-image: linear-gradient(to top, #000 25%, rgba(0, 0, 0, 0.9) 52%, transparent 94%);
  transition: transform 140ms ease-out;
}

.imageedit-angle-height-axis {
  position: absolute;
  z-index: 3;
  top: 15%;
  bottom: 17%;
  left: 3.8%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 34px;
  padding-left: 10px;
  color: rgba(226, 232, 240, 0.42);
  border-left: 1px solid rgba(var(--modal-accent-rgb), 0.48);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  transform: rotateZ(var(--scene-axis-rotate-z));
  transform-origin: 50% 50%;
  transition: transform 140ms ease-out;
}

.imageedit-angle-height-axis::before,
.imageedit-angle-height-axis::after {
  content: '';
  position: absolute;
  left: -4px;
  width: 7px;
  height: 7px;
  border-top: 1px solid rgba(var(--modal-accent-rgb), 0.65);
  border-left: 1px solid rgba(var(--modal-accent-rgb), 0.65);
}

.imageedit-angle-height-axis::before { top: 0; transform: rotate(45deg); }
.imageedit-angle-height-axis::after { bottom: 0; transform: rotate(225deg); }

.imageedit-angle-orbit {
  position: absolute;
  z-index: 1;
  inset: 8% 4% 5%;
  width: 92%;
  height: 87%;
  overflow: visible;
  fill: none;
  stroke: rgba(var(--modal-accent-rgb), 0.48);
  stroke-width: 2;
  stroke-dasharray: 8 10;
  vector-effect: non-scaling-stroke;
  transform-origin: 50% 55%;
}

.imageedit-angle-orbit ellipse,
.imageedit-angle-orbit path {
  stroke: rgba(var(--modal-accent-rgb), 0.22);
  transform: rotateX(var(--scene-orbit-rotate-x)) rotateZ(var(--scene-orbit-rotate-z));
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 140ms ease-out;
}

.imageedit-angle-orbit line {
  stroke: rgba(255, 255, 255, 0.64);
  stroke-width: 2.5;
  stroke-dasharray: 5 8;
}

.imageedit-angle-motion-axes {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  pointer-events: none;
}

/* 実操作の水平・垂直・ズーム軌跡を破線で分け、カメラがどの軸に沿って動くかを明示する。 */
.imageedit-angle-motion-axis {
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-dasharray: 1.4 2.2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 7px rgba(var(--modal-accent-rgb), 0.32));
  transition: d 120ms ease-out, opacity 120ms ease-out;
}

.imageedit-angle-motion-axis--horizontal {
  stroke: rgba(255, 255, 255, 0.78);
}

.imageedit-angle-motion-axis--vertical {
  stroke: rgba(var(--modal-accent-rgb), 0.92);
  stroke-dasharray: 0.8 2.4;
}

.imageedit-angle-motion-axis--zoom {
  stroke: rgba(226, 232, 240, 0.58);
  stroke-width: 2.1;
  stroke-dasharray: 3 3.8;
}

.imageedit-angle-axis-legend {
  position: absolute;
  z-index: 8;
  top: 18px;
  right: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(45%, 260px);
  pointer-events: none;
}

.imageedit-angle-axis-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  color: rgba(226, 232, 240, 0.76);
  background: rgba(7, 16, 30, 0.66);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.1em;
  backdrop-filter: blur(8px);
}

.imageedit-angle-axis-legend-item::before {
  content: '';
  width: 18px;
  height: 0;
  border-top: 2px dashed currentColor;
}

.imageedit-angle-axis-legend-item--horizontal { color: rgba(255, 255, 255, 0.88); }
.imageedit-angle-axis-legend-item--vertical { color: rgba(var(--modal-accent-rgb), 0.96); }
.imageedit-angle-axis-legend-item--zoom { color: rgba(226, 232, 240, 0.68); }

.imageedit-angle-subject-frame {
  --subject-rotate-x: -8deg;
  --subject-rotate-y: -14deg;
  --subject-shadow-x: 28px;
  --subject-shadow-y: 34px;
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 55%;
  width: clamp(150px, 31%, 260px);
  height: clamp(190px, 48%, 310px);
  padding: 12px;
  transform: translate(-50%, -50%) rotateX(var(--subject-rotate-x)) rotateY(var(--subject-rotate-y)) translateZ(var(--subject-depth)) scale(var(--subject-scale));
  transform-style: preserve-3d;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.7);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.98), rgba(7, 16, 30, 0.96));
  box-shadow: var(--subject-shadow-x) var(--subject-shadow-y) 70px rgba(0, 0, 0, 0.5), 0 0 0 5px rgba(var(--modal-accent-rgb), 0.08);
  transition: transform 140ms ease-out, box-shadow 140ms ease-out;
}

.imageedit-angle-subject-frame::before {
  content: '';
  position: absolute;
  inset: 10px -10px 10px auto;
  width: 18px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.45);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.86), rgba(var(--modal-accent-rgb), 0.22));
  transform: rotateY(76deg) translateZ(-4px);
  transform-origin: left center;
}

.imageedit-angle-subject-frame::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -42px;
  width: 1px;
  height: 42px;
  background: linear-gradient(rgba(var(--modal-accent-rgb), 0.65), transparent);
}

.imageedit-angle-subject-frame > span {
  position: absolute;
  top: -22px;
  left: 50%;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  transform: translateX(-50%);
}

.imageedit-angle-subject-frame .imageedit-angle-preview {
  position: relative;
  z-index: 1;
  border-radius: 8px;
  box-shadow: inset 18px 0 28px rgba(255, 255, 255, 0.06), inset -18px 0 28px rgba(0, 0, 0, 0.26);
  transform: translateZ(6px);
}

.imageedit-angle-camera-marker {
  --camera-scale: 1;
  --camera-look-rotate: 0deg;
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 74%;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  padding: 0;
  color: #FFFFFF;
  background: linear-gradient(145deg, var(--modal-accent), var(--modal-accent-dark));
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34), 0 0 28px rgba(var(--modal-accent-rgb), 0.4);
  transform: translate(-50%, -50%) scale(var(--camera-scale));
  transition: left 120ms ease-out, top 120ms ease-out, transform 120ms ease-out, opacity 120ms ease-out;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}

.imageedit-angle-camera-marker:hover,
.imageedit-angle-camera-marker:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
}

.imageedit-angle-camera-marker.is-dragging {
  cursor: grabbing;
  transition: none;
}

.imageedit-angle-camera-marker.is-behind {
  z-index: 2;
  opacity: 0.66;
}

.imageedit-angle-camera-marker svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
  transform: rotate(var(--camera-look-rotate));
  transition: transform 120ms ease-out;
}

.imageedit-angle-camera-marker strong {
  position: absolute;
  top: calc(100% + 6px);
  color: rgba(255, 255, 255, 0.88);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.imageedit-angle-camera-help {
  position: absolute;
  z-index: 8;
  right: 18px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  color: rgba(226, 232, 240, 0.66);
  background: rgba(7, 16, 30, 0.7);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.25);
  border-radius: 9px;
  font-size: 9px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}

.imageedit-angle-camera-help strong {
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.imageedit-angle-camera-help span {
  width: 1px;
  height: 12px;
  background: rgba(var(--modal-accent-rgb), 0.42);
}

.imageedit-angle-camera-pulse {
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.7);
  border-radius: 50%;
  animation: imageedit-camera-pulse 1.8s ease-out infinite;
}

@keyframes imageedit-camera-pulse {
  0% { opacity: 0.9; transform: scale(0.82); }
  80%, 100% { opacity: 0; transform: scale(1.28); }
}

.imageedit-angle-scene-label {
  position: absolute;
  z-index: 3;
  color: rgba(226, 232, 240, 0.5);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.imageedit-angle-scene-label--front { bottom: 11%; left: 50%; transform: translateX(-50%); }
.imageedit-angle-scene-label--back { top: 19%; left: 50%; transform: translateX(-50%); }
.imageedit-angle-scene-label--left { top: 55%; left: 8%; }
.imageedit-angle-scene-label--right { top: 55%; right: 8%; }

.imageedit-angle-view-readout {
  position: absolute;
  z-index: 8;
  top: 18px;
  left: 18px;
  display: grid;
  gap: 2px;
  padding: 11px 14px;
  color: rgba(226, 232, 240, 0.68);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.32);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.imageedit-angle-view-readout span,
.imageedit-angle-view-readout small {
  font-size: 10px;
}

.imageedit-angle-view-readout strong {
  color: #FFFFFF;
  font-size: 14px;
}

.imageedit-angle-controls {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: clamp(20px, 2vw, 26px);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.3);
  border-radius: calc(var(--radius-lg) + 6px);
  background: linear-gradient(145deg, var(--modal-accent-soft), #FFFFFF 52%);
}

.imageedit-angle-controls-header {
  display: grid;
  gap: 3px;
}

.imageedit-angle-instruction-tabs {
  --gallery-panel-accent-rgb: var(--modal-accent-rgb);
  --gallery-panel-accent-dark: var(--modal-accent-dark);
  grid-auto-flow: column;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.imageedit-angle-tab-pane {
  display: grid;
  gap: 18px;
}

.imageedit-angle-tab-pane[hidden] {
  display: none;
}

.imageedit-angle-spec {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(var(--modal-accent-rgb), 0.06);
}

.imageedit-angle-spec strong {
  color: var(--modal-accent-dark);
}

.imageedit-angle-spec span,
.imageedit-angle-spec small {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.imageedit-angle-summary {
  margin: 12px 0 0;
  padding: 9px 11px;
  color: var(--modal-accent-dark);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
}

.imageedit-angle-field {
  display: grid;
  gap: 10px;
}

.imageedit-angle-field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.imageedit-angle-field label strong {
  min-width: 58px;
  padding: 5px 9px;
  color: var(--modal-accent-dark);
  background: var(--color-surface);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.3);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.imageedit-angle-field input[type="range"] {
  width: 100%;
  accent-color: var(--modal-accent-dark);
}

.imageedit-angle-field input[type="range"]:focus-visible {
  outline-color: var(--modal-accent-dark);
}

.imageedit-angle-range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.imageedit-angle-submit {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--modal-accent-rgb), 0.18);
}

.imageedit-angle-submit p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

#screen-imageeditangle .btn-primary {
  min-height: 48px;
  color: #FFFFFF;
  background: var(--modal-accent-dark);
  border-color: var(--modal-accent-dark);
}

#screen-imageeditangle .btn-primary:hover {
  background: color-mix(in srgb, var(--modal-accent-dark) 88%, #000000);
  border-color: color-mix(in srgb, var(--modal-accent-dark) 88%, #000000);
}

.imageedit-angle-result {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin-top: 0;
}

.imageedit-angle-result:empty {
  display: none;
}

.imageedit-angle-result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: clamp(18px, 2vw, 24px);
  border: 1px solid rgba(var(--modal-accent-rgb), 0.3);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}

.imageedit-angle-result-card img {
  grid-row: 1 / span 2;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: 1px solid rgba(var(--modal-accent-rgb), 0.24);
  border-radius: var(--radius-md);
  background: rgba(var(--modal-accent-rgb), 0.045);
}

.imageedit-angle-result-actions {
  align-self: end;
}

.imageedit-angle-result-card .card-meta {
  align-self: start;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.imageedit-angle-error {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
  border-radius: var(--radius-md);
  background: var(--color-error-bg);
  color: var(--color-error);
  font-size: 0.92rem;
}

/* ---------------------------------------------------------------------------
   PSD書き換えツール
   --------------------------------------------------------------------------- */

.psd-rewrite-workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.psd-rewrite-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 20px;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(var(--color-script-rgb), 0.24);
  border-radius: calc(var(--radius-lg) + 8px);
  background:
    radial-gradient(circle at 86% 8%, rgba(var(--color-script-rgb), 0.28), transparent 17rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(var(--color-script-rgb), 0.1));
  box-shadow: 0 24px 70px rgba(var(--color-script-rgb), 0.14), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.psd-rewrite-hero::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: calc(var(--radius-lg) + 2px);
  pointer-events: none;
}

.psd-rewrite-kicker {
  margin: 0 0 6px;
  color: var(--color-script-dark);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.psd-rewrite-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.psd-rewrite-hero p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.psd-rewrite-flow {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: center;
}

.psd-rewrite-flow span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(var(--color-script-rgb), 0.12);
  color: var(--color-script-dark);
  font-size: var(--text-xs);
  font-weight: 800;
}

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

.psd-rewrite-analyze-panel {
  grid-column: auto;
  padding: 16px;
}

.psd-rewrite-analyze-panel h3 {
  margin-bottom: 8px;
  font-size: var(--text-md);
}

.psd-rewrite-analyze-panel .psd-rewrite-note {
  margin-top: 0;
  font-size: var(--text-xs);
  line-height: 1.55;
}

.psd-rewrite-analyze-panel .btn-large {
  padding: 9px 18px;
  font-size: var(--text-sm);
}

.psd-rewrite-analyze-panel .psd-rewrite-status {
  font-size: var(--text-xs);
}

.psd-rewrite-panel,
.psd-rewrite-layer-panel,
.psd-rewrite-table-panel {
  padding: 20px;
  border: 1px solid rgba(var(--color-script-rgb), 0.22);
  border-radius: calc(var(--radius-lg) + 4px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.07), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  backdrop-filter: blur(12px);
}

.psd-rewrite-panel h3,
.psd-rewrite-layer-panel h3,
.psd-rewrite-table-panel h3 {
  margin: 0 0 12px;
}

.psd-rewrite-drop {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  border: 2px dashed rgba(var(--color-script-rgb), 0.38);
  border-radius: calc(var(--radius-lg) + 2px);
  background:
    radial-gradient(circle at 50% 35%, rgba(var(--color-script-rgb), 0.14), transparent 35%),
    rgba(255, 255, 255, 0.72);
  color: var(--color-script-dark);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.psd-rewrite-drop:hover,
.psd-rewrite-drop.dragover {
  border-color: var(--color-script);
  background: rgba(var(--color-script-rgb), 0.12);
  transform: translateY(-1px);
}

.psd-rewrite-drop span {
  font-weight: 800;
}

.psd-rewrite-drop small,
.psd-rewrite-note,
.psd-rewrite-status,
.psd-rewrite-table-header p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.psd-rewrite-panel .btn {
  width: 100%;
  margin-top: 14px;
}

.psd-rewrite-note {
  margin: 12px 0 0;
  line-height: 1.65;
}

.psd-rewrite-status {
  margin-top: 10px;
}

.psd-rewrite-table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.psd-rewrite-table-header p {
  margin: 0;
}

.psd-rewrite-output-controls {
  display: flex;
  align-items: center;
  min-width: min(600px, 100%);
  gap: 10px;
}

.psd-rewrite-output-controls label {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.psd-rewrite-output-controls input {
  width: min(220px, 100%);
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: white;
  color: var(--color-text);
  font: inherit;
  font-weight: 500;
}

.psd-rewrite-output-controls .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

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

.psd-rewrite-layer-list {
  display: grid;
  gap: 18px;
}

.psd-rewrite-assignment-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(var(--color-script-rgb), 0.16);
  border-radius: 18px;
  background: rgba(var(--color-script-rgb), 0.035);
}

.psd-rewrite-assignment-section.is-background {
  background: rgba(255, 255, 255, 0.7);
}

.psd-rewrite-assignment-heading,
.psd-rewrite-speaker-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.psd-rewrite-assignment-heading h4,
.psd-rewrite-assignment-heading p {
  margin: 0;
}

.psd-rewrite-assignment-heading h4 {
  margin-bottom: 3px;
  font-size: var(--text-base);
}

.psd-rewrite-assignment-heading p {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: 1.55;
}

.psd-rewrite-assignment-heading > span {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(var(--color-script-rgb), 0.12);
  color: var(--color-script-dark);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.psd-rewrite-speaker-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}

.psd-rewrite-speaker-card {
  display: grid;
  align-content: start;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: white;
}

.psd-rewrite-speaker-card.is-assigned {
  border-color: rgba(var(--color-script-rgb), 0.38);
}

.psd-rewrite-speaker-card-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: var(--text-sm);
}

.psd-rewrite-speaker-card-heading small {
  flex: 0 0 auto;
  max-width: 55%;
  overflow: hidden;
  color: var(--color-script-dark);
  font-size: var(--text-xs);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.psd-rewrite-layer-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.psd-rewrite-layer-choice {
  position: relative;
  cursor: pointer;
}

.psd-rewrite-layer-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.psd-rewrite-layer-choice span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 10px;
  border-color: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
}

.psd-rewrite-layer-choice input:checked + span {
  border-color: var(--color-script);
  background: rgba(var(--color-script-rgb), 0.14);
  color: var(--color-script-dark);
}

.psd-rewrite-layer-choice input:focus-visible + span {
  outline: 2px solid rgba(var(--color-script-rgb), 0.42);
  outline-offset: 2px;
}

.psd-rewrite-no-layer {
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.psd-rewrite-background-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 8px;
}

.psd-rewrite-background-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: white;
  cursor: pointer;
}

.psd-rewrite-background-choice:has(input:checked) {
  border-color: rgba(var(--color-script-rgb), 0.42);
  background: rgba(var(--color-script-rgb), 0.07);
}

.psd-rewrite-background-choice input {
  flex: 0 0 auto;
  margin-top: 3px;
  accent-color: var(--color-script);
}

.psd-rewrite-background-choice > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.psd-rewrite-background-choice strong {
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: var(--text-xs);
}

.psd-rewrite-background-choice small {
  color: var(--text-secondary);
  font-size: 0.68rem;
}

.psd-rewrite-assigned-layer {
  display: inline-flex;
  padding: 6px 9px;
  border: 1px solid rgba(var(--color-script-rgb), 0.16);
  border-radius: 9px;
  background: rgba(var(--color-script-rgb), 0.07);
  color: var(--color-script-dark);
  font-size: var(--text-xs);
  font-weight: 700;
}

.psd-rewrite-table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.psd-rewrite-table th {
  padding: 0 10px 6px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-align: left;
}

.psd-rewrite-table td {
  padding: 10px;
  background: var(--bg-secondary);
  vertical-align: top;
}

.psd-rewrite-table td:first-child {
  border-radius: 12px 0 0 12px;
}

.psd-rewrite-table td:last-child {
  border-radius: 0 12px 12px 0;
}

.psd-rewrite-table input,
.psd-rewrite-table textarea,
.psd-rewrite-table select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: white;
  font: inherit;
}

.psd-rewrite-speaker-cell small {
  display: block;
  margin-top: 5px;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.psd-rewrite-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: 10px;
  background: #fff1f2;
  color: var(--color-danger, #dc2626);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.psd-rewrite-delete:hover {
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.48);
  background: #ffe4e6;
  transform: translateY(-1px);
}

.psd-rewrite-no {
  width: 56px;
  color: var(--text-secondary);
  font-weight: 800;
  text-align: center;
}

.psd-rewrite-placeholder {
  color: var(--text-secondary);
  text-align: center;
}

@media (max-width: 980px) {
  .imageedit-angle-layout {
    grid-template-columns: 1fr;
  }

  .imageedit-angle-stage-header {
    align-items: stretch;
    flex-direction: column;
  }

  .imageedit-angle-status {
    align-self: flex-start;
  }

  #screen-imageeditangle .imageedit-angle-composer {
    min-height: 480px;
  }

  .psd-rewrite-hero,
  .psd-rewrite-grid {
    grid-template-columns: 1fr;
  }

  .psd-rewrite-table-header {
    display: grid;
  }
}

@media (max-width: 640px) {
  .imageedit-angle-stage,
  .imageedit-angle-controls {
    padding: 16px;
  }

  #screen-imageeditangle .imageedit-angle-composer {
    min-height: 390px;
  }

  .imageedit-angle-subject-frame {
    width: 138px;
    height: 190px;
  }

  .imageedit-angle-camera-marker {
    width: 50px;
    height: 50px;
  }

  .imageedit-angle-camera-marker svg {
    width: 24px;
    height: 24px;
  }

  .imageedit-angle-scene-label--left { left: 4%; }
  .imageedit-angle-scene-label--right { right: 4%; }

  .imageedit-angle-view-readout {
    top: 10px;
    left: 10px;
    padding: 9px 11px;
  }

  .imageedit-angle-axis-legend {
    top: auto;
    right: 10px;
    bottom: 50px;
    max-width: 160px;
  }

  .imageedit-angle-axis-legend-item {
    padding: 5px 7px;
    font-size: 8px;
  }

  .imageedit-angle-camera-help {
    right: 10px;
    bottom: 10px;
  }

  .imageedit-angle-height-axis {
    display: none;
  }

  .imageedit-angle-result-card {
    grid-template-columns: 1fr;
  }

  .imageedit-angle-result-card img {
    grid-row: auto;
  }

  .imageedit-angle-result-actions .btn {
    width: 100%;
  }

  .psd-rewrite-output-controls,
  .psd-rewrite-output-controls label {
    display: grid;
    width: 100%;
    min-width: 0;
  }

  .psd-rewrite-output-controls input,
  .psd-rewrite-output-controls .btn {
    width: 100%;
  }
}
.script-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.script-cut-plan-panel {
  margin-top: 0;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface);
}

.script-generation-panel {
  margin-top: 0;
  padding: 18px;
  border: 1px solid rgba(var(--color-script-rgb), 0.18);
  border-radius: 18px;
  background: rgba(var(--color-script-rgb), 0.05);
}

.script-workspace {
  display: grid;
  gap: 16px;
}

.script-control-strip {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(320px, 1.25fr);
  gap: 14px;
  align-items: stretch;
}

.script-upload-area--compact,
.script-history--compact {
  padding: 14px;
  border: 1px solid rgba(var(--color-script-rgb), 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.script-control-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.script-control-heading h3,
.script-control-heading p {
  margin: 0;
}

.script-upload-zone-compact {
  min-height: 104px;
  padding: 14px;
}

.script-upload-zone-compact .upload-icon {
  margin-bottom: 6px;
  font-size: 1.8rem;
}

.script-upload-zone-compact .upload-hint {
  margin: 0;
  font-size: 0.9rem;
}

.script-history-empty {
  margin: 8px 0 0;
}

.storyboard-custom-prompt-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(var(--color-script-rgb), 0.18);
  border-radius: 14px;
  background: rgba(var(--color-script-rgb), 0.06);
}

.storyboard-custom-prompt-panel label {
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 700;
}

.storyboard-custom-prompt-panel textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
}

.storyboard-custom-prompt-panel p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.script-list--compact {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.script-history-statuses {
  display: grid;
  gap: 10px;
  margin: 0 0 10px;
}

.script-history-statuses:empty {
  display: none;
}

.script-history-statuses .storyboard-work-status-list {
  margin: 0;
}

.script-history-statuses .storyboard-work-status-list h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.script-item--compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.78);
}

.script-item--compact.is-selected {
  border-color: rgba(var(--color-script-rgb), 0.44);
  background: rgba(var(--color-script-rgb), 0.09);
}

.script-item--compact .script-info {
  min-width: 0;
}

.script-item--compact .script-name,
.script-item--compact .script-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-item--compact .script-name {
  font-weight: 700;
}

.script-item--compact .script-meta {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.script-generation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.script-generation-summary--empty {
  color: rgba(var(--color-script-rgb), 0.72);
}

.script-item--compact .script-actions {
  display: flex;
  gap: 6px;
}

.script-cut-plan-main {
  display: grid;
  gap: 12px;
}

.script-cut-plan-panel--empty {
  min-height: 220px;
}

.script-cut-plan-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.script-cut-plan-header h3 {
  margin: 0 0 6px;
}

.script-cut-plan-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.script-cut-plan-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(240px, 0.8fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--bg-secondary);
}

.script-cut-plan-cut-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.script-cut-plan-cut-title span {
  font-weight: 700;
}

.script-cut-plan-cut-body {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.script-cut-plan-refs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.script-cut-plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.script-cut-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  min-height: 46px;
  padding: 5px 8px 5px 5px;
  border: 1px solid rgba(var(--color-script-rgb), 0.18);
  border-radius: 14px;
  background: rgba(79, 70, 229, 0.12);
  color: var(--color-text);
  font-size: 0.85rem;
}

.script-cut-plan-chip-thumb {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.84);
}

.script-cut-plan-chip-thumb--empty {
  display: inline-block;
  background: repeating-linear-gradient(135deg, rgba(var(--color-script-rgb), 0.12), rgba(var(--color-script-rgb), 0.12) 6px, rgba(255, 255, 255, 0.82) 6px, rgba(255, 255, 255, 0.82) 12px);
}

.script-cut-plan-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-cut-plan-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.script-cut-plan-add {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
}

.script-cut-plan-empty {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.script-generation-history {
  display: grid;
  gap: 8px;
}

.script-generation-history h4 {
  margin: 0 0 4px;
}

.script-generation-history .run-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.script-generation-empty {
  margin: 0;
}

@media (max-width: 760px) {
  .script-control-strip,
  .script-cut-plan-row,
  .script-item--compact,
  .script-generation-history .run-item {
    grid-template-columns: 1fr;
  }

  .script-cut-plan-header {
    flex-direction: column;
  }
}

/* ---------------------------------------------------------------------------
   animaloramaker
   Toolカテゴリのオレンジだけを使い、素材・タグ・学習Workを一つの制作台にまとめる。
   --------------------------------------------------------------------------- */

.animalora-workspace {
  --animalora-accent: var(--modal-spec-tools-accent);
  --animalora-accent-dark: var(--modal-spec-tools-accent-dark);
  --animalora-accent-rgb: var(--modal-spec-tools-accent-rgb);
  --animalora-accent-soft: var(--modal-spec-tools-accent-soft);
  display: grid;
  gap: 22px;
}

.stylelora-pair-preview {
  width: 100%;
  max-height: 22rem;
  margin-top: var(--space-sm);
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--color-surface-subtle);
}

.stylelora-pair-grid {
  align-items: start;
}

.stylelora-drop-zone {
  display: grid;
  min-height: 10rem;
  place-content: center;
  gap: 7px;
  padding: 18px;
  border: 1px dashed rgba(var(--animalora-accent-rgb), 0.5);
  border-radius: var(--radius-md);
  background: var(--animalora-accent-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.stylelora-drop-zone.is-dragover {
  border-color: var(--animalora-accent);
  box-shadow: 0 0 0 4px rgba(var(--animalora-accent-rgb), 0.14);
  transform: translateY(-2px);
}

.stylelora-drop-zone > span {
  color: var(--animalora-accent-dark);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.stylelora-drop-zone > small {
  color: var(--color-text-muted);
}

.stylelora-tag-cta,
.stylelora-train-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.18);
  border-radius: var(--radius-md);
}

.stylelora-tag-cta {
  background: var(--animalora-accent-soft);
}

.stylelora-train-cta {
  margin-top: 22px;
  border-style: solid;
  background: linear-gradient(135deg, var(--color-surface), var(--animalora-accent-soft));
}

.stylelora-tag-cta > div,
.stylelora-train-cta > div {
  display: grid;
  gap: 3px;
}

.stylelora-tag-cta span,
.stylelora-train-cta span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

@media (max-width: 640px) {
  .stylelora-tag-cta,
  .stylelora-train-cta {
    align-items: stretch;
    flex-direction: column;
  }
}

.animalora-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 0.8fr);
  align-items: end;
  gap: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 10%, rgba(var(--animalora-accent-rgb), 0.2), transparent 34%),
    linear-gradient(135deg, var(--color-surface) 0%, var(--animalora-accent-soft) 145%);
}

.animalora-kicker,
.animalora-section-heading span,
.animalora-work-heading > span,
.animalora-model-card > div > span {
  margin: 0;
  color: var(--animalora-accent-dark);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.13em;
}

.animalora-step-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.animalora-step-rail button {
  appearance: none;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}

.animalora-step-rail button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.animalora-step-rail button span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.22);
  border-radius: 50%;
  background: var(--color-surface);
}

.animalora-step-rail button.is-current,
.animalora-step-rail button.is-complete {
  color: var(--animalora-accent-dark);
}

.animalora-step-rail button.is-current span,
.animalora-step-rail button.is-complete span {
  border-color: var(--animalora-accent);
  background: var(--animalora-accent);
  color: var(--color-ink-inverse);
  box-shadow: 0 8px 18px rgba(var(--animalora-accent-rgb), 0.22);
}

.animalora-session-history {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.74);
}

.animalora-session-history > p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.animalora-session-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.animalora-session-card {
  appearance: none;
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.18);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink-strong);
  text-align: left;
  cursor: pointer;
}

.animalora-session-card.is-current {
  border-color: var(--animalora-accent);
  box-shadow: 0 10px 26px rgba(var(--animalora-accent-rgb), 0.18);
}

.animalora-session-card span {
  color: var(--animalora-accent-dark);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 800;
}

.animalora-session-card strong,
.animalora-session-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.animalora-session-card small {
  color: var(--color-text-muted);
}

.animalora-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  align-items: start;
  gap: 22px;
}

.animalora-builder,
.animalora-work-column {
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.16);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
}

.animalora-builder {
  min-width: 0;
  padding: clamp(18px, 3vw, 32px);
}

.animalora-work-column {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  display: grid;
  max-height: calc(100vh - var(--header-height) - 40px);
  gap: 14px;
  padding: 20px;
  overflow: auto;
  background: linear-gradient(180deg, var(--animalora-accent-soft), var(--color-surface) 220px);
}

.animalora-work-heading h3,
.animalora-section-heading h3 {
  margin: 3px 0 0;
  color: var(--color-ink-strong);
  font-family: var(--font-display);
}

.animalora-work-column > p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.animalora-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.animalora-section-heading > strong {
  padding: 7px 11px;
  border-radius: var(--radius-pill);
  background: var(--animalora-accent-soft);
  color: var(--animalora-accent-dark);
}

.animalora-step-panel[hidden] {
  display: none;
}

.animalora-step-panel.is-current {
  animation: animalora-panel-in 180ms ease-out;
}

@keyframes animalora-panel-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.animalora-drop-zone {
  display: grid;
  min-height: 210px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  border: 2px dashed rgba(var(--animalora-accent-rgb), 0.42);
  border-radius: var(--radius-lg);
  background:
    repeating-linear-gradient(135deg, transparent, transparent 15px, rgba(var(--animalora-accent-rgb), 0.025) 15px, rgba(var(--animalora-accent-rgb), 0.025) 30px),
    var(--animalora-accent-soft);
  color: var(--color-text);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.animalora-drop-zone:hover,
.animalora-drop-zone.is-dragging {
  border-color: var(--animalora-accent);
  transform: translateY(-2px);
}

.animalora-drop-zone small {
  max-width: 620px;
  color: var(--color-text-muted);
  line-height: var(--line-body);
}

.animalora-upload-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 17px;
  background: var(--animalora-accent);
  color: white;
  font-size: 1.8rem;
  box-shadow: 0 10px 24px rgba(var(--animalora-accent-rgb), 0.24);
}

.animalora-limit-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 11px 2px 18px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.animalora-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.animalora-tagger-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--animalora-accent-soft), var(--color-surface));
}

.animalora-tagger-cta > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.animalora-tagger-cta strong {
  color: var(--animalora-accent-dark);
  font-family: var(--font-display);
}

.animalora-tagger-cta span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.animalora-tag-tool-card .animalora-tagger-cta {
  margin-top: 0;
  padding: 12px;
  background: var(--animalora-accent-soft);
}

.animalora-image-card {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-canvas);
}

.animalora-image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.animalora-image-card > .animalora-restored-thumb {
  width: 100%;
  aspect-ratio: 1;
}

.animalora-image-card figcaption {
  display: grid;
  gap: 2px;
  padding: 10px;
}

.animalora-image-card figcaption strong,
.animalora-image-card figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.animalora-image-card figcaption span {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.animalora-image-card > button {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.78);
  color: white;
  cursor: pointer;
}

.animalora-important-note {
  margin: 0 0 16px;
  padding: 13px 15px;
  border-left: 4px solid var(--animalora-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--animalora-accent-soft);
  color: var(--animalora-accent-dark);
  font-weight: 700;
}

.animalora-tag-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.animalora-tag-tool-card {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.18);
  border-radius: var(--radius-md);
  background: var(--color-surface-canvas);
}

.animalora-tag-tool-card--trigger {
  background: linear-gradient(135deg, var(--animalora-accent-soft), var(--color-surface-canvas));
}

.animalora-tag-tool-copy {
  display: grid;
  gap: 4px;
}

.animalora-tag-tool-copy h4,
.animalora-tag-tool-copy p {
  margin: 0;
}

.animalora-tag-tool-copy h4 {
  color: var(--animalora-accent-dark);
  font-family: var(--font-display);
  font-size: var(--text-md);
}

.animalora-tag-tool-copy p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--line-body);
}

.animalora-bulk-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
}

.animalora-trigger-field {
  display: grid;
  gap: 6px;
  color: var(--color-text);
  font-weight: 700;
}

.animalora-trigger-field input {
  min-height: 42px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.animalora-trigger-field small {
  color: var(--color-text-muted);
  font-weight: 400;
}

.animalora-bulk-tools input,
.animalora-form-grid input,
.animalora-form-grid select,
.animalora-tag-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.animalora-tag-grid {
  display: grid;
  gap: 12px;
}

.animalora-tag-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-canvas);
}

.animalora-tag-card > img {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.animalora-tag-card > .animalora-restored-thumb {
  width: 120px;
  height: 120px;
  min-height: 120px;
  border-radius: var(--radius-sm);
}

.animalora-tag-card > div,
.animalora-tag-card label {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.animalora-tag-card label span {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.animalora-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 26px;
}

.animalora-tag-chips button {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.22);
  border-radius: var(--radius-pill);
  background: var(--animalora-accent-soft);
  color: var(--animalora-accent-dark);
  font-size: var(--text-xs);
  cursor: pointer;
}

.animalora-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.animalora-form-grid label {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--color-text);
  font-weight: 700;
}

.animalora-form-grid label small {
  color: var(--color-text-muted);
  font-weight: 400;
}

.animalora-form-grid .animalora-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: center;
}

.animalora-form-grid .animalora-check input {
  width: 18px;
  min-height: 18px;
}

.animalora-advanced {
  margin-top: 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-canvas);
}

.animalora-advanced summary {
  padding: 14px 16px;
  color: var(--animalora-accent-dark);
  font-weight: 800;
  cursor: pointer;
}

.animalora-advanced .animalora-form-grid {
  padding: 4px 16px 18px;
}

.animalora-review {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(var(--animalora-accent-rgb), 0.18);
  border-radius: var(--radius-md);
  background: var(--animalora-accent-soft);
}

.animalora-review dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.animalora-review dl div {
  display: grid;
  gap: 3px;
}

.animalora-review dt {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.animalora-review dd {
  margin: 0;
  font-weight: 800;
}

.animalora-complete-guide {
  margin-bottom: 18px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--animalora-accent-soft);
}

.animalora-complete-guide strong {
  color: var(--animalora-accent-dark);
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

.animalora-model-list,
.animalora-work-list {
  display: grid;
  gap: 12px;
}

.animalora-model-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.animalora-restored-thumb {
  display: grid;
  min-height: 120px;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(var(--animalora-accent-rgb), 0.12), rgba(var(--animalora-accent-rgb), 0.04));
  color: var(--animalora-accent-dark);
  font-family: var(--font-mono);
  font-weight: 800;
}

.animalora-model-card h4,
.animalora-model-card p {
  margin: 4px 0 0;
}

.animalora-model-card p,
.animalora-empty-copy {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.animalora-work-list .image-card.pending-card {
  grid-template-columns: 54px minmax(0, 1fr);
  width: 100%;
  min-width: 0;
}

.animalora-work-list .pending-card-thumb {
  min-height: 54px;
}

.animalora-work-list .pending-badge {
  top: 8px;
  left: 8px;
}

@media (max-width: 1100px) {
  .animalora-hero,
  .animalora-layout {
    grid-template-columns: 1fr;
  }

  .animalora-work-column {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .animalora-hero {
    gap: 20px;
  }

  .animalora-step-rail button {
    font-size: 0;
  }

  .animalora-step-rail button span {
    font-size: var(--text-xs);
  }

  .animalora-bulk-tools,
  .animalora-form-grid,
  .animalora-tagger-cta,
  .animalora-tag-tool-card,
  .animalora-review dl {
    grid-template-columns: 1fr;
  }

  .animalora-tagger-cta {
    display: grid;
  }

  .animalora-tag-card {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .animalora-tag-card > img {
    width: 86px;
    height: 86px;
  }

  .animalora-section-heading,
  .animalora-model-card {
    align-items: stretch;
    flex-direction: column;
  }

  .animalora-limit-line {
    flex-direction: column;
  }
}
