:root {
  --bg: #090d18;
  --bg-soft: #11172a;
  --panel: rgba(18, 25, 47, 0.88);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --border: rgba(135, 156, 255, 0.14);
  --border-strong: rgba(135, 156, 255, 0.24);
  --text: #edf1ff;
  --muted: rgba(237, 241, 255, 0.64);
  --accent: #6f7cff;
  --accent-soft: rgba(111, 124, 255, 0.18);
  --success: #70e2a2;
  --danger: #ff9489;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  --gallery-panel-height: calc(100svh - 132px);
  --scrollbar-size: 10px;
  --scrollbar-track-color: rgba(255, 255, 255, 0.06);
  --scrollbar-track-color-hover: rgba(255, 255, 255, 0.08);
  --scrollbar-thumb-color: rgba(132, 147, 255, 0.42);
  --scrollbar-thumb-color-strong: rgba(156, 170, 255, 0.58);
  --scrollbar-thumb-shadow: rgba(56, 68, 150, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(111, 124, 255, 0.2), transparent 26%),
    radial-gradient(circle at bottom center, rgba(100, 40, 220, 0.14), transparent 30%),
    linear-gradient(180deg, #08101d 0%, #090d18 100%);
  color: var(--text);
  font-size: var(--ui-root-font-size, 16px);
  font-family: "IBM Plex Sans", sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
textarea,
select,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.settings-form,
.timeline-list,
.recent-list,
.filmstrip,
.drawer-panel,
.lightbox-dialog,
textarea {
  scrollbar-width: thin;
  scrollbar-color:
    var(--scrollbar-thumb-color, rgba(132, 147, 255, 0.42))
    var(--scrollbar-track-color, rgba(255, 255, 255, 0.06));
}

.settings-form,
.timeline-list,
.recent-list,
.drawer-panel,
.lightbox-dialog {
  scrollbar-gutter: stable;
}

.settings-form::-webkit-scrollbar,
.timeline-list::-webkit-scrollbar,
.recent-list::-webkit-scrollbar,
.filmstrip::-webkit-scrollbar,
.drawer-panel::-webkit-scrollbar,
.lightbox-dialog::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: var(--scrollbar-size, 10px);
  height: var(--scrollbar-size, 10px);
}

.settings-form::-webkit-scrollbar-track,
.timeline-list::-webkit-scrollbar-track,
.recent-list::-webkit-scrollbar-track,
.filmstrip::-webkit-scrollbar-track,
.drawer-panel::-webkit-scrollbar-track,
.lightbox-dialog::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--scrollbar-track-color, rgba(255, 255, 255, 0.06));
}

.settings-form::-webkit-scrollbar-thumb,
.timeline-list::-webkit-scrollbar-thumb,
.recent-list::-webkit-scrollbar-thumb,
.filmstrip::-webkit-scrollbar-thumb,
.drawer-panel::-webkit-scrollbar-thumb,
.lightbox-dialog::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(156, 170, 255, 0.58), rgba(111, 124, 255, 0.34));
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.settings-form::-webkit-scrollbar-thumb:hover,
.timeline-list::-webkit-scrollbar-thumb:hover,
.recent-list::-webkit-scrollbar-thumb:hover,
.filmstrip::-webkit-scrollbar-thumb:hover,
.drawer-panel::-webkit-scrollbar-thumb:hover,
.lightbox-dialog::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(176, 188, 255, 0.72), rgba(123, 138, 255, 0.46));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 0 1px rgba(111, 124, 255, 0.12);
}

.settings-form::-webkit-scrollbar-thumb:active,
.timeline-list::-webkit-scrollbar-thumb:active,
.recent-list::-webkit-scrollbar-thumb:active,
.filmstrip::-webkit-scrollbar-thumb:active,
.drawer-panel::-webkit-scrollbar-thumb:active,
.lightbox-dialog::-webkit-scrollbar-thumb:active,
textarea::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, rgba(188, 198, 255, 0.78), rgba(136, 149, 255, 0.54));
}

.settings-form::-webkit-scrollbar-track:hover,
.timeline-list::-webkit-scrollbar-track:hover,
.recent-list::-webkit-scrollbar-track:hover,
.filmstrip::-webkit-scrollbar-track:hover,
.drawer-panel::-webkit-scrollbar-track:hover,
.lightbox-dialog::-webkit-scrollbar-track:hover,
textarea::-webkit-scrollbar-track:hover {
  background: var(--scrollbar-track-color-hover, rgba(255, 255, 255, 0.08));
}

.settings-form::-webkit-scrollbar-corner,
.timeline-list::-webkit-scrollbar-corner,
.recent-list::-webkit-scrollbar-corner,
.filmstrip::-webkit-scrollbar-corner,
.drawer-panel::-webkit-scrollbar-corner,
.lightbox-dialog::-webkit-scrollbar-corner,
textarea::-webkit-scrollbar-corner {
  background: transparent;
}

.app-shell {
  width: min(var(--app-shell-max-width, 1680px), calc(100vw - 20px));
  margin: 0 auto;
  padding: var(--app-shell-padding-top, 8px) 0 var(--app-shell-padding-bottom, 10px);
  height: 100svh;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: var(--topbar-gap, 18px);
  align-items: center;
  padding: var(--topbar-padding, 6px 10px 14px);
}

.brand-cluster,
.brand-title-row,
.view-tabs,
.topbar-actions,
.preview-meta,
.preview-toolbar,
.zoom-controls,
.preview-actions,
.lightbox-meta,
.lightbox-actions,
.gallery-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-cluster {
  gap: 14px;
}

.brand-mark {
  width: var(--brand-mark-size, 40px);
  height: var(--brand-mark-size, 40px);
  border-radius: 14px;
  border: 1px solid rgba(156, 170, 255, 0.24);
  background:
    radial-gradient(circle at 50% 50%, rgba(125, 221, 255, 0.32), transparent 34%),
    radial-gradient(circle at 20% 20%, rgba(150, 90, 255, 0.28), transparent 40%),
    rgba(255, 255, 255, 0.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 30px rgba(73, 56, 196, 0.28);
  position: relative;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark-core {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(162, 175, 255, 0.44);
  border-radius: 10px;
  transform: rotate(45deg);
}

.brand-mark::after {
  inset: 15px;
  border-color: rgba(90, 235, 230, 0.5);
}

.brand-mark-core {
  inset: 18px;
  background: linear-gradient(135deg, #86b7ff, #7ce0ff);
  border: 0;
  box-shadow: 0 0 16px rgba(124, 224, 255, 0.5);
}

.brand-copy h1 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1.03rem;
  letter-spacing: -0.04em;
}

.brand-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-ai-badge,
.model-badge,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 9px;
  background: rgba(110, 125, 255, 0.24);
  color: #eef2ff;
  font-size: 0.78rem;
  font-weight: 600;
}

.count-pill.small {
  min-height: 30px;
  padding: 0 12px;
}

.view-tabs {
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.view-tab,
.header-button,
.toolbar-button,
.ghost-link,
.mini-action,
.icon-button,
.ratio-chip,
.generate-button,
.inline-button,
.reference-remove {
  border: 1px solid transparent;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

.view-tab:hover,
.header-button:hover,
.toolbar-button:hover,
.ghost-link:hover,
.mini-action:hover,
.icon-button:hover,
.ratio-chip:hover,
.generate-button:hover,
.inline-button:hover,
.reference-remove:hover,
.recent-item:hover,
.filmstrip-item:hover,
.gallery-tile:hover {
  transform: translateY(-1px);
}

.view-tab {
  min-width: var(--view-tab-min-width, 116px);
  min-height: var(--view-tab-height, 40px);
  padding: 0 18px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.view-tab.active {
  background: linear-gradient(180deg, rgba(118, 132, 255, 0.2), rgba(118, 132, 255, 0.08));
  border-color: rgba(132, 149, 255, 0.3);
  color: var(--text);
  box-shadow: inset 0 -2px 0 rgba(123, 137, 255, 0.8);
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.header-pill,
.header-button,
.toolbar-button,
.count-pill {
  min-height: var(--header-control-height, 38px);
  padding: 0 var(--header-control-padding-x, 16px);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.header-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.header-button,
.toolbar-button,
.mini-action,
.icon-button,
.generate-button,
.inline-button,
.reference-remove {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.header-button.strong {
  background: rgba(255, 255, 255, 0.05);
}

.toolbar-button.disabled,
.toolbar-button:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.toolbar-button.danger {
  color: #ffd1cb;
  border-color: rgba(255, 148, 137, 0.24);
  background: rgba(255, 148, 137, 0.08);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.04);
}

#connectionStatus[data-state="ready"] .status-dot {
  background: var(--success);
}

#connectionStatus[data-state="busy"] .status-dot {
  background: #7dbeff;
}

#connectionStatus[data-state="error"] .status-dot {
  background: var(--danger);
}

.view-root {
  margin-top: 2px;
  min-height: calc(100svh - var(--view-root-offset, 88px));
  height: calc(100svh - var(--view-root-offset, 88px));
  overflow: hidden;
}

.view-panel {
  min-height: 0;
  height: 100%;
}

.studio-grid {
  display: grid;
  grid-template-columns: var(--studio-grid-left, 392px) minmax(0, 1fr) var(--studio-grid-right, 328px);
  gap: var(--studio-grid-gap, 14px);
  align-items: start;
  min-height: calc(100svh - var(--view-root-offset, 88px));
  height: calc(100svh - var(--view-root-offset, 88px));
  overflow: hidden;
}

.studio-panel,
.drawer-panel,
.lightbox-dialog {
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.studio-panel,
.drawer-panel,
.lightbox-dialog {
  padding: var(--panel-padding, 12px);
}

.settings-panel,
.preview-panel,
.live-panel,
.recent-panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.settings-panel {
  height: var(--studio-column-height, auto);
}

.panel-title,
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title.between {
  align-items: center;
}

.panel-title h2,
.drawer-head h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

.panel-title p,
.drawer-head p,
.field-heading small,
.config-note,
.settings-tip p,
.reference-dropzone span,
.preview-placeholder span,
.recent-empty,
.gallery-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.settings-form {
  display: grid;
  gap: calc(var(--field-gap, 6px) + 6px);
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  align-content: start;
  grid-auto-rows: max-content;
}

.field-group {
  display: grid;
  gap: var(--field-gap, 6px);
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-heading.inline {
  justify-content: space-between;
}

.field-heading span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border-color: var(--border);
}

.prompt-field {
  position: relative;
  display: block;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  padding: var(--input-padding-y, 10px) var(--input-padding-x, 12px);
  outline: none;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 3px rgba(111, 124, 255, 0.1);
}

textarea {
  resize: vertical;
  min-height: var(--textarea-min-height, 96px);
}

.field-counter {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--field-gap, 6px);
}

.ratio-chip {
  min-height: var(--ratio-chip-height, 48px);
  border-radius: 12px;
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 6px;
}

.ratio-chip strong {
  font-family: "Sora", sans-serif;
  font-size: 1rem;
  line-height: 1;
}

.ratio-chip.active {
  border-color: rgba(128, 143, 255, 0.5);
  background: rgba(111, 124, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(148, 160, 255, 0.12);
}

.reference-dropzone {
  position: relative;
  min-height: var(--reference-dropzone-min-height, 140px);
  border-radius: 16px;
  border: 1px dashed var(--border-strong);
  background:
    radial-gradient(circle at top, rgba(111, 124, 255, 0.18), transparent 56%),
    rgba(255, 255, 255, 0.025);
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--field-gap, 6px);
  text-align: center;
  padding: calc(var(--panel-padding, 12px) + 6px);
}

.reference-dropzone.dragover {
  border-color: rgba(130, 145, 255, 0.56);
  background:
    radial-gradient(circle at top, rgba(111, 124, 255, 0.24), transparent 56%),
    rgba(255, 255, 255, 0.04);
}

.reference-dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.reference-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(145, 159, 255, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.03);
  position: relative;
}

.reference-icon::before,
.reference-icon::after {
  content: "";
  position: absolute;
}

.reference-icon::before {
  inset: 11px 10px 14px;
  border: 1px solid rgba(176, 187, 255, 0.46);
  border-radius: 7px;
}

.reference-icon::after {
  left: 18px;
  right: 18px;
  top: 16px;
  height: 2px;
  background: rgba(176, 187, 255, 0.46);
  box-shadow: 0 8px 0 rgba(176, 187, 255, 0.46);
}

.reference-dropzone strong {
  font-size: 0.96rem;
}

.reference-dropzone em {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(129, 144, 255, 0.4);
  background: rgba(111, 124, 255, 0.12);
  color: #eef1ff;
  font-style: normal;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.reference-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-height: 122px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.reference-card img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
}

.reference-remove {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border-color: var(--border);
  color: var(--muted);
  font-size: 0.74rem;
  justify-self: center;
}

.parameter-settings .advanced-content {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 12px;
}

.advanced-content {
  display: grid;
  gap: 8px;
  padding-bottom: 2px;
}

.advanced-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact-field {
  display: grid;
  gap: 6px;
  position: relative;
}

.compact-field span {
  color: var(--muted);
  font-size: 0.8rem;
}

.compact-field::after {
  content: "";
  position: absolute;
  right: 15px;
  bottom: 17px;
  width: 9px;
  height: 9px;
  border-right: 2px solid rgba(234, 239, 255, 0.74);
  border-bottom: 2px solid rgba(234, 239, 255, 0.74);
  transform: rotate(45deg);
  pointer-events: none;
}

.compact-field select {
  min-height: 40px;
  padding: 0 40px 0 12px;
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: #f5f7ff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    rgba(16, 22, 40, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(109, 122, 255, 0.05);
}

.compact-field select option {
  color: #101728;
  background: #edf1ff;
}

.parameter-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-content: end;
  align-items: baseline;
  column-gap: 8px;
  row-gap: 5px;
  min-height: 64px;
  padding: 20px 0 3px;
}

.parameter-meta span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.parameter-meta strong {
  min-width: 0;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.generate-button {
  min-height: var(--generate-button-height, 42px);
  border-radius: 14px;
  border-color: rgba(132, 148, 255, 0.24);
  background: linear-gradient(135deg, #6678ff 0%, #7254ff 100%);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 14px 30px rgba(102, 120, 255, 0.24);
}

.generate-button:disabled {
  opacity: 0.7;
  cursor: default;
}

.settings-tip {
  margin-top: calc(var(--field-gap, 6px) + 8px);
  border-radius: 16px;
  border: 1px solid rgba(126, 139, 255, 0.18);
  background: rgba(111, 124, 255, 0.07);
  padding: var(--panel-padding, 12px);
}

.settings-tip strong {
  display: block;
  margin-bottom: 6px;
}

.preview-stage {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  padding: var(--preview-stage-padding, 10px);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.preview-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-canvas {
  margin-top: 12px;
  min-height: 0;
  flex: 1 1 auto;
  max-height: none;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 40%),
    rgba(8, 11, 18, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--preview-canvas-padding, 12px);
  overflow: hidden;
  position: relative;
}

.preview-placeholder {
  display: grid;
  gap: 8px;
  text-align: center;
  max-width: 480px;
}

.preview-placeholder-loading {
  width: min(100%, 560px);
  max-width: 560px;
}

.preview-placeholder p {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-size: 0.7rem;
}

.preview-placeholder h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1.34rem;
  line-height: 1.15;
}

.preview-loading-shell {
  --loading-stage-primary: #7b88ff;
  --loading-stage-secondary: rgba(123, 136, 255, 0.22);
  --loading-stage-glow: rgba(123, 136, 255, 0.36);
  --loading-motion-tilt: 0deg;
  --loading-motion-scale: 1;
  --loading-morph-duration-a: 15000ms;
  --loading-morph-duration-b: 18600ms;
  --loading-pulse-duration: 7600ms;
  --loading-drift-duration: 18000ms;
  width: 100%;
  display: grid;
  gap: 20px;
  justify-items: center;
}

.preview-loading-shell[data-stage="uploading"] {
  --loading-stage-primary: #6dd8ff;
  --loading-stage-secondary: rgba(109, 216, 255, 0.2);
  --loading-stage-glow: rgba(109, 216, 255, 0.32);
}

.preview-loading-shell[data-stage="connecting"] {
  --loading-stage-primary: #7b88ff;
  --loading-stage-secondary: rgba(123, 136, 255, 0.22);
  --loading-stage-glow: rgba(123, 136, 255, 0.36);
}

.preview-loading-shell[data-stage="generating"] {
  --loading-stage-primary: #9b7cff;
  --loading-stage-secondary: rgba(155, 124, 255, 0.24);
  --loading-stage-glow: rgba(155, 124, 255, 0.38);
}

.preview-loading-shell[data-stage="saving"] {
  --loading-stage-primary: #70dca2;
  --loading-stage-secondary: rgba(112, 220, 162, 0.2);
  --loading-stage-glow: rgba(112, 220, 162, 0.34);
}

.preview-loading-shell,
.preview-loading-morph,
.preview-loading-trace,
.preview-loading-core-shell,
.preview-loading-core,
.preview-loading-status,
.preview-loading-metric,
.preview-loading-step {
  transition:
    background 1800ms ease,
    border-color 1800ms ease,
    box-shadow 1800ms ease,
    color 1800ms ease,
    opacity 1200ms ease,
    transform 1200ms ease;
}

.preview-loading-motion {
  position: relative;
  width: min(54vw, 286px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: rotate(var(--loading-motion-tilt)) scale(var(--loading-motion-scale));
  transition: transform 1800ms ease;
}

.preview-loading-aura,
.preview-loading-morph,
.preview-loading-trace,
.preview-loading-core-shell,
.preview-loading-core,
.preview-loading-core-shell::before {
  position: absolute;
}

.preview-loading-aura {
  inset: 18%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 36%),
    radial-gradient(circle, var(--loading-stage-glow) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(22px);
  opacity: 0.82;
  animation: preview-loading-aura var(--loading-drift-duration) ease-in-out infinite;
}

.preview-loading-morph {
  border: 1px solid color-mix(in srgb, var(--loading-stage-primary) 38%, white 8%);
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--loading-stage-primary) 52%, white 12%), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.02);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 36px color-mix(in srgb, var(--loading-stage-glow) 48%, transparent);
  opacity: 0.32;
}

.preview-loading-morph-a {
  width: 74%;
  aspect-ratio: 1;
  animation: preview-loading-morph-a var(--loading-morph-duration-a) ease-in-out infinite;
}

.preview-loading-morph-b {
  width: 54%;
  aspect-ratio: 1;
  opacity: 0.46;
  mix-blend-mode: screen;
  animation: preview-loading-morph-b var(--loading-morph-duration-b) ease-in-out infinite;
}

.preview-loading-trace {
  width: 82%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--loading-stage-primary) 30%, white 10%);
  border-left-color: transparent;
  border-right-color: transparent;
  opacity: 0.58;
  animation: preview-loading-drift var(--loading-drift-duration) linear infinite;
}

.preview-loading-core-shell {
  width: 32%;
  aspect-ratio: 1;
  border-radius: 42% 58% 50% 50% / 48% 40% 60% 52%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    rgba(10, 15, 28, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 26px var(--loading-stage-secondary);
  animation: preview-loading-shell-breathe var(--loading-pulse-duration) ease-in-out infinite;
}

.preview-loading-core {
  width: 22%;
  aspect-ratio: 1;
  border-radius: 48% 52% 40% 60% / 58% 36% 64% 42%;
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.95), transparent 38%),
    radial-gradient(circle, color-mix(in srgb, var(--loading-stage-primary) 74%, white 12%) 0%, rgba(15, 19, 32, 0.96) 74%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 24px var(--loading-stage-secondary),
    0 0 64px rgba(0, 0, 0, 0.24);
  animation: preview-loading-core-pulse var(--loading-pulse-duration) ease-in-out infinite;
}

.preview-loading-copy {
  display: grid;
  gap: 8px;
  justify-items: center;
  max-width: 480px;
}

.preview-loading-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.preview-loading-metric {
  min-height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(244, 247, 255, 0.78);
  font-size: 0.74rem;
  font-weight: 500;
}

.preview-loading-status {
  min-height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--loading-stage-primary) 38%, white 10%);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--loading-stage-primary) 18%, white 4%), rgba(255, 255, 255, 0.02)),
    rgba(12, 17, 28, 0.82);
  color: #f4f7ff;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 28px rgba(0, 0, 0, 0.16);
}

.preview-loading-detail {
  max-width: 460px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.preview-loading-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 480px;
}

.preview-loading-step {
  min-height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.76rem;
}

.preview-loading-step.is-done {
  border-color: rgba(112, 220, 162, 0.26);
  background: rgba(112, 220, 162, 0.1);
  color: #e7fff0;
}

.preview-loading-step.is-active {
  border-color: color-mix(in srgb, var(--loading-stage-primary) 42%, white 10%);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--loading-stage-primary) 22%, white 5%), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
  color: #f7f8ff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 20px color-mix(in srgb, var(--loading-stage-primary) 18%, transparent);
}

@keyframes preview-loading-morph-a {
  0%,
  100% {
    transform: translate(-5%, 2%) rotate(0deg) scale(0.95);
    border-radius: 38% 62% 46% 54% / 44% 38% 62% 56%;
  }

  35% {
    transform: translate(4%, -4%) rotate(102deg) scale(1.03);
    border-radius: 64% 36% 58% 42% / 40% 61% 39% 60%;
  }

  68% {
    transform: translate(2%, 5%) rotate(194deg) scale(0.98);
    border-radius: 42% 58% 34% 66% / 62% 43% 57% 38%;
  }
}

@keyframes preview-loading-morph-b {
  0%,
  100% {
    transform: translate(4%, -3%) rotate(0deg) scale(0.92);
    border-radius: 54% 46% 62% 38% / 46% 60% 40% 54%;
  }

  40% {
    transform: translate(-6%, 4%) rotate(-122deg) scale(1.04);
    border-radius: 34% 66% 44% 56% / 60% 36% 64% 40%;
  }

  70% {
    transform: translate(3%, 3%) rotate(-224deg) scale(0.97);
    border-radius: 66% 34% 56% 44% / 38% 54% 46% 62%;
  }
}

@keyframes preview-loading-drift {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes preview-loading-aura {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.56;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.88;
  }
}

@keyframes preview-loading-shell-breathe {
  0%,
  100% {
    transform: scale(0.94);
  }

  50% {
    transform: scale(1.04);
  }
}

@keyframes preview-loading-core-pulse {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.88;
  }

  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-loading-aura,
  .preview-loading-morph-a,
  .preview-loading-morph-b,
  .preview-loading-trace,
  .preview-loading-core-shell,
  .preview-loading-core,
  .preview-loading-motion {
    animation-duration: 1ms;
    animation-iteration-count: 1;
    transition-duration: 1ms;
  }
}

.preview-panel {
  height: var(--studio-column-height, auto);
}

#previewImage {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 18px;
  box-shadow: 0 18px 64px rgba(0, 0, 0, 0.26);
  opacity: 0;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
  transform-origin: center center;
}

#previewImage.is-mounted {
  display: block;
}

#previewImage.is-visible {
  opacity: 1;
}

.preview-toolbar {
  justify-content: space-between;
  margin-top: 10px;
  flex-wrap: wrap;
}

.zoom-controls,
.preview-actions {
  gap: 8px;
}

.zoom-label {
  min-width: 66px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
}

.filmstrip-row {
  margin-top: 4px;
  min-height: 118px;
  overflow: hidden;
  flex: 0 0 auto;
}

.filmstrip {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 92px;
  gap: 10px;
  min-height: 118px;
  align-items: start;
  justify-content: start;
  overflow-x: auto;
  overflow-y: hidden;
  padding-inline: 2px;
  padding-bottom: 6px;
}

.filmstrip-entry {
  position: relative;
  width: 92px;
  min-height: 104px;
}

.filmstrip-item {
  display: grid;
  grid-template-rows: 84px auto;
  justify-items: center;
  align-content: start;
  width: 100%;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.filmstrip-item img,
.filmstrip-ghost {
  width: 84px;
  height: 84px;
  display: block;
  border-radius: 10px;
}

.filmstrip-item img {
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.filmstrip-ghost {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.66rem;
}

.filmstrip-item span {
  display: block;
  margin-top: 4px;
  width: 100%;
  font-size: 12px;
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.filmstrip-item.active img,
.filmstrip-item.active .filmstrip-ghost {
  border-color: rgba(141, 156, 255, 0.56);
  box-shadow: 0 0 0 2px rgba(111, 124, 255, 0.16);
}

.filmstrip-cancel {
  position: absolute;
  top: 3px;
  right: 7px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(14, 18, 32, 0.9);
  color: #ffffff;
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
}

.filmstrip-cancel:hover {
  border-color: rgba(255, 148, 137, 0.62);
  background: rgba(255, 148, 137, 0.24);
  color: #ffd3cf;
}

.side-column {
  display: grid;
  gap: var(--studio-grid-gap, 14px);
  min-height: 0;
  height: var(--studio-column-height, auto);
  grid-template-rows: minmax(0, 1fr);
}

.live-panel {
  height: 100%;
  position: relative;
}

.error-banner {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 148, 137, 0.18);
  background: rgba(255, 148, 137, 0.08);
  color: #ffd3cf;
  font-size: 0.83rem;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  overflow: auto;
}

.timeline-new-indicator {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(132, 148, 255, 0.34);
  border-radius: 999px;
  background: rgba(17, 23, 42, 0.92);
  color: #eef2ff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.timeline-new-indicator:hover {
  border-color: rgba(150, 164, 255, 0.58);
  background: rgba(31, 39, 72, 0.94);
}

.timeline-new-indicator span {
  font-size: 1rem;
  line-height: 1;
}

.timeline-new-indicator strong {
  font-size: 0.82rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto auto;
  column-gap: 10px;
  row-gap: 3px;
  padding: var(--timeline-item-padding-y, 8px) 0;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 32px;
  bottom: -4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.09);
}

.timeline-dot {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  z-index: 1;
}

.timeline-item.done .timeline-dot {
  border-color: rgba(112, 226, 162, 0.35);
  background: rgba(112, 226, 162, 0.12);
}

.timeline-item.done .timeline-dot::after,
.timeline-item.active .timeline-dot::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
}

.timeline-item.done .timeline-dot::after {
  background: var(--success);
}

.timeline-item.active .timeline-dot {
  border-color: rgba(132, 148, 255, 0.46);
  background: rgba(111, 124, 255, 0.12);
}

.timeline-item.active .timeline-dot::after {
  background: var(--accent);
}

.timeline-item.error .timeline-dot {
  border-color: rgba(255, 148, 137, 0.42);
  background: rgba(255, 148, 137, 0.12);
}

.timeline-item.error .timeline-dot::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--danger);
}

.timeline-copy {
  display: contents;
}

.timeline-copy strong {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  font-size: 0.94rem;
}

.timeline-copy > span {
  grid-column: 2 / -1;
  grid-row: 2;
  min-width: 0;
}

.timeline-copy span,
.timeline-ratio,
.timeline-resolution,
.timeline-item time {
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-ratio {
  grid-column: 3;
  grid-row: 1;
}

.timeline-resolution {
  grid-column: 4;
  grid-row: 1;
}

.timeline-ratio,
.timeline-resolution {
  align-self: start;
  white-space: nowrap;
}

.timeline-item time {
  grid-column: 5;
  grid-row: 1;
  align-self: start;
  white-space: nowrap;
}

.ghost-link {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.recent-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.recent-item {
  width: 100%;
  padding: var(--recent-item-padding, 8px);
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  grid-template-columns: var(--recent-thumb-size, 60px) minmax(0, 1fr) auto;
  gap: var(--recent-item-padding, 8px);
  align-items: center;
  color: var(--text);
  text-align: left;
}

.recent-item.active {
  border-color: rgba(132, 148, 255, 0.38);
  background: rgba(111, 124, 255, 0.1);
}

.recent-item img {
  width: var(--recent-thumb-size, 60px);
  height: var(--recent-thumb-size, 60px);
  object-fit: cover;
  border-radius: 12px;
}

.recent-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.recent-copy strong,
.gallery-tile-overlay strong {
  font-size: 0.86rem;
  line-height: 1.4;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.recent-copy span,
.recent-copy time,
.gallery-tile-overlay span {
  color: var(--muted);
  font-size: 0.76rem;
}

.recent-actions {
  display: grid;
  gap: 8px;
}

.mini-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border-color: var(--border);
}

.clear-history-button {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.gallery-view {
  --gallery-panel-padding: 8px;
  --gallery-control-height: 34px;
  --gallery-control-padding-x: 12px;
  --gallery-control-radius: 999px;
  --gallery-filter-row-gap: 6px;
  --gallery-filter-label-gap: 8px;
  --gallery-filter-label-size: 0.72rem;
  --gallery-toolbar-gap: 6px;
  --gallery-toolbar-margin-bottom: 8px;
  --gallery-chip-height: 28px;
  --gallery-chip-padding-x: 10px;
  --gallery-helper-text-size: 0.72rem;
  --gallery-scroll-shell-gap: 12px;
  --gallery-scrollbar-width: 42px;
  --gallery-scroll-track-width: 36px;
  --gallery-scroll-track-min-height: 160px;
  --gallery-scroll-arrow-size: 34px;
  --gallery-sections-gap: 14px;
  --gallery-section-gap: 10px;
  --gallery-section-header-padding: 10px 12px;
  --gallery-section-heading-size: 0.9rem;
  --gallery-section-meta-size: 0.76rem;
  --gallery-masonry-gap: 12px;
  --gallery-tile-radius: 14px;
}

.gallery-panel {
  min-height: var(--gallery-panel-height);
  height: var(--gallery-panel-height);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--gallery-panel-padding, var(--panel-padding, 12px));
}

.gallery-panel > .panel-title {
  gap: 10px;
  margin-bottom: 10px;
}

.gallery-panel > .panel-title h2 {
  font-size: 0.96rem;
}

.gallery-panel > .panel-title p {
  font-size: 0.76rem;
}

.gallery-panel .count-pill,
.gallery-panel .header-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.76rem;
}

.gallery-panel .count-pill.small {
  min-height: 26px;
  padding: 0 10px;
}

.gallery-top-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.gallery-column-switch {
  min-height: var(--gallery-control-height);
  padding: 2px;
  display: inline-grid;
  grid-template-columns: auto repeat(5, minmax(30px, 1fr));
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--gallery-control-radius);
  background: rgba(255, 255, 255, 0.03);
}

.gallery-column-label {
  padding: 0 6px 0 8px;
  color: var(--muted);
  font-size: var(--gallery-filter-label-size);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.gallery-column-button {
  min-width: 30px;
  min-height: calc(var(--gallery-control-height) - 6px);
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.gallery-column-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.gallery-column-button.active {
  border-color: rgba(157, 171, 255, 0.34);
  background: rgba(110, 125, 255, 0.3);
  color: #f5f7ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.gallery-toolbar {
  display: grid;
  gap: var(--gallery-toolbar-gap);
  margin-bottom: var(--gallery-toolbar-margin-bottom);
}

.gallery-toolbar-head {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.gallery-filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gallery-filter-row-gap);
  align-items: stretch;
}

.gallery-search-field,
.gallery-inline-field {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--gallery-filter-label-gap);
  min-height: var(--gallery-control-height);
  padding: 0 var(--gallery-control-padding-x);
  border-radius: var(--gallery-control-radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.gallery-search-field span,
.gallery-inline-field span {
  color: var(--muted);
  font-size: var(--gallery-filter-label-size);
  font-weight: 600;
  white-space: nowrap;
}

.gallery-search-input,
.gallery-date-input,
.gallery-filter-select,
.gallery-reset-button {
  min-height: var(--gallery-control-height);
  border-radius: var(--gallery-control-radius);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.gallery-filter-select {
  color-scheme: dark;
  background-color: transparent;
}

.gallery-filter-select option,
.gallery-filter-select optgroup {
  background: #1a1f36;
  color: #f3f6ff;
}

.gallery-filter-select option:checked,
.gallery-filter-select option:hover,
.gallery-filter-select option:focus {
  background:
    linear-gradient(180deg, rgba(103, 120, 255, 0.94), rgba(82, 101, 232, 0.94)),
    #5265e8;
  color: #ffffff;
}

.gallery-search-input,
.gallery-date-input,
.gallery-filter-select {
  width: 100%;
  min-width: 0;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.gallery-search-input::placeholder {
  color: rgba(193, 199, 220, 0.5);
}

.gallery-search-field:focus-within,
.gallery-inline-field:focus-within,
.gallery-reset-button:focus {
  outline: none;
  border-color: rgba(142, 156, 255, 0.34);
  box-shadow: 0 0 0 1px rgba(142, 156, 255, 0.14);
}

.gallery-search-input:focus,
.gallery-date-input:focus,
.gallery-filter-select:focus,
.gallery-reset-button:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.gallery-date-input::-webkit-calendar-picker-indicator {
  opacity: 0.72;
  filter: invert(0.82);
}

.gallery-reset-button {
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  justify-self: end;
}

.gallery-reset-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.gallery-filters {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.gallery-toolbar-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.gallery-filter-chip {
  min-height: var(--gallery-chip-height);
  padding: 0 var(--gallery-chip-padding-x);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.76rem;
}

.gallery-filter-chip.active {
  border-color: rgba(142, 156, 255, 0.36);
  background:
    linear-gradient(180deg, rgba(118, 132, 255, 0.22), rgba(118, 132, 255, 0.08)),
    rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.gallery-helper-text {
  overflow: hidden;
  flex: 0 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: var(--gallery-helper-text-size);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-scroll-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--gallery-scrollbar-width);
  gap: var(--gallery-scroll-shell-gap);
}

.gallery-scroll-region {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  padding-bottom: 10px;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.gallery-scroll-region::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.gallery-sections {
  display: grid;
  gap: var(--gallery-sections-gap);
}

.gallery-section {
  display: grid;
  gap: var(--gallery-section-gap);
}

.gallery-section-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: var(--gallery-section-header-padding);
  border-radius: 14px;
  border: 1px solid rgba(135, 156, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(14, 20, 36, 0.94), rgba(14, 20, 36, 0.84)),
    rgba(14, 20, 36, 0.88);
  backdrop-filter: blur(14px);
}

.gallery-section-copy {
  display: block;
  min-width: 0;
}

.gallery-section-copy strong {
  display: block;
  overflow: hidden;
  font-size: var(--gallery-section-heading-size);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-section-head .count-pill {
  flex: 0 0 auto;
}

.gallery-scrollbar {
  min-height: 0;
  display: grid;
  grid-template-rows: var(--gallery-scroll-arrow-size) minmax(0, 1fr) var(--gallery-scroll-arrow-size);
  gap: 8px;
  align-items: center;
  justify-items: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.gallery-scrollbar:hover .gallery-scroll-track {
  border-color: rgba(138, 151, 255, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(111, 124, 255, 0.08);
}

.gallery-scrollbar[data-disabled="true"] {
  opacity: 0.34;
}

.gallery-scroll-track {
  position: relative;
  width: var(--gallery-scroll-track-width);
  height: 100%;
  min-height: var(--gallery-scroll-track-min-height);
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    rgba(17, 24, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.gallery-scroll-arrow {
  width: var(--gallery-scroll-arrow-size);
  height: var(--gallery-scroll-arrow-size);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1;
}

.gallery-scroll-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.gallery-scroll-thumb {
  position: absolute;
  left: 5px;
  right: 5px;
  top: 0;
  min-height: 54px;
  border-radius: 999px;
  border: 1px solid rgba(149, 161, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(150, 162, 255, 0.34), rgba(111, 124, 255, 0.16)),
    rgba(111, 124, 255, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 14px 28px rgba(67, 79, 169, 0.18);
  cursor: grab;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    filter 180ms ease;
}

.gallery-scroll-thumb:hover,
.gallery-scrollbar.is-dragging .gallery-scroll-thumb {
  border-color: rgba(171, 184, 255, 0.54);
  background:
    linear-gradient(180deg, rgba(166, 178, 255, 0.56), rgba(111, 124, 255, 0.26)),
    rgba(111, 124, 255, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(111, 124, 255, 0.14),
    0 0 24px rgba(111, 124, 255, 0.28),
    0 16px 34px rgba(67, 79, 169, 0.22);
}

.gallery-scrollbar.is-dragging .gallery-scroll-thumb {
  cursor: grabbing;
  filter: saturate(118%);
}

.gallery-scrollbar[data-disabled="true"] .gallery-scroll-thumb {
  cursor: default;
  box-shadow: none;
}

.gallery-masonry {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns, 4), minmax(0, 1fr));
  gap: var(--gallery-masonry-gap);
  align-items: start;
}

.gallery-masonry-column {
  display: grid;
  align-content: start;
  gap: var(--gallery-masonry-gap);
}

.gallery-tile {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  display: block;
  border-radius: var(--gallery-tile-radius);
  overflow: hidden;
  position: relative;
  background: transparent;
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: auto;
}

.gallery-tile-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: 6px;
  padding: 14px;
  background: linear-gradient(180deg, transparent 0%, rgba(6, 10, 18, 0.94) 100%);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 16px;
  display: grid;
  place-items: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 12, 0.48);
  backdrop-filter: blur(24px) saturate(120%);
}

.lightbox-dialog {
  position: relative;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow: auto;
  background: rgba(17, 22, 37, 0.76);
}

.lightbox-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lightbox-media-stage {
  margin-top: 14px;
  position: relative;
  min-height: 48svh;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(8, 11, 18, 0.62);
}

.lightbox-ambient {
  position: absolute;
  inset: -8%;
  background-position: center;
  background-size: cover;
  filter: blur(52px) saturate(115%);
  opacity: 0.32;
  transform: scale(1.08);
}

.lightbox-image-shell {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  width: 100%;
  transition: padding 180ms ease;
}

#lightboxImage {
  max-width: 100%;
  max-height: 60svh;
  display: block;
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32);
  cursor: zoom-in;
  transition:
    max-height 180ms ease,
    transform 180ms ease,
    cursor 180ms ease;
}

.lightbox-media-stage.is-zoomed {
  min-height: 72svh;
}

.lightbox-image-shell.is-zoomed {
  padding: 14px;
}

#lightboxImage.is-zoomed {
  max-height: 82svh;
  cursor: zoom-out;
  transform: scale(1.04);
}

.lightbox-fields {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  gap: 12px;
}

.detail-field {
  display: grid;
  gap: 8px;
}

.detail-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-field span {
  font-size: 0.84rem;
  color: var(--muted);
}

.detail-copy-button {
  min-height: 32px;
  padding: 0 12px;
  border-color: var(--border);
  color: var(--muted);
  flex: 0 0 auto;
}

.detail-copy-button[data-copied="true"] {
  color: var(--text);
  border-color: rgba(112, 226, 162, 0.3);
  background: rgba(112, 226, 162, 0.12);
}

.detail-field textarea {
  min-height: 150px;
  resize: none;
  line-height: 1.65;
}

.prompt-agent-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.prompt-agent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(10px);
}

.prompt-agent-dialog {
  position: relative;
  width: min(960px, calc(100vw - 28px));
  max-height: min(760px, calc(100svh - 28px));
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background:
    linear-gradient(180deg, rgba(24, 32, 58, 0.96), rgba(12, 17, 30, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.prompt-agent-head,
.prompt-agent-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.prompt-agent-head h2,
.prompt-agent-history-head h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.prompt-agent-body {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(0, 1.18fr);
  gap: 16px;
  margin-top: 16px;
}

.prompt-agent-upload,
.prompt-agent-output {
  display: grid;
  align-content: start;
  gap: 12px;
}

.prompt-agent-dropzone {
  position: relative;
  min-height: 220px;
  border-radius: 16px;
  border: 1px dashed var(--border-strong);
  background:
    radial-gradient(circle at top, rgba(112, 226, 162, 0.12), transparent 54%),
    rgba(255, 255, 255, 0.025);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  padding: 18px;
}

.prompt-agent-dropzone.dragover {
  border-color: rgba(112, 226, 162, 0.48);
  background:
    radial-gradient(circle at top, rgba(112, 226, 162, 0.18), transparent 54%),
    rgba(255, 255, 255, 0.04);
}

.prompt-agent-dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.prompt-agent-dropzone em {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(112, 226, 162, 0.34);
  background: rgba(112, 226, 162, 0.1);
  color: #ecfff3;
  font-style: normal;
}

.prompt-agent-preview {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.prompt-agent-preview-button {
  position: relative;
  width: 92px;
  height: 92px;
  overflow: hidden;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(145, 159, 255, 0.26);
  background: rgba(255, 255, 255, 0.03);
  cursor: zoom-in;
}

.prompt-agent-preview-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 24%, transparent 76%, rgba(255, 255, 255, 0.12)),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.44));
  opacity: 0.46;
  pointer-events: none;
}

.prompt-agent-preview-button:hover {
  border-color: rgba(112, 226, 162, 0.42);
  transform: translateY(-1px);
}

.prompt-agent-preview img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
}

.prompt-agent-zoom-badge {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 7px;
  z-index: 3;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(236, 255, 243, 0.22);
  background: rgba(8, 12, 22, 0.72);
  color: #ecfff3;
  font-size: 0.72rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.prompt-agent-scan-line {
  position: absolute;
  left: -18%;
  right: -18%;
  top: -24%;
  z-index: 4;
  height: 28%;
  background:
    linear-gradient(180deg, transparent, rgba(112, 226, 162, 0.45), transparent),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-40%) rotate(-10deg);
}

.prompt-agent-preview.is-analyzing .prompt-agent-scan-line {
  opacity: 1;
  animation: prompt-agent-scan 1600ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.prompt-agent-preview div,
.prompt-agent-history-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.prompt-agent-preview strong,
.prompt-agent-history-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-agent-preview span,
.prompt-agent-feedback,
.prompt-agent-history-head p,
.prompt-agent-history-title span,
.prompt-agent-history-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.prompt-agent-preview-hint {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(112, 226, 162, 0.22);
  background: rgba(112, 226, 162, 0.08);
  color: #cffff0;
}

.prompt-agent-analysis-motion {
  height: 0;
  overflow: hidden;
  opacity: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  transition:
    height 180ms ease,
    opacity 180ms ease;
}

.prompt-agent-analysis-motion.is-active {
  height: 38px;
  opacity: 1;
}

.prompt-agent-analysis-motion span {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(112, 226, 162, 0.18);
  background: rgba(255, 255, 255, 0.03);
}

.prompt-agent-analysis-motion span::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(112, 226, 162, 0.62), transparent);
  transform: translateX(-100%);
  animation: prompt-agent-flow 1300ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.prompt-agent-analysis-motion span:nth-child(2)::before {
  animation-delay: 130ms;
}

.prompt-agent-analysis-motion span:nth-child(3)::before {
  animation-delay: 260ms;
}

.prompt-agent-feedback[data-state="error"] {
  color: var(--danger);
}

.prompt-agent-feedback[data-state="success"] {
  color: var(--success);
}

.prompt-agent-feedback[data-state="busy"] {
  color: #dfe5ff;
}

.prompt-agent-history-list {
  max-height: 260px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.prompt-agent-dialog,
.prompt-agent-history-list {
  scrollbar-width: thin;
  scrollbar-color:
    var(--scrollbar-thumb-color, rgba(132, 147, 255, 0.42))
    var(--scrollbar-track-color, rgba(255, 255, 255, 0.06));
}

.prompt-agent-dialog::-webkit-scrollbar,
.prompt-agent-history-list::-webkit-scrollbar {
  width: var(--scrollbar-size, 10px);
  height: var(--scrollbar-size, 10px);
}

.prompt-agent-dialog::-webkit-scrollbar-track,
.prompt-agent-history-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--scrollbar-track-color, rgba(255, 255, 255, 0.06));
}

.prompt-agent-dialog::-webkit-scrollbar-thumb,
.prompt-agent-history-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(156, 170, 255, 0.58), rgba(111, 124, 255, 0.34));
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.prompt-agent-history-empty {
  min-height: 74px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.prompt-agent-history-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.prompt-agent-history-title {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.prompt-agent-history-title-button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  line-height: 1.55;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-agent-history-title-button:hover {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: rgba(112, 226, 162, 0.58);
  text-underline-offset: 3px;
}

.prompt-agent-history-time {
  white-space: nowrap;
}

.prompt-agent-history-expand-button {
  justify-self: end;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.78rem;
}

.prompt-agent-history-expand-button:hover,
.prompt-agent-history-expand-button[aria-expanded="true"] {
  border-color: rgba(112, 226, 162, 0.38);
  color: var(--text);
  background: rgba(112, 226, 162, 0.1);
}

.prompt-agent-history-detail {
  display: grid;
  gap: 8px;
}

.prompt-agent-history-detail.hidden {
  display: none;
}

.prompt-agent-history-prompt {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
}

.prompt-agent-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-agent-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  place-items: center;
  padding: 18px;
}

.prompt-agent-image-viewer.open {
  display: grid;
}

.prompt-agent-image-viewer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
}

.prompt-agent-image-viewer-dialog {
  position: relative;
  width: min(860px, calc(100vw - 28px));
  max-height: calc(100svh - 28px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(13, 18, 32, 0.96);
  box-shadow: var(--shadow);
  padding: 14px;
}

.prompt-agent-image-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 600;
}

#promptAgentImageViewerImage {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100svh - 126px);
  justify-self: center;
  border-radius: 14px;
  object-fit: scale-down;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

@keyframes prompt-agent-scan {
  0% {
    transform: translateY(-60%) rotate(-10deg);
  }

  100% {
    transform: translateY(430%) rotate(-10deg);
  }
}

@keyframes prompt-agent-flow {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .prompt-agent-preview.is-analyzing .prompt-agent-scan-line,
  .prompt-agent-analysis-motion span::before {
    animation: none;
  }

  .prompt-agent-analysis-motion {
    transition: none;
  }
}

.config-drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.config-drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  transition: opacity 220ms ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(468px, 100vw);
  height: 100%;
  transform: translateX(100%);
  transition: transform 240ms ease;
  overflow-y: auto;
}

.config-drawer.open .drawer-backdrop {
  opacity: 1;
}

.config-drawer.open .drawer-panel {
  transform: translateX(0);
}

.prompt-template-popover {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
}

.prompt-template-popover:not(.hidden) {
  pointer-events: auto;
}

.prompt-template-panel {
  position: absolute;
  top: clamp(86px, 9svh, 118px);
  left: clamp(12px, 2vw, 26px);
  width: min(760px, calc(100vw - 24px));
  max-height: min(720px, calc(100svh - 112px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(142, 156, 255, 0.22);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(21, 28, 48, 0.96), rgba(13, 18, 31, 0.96)),
    rgba(13, 18, 31, 0.96);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px) saturate(126%);
}

.prompt-template-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(142, 156, 255, 0.14);
}

.prompt-template-head h2 {
  margin: 4px 0 0;
  font-size: 1.04rem;
}

.prompt-template-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 0.78fr) minmax(0, 1.22fr);
  gap: 14px;
  padding: 14px;
}

.prompt-template-list {
  min-height: 0;
  max-height: 520px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 4px;
}

.prompt-template-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  text-align: left;
}

.prompt-template-item.active {
  border-color: rgba(142, 156, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(112, 126, 255, 0.2), rgba(112, 126, 255, 0.07)),
    rgba(255, 255, 255, 0.04);
}

.prompt-template-title-button {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-template-title-button:hover {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: rgba(142, 156, 255, 0.62);
  text-underline-offset: 3px;
}

.prompt-template-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.prompt-template-row-actions .mini-action {
  min-height: 28px;
  padding: 0 9px;
  border-color: rgba(142, 156, 255, 0.18);
}

.prompt-template-row-actions .mini-action.danger {
  color: #ffd7d7;
  border-color: rgba(255, 124, 124, 0.22);
  background: rgba(255, 124, 124, 0.08);
}

.prompt-template-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.prompt-template-form {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.prompt-template-form textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.6;
}

.prompt-template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-template-actions .toolbar-button {
  min-height: 34px;
}

.icon-button[aria-expanded="true"] {
  border-color: rgba(142, 156, 255, 0.46);
  background:
    linear-gradient(180deg, rgba(112, 126, 255, 0.28), rgba(112, 126, 255, 0.1)),
    rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.drawer-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
}

.config-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-size: 0.86rem;
  color: var(--muted);
}

.inline-button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border-color: var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

html[data-ui-layout="narrow-desktop"] .studio-grid {
  grid-template-columns: 360px minmax(0, 1fr) 308px;
}

html[data-ui-layout="stacked"] .topbar,
html[data-ui-layout="tablet"] .topbar,
html[data-ui-layout="mobile"] .topbar {
  grid-template-columns: 1fr;
  justify-items: start;
}

html[data-ui-layout="stacked"] .view-tabs,
html[data-ui-layout="stacked"] .topbar-actions,
html[data-ui-layout="tablet"] .view-tabs,
html[data-ui-layout="tablet"] .topbar-actions,
html[data-ui-layout="mobile"] .view-tabs,
html[data-ui-layout="mobile"] .topbar-actions {
  width: 100%;
}

html[data-ui-layout="stacked"] .topbar-actions,
html[data-ui-layout="tablet"] .topbar-actions,
html[data-ui-layout="mobile"] .topbar-actions {
  justify-content: flex-start;
}

html[data-ui-layout="stacked"] .studio-grid,
html[data-ui-layout="tablet"] .studio-grid,
html[data-ui-layout="mobile"] .studio-grid {
  grid-template-columns: 1fr;
  min-height: auto;
  height: auto;
}

html[data-ui-layout="stacked"] .preview-panel,
html[data-ui-layout="stacked"] .side-column,
html[data-ui-layout="tablet"] .preview-panel,
html[data-ui-layout="tablet"] .side-column,
html[data-ui-layout="mobile"] .preview-panel,
html[data-ui-layout="mobile"] .side-column {
  height: auto;
}

html[data-ui-layout="stacked"] .app-shell,
html[data-ui-layout="stacked"] .view-root,
html[data-ui-layout="tablet"] .app-shell,
html[data-ui-layout="tablet"] .view-root,
html[data-ui-layout="mobile"] .app-shell,
html[data-ui-layout="mobile"] .view-root {
  height: auto;
  min-height: 0;
  overflow: visible;
}

html[data-ui-layout="stacked"] .side-column,
html[data-ui-layout="mobile"] .side-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: none;
}

html[data-ui-layout="stacked"] .settings-panel,
html[data-ui-layout="stacked"] .preview-panel,
html[data-ui-layout="stacked"] .live-panel,
html[data-ui-layout="stacked"] .recent-panel,
html[data-ui-layout="stacked"] .settings-form,
html[data-ui-layout="stacked"] .recent-list,
html[data-ui-layout="stacked"] .timeline-list,
html[data-ui-layout="tablet"] .settings-panel,
html[data-ui-layout="tablet"] .preview-panel,
html[data-ui-layout="tablet"] .live-panel,
html[data-ui-layout="tablet"] .recent-panel,
html[data-ui-layout="tablet"] .settings-form,
html[data-ui-layout="tablet"] .recent-list,
html[data-ui-layout="tablet"] .timeline-list,
html[data-ui-layout="mobile"] .settings-panel,
html[data-ui-layout="mobile"] .preview-panel,
html[data-ui-layout="mobile"] .live-panel,
html[data-ui-layout="mobile"] .recent-panel,
html[data-ui-layout="mobile"] .settings-form,
html[data-ui-layout="mobile"] .recent-list,
html[data-ui-layout="mobile"] .timeline-list {
  overflow: visible;
}

html[data-ui-layout="tablet"] .app-shell,
html[data-ui-layout="mobile"] .app-shell {
  width: min(100vw - 12px, 1680px);
}

html[data-ui-layout="tablet"] .side-column,
html[data-ui-layout="mobile"] .side-column {
  grid-template-columns: 1fr;
  grid-template-rows: none;
}

html[data-ui-layout="tablet"] .ratio-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

html[data-ui-layout="tablet"] .reference-grid,
html[data-ui-layout="mobile"] .reference-grid {
  grid-template-columns: 1fr;
}

html[data-ui-layout="tablet"] .preview-toolbar,
html[data-ui-layout="tablet"] .lightbox-fields,
html[data-ui-layout="tablet"] .panel-title,
html[data-ui-layout="tablet"] .drawer-head,
html[data-ui-layout="tablet"] .lightbox-top,
html[data-ui-layout="mobile"] .preview-toolbar,
html[data-ui-layout="mobile"] .lightbox-fields,
html[data-ui-layout="mobile"] .panel-title,
html[data-ui-layout="mobile"] .drawer-head,
html[data-ui-layout="mobile"] .lightbox-top {
  align-items: flex-start;
  flex-direction: column;
}

html[data-ui-layout="tablet"] .preview-canvas {
  min-height: 360px;
}

.gallery-view[data-gallery-layout="tablet"] {
  --gallery-panel-padding: 10px;
  --gallery-scrollbar-width: 38px;
  --gallery-scroll-track-width: 32px;
}

.gallery-view[data-gallery-layout="tablet"] .gallery-scroll-shell {
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
}

.gallery-view[data-gallery-layout="tablet"] .gallery-filter-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-view[data-gallery-layout="tablet"] .gallery-scroll-track {
  width: 34px;
}

html[data-ui-layout="tablet"] .advanced-controls,
html[data-ui-layout="mobile"] .advanced-controls {
  grid-template-columns: 1fr;
}

html[data-ui-layout="tablet"] .prompt-agent-body,
html[data-ui-layout="mobile"] .prompt-agent-body {
  grid-template-columns: 1fr;
}

html[data-ui-layout="mobile"] .prompt-agent-modal {
  padding: 8px;
}

html[data-ui-layout="mobile"] .prompt-agent-dialog {
  width: calc(100vw - 16px);
  max-height: calc(100svh - 16px);
  padding: 12px;
}

html[data-ui-layout="mobile"] .prompt-agent-head,
html[data-ui-layout="mobile"] .prompt-agent-history-head {
  align-items: flex-start;
  flex-direction: column;
}

html[data-ui-layout="mobile"] .app-shell {
  padding-top: 6px;
}

html[data-ui-layout="mobile"] .ratio-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-view[data-gallery-layout="mobile"] {
  --gallery-panel-padding: 9px;
  --gallery-control-height: 34px;
  --gallery-masonry-gap: 10px;
  --gallery-sections-gap: 12px;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-toolbar-head {
  align-items: stretch;
  grid-template-columns: 1fr;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-toolbar-meta {
  align-items: stretch;
  justify-content: flex-start;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-reset-button {
  justify-self: stretch;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-filter-row {
  grid-template-columns: 1fr;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-scroll-shell {
  grid-template-columns: minmax(0, 1fr);
}

.gallery-view[data-gallery-layout="mobile"] .gallery-scrollbar {
  display: none;
}

.gallery-view[data-gallery-layout="mobile"] .gallery-helper-text {
  white-space: normal;
}

html[data-ui-layout="mobile"] .lightbox {
  padding: 10px;
}

html[data-ui-layout="mobile"] .lightbox-dialog {
  width: calc(100vw - 20px);
  max-height: calc(100svh - 20px);
}

html[data-ui-layout="mobile"] .preview-canvas {
  min-height: 280px;
  padding: 14px;
}

html[data-ui-layout="tablet"] .prompt-template-panel,
html[data-ui-layout="mobile"] .prompt-template-panel {
  top: 10px;
  left: 10px;
  width: calc(100vw - 20px);
  max-height: calc(100svh - 20px);
}

html[data-ui-layout="tablet"] .prompt-template-body,
html[data-ui-layout="mobile"] .prompt-template-body {
  grid-template-columns: 1fr;
}

html[data-ui-layout="mobile"] .prompt-template-head {
  align-items: stretch;
  flex-direction: column;
}
/* PPT presentation generator */
.ppt-view {
  min-height: 100%;
}

.ppt-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) minmax(260px, 330px);
  gap: var(--studio-grid-gap, 14px);
  min-height: calc(100svh - var(--view-root-offset, 88px));
}

.ppt-settings-panel,
.ppt-result-panel,
.ppt-history-panel {
  min-height: 0;
  overflow: auto;
}

.ppt-form {
  display: grid;
  gap: 14px;
}

.ppt-source-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ppt-source-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(132, 147, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-weight: 700;
}

.ppt-source-option:has(input:checked) {
  border-color: rgba(132, 147, 255, 0.74);
  background: rgba(112, 121, 255, 0.16);
  color: var(--text);
}

.ppt-source-option input {
  width: 16px;
  height: 16px;
  accent-color: #7c83ff;
}

.ppt-dropzone {
  margin-top: 8px;
}

.ppt-file-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.ppt-file-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.ppt-file-item strong,
.ppt-history-item strong,
.ppt-slide-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ppt-file-item span,
.ppt-feedback,
.ppt-history-empty,
.ppt-slide-copy span,
.ppt-slide-copy p {
  color: var(--muted);
}

.ppt-control-grid {
  display: grid;
  grid-template-columns: minmax(100px, 0.45fr) minmax(0, 1fr);
  gap: 12px;
}

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

.ppt-motion-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ppt-output-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ppt-completion-ratio {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(132, 147, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-weight: 800;
}

.ppt-progress {
  height: 8px;
  margin: 14px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.ppt-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #74d4ff, #7f86ff, #8adf9a);
  transition: width 180ms ease;
}

.ppt-outline-box {
  padding: 12px 14px;
  border: 1px solid rgba(132, 147, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  line-height: 1.55;
}

.ppt-slide-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.ppt-slide-card {
  display: grid;
  grid-template-columns: minmax(180px, 320px) minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(132, 147, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.ppt-slide-card[data-status="failed"] {
  border-color: rgba(255, 117, 117, 0.42);
}

.ppt-slide-card[data-status="saved"] {
  border-color: rgba(138, 223, 154, 0.34);
}

.ppt-slide-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(9, 14, 31, 0.78);
  color: var(--muted);
  text-align: center;
}

.ppt-slide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ppt-slide-copy {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.ppt-slide-retry-button,
.ppt-slide-edit-button {
  justify-self: start;
  min-height: 34px;
  padding: 0 12px;
}

.ppt-slide-retry-button {
  justify-self: start;
}

.ppt-history-list {
  display: grid;
  gap: 10px;
}

.ppt-history-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
}

.ppt-history-item:hover,
.ppt-history-item:focus-visible {
  border-color: rgba(132, 147, 255, 0.42);
  background: rgba(132, 147, 255, 0.08);
  outline: none;
}

.ppt-history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ppt-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.ppt-edit-modal.hidden {
  display: none;
}

.ppt-edit-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 8, 18, 0.78);
}

.ppt-edit-dialog {
  position: relative;
  width: min(1180px, calc(100vw - 40px));
  max-height: calc(100svh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(132, 147, 255, 0.24);
  border-radius: 12px;
  background: rgba(14, 20, 42, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.ppt-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ppt-edit-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.ppt-edit-canvas-wrap {
  position: relative;
  align-self: start;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(132, 147, 255, 0.24);
  border-radius: 8px;
  background: rgba(9, 14, 31, 0.86);
}

.ppt-edit-canvas-wrap img,
.ppt-edit-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ppt-edit-canvas-wrap img {
  object-fit: cover;
}

.ppt-edit-canvas-wrap canvas {
  touch-action: none;
  cursor: crosshair;
}

.ppt-edit-side {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.ppt-edit-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ppt-edit-toolbar .active {
  border-color: rgba(132, 147, 255, 0.7);
  color: var(--text);
}

@media (max-width: 1180px) {
  .ppt-workspace {
    grid-template-columns: 1fr;
  }

  .ppt-slide-card {
    grid-template-columns: 1fr;
  }

  .ppt-edit-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .ppt-source-options,
  .ppt-control-grid {
    grid-template-columns: 1fr;
  }
}
