:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #666666;
  --muted-2: #8a8a8a;
  --surface: #f7f7f7;
  --surface-2: #fbfbfb;
  --border: #e6e6e6;
  --border-strong: #d7d7d7;
  --accent: #2f6feb;
  --accent-strong: #1f55c8;
  --success: #13795b;
  --danger: #b42318;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow: 0 30px 80px rgba(0, 0, 0, .06), 0 12px 30px rgba(0, 0, 0, .04);
  --shadow-sm: 0 16px 40px rgba(0, 0, 0, .06);
  --max: 1180px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img, video, iframe { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  left: 18px;
  top: 14px;
  z-index: 1000;
  transform: translateY(-130%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: #fff;
  padding: 10px 14px;
  transition: transform .18s var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition: transform .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 10px 24px rgba(47, 111, 235, .18); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--fg); }
.btn-secondary:hover { background: var(--surface); border-color: var(--border-strong); }
.btn[disabled], button[disabled] { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }

.nav-link:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
.view-toggle button:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible,
.modal-close:focus-visible,
.wb-tool-btn:focus-visible,
.wb-scenario:focus-visible,
.wb-mode-toggle button:focus-visible,
.wb-views-toggle button:focus-visible,
.wb-type-btn:focus-visible,
.wb-full-tab:focus-visible {
  outline: 3px solid rgba(47, 111, 235, .22);
  outline-offset: 2px;
}

.brand, .tool-brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark, .tool-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--fg);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  flex: 0 0 auto;
}
.brand-text, .tool-brand {
  display: grid;
  gap: 0;
  min-width: 0;
}
.brand-text strong, .tool-brand strong {
  color: var(--fg);
  font-size: 15px;
  line-height: 1.25;
}
.brand-text span, .tool-brand span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-kicker, .eyebrow, .wb-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.tag, .type-chip, .play-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}
.tag.blue, .type-chip { color: var(--accent); border-color: rgba(47, 111, 235, .28); background: rgba(47, 111, 235, .07); }
.tag.green { color: var(--success); border-color: rgba(19, 121, 91, .24); background: rgba(19, 121, 91, .07); }
.tag.red, .play-chip { color: var(--danger); border-color: rgba(180, 35, 24, .22); background: rgba(180, 35, 24, .06); }

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.field.full { grid-column: 1 / -1; }
.field label {
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
}
.field input,
.field textarea,
.field select,
.select,
.search-wrap input,
.wb-keyword,
.wb-text-area,
.wb-template-editor {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--fg);
  padding: 11px 12px;
  font-size: 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.field textarea,
.wb-template-editor { min-height: 110px; resize: vertical; }
.field input:focus,
.field textarea:focus,
.field select:focus,
.select:focus,
.search-wrap input:focus,
.wb-keyword:focus,
.wb-text-area:focus,
.wb-template-editor:focus {
  border-color: rgba(47, 111, 235, .58);
  box-shadow: 0 0 0 4px rgba(47, 111, 235, .1);
  outline: 0;
}
.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, .44);
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative;
  width: min(960px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, .9);
  color: var(--fg);
  font-size: 20px;
  line-height: 1;
}
.modal-player { background: #000; }
.modal-player video,
.modal-player iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}
.modal-info { padding: 28px; }
.modal-info h2 {
  margin: 0 0 10px;
  color: var(--fg);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: 0;
}
.modal-info p { color: var(--muted); margin: 0 0 18px; }
.modal-meta, .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.prompt-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 16px;
  margin: 16px 0;
}
.prompt-box pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
  color: var(--fg);
}
.external-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 64px 24px;
  text-align: center;
  color: #fff;
}
.external-panel p { max-width: 42ch; margin: 0; color: rgba(255, 255, 255, .82); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 300;
  transform: translateY(12px);
  opacity: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), opacity .18s var(--ease);
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.workbench-modal {
  width: min(1120px, 100%);
  max-height: min(92vh, 920px);
}
.wb-inner { display: grid; gap: 24px; padding: 28px; }
.wb-head {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}
.wb-head h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1.03;
  letter-spacing: 0;
}
.wb-head p { max-width: 62ch; margin: 0; color: var(--muted); }
.wb-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.wb-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 12px;
}
.wb-step > span {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--fg);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}
.wb-step strong { display: block; font-size: 13px; line-height: 1.25; }
.wb-step small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.wb-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.wb-rail,
.wb-compose {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.wb-rail { position: sticky; top: 82px; display: grid; gap: 14px; padding: 18px; }
.wb-rail-title,
.wb-compose-title {
  margin: 0;
  color: var(--fg);
  font-size: 15px;
  font-weight: 800;
}
.wb-compose-sub,
.wb-rail-note,
.wb-type-help,
.wb-gen-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.wb-types { display: grid; gap: 8px; }
.wb-type-btn,
.wb-tool-btn,
.wb-scenario,
.wb-mode-toggle button,
.wb-views-toggle button,
.wb-full-tab {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--fg);
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.wb-type-btn:hover,
.wb-tool-btn:hover,
.wb-scenario:hover,
.wb-mode-toggle button:hover,
.wb-views-toggle button:hover,
.wb-full-tab:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.wb-type-btn {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 12px;
  text-align: left;
}
.wb-type-btn.active {
  border-color: rgba(47, 111, 235, .36);
  background: rgba(47, 111, 235, .07);
  color: var(--accent);
}
.wb-type-name { font-size: 14px; font-weight: 800; }
.wb-type-use { color: var(--muted); font-size: 12px; line-height: 1.4; }
.wb-tool-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.wb-rail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wb-tool-btn { min-height: 38px; padding: 8px 12px; font-size: 13px; font-weight: 750; }
.wb-compose { display: grid; gap: 18px; padding: 20px; min-width: 0; }
.wb-compose-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}
.wb-scenarios { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.wb-scenario { min-height: 36px; padding: 7px 11px; font-size: 13px; font-weight: 700; }
.wb-scenario.active,
.wb-mode-toggle button.active,
.wb-views-toggle button.active,
.wb-full-tab.active {
  border-color: var(--fg);
  background: var(--fg);
  color: #fff;
}
.wb-mode-toggle,
.wb-views-toggle,
.wb-full-tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.wb-mode-toggle button,
.wb-views-toggle button,
.wb-full-tab {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 750;
}
.wb-keyword {
  min-height: 150px;
  resize: vertical;
  font-size: 15px;
}
.wb-gen-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.wb-status,
.wb-result,
.wb-actions { display: none; }
.wb-status.show,
.wb-result.show,
.wb-actions.show { display: block; }
.wb-stream {
  min-height: 86px;
  max-height: 230px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}
.wb-stream.empty::before { content: "等待模型响应..."; color: var(--muted); }
.wb-result {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 16px;
}
.wb-form-view,
.wb-text-view { min-width: 0; }
.wb-text-area { min-height: 420px; resize: vertical; font-family: Consolas, "SFMono-Regular", monospace; }
.wb-actions {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.wb-actions.show { display: flex; gap: 10px; flex-wrap: wrap; }
.prompt-editor,
.wb-shot-fields,
.wb-top-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.wb-prompt-editor { display: grid; gap: 14px; }
.wb-shot-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 14px;
  margin-top: 14px;
}
.wb-shot-head {
  color: var(--fg);
  font-size: 14px;
  margin-bottom: 12px;
}
.wb-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}
.wb-empty h4 { margin: 0 0 6px; color: var(--fg); }

@media (max-width: 900px) {
  .modal-overlay { padding: 14px; }
  .modal { max-height: 92vh; }
  .form-grid,
  .wb-layout,
  .prompt-editor,
  .wb-shot-fields,
  .wb-top-fields { grid-template-columns: 1fr; }
  .wb-rail { position: static; }
  .wb-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wb-compose-top { display: grid; }
}

@media (max-width: 560px) {
  .btn { width: 100%; white-space: normal; }
  .brand-text span, .tool-brand span { white-space: normal; }
  .modal-info, .wb-inner { padding: 18px; }
  .wb-head h2 { font-size: 34px; }
  .wb-steps { grid-template-columns: 1fr; }
  .toast { left: 14px; right: 14px; }
}
