@charset "UTF-8";

/* ==========================================================================
   ATELIER STUDIO — Pro Creative Workstation UI
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg-app: #090b0f;
  --bg-panel: #0f1218;
  --bg-surface: #151922;
  --bg-surface-2: #1b202c;
  --bg-hover: #212736;
  --bg-elevated: #171c26;
  --bg-canvas: #0b0e14;
  --canvas-dot: rgba(148, 163, 184, 0.14);
  --canvas-glow: rgba(99, 102, 241, 0.07);
  --canvas-vignette: inset 0 0 48px rgba(0, 0, 0, 0.35);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-bright: #a5b4fc;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-border: rgba(129, 140, 248, 0.45);
  --accent-glow: rgba(99, 102, 241, 0.28);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;

  --topbar-h: 54px;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-app: #eef1f6;
  --bg-panel: #ffffff;
  --bg-surface: #f4f6fa;
  --bg-surface-2: #eaeef5;
  --bg-hover: #e2e7f0;
  --bg-elevated: #ffffff;
  --bg-canvas: #f1f4f9;
  --canvas-dot: rgba(100, 116, 139, 0.22);
  --canvas-glow: rgba(79, 70, 229, 0.06);
  --canvas-vignette: inset 0 1px 4px rgba(15, 23, 42, 0.05);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border-subtle: rgba(15, 23, 42, 0.06);
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-bright: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-border: rgba(79, 70, 229, 0.4);
  --accent-glow: rgba(79, 70, 229, 0.2);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.quiet {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid var(--accent-border);
  font-size: 9px;
}

/* ==========================================================================
   TOP COMMAND BAR (.topbar)
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #4338ca);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.1;
}

.brand-badge {
  font: 600 9px/1 var(--mono);
  font-style: normal;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg-surface-2);
  color: var(--accent-bright);
  border: 1px solid var(--border);
}

.brand small {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Mode Switcher */
.mode-switch {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.mode-switch button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.16s ease;
}

.mode-switch button kbd {
  font: 500 10px/1 var(--mono);
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.mode-switch button:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.mode-switch button.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.mode-switch button.active kbd {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: transparent;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

html:not([data-theme="light"]) .icon-sun {
  display: block;
}
html:not([data-theme="light"]) .icon-moon {
  display: none;
}
html[data-theme="light"] .icon-sun {
  display: none;
}
html[data-theme="light"] .icon-moon {
  display: block;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.connection:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-muted);
  flex-shrink: 0;
}

.connection.ready .dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection.pending .dot {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.atlas-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.atlas-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ==========================================================================
   THREE-PANE WORKSPACE LAYOUT (.workspace)
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: 356px minmax(420px, 1fr) 324px;
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
  background: var(--bg-app);
}

.panel-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.section-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ==========================================================================
   LEFT PANE: ASSET LIBRARY (.library)
   ========================================================================== */

.library {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.library.is-dragover,
.canvas.is-dragover {
  border-color: var(--accent-hover) !important;
  box-shadow: inset 0 0 0 2px var(--accent-hover);
}

.library-intro {
  margin-bottom: 10px;
}

.library h1,
.direction h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 2px;
  color: var(--text-primary);
}

.section-caption {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Role Tabs */
.library-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 4px;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.library-tabs button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.library-tabs button:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.library-tabs button.active {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong);
}

.library-tabs small {
  font: 600 10px/1 var(--mono);
  color: var(--text-muted);
}

.library-tabs button.active small {
  color: var(--accent-bright);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

/* Search & Upload Row */
.search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  min-width: 0;
  flex: 1;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}

.search:focus-within {
  border-color: var(--accent-hover);
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.search input {
  border: 0;
  background: transparent;
  outline: none;
  min-width: 0;
  width: 100%;
  font-size: 12px;
  color: var(--text-primary);
}

.search input::placeholder {
  color: var(--text-muted);
}

.upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.upload-icon:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.library-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.select-wrap {
  flex: 1;
  min-width: 0;
}

.library-tools select {
  width: 100%;
  max-width: 190px;
  height: 28px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  padding: 0 8px;
  color: var(--text-secondary);
}

.drag-hint {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Catalog Grid */
.catalog-scroll {
  overflow-y: auto;
  overflow-anchor: none;
  padding: 12px 14px 16px;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

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

.asset {
  min-width: 0;
  text-align: left;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.asset:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.asset-image {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--bg-surface-2);
  position: relative;
  width: 100%;
}

.asset img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.asset:hover img {
  transform: scale(1.05);
}

.asset.selected {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-hover), 0 4px 14px var(--accent-glow);
}

.asset.selected .asset-image::after {
  content: "✓";
  position: absolute;
  right: 6px;
  top: 6px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.angle-count {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(11, 14, 20, 0.78);
  backdrop-filter: blur(6px);
  border-radius: 4px;
  font: 500 9px/1.3 var(--mono);
  color: #e2e8f0;
}

.asset-info {
  padding: 6px 7px 7px;
}

.asset-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.asset-meta {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.asset-meta.meta-active {
  color: var(--accent-bright);
  font-weight: 500;
}

.load-more {
  width: 100%;
  margin-top: 14px;
  padding: 9px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.load-more:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.library-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.library-footer .dot {
  background: var(--accent);
}

.footer-tag {
  margin-left: auto;
  font: 500 10px/1 var(--mono);
  color: var(--text-muted);
}

/* ==========================================================================
   CENTER PANE: STAGE VIEWPORT, DOCK & FILMSTRIP (.stage)
   ========================================================================== */

.stage {
  padding: 14px 20px;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  background: var(--bg-app);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.stage-top-left,
.stage-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-divider {
  width: 1px;
  height: 12px;
  background: var(--border);
}

.stage-mode-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stage-size {
  font: 600 11px/1 var(--mono);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Canvas Viewport */
.canvas {
  position: relative;
  flex: 1 1 340px;
  min-height: 310px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(circle at 50% 35%, var(--canvas-glow), transparent 65%),
    radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--canvas-vignette);
}

.canvas-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--border-strong);
  border-style: solid;
  pointer-events: none;
  opacity: 0.7;
}

.top-left {
  left: 12px;
  top: 12px;
  border-width: 1.5px 0 0 1.5px;
}

.top-right {
  right: 12px;
  top: 12px;
  border-width: 1.5px 1.5px 0 0;
}

.bottom-left {
  left: 12px;
  bottom: 12px;
  border-width: 0 0 1.5px 1.5px;
}

.bottom-right {
  right: 12px;
  bottom: 12px;
  border-width: 0 1.5px 1.5px 0;
}

/* Welcome Standby State */
.welcome {
  text-align: center;
  animation: arrive 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  padding: 28px;
  max-width: 520px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.welcome-symbol {
  font-size: 13px;
  color: var(--accent-bright);
  line-height: 1;
}

.welcome h2 {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 10px;
  color: var(--text-primary);
}

.welcome > p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 auto;
  max-width: 480px;
  text-wrap: balance;
}

.welcome-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  font-size: 11px;
}

.welcome-steps span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.welcome-steps span:hover {
  border-color: var(--accent-border);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.welcome-steps span.step-done {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--success-soft);
  color: var(--success);
}

.welcome-steps span.step-output {
  cursor: default;
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.welcome-steps i {
  font-style: normal;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* Active Job State */
.job-state {
  text-align: center;
  padding: 32px;
  max-width: 440px;
}

.spinner-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent-hover);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.state-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid var(--accent-border);
}

.state-badge.is-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.job-state h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 12px 0 8px;
}

.job-state p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
  overflow-wrap: anywhere;
}

/* Result Showcase */
.result {
  height: 100%;
  width: 100%;
  padding: 16px 16px 58px;
  display: flex;
  justify-content: center;
  gap: 14px;
  align-items: center;
}

.result figure {
  margin: 0;
  height: 100%;
  min-width: 0;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  position: relative;
}

.result img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.result figcaption {
  position: absolute;
  top: 8px;
  left: 12px;
  background: rgba(11, 14, 20, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  padding: 3px 9px;
  border-radius: 4px;
  font: 600 10px/1.3 var(--mono);
  white-space: nowrap;
}

.result-tools {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 5px;
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.result-tools button,
.result-tools a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}

.result-tools button:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.result-tools a {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.result-tools a:hover {
  background: var(--accent-hover);
}

/* Reference Pipeline Dock (.dock-panel) */
.dock-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 12px;
  flex-shrink: 0;
}

.reference-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
}

.reference-heading-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reference-heading button {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.reference-heading button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.references {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.references.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reference-slot-wrap {
  position: relative;
  min-width: 0;
  display: flex;
}

.reference-slot {
  width: 100%;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  min-height: 70px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  min-width: 0;
  position: relative;
  transition: all 0.16s ease;
}

.reference-slot:hover {
  border-color: var(--accent-hover);
  background: var(--bg-surface-2);
}

.reference-slot.active-tab {
  border-style: solid;
  border-color: var(--accent-border);
  background: var(--bg-surface-2);
}

.reference-slot.filled {
  border-style: solid;
  border-color: var(--border-strong);
  background: var(--bg-surface-2);
}

.reference-slot.filled.active-tab {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.reference-thumb {
  width: 42px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 18px var(--mono);
  color: var(--text-muted);
  overflow: hidden;
}

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

.reference-copy {
  min-width: 0;
  flex: 1;
}

.reference-copy small {
  display: block;
  font: 600 9px/1.2 var(--mono);
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.reference-copy strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.reference-copy span {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-angle {
  display: inline-block;
  font-style: normal;
  font: 500 10px/1.3 var(--mono);
  color: var(--accent-bright);
  margin-top: 2px;
}

.reference-slot .check {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 10px;
  color: var(--success);
  font-weight: 700;
}

.slot-clear {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.reference-slot-wrap:hover .slot-clear,
.slot-clear:focus-visible {
  opacity: 1;
}

.slot-clear:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}

/* Timeline / History Filmstrip (.history-section) */
.history-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex-shrink: 0;
}

.history-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-height: 76px;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.empty-caption {
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
  padding: 6px 0;
}

.history-card {
  flex: 0 0 58px;
  padding: 0;
  text-align: center;
  position: relative;
}

.history-card img,
.history-placeholder {
  width: 58px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  display: block;
  transition: border-color 0.15s, transform 0.15s;
}

.history-card:hover img,
.history-card:hover .history-placeholder {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.history-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 10px;
  padding: 4px;
}

.history-card.status-running .history-placeholder {
  border-color: var(--accent-border);
  color: var(--accent-bright);
  background: var(--accent-soft);
}

.history-card.status-failed .history-placeholder {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
  background: var(--danger-soft);
}

.history-card.active img,
.history-card.active .history-placeholder {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1.5px var(--accent-hover);
}

.history-card small {
  font: 500 9px/1 var(--mono);
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

/* ==========================================================================
   RIGHT PANE: PARAMETER INSPECTOR (.direction)
   ========================================================================== */

.direction {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.inspector-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.field-label span:last-child {
  color: var(--text-muted);
  font: 500 10px/1 var(--mono);
}

textarea,
select,
input[type="password"] {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  color: var(--text-primary);
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
}

textarea:hover,
select:hover,
input[type="password"]:hover {
  border-color: var(--border-strong);
}

textarea:focus,
select:focus,
input[type="password"]:focus {
  border-color: var(--accent-hover);
  background: var(--bg-surface-2);
}

textarea {
  resize: vertical;
  min-height: 88px;
  max-height: 220px;
  line-height: 1.6;
}

textarea::placeholder,
input::placeholder {
  color: var(--text-muted);
}

/* Quick Prompt Chips */
.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--accent-border);
  color: var(--accent-bright);
  background: var(--accent-soft);
}

/* Visual Aspect Ratio Pills */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.ratio-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ratio-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-hover);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.ratio-box {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.85;
  margin-bottom: 2px;
}

.ratio-box.portrait {
  width: 11px;
  height: 16px;
}

.ratio-box.square {
  width: 14px;
  height: 14px;
}

.ratio-box.landscape {
  width: 17px;
  height: 11px;
}

.ratio-btn strong {
  font-size: 11px;
  font-weight: 600;
}

.ratio-btn small {
  font: 500 9px/1 var(--mono);
  color: var(--text-muted);
}

/* Quality Pills */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.quality-btn {
  padding: 7px 4px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  transition: all 0.15s ease;
}

.quality-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.quality-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-hover);
  color: var(--accent-bright);
  font-weight: 600;
}

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

.direction-footnote {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  margin-top: auto;
}

.footnote-icon {
  font-size: 14px;
  color: var(--accent-bright);
}

.direction-footnote p {
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
}

/* Sticky Inspector Action Footer */
.inspector-footer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.generation-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.summary-ready {
  color: var(--success);
  font-weight: 600;
}

.summary-badge {
  font: 500 10px/1 var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.generate {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border: 1px solid var(--accent-hover);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: all 0.16s ease;
}

.generate:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.generate:disabled {
  background: var(--bg-surface-2);
  border-color: var(--border);
  color: var(--text-muted);
  box-shadow: none;
  opacity: 0.75;
}

.generate-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.generate-meta kbd {
  font: 500 10px/1 var(--mono);
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
}

.generate:disabled .generate-meta kbd {
  background: rgba(255, 255, 255, 0.05);
}

.generate-meta i {
  font-style: normal;
  font-size: 15px;
  line-height: 1;
}

.generation-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 8px 0 0;
}

/* ==========================================================================
   TOAST & MODALS (dialog)
   ========================================================================== */

#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--accent-border);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-width: min(92vw, 540px);
  font-size: 12px;
  font-weight: 500;
}

dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  background: var(--bg-panel);
  color: var(--text-primary);
  width: min(520px, 92vw);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(6px);
}

dialog h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 10px 0 6px;
}

dialog p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 6px 0;
}

dialog pre {
  font: 11px/1.75 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  color: var(--accent-bright);
}

.telemetry-list {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  font-size: 12px;
}

.telemetry-list dt {
  color: var(--text-muted);
  font-size: 11px;
  margin: 0;
}

.telemetry-list dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.status-banner {
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.status-banner.is-ready {
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--success-soft);
  color: var(--success);
}

.status-banner.is-pending {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--warning-soft);
  color: var(--warning);
}

.dialog-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.error-text {
  color: var(--danger);
  min-height: 18px;
  font-size: 12px;
}

.secondary {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
}

.secondary:hover {
  background: var(--bg-hover);
}

#loginDialog .generate {
  margin-top: 12px;
}

.asset img.failed {
  opacity: 0.25;
}

/* Inline pose views, kept inside the asset browser. */
.pose-picker {
  grid-column: 1 / -1;
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 0;
}

.pose-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pose-picker-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.pose-picker-title h2 {
  flex-shrink: 0;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.pose-picker-title > span {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pose-picker-heading > button {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  font-size: 17px;
  color: var(--text-muted);
}

.pose-picker-heading > button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pose-picker-status {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-size: 9px;
  color: var(--text-muted);
}

.pose-picker-status > span:last-child { color: var(--accent-bright); }

.pose-angles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.pose-angles button {
  padding: 4px 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-panel);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.pose-angles button:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pose-angles button.active {
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 1px var(--accent-hover);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.pose-angles img {
  display: block;
  width: 100%;
  height: 48px;
  object-fit: contain;
  margin-bottom: 4px;
  border-radius: 3px;
}

.pose-angles span {
  display: block;
  white-space: nowrap;
}

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

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (min-width: 1600px) {
  .workspace {
    grid-template-columns: 390px minmax(520px, 1fr) 356px;
  }
  .catalog {
    gap: 12px 10px;
  }
  .stage {
    padding: 18px 28px;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px minmax(320px, 1fr) 280px;
  }
  .brand small,
  .drag-hint,
  .mode-switch button kbd {
    display: none;
  }
}

@media (max-width: 960px) {
  html,
  body {
    height: auto;
  }
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
    height: auto;
    overflow: visible;
  }
  .library {
    grid-row: 1 / 3;
    height: calc(100dvh - var(--topbar-h));
    position: sticky;
    top: var(--topbar-h);
  }
  .direction {
    grid-column: 2;
    border-top: 1px solid var(--border);
    border-left: 0;
    height: auto;
  }
  .canvas {
    min-height: 400px;
  }
}

@media (max-width: 680px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }
  .mode-switch {
    order: 3;
    width: 100%;
  }
  .mode-switch button {
    flex: 1;
    justify-content: center;
  }
  .atlas-link span {
    display: none;
  }
  .workspace {
    display: flex;
    flex-direction: column;
  }
  .library {
    position: static;
    height: auto;
    max-height: 540px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .catalog {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .stage {
    padding: 14px;
  }
  .canvas {
    min-height: 360px;
  }
  .references {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
