:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --ink: #1d211f;
  --muted: #66706b;
  --line: #dce3dd;
  --accent: #d84f31;
  --accent-strong: #a73922;
  --accent-soft: #fff0eb;
  --teal: #0f766e;
  --teal-soft: #e7f6f3;
  --shadow: 0 16px 40px rgba(29, 33, 31, 0.08);
  --radius: 8px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Aptos", "Yu Gothic", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  background: var(--bg);
}

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

button {
  min-height: 40px;
}

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-kicker,
.mini-label {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(28px, 3.7vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: rgba(15, 118, 110, 0.18);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(520px, 1.12fr);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel,
.output-panel {
  padding: 16px;
}

.section-head,
.result-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2,
.result-title-row h3 {
  margin: 0;
}

.section-head h2 {
  font-size: 24px;
  line-height: 1.1;
}

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #313935;
  font-size: 14px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.55);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.full-width {
  grid-column: 1 / -1;
}

.ai-box {
  display: grid;
  gap: 12px;
  margin: 2px 0 0;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius-lg);
  background: var(--teal-soft);
}

.ai-box legend {
  padding: 0 6px;
  color: var(--teal);
  font-weight: 800;
}

.ai-box p {
  margin: 0;
  color: #47615d;
  font-size: 14px;
  line-height: 1.65;
}

.ai-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, 0.9fr);
  gap: 12px;
}

.inline-actions,
.form-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-actions {
  margin-top: 2px;
}

.toolbar {
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button {
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 750;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button {
  padding: 12px 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 22px rgba(216, 79, 49, 0.18);
}

.compact-button {
  padding: 10px 14px;
  min-height: 40px;
  box-shadow: none;
}

.secondary-button,
.ghost-button {
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.secondary-button {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(216, 79, 49, 0.18);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: progress;
  opacity: 0.65;
  transform: none;
}

.ai-status {
  min-width: min(100%, 260px);
  color: #47615d;
  font-size: 14px;
  line-height: 1.55;
}

.ai-status.error {
  color: var(--accent-strong);
}

.ai-status.success {
  color: var(--teal);
}

.ai-status.loading {
  color: #86520f;
}

.ai-preview {
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  line-height: 1.68;
  white-space: pre-wrap;
}

.empty-state {
  margin-top: 14px;
  padding: 18px;
  border: 1px dashed #c8d4cb;
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.results {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.hidden {
  display: none;
}

.result-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.strategy-card {
  background: #fbfcfa;
}

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

.strategy-grid p,
.scene-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.script-block,
.prompt-block {
  margin: 12px 0 0;
  max-height: 520px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: var(--radius);
  background: #18211e;
  color: #f4fbf6;
  line-height: 1.7;
  font-size: 14px;
}

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

.scene-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.scene-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.scene-index {
  font-size: 16px;
  font-weight: 800;
}

.scene-time {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

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

.scene-meta strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px;
  color: #fff;
  background: rgba(29, 33, 31, 0.92);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(29, 33, 31, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .output-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 100%);
    padding-top: 14px;
  }

  .app-header,
  .section-head,
  .result-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .input-panel,
  .output-panel {
    padding: 16px;
  }

  .form-grid,
  .ai-grid,
  .strategy-grid,
  .scene-meta {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .inline-actions,
  .form-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar button,
  .inline-actions button,
  .form-actions button {
    width: 100%;
  }

  .scene-top {
    align-items: flex-start;
    flex-direction: column;
  }
}

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