:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-muted: #eceeea;
  --ink: #171918;
  --muted: #646a67;
  --line: #d6dad5;
  --teal: #087f76;
  --teal-dark: #05645d;
  --teal-soft: #e1f2ef;
  --coral: #d85f49;
  --coral-soft: #fff0ec;
  --yellow: #f1c75b;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(23, 25, 24, 0.07);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  transform: translateY(-150%);
  padding: 10px 14px;
  color: white;
  background: var(--ink);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 72px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-index {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.brand-name, .brand-meta { margin: 0; }
.brand-name { font-size: 15px; font-weight: 760; }
.brand-meta { margin-top: 2px; color: var(--muted); font-size: 12px; }
.connection-status {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #b9d7d3;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 1fr);
  min-height: calc(100vh - 73px);
}
.composer, .output { min-width: 0; padding: 32px; }
.composer { border-right: 1px solid var(--line); background: var(--surface); }
.output { background: var(--bg); }
.section-heading, .output-heading, .weekly-heading, .field-label-row, .result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.visual-intro {
  position: relative;
  isolation: isolate;
  min-height: 196px;
  margin: -32px -32px 0;
  padding: 28px 32px;
  align-items: flex-end;
  overflow: hidden;
  background-color: rgba(7, 15, 14, 0.58);
  background-image: url("../assets/dance-editorial-banner.webp");
  background-position: center 55%;
  background-size: cover;
  background-blend-mode: multiply;
}
.visual-intro > * { position: relative; z-index: 1; }
.visual-intro .eyebrow { color: #8fe0d7; }
.visual-intro h1 { max-width: 420px; color: white; font-size: 32px; }
.visual-intro .text-button { border-color: rgba(255,255,255,0.62); color: white; background: rgba(15, 22, 21, 0.86); }
.visual-intro .random-button { border-color: #8ed1c9; color: #d8fffa; background: rgba(8, 127, 118, 0.82); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
h1, h2, h3, p { letter-spacing: 0; }
h1 { margin: 0; font-size: 28px; line-height: 1.25; }
h2 { margin: 0; font-size: 18px; line-height: 1.3; }
h3 { margin: 3px 0 0; font-size: 15px; }
.text-button, .icon-button, .copy-button, .published-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}
.text-button { padding: 0 14px; }
.helper-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.random-button { color: var(--teal-dark); border-color: #9dc9c3; background: var(--teal-soft); font-weight: 800; }
.icon-button { width: 44px; font-size: 20px; }

.audience-fieldset { margin: 28px 0 0; padding: 0; border: 0; }
.audience-fieldset legend, .field-label-row label {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
}
.audience-switch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.audience-button {
  min-height: 48px;
  padding: 7px 8px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  line-height: 1.25;
}
.audience-button:last-child { border-right: 0; }
.audience-button[aria-pressed="true"] { color: white; background: var(--ink); }
.daily-recommendation {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--yellow);
  color: #4a4030;
  background: #fff8df;
  font-size: 13px;
}
.material-field { margin-top: 24px; }
.material-field .field-label-row { margin-top: 14px; }
.field-label-row span { color: var(--muted); font-size: 12px; }
textarea {
  width: 100%;
  resize: vertical;
  min-height: 170px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: #fbfcfa;
  font-size: 15px;
  line-height: 1.75;
}
textarea:focus, select:focus, button:focus-visible { outline: 3px solid rgba(8, 127, 118, 0.22); outline-offset: 2px; }
.field-error { margin: 8px 0 0; color: #a33f2f; font-size: 13px; }

.step-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.step-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--ink);
  font-size: 11px;
  font-weight: 800;
}
.step-name { margin: 0; font-size: 14px; font-weight: 800; }
.step-note { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.generation-controls { margin-top: 18px; }
.decision-preview {
  min-height: 58px;
  margin-bottom: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #b9d7d3;
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: var(--teal-soft);
}
.decision-preview div { min-width: 0; display: grid; gap: 3px; }
.decision-preview strong, .decision-preview span { overflow-wrap: anywhere; }
.decision-preview strong { font-size: 13px; }
.decision-preview span { color: #4c6561; font-size: 12px; }
.decision-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(8, 127, 118, 0.12); }
.draft-count-fieldset { margin: 0; padding: 0; border: 0; }
.draft-count-fieldset legend { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.segmented-control label { min-width: 0; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  min-height: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: white;
  font-weight: 800;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.segmented-control label + label span { border-left: 1px solid var(--line); }
.segmented-control input:checked + span { color: white; background: var(--ink); }
.segmented-control input:focus-visible + span { outline: 3px solid rgba(8, 127, 118, 0.22); outline-offset: -3px; }
.primary-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: var(--radius);
  color: white;
  background: var(--teal);
  font-weight: 800;
  transition: background 180ms var(--ease), transform 180ms var(--ease);
}
.primary-button:hover { background: var(--teal-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: not-allowed; background: #9ca5a1; opacity: 1; }
.advanced-options { margin-top: 10px; border-bottom: 1px solid var(--line); }
.advanced-options summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 800; }
.advanced-options[open] summary { color: var(--ink); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 4px 0 18px; }
.settings-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.route-settings-note { grid-column: 1 / -1; margin: 2px 0 -3px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.framework-setting { grid-column: 1 / -1; }
select { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: white; }
select:disabled { cursor: not-allowed; color: #929995; background: var(--surface-muted); }

.weekly-panel { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.weekly-coverage { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.coverage-item { min-height: 54px; display: grid; align-content: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); background: var(--surface); font-size: 12px; }
.coverage-item.is-covered { border-color: #9dc9c3; color: var(--teal-dark); background: var(--teal-soft); font-weight: 800; }

.result-count { color: var(--muted); font-size: 13px; font-weight: 800; }
.route-summary { min-height: 46px; margin-top: 20px; display: flex; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); background: var(--surface); font-size: 13px; }
.fact-warnings { margin-top: 10px; padding: 12px 14px; border: 1px solid #f0b8aa; border-radius: var(--radius); color: #8d3b2e; background: var(--coral-soft); font-size: 13px; line-height: 1.5; }
.results { display: grid; gap: 14px; margin-top: 14px; }
.empty-state { min-height: 340px; display: grid; place-items: center; align-content: center; border: 1px dashed #c7cbc7; border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,0.5); text-align: center; }
.empty-state-visual {
  min-height: 380px;
  place-items: start;
  align-content: end;
  padding: 26px;
  border: 0;
  color: white;
  background-color: rgba(8, 18, 17, 0.46);
  background-image: url("../assets/dance-training-detail.webp");
  background-position: center;
  background-size: cover;
  background-blend-mode: multiply;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.24);
}
.empty-state-visual .empty-index { color: #9ee6dd; }
.empty-state-visual p { max-width: 260px; color: white; font-weight: 700; }
.empty-index { font-size: 12px; font-weight: 800; }
.empty-state p { margin: 8px 0 0; }
.result-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; animation: reveal 280ms var(--ease) both; }
.result-card:nth-child(2) { animation-delay: 70ms; }
.result-card:nth-child(3) { animation-delay: 140ms; }
.result-toolbar { min-height: 66px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.result-number { color: var(--teal-dark); font-size: 11px; font-weight: 800; }
.copy-button { min-width: 62px; padding: 0 12px; }
.result-text { margin: 0; padding: 18px; white-space: pre-wrap; word-break: break-word; color: #292d2b; font-family: inherit; font-size: 14px; line-height: 1.75; }
.published-button { width: calc(100% - 28px); margin: 0 14px 14px; color: var(--teal-dark); border-color: #b9d7d3; }
.published-button.is-published { color: white; background: var(--teal); }
.loading-state { min-height: 340px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); color: var(--teal-dark); background: var(--surface); font-weight: 800; }
.error-state { min-height: 180px; padding: 28px; display: grid; place-items: center; gap: 12px; border: 1px solid #efb9ac; border-radius: var(--radius); color: #8d3b2e; background: var(--coral-soft); text-align: center; }
.retry-button { min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius); color: white; background: var(--coral); }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .topbar { min-height: 64px; padding: 10px 16px; }
  .brand-index { width: 38px; height: 38px; }
  .connection-status { display: none; }
  .composer, .output { padding: 22px 16px; }
  h1 { font-size: 23px; }
  .section-heading { align-items: flex-end; }
  .section-heading { flex-wrap: wrap; }
  .visual-intro {
    min-height: 210px;
    margin: -22px -16px 0;
    padding: 22px 16px;
    background-position: 61% 50%;
  }
  .visual-intro h1 { max-width: 320px; font-size: 25px; }
  .helper-actions { width: 100%; justify-content: stretch; }
  .helper-actions .text-button { flex: 1 1 150px; }
  .audience-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 0; gap: 8px; overflow: visible; }
  .audience-button { min-height: 46px; border: 1px solid var(--line); border-radius: var(--radius); }
  .audience-button:last-child { border-right: 1px solid var(--line); }
  .settings-grid { grid-template-columns: 1fr; }
  .generation-controls { margin-top: 18px; }
  .step-index { width: 30px; height: 30px; }
  .weekly-coverage { grid-template-columns: repeat(2, 1fr); }
  .empty-state, .loading-state { min-height: 240px; }
  .empty-state-visual { min-height: 290px; padding: 20px; background-position: 58% center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
