:root {
  --page: #f2f4f1;
  --surface: #ffffff;
  --surface-soft: #f7f8f6;
  --ink: #18201e;
  --muted: #68716e;
  --line: #dce2de;
  --line-strong: #c7d0cb;
  --teal: #087f75;
  --teal-dark: #05675f;
  --teal-soft: #e5f3f0;
  --coral: #d86145;
  --coral-soft: #f9e9e4;
  --yellow: #f1c75b;
  --danger: #b42318;
  --danger-soft: #fcebea;
  --shadow: 0 18px 48px rgba(27, 39, 35, 0.1);
  --radius: 8px;
  --topbar-height: 70px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid rgba(8, 127, 117, 0.22);
  outline-offset: 2px;
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 0.82fr) minmax(560px, 1.18fr);
  background: var(--surface);
}

.login-panel {
  width: min(390px, calc(100% - 64px));
  margin: auto;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid #111817;
  border-radius: 7px;
  color: #fff;
  background: #18201e;
  font-size: 13px;
  font-weight: 850;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  font-size: 11px;
}

.eyebrow {
  display: block;
  margin: 28px 0 10px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.3;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-subtitle {
  margin: 10px 0 38px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel .button {
  margin-top: 14px;
}

.login-visual {
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 56px;
  color: #fff;
  background: #1f2725;
}

.flow-poster {
  width: min(650px, 100%);
  aspect-ratio: 5 / 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 4.5vw, 58px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  background: #84cfc2;
  color: #12201e;
  box-shadow: 30px 30px 0 #da674b, -20px -20px 0 rgba(241, 199, 91, 0.96);
  transform: rotate(-2deg);
}

.poster-head,
.poster-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 850;
}

.flow-poster > strong {
  font-size: clamp(48px, 6vw, 92px);
  line-height: 0.9;
  letter-spacing: 0;
}

.poster-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.poster-track i {
  height: 11px;
  background: #17201e;
}

.poster-track i:nth-child(4),
.poster-track i:nth-child(5),
.poster-track i:nth-child(6) {
  background: rgba(23, 32, 30, 0.28);
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: 250px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

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

.brand > span:last-child {
  min-width: 0;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.project-switcher {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.project-select {
  width: min(420px, 100%);
  height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-soft);
}

.status-pill,
.badge,
.difficulty,
.shot-time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill,
.badge.teal {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.badge.coral {
  color: #a6412b;
  background: var(--coral-soft);
}

.badge.neutral,
.shot-time,
.difficulty {
  color: #505956;
  background: #eef1ef;
}

.top-actions,
.action-row,
.dialog-actions,
.card-actions,
.shot-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.top-actions {
  justify-content: flex-end;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    transform 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

.button.primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button.secondary {
  color: var(--teal-dark);
  border-color: #abd2cb;
  background: var(--teal-soft);
}

.button.coral {
  color: #fff;
  background: var(--coral);
}

.button.quiet {
  color: #404946;
  border-color: var(--line);
  background: var(--surface);
}

.button.danger {
  color: var(--danger);
  border-color: #efc2bd;
  background: var(--danger-soft);
}

.button.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.button.full {
  width: 100%;
}

.button.linkish {
  min-height: auto;
  padding: 0;
  border: 0;
  color: var(--teal);
  background: transparent;
}

.task-bar {
  position: fixed;
  z-index: 60;
  top: var(--topbar-height);
  left: 0;
  width: 100%;
  min-height: 36px;
  padding: 8px 24px 8px 274px;
  border-bottom: 1px solid #bcd9d3;
  background: #edf8f5;
}

.task-bar p {
  padding-right: 120px;
  margin: 0;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 750;
}

.task-bar > .button {
  position: absolute;
  top: 4px;
  right: 18px;
  min-height: 28px;
}

.task-track {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  overflow: hidden;
  background: #d6ebe7;
}

.task-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 250ms ease;
}

.shell {
  min-height: calc(100vh - var(--topbar-height));
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 20px 16px 28px;
  border-right: 1px solid var(--line);
  background: #f8f9f7;
}

.stage-nav {
  display: grid;
  gap: 3px;
  margin-top: 18px;
}

.stage-nav button {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  grid-template-rows: 1fr;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  color: #5f6865;
  background: transparent;
  text-align: left;
}

.stage-nav button:hover {
  color: var(--ink);
  background: #eef1ef;
}

.stage-nav button.active {
  color: #fff;
  background: #1d2926;
}

.stage-nav button.done::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #79c7ba;
}

.stage-nav button > span {
  font-size: 11px;
  font-weight: 850;
}

.stage-nav button strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-nav button small {
  font-size: 8px;
  font-weight: 850;
  opacity: 0.55;
}

.sidebar-projects {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-title {
  display: flex;
  justify-content: space-between;
  margin: 0 8px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

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

.project-item {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  color: #4f5855;
  background: transparent;
  text-align: left;
}

.project-item:hover,
.project-item.active {
  color: var(--ink);
  background: #e9eeeb;
}

.project-item strong,
.project-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.project-item small {
  color: var(--muted);
  font-size: 10px;
}

.workspace {
  min-width: 0;
  padding: 36px clamp(24px, 4vw, 64px) 80px;
}

.workspace-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.stage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.stage-number {
  display: block;
  margin-bottom: 7px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
}

.stage-head h1,
.empty-project h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.stage-head p {
  max-width: 650px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.stage-head .action-row {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.stage-section {
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2,
.panel h2,
.dialog h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-head p,
.panel-copy,
.field-hint,
.empty-copy {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-field {
  min-width: 0;
}

.form-field.span-2 {
  grid-column: span 2;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: #343c3a;
  font-size: 12px;
  font-weight: 750;
}

.required-dot {
  color: var(--coral);
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  outline: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input {
  min-height: 42px;
  padding: 0 11px;
}

.textarea {
  min-height: 104px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.62;
}

.textarea.compact {
  min-height: 76px;
}

.textarea.prompt {
  min-height: 150px;
  font-size: 12px;
}

.input:focus,
.textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 117, 0.1);
}

.form-error {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel.tint {
  border-color: #bbdcd6;
  background: #edf7f5;
}

.panel.coral-tint {
  border-color: #efcfc6;
  background: #fdf3f0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.fact-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.asset-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.asset-card.master {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 127, 117, 0.1);
}

.asset-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #edf0ee;
  cursor: zoom-in;
}

.asset-info {
  min-width: 0;
  padding: 10px;
}

.asset-info strong {
  display: block;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.upload-slot {
  position: relative;
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed #9bb2ab;
  border-radius: var(--radius);
  color: #52605c;
  background: #f7faf8;
  text-align: center;
  cursor: pointer;
}

.upload-slot:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.upload-slot strong,
.upload-slot small {
  display: block;
}

.upload-slot strong {
  margin-bottom: 6px;
  font-size: 14px;
}

.upload-slot small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.upload-slot input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

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

.fact {
  min-width: 0;
  padding: 16px;
  border-left: 3px solid #b9dcd6;
  background: var(--surface-soft);
}

.fact.wide {
  grid-column: 1 / -1;
}

.fact p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tag-list,
.plain-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tag-list li {
  padding: 6px 9px;
  border: 1px solid #d8e3df;
  border-radius: 999px;
  color: #40514c;
  background: #fff;
  font-size: 11px;
  line-height: 1.35;
}

.plain-list {
  display: grid;
  gap: 7px;
}

.plain-list li {
  position: relative;
  padding-left: 15px;
  color: #3f4845;
  font-size: 12px;
  line-height: 1.55;
}

.plain-list li::before {
  content: "";
  position: absolute;
  top: 0.65em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
}

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

.idea-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.idea-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(24, 32, 30, 0.07);
}

.idea-card.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 127, 117, 0.1);
}

.idea-index {
  color: var(--coral);
  font-size: 11px;
  font-weight: 850;
}

.idea-card h3 {
  margin: 7px 0 5px;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.idea-tagline {
  min-height: 42px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.idea-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.idea-detail {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.idea-detail strong {
  display: block;
  margin: 0 0 5px;
  font-size: 11px;
}

.idea-detail p {
  margin: 0 0 11px;
  color: #515b58;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.idea-card .card-actions {
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
}

.story-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 16px;
}

.story-meta {
  display: grid;
  gap: 8px;
}

.story-meta div {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.story-meta div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.story-meta span,
.story-meta strong {
  display: block;
}

.story-meta span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.story-meta strong {
  font-size: 12px;
  line-height: 1.5;
}

.voiceover-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.voiceover-script {
  min-height: 180px;
}

.voiceover-timeline {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.voiceover-segment {
  min-width: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
}

.voiceover-segment span,
.voiceover-segment small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.voiceover-segment p {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.end-card-editor {
  display: grid;
  align-content: start;
  gap: 12px;
  border-top: 3px solid var(--coral);
}

.shot-list {
  display: grid;
  gap: 14px;
}

.shot-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.shot-card[open] {
  border-color: var(--line-strong);
}

.shot-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.shot-summary::-webkit-details-marker {
  display: none;
}

.shot-number {
  font-size: 21px;
  font-weight: 850;
}

.shot-summary-copy {
  min-width: 0;
}

.shot-summary-copy strong,
.shot-summary-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-summary-copy strong {
  font-size: 13px;
}

.shot-summary-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.shot-summary-badges {
  display: flex;
  gap: 6px;
}

.shot-body {
  padding: 18px;
  border-top: 1px solid var(--line);
}

.segment-beats {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface-muted, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--line);
  border-radius: 10px;
}

.segment-line {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.6;
}

.segment-line strong {
  display: inline-block;
  min-width: 40px;
  margin-right: 8px;
  color: var(--muted, #6b7280);
  font-weight: 600;
}

.beat-list {
  margin: 10px 0 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.beat-list li {
  font-size: 13px;
  line-height: 1.6;
}

.beat-dialogue {
  display: block;
  color: var(--accent, #0d9488);
}

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

.shot-fields .wide {
  grid-column: 1 / -1;
}

.frame-list {
  display: grid;
  gap: 18px;
}

.frame-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr);
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.frame-media {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #e9edeb;
}

.frame-media.portrait {
  aspect-ratio: 2 / 3;
}

.frame-media.landscape {
  aspect-ratio: 3 / 2;
}

.frame-media.square {
  aspect-ratio: 1 / 1;
}

.frame-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.frame-placeholder {
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #78817e;
  background: repeating-linear-gradient(
    -45deg,
    #eef1ef 0,
    #eef1ef 12px,
    #e8ece9 12px,
    #e8ece9 24px
  );
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.generation-running {
  animation: generation-pulse 1.4s ease-in-out infinite alternate;
}

.generation-note,
.generation-error {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.55;
}

.generation-note {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.generation-error {
  color: #8f3828;
  background: var(--coral-soft);
  overflow-wrap: anywhere;
}

@keyframes generation-pulse {
  from { opacity: 0.62; }
  to { opacity: 1; }
}

.frame-order {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 9px;
  min-width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: rgba(24, 32, 30, 0.86);
  font-size: 11px;
  font-weight: 850;
}

.frame-form {
  min-width: 0;
}

.frame-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.frame-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.frame-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.frame-form .form-field + .form-field {
  margin-top: 12px;
}

.frame-form .shot-actions {
  flex-wrap: wrap;
  margin-top: 13px;
}

.continuity-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 9px 11px;
  border-left: 3px solid var(--teal);
  color: #34423e;
  background: #eef6f4;
}

.continuity-bar span,
.continuity-bar small {
  font-size: 10px;
  font-weight: 800;
}

.continuity-bar span {
  color: var(--teal-dark);
}

.continuity-bar strong {
  min-width: 0;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.continuity-bar small {
  color: var(--muted);
  text-align: right;
}

.video-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.video-card:first-child {
  border-top: 0;
}

.video-thumb {
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: #e9edeb;
}

.video-thumb.portrait {
  aspect-ratio: 2 / 3;
}

.video-thumb.landscape {
  aspect-ratio: 3 / 2;
}

.video-thumb.square {
  aspect-ratio: 1 / 1;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.video-content {
  min-width: 0;
}

.video-content h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.video-content > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
}

.prompt-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.prompt-box + .prompt-box {
  margin-top: 9px;
}

.prompt-box span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.prompt-box p {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.video-content .shot-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.tail-handoff {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 13px 0 0;
  border-top: 1px solid var(--line);
}

.tail-handoff-copy {
  min-width: 0;
}

.tail-handoff-copy span,
.tail-handoff-copy strong,
.tail-handoff-copy small {
  display: block;
}

.tail-handoff-copy span {
  margin-bottom: 3px;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 850;
}

.tail-handoff-copy strong {
  font-size: 12px;
  line-height: 1.4;
}

.tail-handoff-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.tail-frame-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 5px;
  cursor: zoom-in;
}

.material-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.material-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  text-align: center;
}

.material-ref {
  font-size: 12px;
  font-weight: 600;
}

.material-thumb img,
.material-missing {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
}

.material-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9a9a90;
  background: #f0f0ec;
  cursor: default;
}

.material-name {
  font-size: 11px;
  line-height: 1.3;
  color: #6b6b63;
}

.material-role {
  font-size: 10px;
  line-height: 1.2;
  color: #9a9a90;
}

.material-item {
  width: 92px;
}

.video-tutorial summary {
  cursor: pointer;
  font-size: 14px;
}

.video-tutorial .tutorial-body {
  margin-top: 10px;
}

.tutorial-steps {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: #4a4a44;
}

.tutorial-steps ul {
  margin: 4px 0;
  padding-left: 18px;
}

.tutorial-steps code {
  background: #ecece7;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 12px;
}

.material-nudge {
  margin: 8px 0 0;
  font-size: 12px;
  color: #b3541e;
}

.tail-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.video-state-fields {
  margin-top: 10px;
}

.edit-note {
  margin-top: 8px;
}

.checklist {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.check-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.check-row.done .check-mark {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.check-copy strong,
.check-copy span {
  display: block;
}

.check-copy strong {
  font-size: 12px;
}

.check-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.export-option {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.export-option h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.export-option p {
  min-height: 42px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.assembly-list {
  border-top: 1px solid var(--line);
}

.history-list {
  border-top: 1px solid var(--line);
}

.history-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}

.history-row strong,
.history-row small {
  display: block;
}

.history-row strong {
  font-size: 12px;
}

.history-row small,
.history-counts {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.history-counts {
  margin: 0;
  white-space: nowrap;
}

.assembly-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(150px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}

.assembly-index {
  font-size: 18px;
  font-weight: 850;
}

.assembly-row strong,
.assembly-row small {
  display: block;
  overflow-wrap: anywhere;
}

.assembly-row strong {
  font-size: 12px;
}

.assembly-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.end-card-summary {
  display: grid;
  grid-template-columns: auto minmax(160px, 0.4fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 15px 16px;
  border-left: 3px solid var(--coral);
  background: var(--coral-soft);
}

.end-card-summary span {
  color: #8f3828;
  font-size: 10px;
  font-weight: 850;
}

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

.end-card-summary p {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.empty-state,
.empty-project {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 46px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.empty-project {
  min-height: calc(100vh - var(--topbar-height) - 116px);
  border: 0;
  background: transparent;
}

.empty-state > div,
.empty-project > div {
  width: min(560px, 100%);
}

.empty-code {
  display: block;
  margin-bottom: 12px;
  color: var(--coral);
  font-size: 11px;
  font-weight: 850;
}

.empty-state h2 {
  margin: 0;
  font-size: 22px;
}

.empty-state .action-row,
.empty-project .action-row {
  justify-content: center;
  margin-top: 20px;
}

.process-line {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 28px 0;
}

.process-line span {
  min-width: 0;
  padding: 10px 5px;
  border-top: 3px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}

.process-line span:nth-child(1),
.process-line span:nth-child(2),
.process-line span:nth-child(3) {
  border-color: var(--teal);
}

.process-line span:nth-child(4),
.process-line span:nth-child(5) {
  border-color: var(--coral);
}

.dialog {
  width: min(680px, calc(100vw - 30px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog::backdrop,
.preview-dialog::backdrop {
  background: rgba(18, 25, 23, 0.62);
  backdrop-filter: blur(3px);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.dialog-head {
  border-bottom: 1px solid var(--line);
}

.dialog-head .eyebrow {
  margin: 0 0 5px;
}

.dialog-body {
  padding: 20px;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.dialog-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #59615f;
  background: transparent;
  font-size: 25px;
  line-height: 1;
}

.dialog-close:hover {
  background: #edf0ee;
}

.dialog-close.dark {
  color: #fff;
}

.dialog-grid {
  margin-top: 16px;
}

.preview-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-width: none;
  height: min(90vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: #111716;
  box-shadow: var(--shadow);
}

.preview-head {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 18px;
  color: #fff;
  background: #111716;
  font-size: 12px;
  font-weight: 750;
}

.preview-dialog img {
  width: 100%;
  height: calc(100% - 52px);
  object-fit: contain;
  background: #171e1c;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid #28433d;
  border-radius: 7px;
  color: #fff;
  background: #1d2926;
  box-shadow: 0 10px 30px rgba(10, 18, 16, 0.22);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-color: #d28f85;
  background: #7e281d;
}

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

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 210px minmax(220px, 1fr) auto;
  }

  .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .task-bar {
    padding-left: 244px;
  }

  .stage-nav button {
    grid-template-columns: 28px 1fr;
  }

  .stage-nav button small {
    display: none;
  }

  .asset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  :root {
    --topbar-height: 64px;
  }

  .login-view {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 42px 0;
  }

  .login-visual {
    display: none;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 0 14px;
  }

  .brand > span:last-child,
  .status-pill,
  .desktop-only {
    display: none !important;
  }

  .project-switcher {
    justify-content: stretch;
  }

  .project-select {
    width: 100%;
  }

  .top-actions .button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 11px;
  }

  .task-bar {
    top: var(--topbar-height);
    padding: 8px 14px;
  }

  .task-bar p {
    padding-right: 108px;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 25;
    top: var(--topbar-height);
    width: 100%;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    display: block;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 249, 247, 0.96);
    backdrop-filter: blur(14px);
  }

  .sidebar > .button,
  .sidebar-projects {
    display: none;
  }

  .stage-nav {
    width: max-content;
    min-width: 100%;
    display: flex;
    gap: 5px;
    margin: 0;
  }

  .stage-nav button {
    min-width: 108px;
    grid-template-columns: 22px 1fr;
    min-height: 42px;
    padding: 6px 8px;
  }

  .stage-nav button.done::after {
    left: 12px;
    bottom: 4px;
  }

  .workspace {
    padding: 26px 18px 70px;
  }

  .stage-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .stage-head .action-row {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .idea-grid,
  .story-overview,
  .voiceover-grid,
  .frame-card {
    grid-template-columns: 1fr;
  }

  .frame-media {
    width: min(430px, 100%);
    max-height: 560px;
    justify-self: center;
  }

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

@media (max-width: 620px) {
  .workspace {
    padding: 22px 14px 64px;
  }

  .stage-head h1,
  .empty-project h1 {
    font-size: 28px;
  }

  .form-grid.two,
  .form-grid.three,
  .form-grid.four,
  .fact-grid,
  .export-grid,
  .metric-strip,
  .shot-fields {
    grid-template-columns: 1fr;
  }

  .voiceover-segment,
  .history-row,
  .assembly-row,
  .end-card-summary {
    grid-template-columns: 1fr;
  }

  .history-row .button {
    justify-self: start;
  }

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

  .continuity-bar small {
    grid-column: 2;
    text-align: left;
  }

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

  .tail-frame-thumb {
    display: none;
  }

  .form-field.span-2,
  .fact.wide,
  .shot-fields .wide {
    grid-column: auto;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

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

  .upload-slot {
    min-height: 150px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head .action-row,
  .shot-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .section-head .button,
  .shot-actions .button {
    flex: 1 1 auto;
  }

  .shot-summary {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding: 10px 12px;
  }

  .shot-summary-badges {
    grid-column: 2;
  }

  .frame-card {
    padding: 12px;
  }

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

  .video-thumb {
    width: min(270px, 100%);
    max-height: 400px;
    justify-self: center;
  }

  .check-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .check-row .button {
    grid-column: 2;
    justify-self: start;
  }

  .dialog-grid {
    grid-template-columns: 1fr !important;
  }

  .dialog-actions .button {
    flex: 1;
  }
}

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

/* Per-field AI optimize header */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.field-head .field-label {
  margin-bottom: 0;
}
.button.micro {
  min-height: 26px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
}
.button.ghost {
  color: var(--coral);
  border-color: var(--coral-soft);
  background: var(--coral-soft);
}
.button.ghost:hover:not(:disabled) {
  border-color: var(--coral);
}

/* Idea co-creation chat */
.idea-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.idea-chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty {
  color: #6b7571;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}
.chat-msg {
  display: flex;
}
.chat-msg.user {
  justify-content: flex-end;
}
.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.chat-msg.user .chat-bubble {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}
.chat-bubble.thinking {
  color: #6b7571;
  font-style: italic;
}
.idea-chat-input {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.idea-chat-input .textarea {
  flex: 1;
}
.idea-chat-input .button {
  flex: 0 0 auto;
}
.idea-card.draft {
  border-style: dashed;
  border-color: var(--coral);
  background: var(--coral-soft);
}
.shot-outline .shot-sec {
  display: inline-block;
  min-width: 30px;
  margin-right: 8px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

/* 智能多帧 */
.mf-section { margin-top: 16px; }
.mf-groups { display: grid; gap: 14px; }
.mf-group { border: 1px solid var(--line, #e4e4df); border-radius: 12px; padding: 14px; background: #fff; }
.mf-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mf-frames { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.mf-frames li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #444; }
.mf-frames .shot-sec { flex: none; }
