:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #68707c;
  --line: #d9dee7;
  --soft: #f4f6f9;
  --paper: #ffffff;
  --accent: #116b67;
  --accent-strong: #0b514d;
  --gold: #b87918;
  --danger: #b23b3b;
  --shadow: 0 20px 50px rgba(32, 36, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(17, 107, 103, 0.10), transparent 34%),
    linear-gradient(315deg, rgba(184, 121, 24, 0.10), transparent 38%),
    #eef2f5;
  color: var(--ink);
}

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

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 28px auto;
}

.workspace {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 222, 231, 0.9);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 56px);
  padding: 24px;
}

.topbar,
.file-row,
.controls,
.progress-meta,
.results-head,
.card-title {
  display: flex;
  align-items: center;
}

.topbar,
.results-head {
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
}

h2 {
  font-size: 22px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.input-band,
.mode-switch,
.controls,
.progress-wrap,
.results-head,
.result-card {
  margin-top: 20px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-button {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 14px 18px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
}

.mode-button strong { font-size: 16px; }
.mode-button span { color: var(--muted); font-size: 13px; }
.mode-button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: rgba(17, 107, 103, 0.06); }
.mode-button.shorts.active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: rgba(184, 121, 24, 0.08); }
.mode-button .mode-badge { position: absolute; top: 8px; right: 10px; color: #fff; background: var(--gold); padding: 2px 6px; font-size: 10px; font-weight: 800; }
.shorts-only { display: none; }
.shorts-mode .chapter-only { display: none; }
.shorts-mode .shorts-only { display: grid; }

.toggle-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  cursor: pointer;
}

.toggle-row input {
  width: auto;
  accent-color: var(--accent);
}

.input-band {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 18px;
}

.file-row {
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-picker span,
button,
select {
  min-height: 42px;
}

.file-picker span,
.primary,
.secondary,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
}

.file-picker span,
.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 0 16px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 107, 103, 0.16);
}

#storyInput {
  min-height: 270px;
  resize: vertical;
  padding: 16px;
  line-height: 1.65;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
}

.primary {
  justify-self: start;
  min-width: 190px;
}

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

.label,
.control label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.number-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
}

.number-field input {
  border: 0;
  padding: 0 12px;
  min-height: 42px;
}

.number-field span {
  padding-right: 12px;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.segmented label {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #fff;
}

select {
  padding: 0 12px;
}

.primary {
  align-self: end;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 700;
}

.primary:hover,
.primary:focus {
  background: var(--accent-strong);
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
  font-size: 24px;
}

.progress-meta {
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.progress-track {
  height: 12px;
  background: #dfe5ec;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.results {
  display: grid;
  gap: 14px;
  padding-bottom: 20px;
}

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

.card-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.segment-title {
  font-size: 18px;
}

.segment-meta {
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.result-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.result-card label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.copy-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.copy-btn:hover,
.copy-btn:focus {
  border-color: var(--accent);
  background: #fff;
}

.script-field {
  resize: vertical;
  line-height: 1.6;
  padding: 12px;
  min-height: 180px;
}

.production-note {
  margin: -2px 0 12px;
  padding: 9px 11px;
  color: var(--accent-strong);
  background: rgba(17, 107, 103, 0.08);
  border-left: 3px solid var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.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;
}

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

  .primary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: 100%;
    margin: 0;
  }

  .workspace {
    min-height: 100vh;
    padding: 18px;
  }

  .topbar,
  .results-head {
    align-items: flex-start;
  }

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

  .mode-switch { grid-template-columns: 1fr; }

  .card-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
