:root {
  color-scheme: dark;
  --bg: #08090d;
  --bg-soft: rgba(16, 18, 25, 0.76);
  --panel: rgba(17, 20, 27, 0.82);
  --panel-strong: rgba(22, 25, 35, 0.94);
  --line: rgba(230, 232, 240, 0.14);
  --line-strong: rgba(235, 238, 246, 0.25);
  --text: #f2f3f0;
  --muted: rgba(242, 243, 240, 0.66);
  --faint: rgba(242, 243, 240, 0.42);
  --moon: #e9e2d3;
  --teal: #7dd7d2;
  --teal-strong: #55bdb8;
  --night-purple: #1a1026;
  --bruise-violet: #7c5aa6;
  --eclipse-red: #b24b62;
  --dream-cyan: #68d4d0;
  --moon-silver: #d9d5c8;
  --copper: #b7825d;
  --red: #bc574d;
  --danger: #ff7068;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(8, 9, 13, 0.9) 0%, rgba(8, 9, 13, 0.28) 48%, rgba(8, 9, 13, 0.88) 100%),
    linear-gradient(180deg, rgba(8, 9, 13, 0.05) 0%, rgba(8, 9, 13, 0.94) 100%),
    url("./assets/yanyue-bg-eclipse-workbench.png") center / cover no-repeat;
}

.app-bg::before {
  content: "";
  position: absolute;
  inset: -12%;
  background:
    radial-gradient(circle at 50% 20%, rgba(217, 213, 200, 0.16), transparent 16%),
    radial-gradient(circle at 44% 18%, rgba(178, 75, 98, 0.18), transparent 22%),
    conic-gradient(from 120deg at 50% 20%, transparent 0 16%, rgba(124, 90, 166, 0.16) 18% 21%, transparent 24% 55%, rgba(104, 212, 208, 0.1) 58% 60%, transparent 64%);
  filter: blur(1px);
  animation: moonDrift 18s ease-in-out infinite alternate;
}

.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(233, 226, 211, 0.055) 0 1px, transparent 1.5px),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 80px 80px, 42px 42px, 42px 42px;
  mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 82%, transparent 100%);
}

@keyframes moonDrift {
  from { transform: translate3d(-1%, -1%, 0) scale(1); opacity: 0.82; }
  to { transform: translate3d(1%, 1.5%, 0) scale(1.03); opacity: 1; }
}

.app-shell {
  height: 100vh;
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  overflow: hidden;
}

.topbar,
.project-panel,
.workspace-panel,
.side-panel,
.shot-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.018)),
    radial-gradient(circle at 0 0, rgba(124, 90, 166, 0.16), transparent 42%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
}

.topbar {
  min-height: 72px;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.topbar::after,
.workspace-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(104, 212, 208, 0), rgba(104, 212, 208, 0.18), rgba(178, 75, 98, 0));
  height: 1px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 13, 0.52);
  box-shadow: 0 0 34px rgba(233, 226, 211, 0.24), inset 0 0 18px rgba(178, 75, 98, 0.22);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  min-width: 0;
}

.brand h1,
.workspace-titlebox h2,
.panel-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 24px;
  font-weight: 700;
}

.brand p {
  margin: 3px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions,
.workspace-toolbar,
.batchbar,
.project-actions,
.shot-head-actions,
.prompt-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  gap: 14px;
  overflow: hidden;
}

.project-panel,
.workspace-panel,
.side-panel {
  min-height: 0;
  border-radius: var(--radius);
}

.project-panel,
.side-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.workspace-panel {
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
}

.workspace-panel::after {
  content: "";
  position: absolute;
  top: -90px;
  right: 18%;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(233, 226, 211, 0.13);
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle, transparent 56%, rgba(178, 75, 98, 0.1) 57% 58%, transparent 59%),
    conic-gradient(from 30deg, transparent 0 18%, rgba(104, 212, 208, 0.18) 19% 20%, transparent 21% 45%, rgba(233, 226, 211, 0.16) 46% 47%, transparent 48%);
  opacity: 0.7;
}

.panel-head,
.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-titlebox {
  min-width: 0;
}

.dream-meter {
  min-width: 178px;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid rgba(233, 226, 211, 0.18);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(3, 4, 8, 0.34);
}

.dream-meter-orbit {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(233, 226, 211, 0.45);
  background:
    radial-gradient(circle at 60% 42%, transparent 0 28%, rgba(8, 9, 13, 0.95) 29% 46%, transparent 47%),
    radial-gradient(circle, rgba(233, 226, 211, 0.96), rgba(178, 75, 98, 0.28) 62%, transparent 64%);
  box-shadow: 0 0 18px rgba(233, 226, 211, 0.2);
  animation: orbitPulse 2.8s ease-in-out infinite;
}

.dream-meter strong,
.dream-meter span {
  display: block;
}

.dream-meter strong {
  font-size: 13px;
}

.dream-meter span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
}

@keyframes orbitPulse {
  0%, 100% { transform: scale(0.96); filter: saturate(0.9); }
  50% { transform: scale(1.04); filter: saturate(1.25); }
}

.panel-head.slim {
  margin-bottom: 2px;
}

.panel-kicker {
  display: block;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.panel-head h2,
.workspace-titlebox h2 {
  font-size: 18px;
}

.icon-button,
.ghost-button,
.primary-button,
.model-chip,
.side-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.icon-button svg,
.ghost-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
}

.ghost-button,
.primary-button {
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.primary-button {
  border-color: rgba(233, 226, 211, 0.44);
  background:
    linear-gradient(135deg, rgba(104, 212, 208, 0.34), rgba(178, 75, 98, 0.28)),
    rgba(255, 255, 255, 0.06);
  color: #fff;
  font-weight: 700;
}

.primary-button.full {
  width: 100%;
}

.ghost-button:hover,
.primary-button:hover,
.icon-button:hover,
.model-chip:hover,
.side-tab:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.ghost-button:focus-visible,
.primary-button:focus-visible,
.icon-button:focus-visible,
.model-chip:focus-visible,
.side-tab:focus-visible,
.reference-drop:focus-visible {
  outline: 2px solid rgba(104, 212, 208, 0.72);
  outline-offset: 2px;
}

.ghost-button:disabled,
.primary-button:disabled,
.icon-button:disabled,
.model-chip:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.danger {
  color: var(--danger);
}

.compact-field,
.settings-field,
.control-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.compact-field {
  width: 96px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(230, 232, 240, 0.15);
  border-radius: var(--radius);
  background: rgba(4, 6, 9, 0.55);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(125, 215, 210, 0.58);
  box-shadow: 0 0 0 3px rgba(125, 215, 210, 0.12);
}

.project-list,
.shots-container,
.asset-list,
.history-list {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 215, 210, 0.55) rgba(255, 255, 255, 0.08);
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-item {
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.project-item.is-active {
  border-color: rgba(125, 215, 210, 0.6);
  background: rgba(125, 215, 210, 0.12);
}

.project-item strong,
.project-item span {
  display: block;
}

.project-item strong {
  font-size: 14px;
}

.project-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.model-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-chip {
  padding: 0 14px;
  color: var(--muted);
}

.model-chip.is-active {
  border-color: rgba(233, 226, 211, 0.52);
  background: rgba(233, 226, 211, 0.13);
  color: var(--moon);
}

.batchbar {
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.batch-summary {
  color: rgba(233, 226, 211, 0.72);
  font-size: 12px;
}

.floating-batchbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 46px;
  padding: 8px;
  border: 1px solid rgba(104, 212, 208, 0.28);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(9, 12, 18, 0.92);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
}

.floating-batchbar span {
  margin-right: auto;
  color: var(--moon-silver);
  font-size: 13px;
  font-weight: 700;
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.switch-line input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.status-line {
  margin-left: auto;
  color: var(--faint);
  font-size: 12px;
}

.shots-container {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.shot-card {
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.shot-card.is-busy {
  border-color: rgba(178, 75, 98, 0.58);
  animation: nightmareBorder 1.8s ease-in-out infinite;
}

@keyframes nightmareBorder {
  0%, 100% { box-shadow: var(--shadow), inset 0 0 0 rgba(178, 75, 98, 0); }
  50% { box-shadow: var(--shadow), 0 0 28px rgba(178, 75, 98, 0.22), inset 0 0 18px rgba(104, 212, 208, 0.08); }
}

.shot-head {
  min-height: 54px;
  padding: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.shot-select-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.shot-select {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.shot-index {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid rgba(233, 226, 211, 0.22);
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--moon-silver);
  font-weight: 800;
  font-size: 13px;
  background:
    conic-gradient(from 30deg, rgba(104, 212, 208, 0.22), transparent 18%, rgba(178, 75, 98, 0.22), transparent 58%, rgba(233, 226, 211, 0.18)),
    rgba(4, 6, 10, 0.52);
}

.shot-title-input {
  border-color: transparent;
  background: transparent;
  font-weight: 700;
}

.shot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  padding: 12px;
}

.shot-editor,
.shot-controls {
  min-width: 0;
}

.editor-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.prompt-actions {
  margin-top: 8px;
  flex-wrap: wrap;
}

.reference-zone {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.reference-drop,
.asset-drop {
  border: 1px dashed rgba(233, 226, 211, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.reference-drop {
  min-height: 54px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
}

.reference-drop.is-dragover,
.asset-drop.is-dragover {
  border-color: var(--teal);
  background: rgba(125, 215, 210, 0.09);
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.reference-list,
.asset-list,
.history-list {
  display: grid;
  gap: 8px;
}

.reference-list {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.reference-card,
.asset-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
}

.reference-card {
  position: relative;
}

.reference-media,
.asset-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.34);
  color: var(--muted);
}

.reference-media img,
.reference-media video,
.asset-media img,
.asset-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-meta,
.asset-meta,
.history-meta {
  padding: 8px;
  display: grid;
  gap: 3px;
}

.reference-meta strong,
.asset-meta strong,
.history-meta strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reference-meta span,
.asset-meta span,
.history-meta span {
  color: var(--faint);
  font-size: 11px;
}

.reference-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.video-stage {
  position: relative;
  margin-top: 12px;
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(233, 226, 211, 0.16);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(178, 75, 98, 0.12), transparent 44%),
    linear-gradient(135deg, rgba(104, 212, 208, 0.08), transparent 42%),
    rgba(0, 0, 0, 0.36);
}

.video-empty,
.video-loading,
.result-video {
  width: 100%;
  height: 100%;
}

.video-empty,
.video-loading {
  display: grid;
  place-items: center;
  color: var(--faint);
}

.video-loading {
  gap: 8px;
}

.result-video {
  object-fit: contain;
  background: #000;
}

.loader {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--dream-cyan);
  border-left-color: var(--eclipse-red);
  animation: spin 0.9s linear infinite;
}

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

.shot-status {
  min-height: 32px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  line-height: 1.45;
}

.result-actions {
  margin-top: 8px;
}

.side-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.side-tab {
  color: var(--muted);
}

.side-tab.is-active {
  color: var(--moon);
  border-color: rgba(233, 226, 211, 0.48);
  background: rgba(233, 226, 211, 0.12);
}

.side-page {
  min-height: 0;
  display: none;
}

.side-page.is-active {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
}

.reverse-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}

.reverse-modal-layer[hidden] {
  display: none;
}

.reverse-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 7, 0.68);
  backdrop-filter: blur(12px);
}

.reverse-modal {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(380px, 1.15fr);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(233, 226, 211, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(26, 16, 38, 0.96), rgba(11, 13, 19, 0.96)),
    var(--panel-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}

.reverse-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(circle at 16% 0, rgba(104, 212, 208, 0.16), transparent 34%),
    radial-gradient(circle at 100% 24%, rgba(178, 75, 98, 0.18), transparent 30%);
  pointer-events: none;
}

.reverse-modal .panel-head {
  grid-column: 1 / -1;
}

.reverse-modal .reverse-output {
  grid-column: 2;
  grid-row: 2 / 5;
  min-height: 0;
}

.reverse-modal .reverse-actions {
  align-self: end;
}

.asset-drop {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.reverse-drop {
  min-height: 132px;
  padding: 14px;
  border: 1px dashed rgba(233, 226, 211, 0.28);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(124, 90, 166, 0.14), rgba(178, 75, 98, 0.08)),
    rgba(255, 255, 255, 0.035);
}

.reverse-drop p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.reverse-drop.is-dragover {
  border-color: var(--dream-cyan);
  background: rgba(104, 212, 208, 0.09);
}

.reverse-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
  background: #000;
}

.reverse-image-preview {
  display: block;
}

.reverse-meta {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px;
}

.reverse-options,
.reverse-actions {
  display: grid;
  gap: 8px;
}

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

.reverse-output {
  min-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
}

.reverse-output pre,
.error-drawer pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(242, 243, 240, 0.88);
  font-size: 12px;
  line-height: 1.65;
}

.asset-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
}

.asset-media {
  aspect-ratio: 1;
}

.asset-actions,
.history-actions {
  padding: 0 8px 8px;
  display: flex;
  gap: 6px;
}

.asset-actions .ghost-button,
.history-actions .ghost-button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.history-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
  display: block;
}

.settings-field {
  margin-bottom: 10px;
}

.settings-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ui-board-preview {
  margin: 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.24);
}

.ui-board-preview img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.ui-board-preview figcaption {
  padding: 8px 10px;
  color: var(--faint);
  font-size: 11px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(12, 14, 20, 0.94);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.toast.is-error {
  border-color: rgba(255, 112, 104, 0.52);
}

.toast button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: var(--moon-silver);
  cursor: pointer;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--faint);
  text-align: center;
  line-height: 1.6;
}

.empty-state.illustrated::before {
  content: "";
  display: block;
  width: min(120px, 58%);
  aspect-ratio: 1;
  margin: 0 auto 10px;
  border-radius: var(--radius);
  background: url("./assets/yanyue-empty-state-dream.png") center / cover no-repeat;
  opacity: 0.74;
  filter: saturate(0.88);
}

.empty-state.compact::before {
  width: 72px;
}

.modal-layer,
.error-drawer {
  position: fixed;
  z-index: 20;
}

.modal-layer {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-layer[hidden],
.error-drawer[hidden],
.floating-batchbar[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  width: min(460px, 100%);
  border: 1px solid rgba(233, 226, 211, 0.22);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 12px;
  background:
    radial-gradient(circle at top right, rgba(178, 75, 98, 0.18), transparent 38%),
    rgba(14, 16, 23, 0.96);
  box-shadow: var(--shadow);
}

.modal-sigil {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: url("./assets/yanyue-emblem-nightmare-moon.png") center / cover no-repeat;
}

.modal-dialog h2,
.error-drawer h2 {
  margin: 0;
  font-size: 18px;
}

.modal-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modal-input-wrap {
  display: grid;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.error-drawer {
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100vw - 36px));
  max-height: min(620px, calc(100vh - 36px));
  border: 1px solid rgba(255, 112, 104, 0.42);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(12, 14, 20, 0.96);
  box-shadow: var(--shadow);
}

.error-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.error-drawer pre {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
}

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

  .side-panel {
    grid-column: 1 / -1;
    min-height: 300px;
  }

  .side-page.is-active {
    max-height: 360px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-shell {
    padding: 10px;
  }

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

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .brand p {
    white-space: normal;
  }

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

  .project-panel,
  .side-panel {
    min-height: auto;
  }

  .reverse-modal-layer {
    padding: 12px;
  }

  .reverse-modal {
    width: 100%;
    max-height: none;
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow: auto;
  }

  .reverse-modal .reverse-output {
    grid-column: auto;
    grid-row: auto;
  }

  .workspace-head,
  .batchbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dream-meter {
    width: 100%;
  }

  .floating-batchbar {
    flex-wrap: wrap;
  }

  .workspace-toolbar {
    flex-wrap: wrap;
  }

  .shot-grid {
    grid-template-columns: 1fr;
  }

  .shot-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .shot-head-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .topbar-actions .ghost-button,
  .topbar-actions .primary-button {
    flex: 1 1 120px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .reference-list {
    grid-template-columns: 1fr 1fr;
  }

  .asset-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
