:root {
  --bg: #fff8ef;
  --surface: #ffffff;
  --surface-soft: #fffaf2;
  --ink: #24304a;
  --text: #42526e;
  --muted: #7d8aa3;
  --line: #f0dfc7;
  --blue: #2687d8;
  --blue-strong: #1667aa;
  --orange: #f5a936;
  --purple: #9b64f5;
  --pink: #f678b9;
  --mint: #73c9a4;
  --cream: #fff2d9;
  --green: #20a87b;
  --shadow-sm: 0 10px 24px rgba(115, 84, 42, 0.08);
  --shadow-md: 0 18px 48px rgba(115, 84, 42, 0.13);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family:
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  background: var(--bg);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.studio-shell {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  grid-template-rows: 74px minmax(0, 1fr);
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 214, 119, 0.34), transparent 20%),
    radial-gradient(circle at 94% 10%, rgba(141, 216, 245, 0.32), transparent 22%),
    linear-gradient(135deg, rgba(115, 201, 164, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(246, 120, 185, 0.08), transparent 28%),
    var(--bg);
}

.global-header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 74px;
  padding: 0 28px 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(18px);
  z-index: 30;
}

.global-brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  color: var(--ink);
  text-decoration: none;
}

.global-brand img {
  width: 118px;
  height: auto;
}

.global-brand strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  line-height: 1;
}

.global-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar {
  position: relative;
  top: auto;
  grid-column: 1;
  grid-row: 2;
  min-height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background: rgba(255, 253, 248, 0.94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.project-card {
  width: 100%;
  padding: 18px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background:
    linear-gradient(145deg, rgba(36, 48, 74, 0.38), rgba(36, 48, 74, 0.02)),
    linear-gradient(135deg, #2d8dd2, #68c7b3 58%, #f4b340);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.project-card.is-active {
  box-shadow: 0 16px 36px rgba(38, 123, 198, 0.24);
}

.project-card.is-complete {
  opacity: 0.92;
}

.eyebrow,
.page-kicker,
.status-pill {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.project-card .eyebrow {
  color: rgba(255, 255, 255, 0.76);
}

.project-card h1 {
  margin: 8px 0 8px;
  font-size: 26px;
  line-height: 1.2;
  text-align: center;
}

.project-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

.side-steps {
  display: grid;
  gap: 10px;
}

.side-step {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
  text-align: left;
}

.side-step span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  background: #eef3f8;
  font-weight: 900;
}

.side-step b {
  font-size: 15px;
}

.side-step small {
  color: var(--muted);
  font-size: 12px;
}

.side-step.is-active {
  border-color: rgba(33, 119, 199, 0.25);
  background: #eef7ff;
}

.side-step.is-active span {
  color: #fff;
  background: var(--blue);
}

.side-step.is-complete span {
  color: var(--green);
  background: #e6f7f1;
}

.usage-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.usage-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.usage-card strong {
  display: block;
  margin-top: 2px;
  font-size: 30px;
  line-height: 1;
}

.usage-card button {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}

.page-kicker {
  margin: 0 0 6px;
  color: var(--blue);
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiet-button,
.accent-button,
.avatar-button,
.primary-button,
.secondary-button,
.outline-button,
.primary-blue {
  height: 42px;
  border-radius: var(--radius);
  font-weight: 800;
}

.quiet-button {
  padding: 0 16px;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--surface);
}

.accent-button {
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: 0 12px 26px rgba(138, 53, 255, 0.22);
}

.avatar-button {
  width: 42px;
  color: var(--blue-strong);
  border: 2px solid #8ad9ff;
  background: #e9f9ff;
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.progress-step {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
  font-weight: 900;
}

.progress-step span {
  margin-right: 10px;
  color: inherit;
}

.progress-step.is-active {
  color: var(--blue-strong);
  border-color: rgba(33, 119, 199, 0.35);
  background: #ecf7ff;
}

.progress-step.is-complete {
  color: var(--green);
  background: #effaf6;
}

.screen {
  display: none;
}

.screen.is-visible {
  display: block;
}

.screen-grid,
.review-layout,
.storyboard-layout,
.params-layout {
  min-height: calc(100vh - 150px);
}

.story-grid {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(460px, 560px);
  align-items: start;
  gap: 18px;
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 0.82fr) minmax(420px, 1fr);
  align-items: center;
  min-height: 330px;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 222, 131, 0.54), transparent 25%),
    linear-gradient(135deg, #fffdf7, #e9f8ff 54%, #fff0cf);
  box-shadow: var(--shadow-sm);
}

.hero-copy {
  max-width: 620px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  color: #8a5a09;
  background: #fff0c6;
}

.hero-copy h2 {
  margin: 16px 0 12px;
  font-size: 20px;
  line-height: 1.55;
  font-weight: 900;
}

.hero-copy p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.storybook-visual {
  position: relative;
  height: 270px;
  margin: 0;
  overflow: hidden;
  border: 6px solid #fff;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 22px 54px rgba(65, 83, 103, 0.16);
  transform: rotate(1.2deg);
}

.storybook-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 248, 228, 0.28));
  pointer-events: none;
}

.storybook-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-card,
.insight-panel,
.script-paper,
.review-tools,
.shot-list,
.shot-preview,
.option-card,
.property-panel,
.page-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow-sm);
}

.composer-card {
  grid-column: 1;
  grid-row: 1;
  padding: 18px;
}

.segmented,
.upload-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border-radius: var(--radius);
  background: #fff0d7;
}

.segmented button,
.upload-tabs button {
  height: 40px;
  padding: 0 18px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.segmented button.is-active,
.upload-tabs button.is-active {
  color: var(--ink);
  background: #fffdf8;
  box-shadow: var(--shadow-sm);
}

.composer-panel {
  margin-top: 18px;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 900;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestions button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 800;
}

.suggestions .refresh {
  color: var(--purple);
  border-color: rgba(138, 53, 255, 0.24);
  background: #f6f0ff;
}

.story-input,
.import-text,
.subtitle-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  outline: 0;
  resize: none;
}

.story-input {
  min-height: 180px;
  padding: 18px;
  font-size: 18px;
  line-height: 1.8;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}

.composer-footer.action-bottom {
  justify-content: flex-end;
  padding-top: 4px;
}

.thinking-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 99px;
  color: var(--blue-strong);
  background: #eaf6ff;
  font-size: 13px;
  font-weight: 900;
}

.primary-button,
.secondary-button,
.outline-button {
  padding: 0 20px;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #2f96df, #8f78f7 52%, #f678b9);
  box-shadow: 0 14px 30px rgba(143, 120, 247, 0.2);
}

.secondary-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
}

.outline-button {
  color: var(--blue-strong);
  border: 1px solid rgba(33, 119, 199, 0.38);
  background: #f8fcff;
}

.full {
  width: 100%;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.control-row label,
.size-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

select,
.size-grid input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
}

.switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: #cdd6e2;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.upload-drop {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin-top: 14px;
  border: 1px dashed #b9c7d8;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.file-icons {
  display: flex;
  gap: 10px;
}

.file-icons span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 58px;
  border: 2px solid #9ec7e8;
  border-radius: 7px;
  color: var(--blue-strong);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.upload-drop p {
  margin: 14px 0 4px;
  color: var(--text);
  font-weight: 900;
}

.import-text {
  min-height: 210px;
  margin-top: 14px;
  padding: 16px;
  line-height: 1.8;
}

.insight-panel {
  grid-column: 2;
  padding: 18px;
}

.side-hero-panel {
  grid-row: 1;
  grid-template-columns: 1fr;
  gap: 22px;
  justify-self: end;
  width: 100%;
  max-width: 540px;
  min-width: 420px;
  min-height: 0;
  align-self: start;
  padding: 26px;
}

.side-hero-panel .hero-copy {
  max-width: 760px;
}

.side-hero-panel .storybook-visual {
  height: 220px;
  width: 100%;
  transform: none;
}

.hero-copy h3 {
  margin: 12px 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.45;
}

.side-hero-panel .hero-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.3;
}

.insight-panel h3,
.review-tools h3,
.shot-preview h3,
.property-panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.metric-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.metric-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.metric-list span {
  color: var(--muted);
  font-weight: 800;
}

.metric-list b {
  font-size: 18px;
}

.mini-cover {
  position: relative;
  display: grid;
  align-content: end;
  height: 340px;
  padding: 22px;
  overflow: hidden;
  border-radius: var(--radius);
  color: #fff;
  background:
    linear-gradient(180deg, rgba(36, 48, 74, 0.04), rgba(36, 48, 74, 0.54)),
    url("assets/storybook-hero.png") center / cover;
}

.mini-cover img {
  position: absolute;
  top: 30px;
  left: 26px;
  width: 210px;
  opacity: 0.13;
}

.mini-cover strong {
  position: relative;
  font-size: 34px;
  line-height: 1.1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.2);
}

.mini-cover span {
  position: relative;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.review-layout,
.storyboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.script-paper,
.shot-list {
  padding: 24px;
}

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

.section-head h2 {
  margin: 10px 0 0;
  font-size: 28px;
}

.word-count {
  color: var(--muted);
  font-weight: 900;
}

.script-paper p {
  margin: 0 0 22px;
  color: #4b5a6b;
  font-size: 19px;
  line-height: 2;
}

.review-tools,
.shot-preview {
  padding: 18px;
  height: max-content;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  color: var(--text);
  font-weight: 800;
}

.check-row b {
  width: 14px;
  height: 14px;
  border: 2px solid #c7d2df;
  border-radius: 50%;
}

.check-row.is-done b {
  border-color: var(--green);
  background: var(--green);
}

.review-tools .primary-button,
.shot-preview .primary-button,
.shot-preview .secondary-button {
  margin-top: 16px;
}

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

.shot-card + .shot-card {
  margin-top: 14px;
}

.shot-card.is-selected {
  border-color: rgba(33, 119, 199, 0.38);
  background: #f1f8ff;
}

.shot-card label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 900;
}

.shot-card input {
  accent-color: var(--blue);
}

.shot-card p {
  margin: 10px 0 0;
  color: #536273;
  line-height: 1.8;
}

.frame-preview {
  display: grid;
  align-content: end;
  height: 220px;
  padding: 18px;
  border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(circle at 70% 22%, #f8de9a, transparent 18%),
    linear-gradient(150deg, #1a2a44, #3a6f71 58%, #d19a2d);
}

.frame-preview span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 900;
}

.frame-preview b {
  margin-top: 86px;
  font-size: 18px;
}

.params-layout {
  display: grid;
  gap: 16px;
  padding-bottom: 124px;
}

.option-card {
  padding: 20px;
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, 110px);
  gap: 12px;
}

.ratio {
  display: grid;
  place-items: center;
  gap: 10px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  font-weight: 900;
}

.ratio i {
  width: 50px;
  height: 30px;
  border: 3px solid #8ebee5;
  border-radius: 5px;
}

.ratio.is-selected {
  color: #8a5a09;
  border-color: rgba(245, 169, 54, 0.68);
  background: #fff4d8;
}

.ratio.is-selected i {
  border-color: var(--orange);
}

.model-grid,
.style-grid,
.template-grid {
  display: grid;
  gap: 14px;
}

.model-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.model-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
}

.model-card.is-selected,
.style-tile.is-selected,
.template-card.is-selected {
  border-color: rgba(245, 169, 54, 0.72);
  box-shadow: 0 0 0 4px rgba(245, 169, 54, 0.14);
}

.model-thumb {
  display: block;
  height: 118px;
}

.thumb-a { background: url("assets/storybook-hero.png") 22% 50% / 220% auto; }
.thumb-b { background: url("assets/storybook-hero.png") 50% 48% / 190% auto; }
.thumb-c { background: url("assets/storybook-hero.png") 73% 45% / 205% auto; }
.thumb-d { background: url("assets/storybook-hero.png") 38% 62% / 185% auto; }

.model-card b,
.model-card small {
  display: block;
  padding: 0 14px;
}

.model-card b {
  margin-top: 12px;
  font-size: 17px;
}

.model-card small {
  margin: 5px 0 14px;
  color: var(--muted);
}

.style-grid {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.style-tile {
  position: relative;
  height: 126px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: #dfe7ef;
}

.style-tile span {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.26);
}

.style-tile::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 60%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.36));
}

.style-tile span {
  z-index: 1;
}

.style-forest { background: url("assets/storybook-hero.png") 20% 52% / 210% auto; }
.style-watercolor { background: linear-gradient(135deg, rgba(255, 205, 218, 0.72), rgba(137, 214, 255, 0.72)), url("assets/storybook-hero.png") center / cover; }
.style-ink { background: linear-gradient(135deg, rgba(255, 251, 238, 0.8), rgba(102, 149, 128, 0.68)), url("assets/storybook-hero.png") 38% 55% / 190% auto; }
.style-clay { background: linear-gradient(135deg, rgba(238, 148, 102, 0.75), rgba(246, 200, 121, 0.7)), url("assets/storybook-hero.png") 58% 56% / 200% auto; }
.style-pencil { background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(198, 207, 218, 0.82)), url("assets/storybook-hero.png") 72% 42% / 210% auto; }
.style-dream { background: linear-gradient(135deg, rgba(38, 24, 80, 0.74), rgba(111, 70, 194, 0.42)), url("assets/storybook-hero.png") 70% 34% / 180% auto; }

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

.template-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  font-weight: 900;
}

.template-scene {
  display: block;
  height: 140px;
  border-radius: 6px;
}

.scene-a { background: url("assets/storybook-hero.png") center / cover; }
.scene-b { background: linear-gradient(90deg, rgba(255, 253, 248, 0.94) 0 42%, rgba(255, 253, 248, 0.46) 42% 100%), url("assets/storybook-hero.png") 74% 50% / cover; }
.scene-c { background: linear-gradient(135deg, rgba(255, 248, 221, 0.92), rgba(255, 255, 255, 0.65) 48%, rgba(202, 232, 214, 0.75)), url("assets/storybook-hero.png") 46% 44% / cover; }

.sticky-actions {
  position: fixed;
  left: 304px;
  right: 22px;
  bottom: 18px;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.editor-screen {
  margin: -4px -4px 0;
}

.editor {
  display: grid;
  grid-template-columns: 76px 230px minmax(0, 1fr) 260px;
  height: calc(100vh - 118px);
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

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

.editor.is-auto .tool-rail,
.editor.is-auto .page-panel,
.editor.is-auto .property-panel {
  display: none;
}

.tool-rail,
.page-panel,
.property-panel {
  border-right: 1px solid var(--line);
  background: #fff;
}

.tool-rail {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px 8px;
}

.tool-rail button {
  height: 54px;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
  font-weight: 900;
}

.tool-rail button.is-active {
  color: #fff;
  background: var(--blue);
}

.page-panel {
  padding: 18px;
  overflow: auto;
}

.new-scene {
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  color: var(--blue-strong);
  background: #eaf6ff;
  font-weight: 900;
}

.page-panel p {
  color: var(--muted);
  font-weight: 900;
}

.page-thumb {
  position: relative;
  display: block;
  width: 100%;
  height: 122px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f7fafc;
  text-align: left;
}

.page-thumb.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(33, 119, 199, 0.11);
}

.page-thumb span {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  color: #fff;
  background: #65758a;
  font-size: 12px;
  font-weight: 900;
}

.page-thumb b {
  display: block;
  margin: 58px 16px 0;
  color: #a26516;
  font-size: 22px;
}

.canvas-workspace {
  display: grid;
  grid-template-rows: 62px minmax(0, 1fr);
  min-width: 0;
  background: #f4f6fa;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.editor-actions h2 {
  flex: 1;
  min-width: 92px;
  margin: 0;
  text-align: center;
  font-size: 18px;
  white-space: nowrap;
}

.editor-actions button {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text);
  background: #eef3f8;
  font-weight: 900;
}

.editor-actions .primary-blue {
  color: #fff;
  background: var(--blue);
}

.editor-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
}

.editor-mode-switch button {
  height: 30px;
  min-width: 64px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.editor-mode-switch button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 8px 18px rgba(33, 119, 199, 0.18);
}

.editor-panel {
  min-height: 0;
}

.editor-panel[hidden] {
  display: none !important;
}

.manual-editor {
  display: grid;
  grid-template-rows: minmax(440px, 1fr) 220px;
}

.canvas-stage {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.canvas-board {
  position: relative;
  width: min(100%, 980px);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 247, 229, 0.22)),
    linear-gradient(45deg, #d7dce4 25%, transparent 25% 75%, #d7dce4 75%),
    linear-gradient(45deg, #d7dce4 25%, transparent 25% 75%, #d7dce4 75%),
    #edf1f6;
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
}

.canvas-board::before {
  content: "";
  position: absolute;
  inset: 42px 64px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(36, 48, 74, 0.3)),
    url("assets/storybook-hero.png") center / cover;
  box-shadow: var(--shadow-md);
}

.ai-badge {
  position: absolute;
  top: 58px;
  left: 82px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  font-size: 26px;
  font-weight: 900;
}

.cover-title {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 360px;
  height: 220px;
  border-radius: 50%;
  color: #8f5b0d;
  background: rgba(255, 247, 218, 0.84);
  text-align: center;
  box-shadow: 0 18px 44px rgba(84, 61, 34, 0.18);
}

.cover-title img {
  position: absolute;
  width: 230px;
  opacity: 0.15;
}

.cover-title h3 {
  margin: 0;
  font-size: 44px;
}

.cover-title p {
  margin: -18px 0 0;
  font-size: 20px;
  font-weight: 900;
}

.cover-title small {
  margin-top: -18px;
  color: var(--blue-strong);
  font-weight: 900;
}

.subtitle-panel {
  border-top: 1px solid var(--line);
  background: #fff;
}

.subtitle-toolbar {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 42px;
  padding: 0 16px;
  color: var(--muted);
  font-weight: 800;
}

.subtitle-toolbar b {
  margin-right: auto;
  color: var(--ink);
}

.subtitle-panel textarea {
  width: calc(100% - 32px);
  height: 110px;
  margin: 0 16px 16px;
  padding: 14px;
}

.auto-editor {
  grid-template-columns: minmax(520px, 1.05fr) minmax(480px, 0.95fr);
  gap: 28px;
  padding: 26px 30px;
  overflow: hidden;
  background: #f4f6fa;
}

.auto-editor.is-visible {
  display: grid;
}

.auto-preview,
.auto-script-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow-sm);
}

.auto-preview {
  display: grid;
  grid-template-rows: auto auto auto;
  padding: 28px;
}

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

.auto-screen-head h3 {
  max-width: 320px;
  margin: 12px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.auto-screen-head > span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
}

.auto-canvas {
  position: relative;
  align-self: start;
  width: min(92%, 760px);
  aspect-ratio: 16 / 9;
  margin: 34px auto 18px;
  overflow: hidden;
  border: 10px solid #fff;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(22, 31, 52, 0.12), rgba(22, 31, 52, 0.28)),
    url("assets/storybook-hero.png") center / cover;
  box-shadow: 0 24px 54px rgba(36, 48, 74, 0.18);
}

.auto-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 246, 186, 0.5), transparent 24%),
    linear-gradient(180deg, transparent 45%, rgba(17, 29, 52, 0.42));
}

.auto-canvas .ai-badge {
  top: 24px;
  left: 24px;
  z-index: 2;
}

.auto-caption {
  position: absolute;
  left: 32px;
  bottom: 28px;
  z-index: 2;
  display: grid;
  gap: 4px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(17, 29, 52, 0.55);
}

.auto-caption b {
  font-size: 38px;
}

.auto-caption small {
  font-size: 16px;
  font-weight: 900;
}

.auto-page-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 8px;
}

.auto-page-strip button {
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  font-weight: 900;
  font-size: 18px;
}

.auto-page-strip button.is-active {
  color: #fff;
  border-color: transparent;
  background: var(--blue);
}

.auto-script-panel {
  display: grid;
  grid-template-rows: auto 1fr 1.15fr auto;
  gap: 14px;
  padding: 28px;
  overflow: auto;
}

.auto-script-head span {
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

.auto-script-panel label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.auto-script-panel textarea {
  min-height: 176px;
  padding: 14px;
  resize: vertical;
  color: #000;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.7;
}

.auto-script-panel label:nth-of-type(2) textarea {
  min-height: 244px;
}

.auto-tips {
  display: grid;
  gap: 12px;
}

.auto-tips span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.auto-editor.is-generating .auto-canvas::before {
  content: "生成中...";
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(42, 55, 83, 0.48);
  font-size: 24px;
  font-weight: 900;
}

.property-panel {
  padding: 0 16px 18px;
  border-right: 0;
  border-left: 1px solid var(--line);
  box-shadow: none;
  overflow: auto;
}

.panel-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  height: 58px;
  align-items: end;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-tabs button {
  height: 42px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.panel-tabs button.is-active {
  color: var(--blue);
  border-bottom: 3px solid var(--blue);
}

.size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.property-panel h3 {
  margin-top: 22px;
}

.property-panel select {
  margin-top: 10px;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 120px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
}

.help-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 20;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(33, 119, 199, 0.25);
}

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

  .story-grid,
  .review-layout,
  .storyboard-layout {
    grid-template-columns: 1fr;
  }

  .insight-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .mini-cover {
    height: 240px;
  }

  .model-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .style-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .sticky-actions {
    left: 262px;
  }

  .editor {
    grid-template-columns: 70px 240px minmax(0, 1fr);
  }

  .property-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  body {
    overflow-x: hidden;
  }

  .studio-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-x: hidden;
  }

  .global-header {
    position: relative;
    flex-wrap: wrap;
    height: auto;
    padding: 14px;
  }

  .global-brand {
    width: 100%;
    gap: 12px;
  }

  .global-brand img {
    width: 110px;
  }

  .global-brand strong {
    font-size: 18px;
  }

  .global-actions {
    width: 100%;
    overflow-x: auto;
  }

  .sidebar {
    position: relative;
    top: auto;
    grid-column: 1;
    grid-row: 2;
    height: auto;
  }

  .main {
    grid-column: 1;
    grid-row: 3;
  }

  .side-steps {
    display: flex;
    overflow-x: auto;
  }

  .side-step {
    min-width: 180px;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .composer-footer,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-strip,
  .control-row,
  .ratio-grid,
  .model-grid,
  .style-grid,
  .template-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .progress-strip {
    overflow-x: auto;
  }

  .progress-step {
    min-width: 160px;
  }

  .storybook-visual {
    display: none;
  }

  .hero-copy h2 {
    font-size: 20px;
  }

  .insight-panel,
  .composer-card,
  .script-paper,
  .shot-list,
  .option-card {
    padding: 16px;
  }

  .sticky-actions {
    position: static;
    flex-direction: column;
    margin-top: 16px;
  }

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

  .page-panel {
    min-width: 0;
  }

  .canvas-workspace {
    grid-column: 1 / -1;
  }

  .editor-actions {
    flex-wrap: wrap;
    padding: 10px;
  }

  .editor-actions h2 {
    order: -1;
    width: 100%;
  }

  .property-panel {
    grid-column: 1 / -1;
  }

  .help-fab {
    right: 14px;
    bottom: 14px;
    width: 52px;
    height: 52px;
    font-size: 13px;
  }
}
