:root {
  color-scheme: dark;
  --bg: #101113;
  --surface: #191b1f;
  --surface-2: #22262b;
  --surface-3: #2b3037;
  --line: #343a43;
  --text: #f2f3ee;
  --muted: #aab0b7;
  --soft: #737c86;
  --accent: #f2b84b;
  --accent-2: #62b8d9;
  --danger: #ef6f6c;
  --ready: #66c48f;
  --rendering: #f2b84b;
  --draft: #8f98a3;
  --failed: #ef6f6c;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #56606c;
  background: var(--surface-3);
}

.primary {
  border-color: #d69a35;
  background: var(--accent);
  color: #16120b;
  font-weight: 700;
}

.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button svg path:first-child:last-child {
  fill: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(12, 14, 18, 0.72);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  display: grid;
  gap: 12px;
}

.auth-card h2 {
  margin: 0 0 8px;
}

.auth-card p,
.auth-message {
  color: var(--muted);
}

.auth-card p {
  margin: 0;
}

.auth-card input,
.invite-url {
  width: 100%;
}

.invite-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.invite-copy-button {
  color: var(--muted);
}

.invite-copy-button:hover {
  color: var(--text);
}

.auth-message {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.role-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

.team-user,
.presence-list,
.member-list,
.team-empty {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.team-empty {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  line-height: 1.35;
}

.team-empty strong {
  color: var(--text);
}

.team-panel {
  background: transparent;
  border: 0;
  padding: 0;
}

.team-summary {
  margin-bottom: 8px;
}

.team-body {
  display: grid;
  gap: 8px;
}

.wallet-panel {
  display: grid;
  gap: 8px;
  margin: -8px 0 10px;
}

.wallet-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  color: var(--muted);
  text-align: left;
}

.wallet-summary:hover {
  border-color: #56606c;
  background: var(--surface-2);
}

.wallet-summary svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.wallet-summary strong {
  color: var(--text);
}

.wallet-body {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(98, 184, 217, 0.08);
  padding: 10px;
}

.wallet-error,
.wallet-pricing-list span {
  color: var(--muted);
  font-size: 12px;
}

.wallet-pack-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.wallet-pack-row button {
  min-height: 30px;
  padding: 0 6px;
  font-size: 12px;
}

.wallet-pricing summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.wallet-pricing-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.wallet-pricing-list div {
  display: grid;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.wallet-pricing-list strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
}

.presence-list span,
.member-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
}

.invite-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 10px 0;
}

.danger-button {
  border-color: rgba(239, 111, 108, 0.6);
  background: #321a1d;
  color: #ffd6d6;
  font-weight: 700;
}

.danger-button:hover {
  border-color: var(--danger);
  background: #442126;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(560px, 1fr) 360px;
  height: 100vh;
  min-height: 0;
}

.app-shell.chat-collapsed {
  grid-template-columns: 260px minmax(560px, 1fr) 56px;
}

.sidebar,
.chat-panel,
.workspace {
  min-width: 0;
}

.sidebar,
.chat-panel {
  background: var(--surface);
  border-color: var(--line);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d85f4d;
  color: #fff7ef;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 15px;
}

.brand p,
.chat-header p,
.timeline-header p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  margin-top: 18px;
}

.panel-heading,
.timeline-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.timeline-header h2,
.chat-header h2 {
  font-size: 13px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-actions button:not(.icon-button) {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.scene-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.project-panel select {
  margin-top: 10px;
  min-height: 36px;
  background: var(--surface-2);
}

.scene-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15171b;
  padding: 10px;
  text-align: left;
}

.scene-card.active {
  border-color: var(--accent-2);
}

.scene-card strong {
  display: block;
  font-size: 13px;
}

.scene-card span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-empty {
  min-width: 180px;
  height: 90px;
  display: grid;
  place-items: center;
}

.asset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.asset-chip {
  min-height: 30px;
  font-size: 12px;
  color: var(--muted);
}

.asset-chip.active {
  color: #111;
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.asset-grid .empty-state {
  width: 100%;
}

.continuity-palette-summary {
  display: grid;
  gap: 2px;
  min-width: 150px;
  max-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 7px 9px;
}

.continuity-palette-summary strong {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

.continuity-palette-summary span {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.job-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 9px;
  color: var(--muted);
  font-size: 12px;
}

.job-item-button {
  width: 100%;
  min-height: 0;
  text-align: left;
}

.job-item-button:hover,
.job-item-button.active {
  border-color: var(--accent-2);
  background: #172027;
}

.job-item strong,
.job-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-item strong {
  color: var(--text);
  margin-bottom: 3px;
}

.workspace {
  display: grid;
  grid-template-rows: 74px minmax(320px, 1fr) 236px;
  min-height: 0;
  overflow: hidden;
  background: #111316;
}

.workspace.story-mode {
  grid-template-rows: 74px minmax(0, 1fr);
}

.workspace.story-mode .viewer-row,
.workspace.story-mode .timeline-section {
  display: none;
}

.workspace.no-project {
  grid-template-rows: 74px minmax(0, 1fr);
}

.workspace.no-project .mode-toggle,
.workspace.no-project .export-actions,
.workspace.no-project .story-workspace,
.workspace.no-project .viewer-row,
.workspace.no-project .timeline-section {
  display: none;
}

.no-project-panel {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 32px;
}

.no-project-panel > div {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
}

.no-project-panel h2 {
  margin: 8px 0;
  font-size: 22px;
}

.no-project-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.4;
}

.empty-steps {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.empty-steps span {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.empty-steps strong {
  width: 22px;
  height: 22px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #16120b;
  font-size: 12px;
}

.no-project-panel[hidden] {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.topbar h2 {
  font-size: 20px;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101216;
  padding: 3px;
}

.mode-toggle button {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.mode-toggle button.active {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-workspace {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
  padding: 14px 18px;
}

.story-workspace[hidden] {
  display: none;
}

.story-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  align-items: end;
}

.story-toolbar label {
  margin-top: 0;
}

.story-controls {
  display: grid;
  gap: 10px;
}

.story-controls .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.story-controls .inline-check input {
  width: auto;
}

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

.story-list,
.story-detail {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.story-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.story-card {
  width: 100%;
  min-height: 0;
  min-width: 0;
  display: grid;
  gap: 6px;
  border-radius: 8px;
  background: #15171b;
  padding: 11px;
  text-align: left;
  overflow: hidden;
}

.story-card.active {
  border-color: var(--accent-2);
  outline: 2px solid rgba(98, 184, 217, 0.2);
}

.story-card strong,
.story-detail h2,
.story-detail h3 {
  color: var(--text);
}

.story-card strong,
.story-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-card span {
  color: var(--muted);
  font-size: 12px;
}

.story-card p {
  display: -webkit-box;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.story-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 22px;
  overflow: hidden;
}

.story-tags i {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.story-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.story-empty-detail {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.story-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.story-detail h2 {
  margin-top: 2px;
  font-size: 20px;
}

.story-logline {
  margin-top: 12px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.story-detail section {
  margin-top: 16px;
}

.story-detail h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.story-detail section > p,
.story-scene p,
.story-beat p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.story-beats,
.story-scenes {
  display: grid;
  gap: 8px;
}

.story-beat,
.story-scene {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 10px;
}

.story-beat strong,
.story-scene strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 13px;
}

.story-beat span {
  display: block;
  margin-top: 4px;
  color: var(--soft);
  font-size: 12px;
}

.story-actions {
  position: sticky;
  bottom: -14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px -14px -14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 14px;
}

.atlas-balance-chip {
  min-width: 96px;
  color: var(--text);
}

.atlas-balance-chip.error {
  border-color: rgba(239, 111, 108, 0.6);
  color: var(--danger);
}

.viewer-row {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 300px;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  padding: 14px 18px;
}

.viewer {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050607;
}

.viewer video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.viewer video[hidden] {
  display: none;
}

.viewer-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.viewer-empty[hidden] {
  display: none;
}

.viewer-overlay {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  gap: 8px;
}

.viewer-overlay span,
.legend span,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  padding: 5px 9px;
  color: var(--text);
  font-size: 12px;
}

.inspector {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.inspector > .panel-heading {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.inspector-scroll {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 14px 14px;
}

label {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101216;
  color: var(--text);
  padding: 9px 10px;
  resize: vertical;
}

.take-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  min-width: 0;
}

.take-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #14171b;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

button.take-item {
  width: 100%;
  min-height: 0;
  text-align: left;
}

.take-item.selected {
  border-color: var(--accent-2);
  outline: 2px solid rgba(98, 184, 217, 0.24);
}

.take-item strong {
  display: block;
  color: var(--text);
  margin-bottom: 3px;
}

.material-panel {
  min-width: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.material-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.material-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101318;
  padding: 7px;
  font-size: 12px;
}

.selectable-material {
  grid-template-columns: 14px 18px minmax(0, 1fr) auto;
  cursor: pointer;
}

.selectable-material input {
  margin: 0;
}

.material-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.material-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-values {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.palette-save-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.palette-save-form input,
.palette-save-form select {
  min-width: 0;
}

.palette-save-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
}

.atlas-panel {
  min-width: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.shot-assets-panel {
  min-width: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.atlas-heading,
.reference-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.atlas-heading > div,
.reference-header > strong {
  min-width: 0;
}

.atlas-heading h3 {
  margin: 0;
  font-size: 13px;
}

.atlas-heading p,
.reference-header span,
.atlas-estimate span {
  color: var(--muted);
  font-size: 12px;
}

.atlas-heading p {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

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

.atlas-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.atlas-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.atlas-toggles input {
  width: auto;
}

.atlas-advanced {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 8px 9px;
}

.atlas-advanced summary {
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.reference-header {
  margin-top: 14px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  max-height: 172px;
  overflow: auto;
  padding-right: 2px;
}

.reference-thumb {
  position: relative;
  min-height: 72px;
  aspect-ratio: 1.35;
  overflow: hidden;
  padding: 0;
  background: #090a0c;
}

.reference-thumb.selected {
  border-color: var(--accent-2);
  outline: 2px solid rgba(98, 184, 217, 0.28);
}

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

.reference-thumb span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  padding: 2px 5px;
  color: var(--text);
  font-size: 10px;
}

.reference-empty,
.atlas-estimate {
  min-width: 0;
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 9px;
  color: var(--muted);
  font-size: 12px;
}

.atlas-estimate {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.atlas-estimate strong {
  color: var(--text);
}

.atlas-estimate.blocked strong {
  color: var(--danger);
}

.atlas-render-button {
  width: 100%;
  margin-top: 10px;
}

.attached-assets {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  min-width: 0;
}

.attached-asset {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 8px;
  font-size: 12px;
}

.attached-asset span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  min-width: 0;
}

.attached-asset strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-asset button {
  width: 28px;
  min-height: 28px;
  padding: 0;
}

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

.timeline-section {
  border-top: 1px solid var(--line);
  padding: 14px 18px 18px;
  min-width: 0;
  overflow: hidden;
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.dot.draft {
  background: var(--draft);
}

.dot.rendering {
  background: var(--rendering);
}

.dot.ready {
  background: var(--ready);
}

.dot.failed {
  background: var(--failed);
}

.timeline {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.shot-card {
  flex: 0 0 auto;
  min-width: 150px;
  max-width: 320px;
  height: 136px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--draft);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.shot-card.ready {
  border-top-color: var(--ready);
}

.shot-card.rendering {
  border-top-color: var(--rendering);
}

.shot-card.failed {
  border-top-color: var(--failed);
}

.shot-card.selected {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.shot-card strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shot-card p {
  display: -webkit-box;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.shot-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--soft);
  font-size: 12px;
}

.chat-panel {
  display: grid;
  grid-template-rows: 70px 1fr auto;
  border-left: 1px solid var(--line);
  min-height: 0;
}

.chat-header {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.chat-title {
  min-width: 0;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-rail-button {
  display: none;
}

.chat-panel.collapsed {
  grid-template-rows: 1fr;
}

.chat-panel.collapsed .chat-header {
  display: grid;
  place-items: start center;
  border-bottom: 0;
  padding: 14px 11px;
}

.chat-panel.collapsed .chat-title,
.chat-panel.collapsed .chat-actions,
.chat-panel.collapsed .chat-messages,
.chat-panel.collapsed .chat-composer {
  display: none;
}

.chat-panel.collapsed .chat-rail-button {
  display: inline-grid;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 14px;
}

.message {
  max-width: 94%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #13161a;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.message.user {
  justify-self: end;
  background: #21323b;
  border-color: #345568;
}

.message.system {
  justify-self: start;
}

.message.pending {
  color: var(--muted);
}

.message small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-dot 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-composer {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.chat-composer textarea:disabled,
.chat-composer button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
}

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

.modal {
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.asset-modal {
  width: min(960px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
}

.bridge-modal {
  width: min(460px, 100%);
}

.bridge-form {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.bridge-form .reference-empty {
  grid-column: auto;
  margin-top: 0;
}

.atlas-preflight-modal {
  width: min(1040px, 100%);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.atlas-preflight-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.atlas-preflight-body section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 12px;
}

.atlas-preflight-body h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.preflight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 14px;
}

.preflight-references {
  display: grid;
  gap: 8px;
}

.preflight-reference {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.preflight-reference img {
  width: 72px;
  aspect-ratio: 1.35;
  border-radius: 6px;
  object-fit: cover;
  background: #090a0c;
}

.preflight-reference span,
.preflight-reference strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preflight-reference span {
  color: var(--muted);
  font-size: 12px;
}

.preflight-reference strong {
  color: var(--text);
}

.preflight-prompt {
  min-width: 0;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.preflight-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preflight-list.blocked {
  color: var(--danger);
}

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

.preflight-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101318;
  padding: 10px;
}

.preflight-review > strong {
  text-transform: capitalize;
}

.preflight-review.ready > strong {
  color: var(--ready);
}

.preflight-review.needs_changes > strong {
  color: var(--accent);
}

.preflight-review.blocked > strong,
.error-text {
  color: var(--danger);
}

.preflight-review p,
.prompt-rewrite p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.preflight-review ul {
  margin: 6px 0 10px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.prompt-rewrite {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.prompt-rewrite button {
  margin-top: 8px;
}

.atlas-preflight-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.asset-modal-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.asset-form {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 12px;
}

.asset-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inline-check input {
  width: auto;
}

.asset-library {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
}

.asset-library h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.asset-library h4 {
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.asset-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 8px;
  margin-top: 8px;
}

.asset-card img,
.asset-card-placeholder {
  width: 86px;
  aspect-ratio: 1.2;
  border-radius: 6px;
  background: #090a0c;
  object-fit: cover;
}

.asset-card-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.asset-card strong,
.asset-card span {
  display: block;
}

.asset-card strong {
  font-size: 13px;
}

.asset-card span,
.asset-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.asset-card p {
  margin-top: 6px;
}

.palette-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14171b;
  padding: 9px;
  margin-top: 8px;
}

.palette-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.palette-card-header strong,
.palette-card-header span {
  display: block;
}

.palette-card-header strong {
  font-size: 13px;
}

.palette-card-header span {
  color: var(--muted);
  font-size: 12px;
}

.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.palette-swatches span {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.palette-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.small-action-button {
  min-height: 28px;
  margin-top: 8px;
  padding: 0 9px;
  color: var(--text);
  font-size: 12px;
}

.confirm-modal {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.modal-header h2 {
  margin-top: 2px;
  font-size: 16px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confirm-copy {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.job-modal-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.job-modal-summary div {
  min-width: 0;
}

.job-modal-summary .job-stale-warning {
  grid-column: 1 / -1;
  border: 1px solid rgba(242, 184, 75, 0.42);
  border-radius: 8px;
  background: rgba(242, 184, 75, 0.08);
  padding: 9px;
}

.job-modal-summary strong,
.job-modal-summary span {
  display: block;
}

.job-modal-summary strong {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.job-modal-summary span {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-log-output {
  margin: 0;
  overflow: auto;
  background: #080a0d;
  color: #dce4ea;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(480px, 1fr) 320px;
  }

  .app-shell.chat-collapsed {
    grid-template-columns: 220px minmax(480px, 1fr) 56px;
  }

  .viewer-row {
    grid-template-columns: 1fr;
  }

  .inspector {
    max-height: 220px;
  }

  .inspector-scroll {
    padding-bottom: 14px;
  }
}

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

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .app-shell.chat-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .chat-panel {
    border: 0;
  }

  .chat-panel.collapsed {
    min-height: 56px;
  }

  .workspace {
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .asset-modal-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

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

  .asset-form,
  .asset-library {
    overflow: visible;
  }

  .job-modal-summary {
    grid-template-columns: 1fr;
  }
}
