:root {
  color-scheme: light;
  --bg: #eef3fb;
  --sidebar: #0f172a;
  --sidebar-soft: #18233a;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f9f6e;
  --warning: #b7791f;
  --danger: #dc2626;
  --border: #d9e2ef;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top right, #dbeafe 0, transparent 28%), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
  color: #1f2a44;
  background: #e8eef9;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .62; transform: none; }
.primary { background: var(--primary); color: #fff; box-shadow: 0 10px 22px rgba(37,99,235,.24); }
.primary:hover { background: var(--primary-dark); }
.primary.generating {
  background: var(--danger);
  box-shadow: 0 10px 22px rgba(220,38,38,.32);
  animation: pulse-danger 1.6s ease-in-out infinite;
}
.primary.generating:hover { background: #b91c1c; }
@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 10px 22px rgba(220,38,38,.32); }
  50% { box-shadow: 0 14px 32px rgba(220,38,38,.52); }
}
.ghost { background: transparent; border: 1px solid var(--border); box-shadow: none; }
.guide-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--primary-dark);
  background: #ffffff;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}
.guide-link:hover { transform: translateY(-1px); }
.full { width: 100%; }
.tiny { padding: 5px 8px; border-radius: 8px; font-size: 12px; }

.app-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  color: #dbeafe;
  background: linear-gradient(180deg, var(--sidebar), #111827);
  border-right: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  font-weight: 900;
}
.brand strong { display: block; font-size: 18px; color: #fff; }
.brand span { display: block; margin-top: 3px; color: #93a4bf; font-size: 12px; }
.side-section { margin-top: 22px; }
.side-title { color: #93a4bf; font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.row-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.template-list { display: grid; gap: 10px; }
.template-menu {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding-right: 4px;
}
.template-menu[hidden] { display: none; }
.template-menu::-webkit-scrollbar { width: 6px; }
.template-menu::-webkit-scrollbar-thumb { background: rgba(147, 197, 253, .38); border-radius: 999px; }
.template-menu::-webkit-scrollbar-track { background: transparent; }
.template-menu-toggle,
.template-category-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  color: #dbeafe;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: none;
}
.template-menu-toggle { padding: 12px 14px; }
.template-menu-toggle span,
.template-category-title span { font-size: 13px; font-weight: 900; color: #fff; }
.template-menu-toggle small,
.template-category-title small { color: #93a4bf; font-size: 12px; font-weight: 700; }
.template-menu-toggle::after,
.template-category-title::after { content: "›"; color: #93c5fd; font-size: 18px; transition: transform .16s ease; }
.template-menu-toggle.open::after,
.template-category-title.open::after { transform: rotate(90deg); }
.template-menu-toggle:hover,
.template-category-title:hover { background: rgba(37,99,235,.18); transform: none; }
.template-category { display: grid; gap: 8px; }
.template-category-title { padding: 9px 12px; border-radius: 10px; }
.template-category-items { display: grid; gap: 8px; padding-left: 10px; border-left: 1px solid rgba(147,197,253,.25); }
.template-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-areas: "icon name" "icon lang";
  gap: 3px 10px;
  text-align: left;
  color: #dbeafe;
  background: transparent;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: none;
}
.template-item span { grid-area: icon; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--sidebar-soft); font-size: 11px; font-weight: 900; color: #93c5fd; }
.template-item strong { grid-area: name; font-size: 13px; color: #fff; }
.template-item small { grid-area: lang; color: #93a4bf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-item.active, .template-item:hover { background: rgba(37,99,235,.22); border-color: rgba(96,165,250,.5); transform: none; }


.history-side { padding-bottom: 20px; }
.history-list { display: grid; gap: 10px; }
.history-item {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.04);
}
.history-item strong { display: block; color: #fff; font-size: 13px; line-height: 1.4; max-height: 38px; overflow: hidden; }
.history-item span { display: block; margin-top: 6px; color: #93a4bf; font-size: 12px; }
.history-item p { margin: 8px 0 0; color: #cbd5e1; font-size: 12px; line-height: 1.5; }
.history-actions { display: flex; gap: 8px; margin-top: 10px; }
.history-actions button { flex: 1; padding: 7px 8px; border-radius: 9px; font-size: 12px; }
.history-actions .danger { background: rgba(220, 38, 38, .16); color: #fecaca; }
.history-actions .danger:hover { background: rgba(220, 38, 38, .28); }

.workspace { min-width: 0; padding: 26px; }


.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow.small { font-size: 11px; }
h1 { margin: 0; font-size: clamp(26px, 3.5vw, 42px); line-height: 1.08; }
h2 { margin: 0; font-size: 20px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.badge, .status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #eef4ff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}
.badge.muted { background: #f2f4f7; color: #475467; }
.status.success { background: #ecfdf3; color: var(--success); }
.status.processing { background: #fff7ed; color: var(--warning); }
.status.error { background: #fef2f2; color: var(--danger); }

.config-card, .panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.config-card { padding: 10px 18px; margin-bottom: 18px; }
details { border-bottom: 1px solid var(--border); padding: 14px 0; }
details:last-child { border-bottom: 0; }
summary { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; cursor: pointer; list-style: none; font-weight: 850; }
summary::-webkit-details-marker { display: none; }
summary em { color: var(--muted); font-style: normal; font-size: 13px; font-weight: 500; }
.config-layout { display: grid; gap: 12px; margin-top: 16px; }
.config-group {
  border: 1px solid #e7edf7;
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.group-head strong { color: #1d2939; font-size: 14px; }
.group-head span { color: var(--muted); font-size: 12px; line-height: 1.5; text-align: right; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.connection-grid { grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.1fr) minmax(280px, 1.1fr); }
.wide-field { min-width: 0; }
.model-row { display: grid; grid-template-columns: minmax(220px, .9fr) minmax(280px, 1.2fr) auto; align-items: end; gap: 14px; }
.model-add-field { min-width: 0; }
.model-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.danger { color: var(--danger); background: #fff1f2; border-color: #fecdd3; }
.danger:hover { background: #ffe4e6; }
.sync-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); margin-top: 16px; }
label { display: grid; gap: 8px; color: #344054; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}
textarea { resize: vertical; line-height: 1.58; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.split-actions { justify-content: space-between; }
.split-actions > div { display: flex; gap: 10px; flex-wrap: wrap; }
.config-actions { padding-top: 2px; }
.config-actions .hint { max-width: 520px; text-align: right; }
.hint { color: var(--muted); margin: 0; line-height: 1.55; }
.hint.mini { color: #93a4bf; font-size: 12px; }

.main-grid { display: grid; grid-template-columns: minmax(360px, .86fr) minmax(0, 1.14fr); gap: 18px; align-items: start; }
.left-stack { display: grid; gap: 18px; align-content: start; }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.composer { display: grid; gap: 14px; }

.diagnosis-panel { border-color: rgba(37,99,235,.18); padding: 16px; box-shadow: 0 14px 36px rgba(15, 23, 42, .08); max-height: 340px; overflow-y: auto; flex-shrink: 0; }
.diagnosis-panel .panel-head { margin-bottom: 12px; align-items: flex-start; }
.diagnosis-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.diagnosis-head-right .tiny { padding: 4px 8px; font-size: 11px; transition: transform .2s; }
.diagnosis-head-right .tiny.collapsed { transform: rotate(-90deg); }
.diagnosis-detail { overflow: hidden; transition: max-height .35s ease, opacity .25s ease; max-height: 800px; opacity: 1; }
.diagnosis-detail.collapsed { max-height: 0; opacity: 0; margin: 0; }
.diagnosis-panel.collapsed-panel { max-height: 62px; overflow: hidden; cursor: pointer; }
.diagnosis-panel h2 { font-size: 18px; }
.diagnosis-panel .badge { max-width: 180px; white-space: normal; text-align: center; justify-content: center; line-height: 1.35; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.metrics div { min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: #f8fbff; padding: 10px 11px; }
.metrics span { display: block; font-size: 15px; font-weight: 900; color: var(--primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrics small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.diagnosis-summary { margin: 12px 0; color: #344054; line-height: 1.58; font-size: 13px; }
.diagnosis-lists { display: grid; grid-template-columns: 1fr; gap: 10px; }
.diagnosis-lists div { min-width: 0; border-radius: 14px; background: #f8fafc; padding: 11px 12px; border: 1px solid var(--border); }
.diagnosis-lists strong { display: block; margin-bottom: 6px; font-size: 13px; }
.diagnosis-lists ul { max-height: 132px; overflow: auto; padding-right: 4px; }
.diagnosis-lists li { margin-bottom: 4px; }
ul { margin: 0; padding-left: 18px; color: #475467; line-height: 1.6; }

.output-panel { display: flex; flex-direction: column; height: calc(100vh - 164px); min-height: 560px; position: sticky; top: 18px; }
.output-tabs { display: flex; gap: 6px; margin-top: 6px; }
.output-tab {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.output-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(37,99,235,.18);
}
.output-tab:hover:not(.active) { background: #eef4ff; color: var(--primary-dark); }
.output-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#output, #promptOutput, .preview {
  flex: 1;
  min-height: 0;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 18px;
  padding: 18px;
  overflow: auto;
  line-height: 1.68;
}
#output, #promptOutput { background: #0f172a; color: #dbeafe; }
#output:empty::after,
#output.placeholder::after {
  content: "✨ 输入需求并点击「生成指令」，AI 将在诊断后自动生成完整开发指令。";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  font-size: 15px;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.7;
}
#promptOutput:empty::after,
#promptOutput.placeholder::after {
  content: "✨ 生成后将在此显示可直接复制给 AI 使用的 Prompt 指令。";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  font-size: 15px;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.7;
}
.preview { background: #ffffff; color: #172033; border: 1px solid var(--border); }
.preview h1, .preview h2, .preview h3 { margin: 1em 0 .45em; }
.preview li { margin-left: 18px; }

.log-panel {
  margin-top: 18px;
  height: 112px;
  overflow: auto;
  border-radius: 18px;
  padding: 12px;
  background: #111827;
  color: #d1d5db;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.log-entry { padding: 3px 0; }
.log-entry.success { color: #86efac; }
.log-entry.error { color: #fca5a5; }
.log-entry.warn { color: #fcd34d; }
.log-entry.info { color: #bfdbfe; }

.app-footer {
  text-align: center;
  padding: 10px 0 6px;
  font-size: 11px;
  color: #94a3b8;
  border-top: 1px solid #e2e8f0;
  margin-top: 12px;
}

.guide-page {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0, #dbeafe 0, transparent 30%), radial-gradient(circle at 100% 10%, #ede9fe 0, transparent 30%), var(--bg);
}
.guide-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.guide-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 850;
}
.guide-nav a {
  color: var(--primary-dark);
  text-decoration: none;
  padding: 9px 13px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
}
.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}
.guide-hero > div,
.guide-card,
.guide-flow article {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.guide-hero > div { padding: 28px; }
.guide-hero p { color: var(--muted); line-height: 1.75; font-size: 16px; }
.guide-hero-card { display: grid; align-content: center; gap: 12px; }
.guide-hero-card strong { font-size: 22px; }
.guide-hero-card span { color: #475467; line-height: 1.7; }
.guide-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.guide-flow article { padding: 16px; position: relative; overflow: hidden; }
.guide-flow b {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.guide-flow strong { display: block; margin-bottom: 6px; }
.guide-flow span { color: var(--muted); font-size: 13px; line-height: 1.55; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.guide-card { padding: 22px; }
.guide-card.wide { grid-column: 1 / -1; }
.guide-card h2 { margin-bottom: 14px; }
.guide-card h3 { margin: 0 0 8px; }
.guide-card p { color: #475467; line-height: 1.75; }
.guide-card li { margin-bottom: 8px; color: #475467; line-height: 1.65; }
.guide-card pre {
  overflow: auto;
  margin: 12px 0;
  padding: 14px;
  border-radius: 16px;
  color: #dbeafe;
  background: #0f172a;
  line-height: 1.65;
}
.guide-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.compare { display: grid; gap: 12px; }
.compare div {
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #f8fbff;
}
.compare strong { display: block; margin-bottom: 6px; color: var(--primary-dark); }
.compare span { color: #475467; line-height: 1.65; }
.mini-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.mini-flow span {
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: #eef4ff;
  font-weight: 850;
}
.mindmap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.mindmap div {
  min-height: 92px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
  border: 1px solid #dbeafe;
  font-weight: 900;
}
.mindmap small { color: var(--muted); font-weight: 650; line-height: 1.5; }
.mindmap .mind-root {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: 0;
  font-size: 20px;
}
.doc-layout {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.doc-sidebar {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.doc-sidebar a,
.doc-card {
  color: inherit;
  text-decoration: none;
}
.doc-sidebar a {
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 850;
}
.doc-sidebar a.active,
.doc-sidebar a:hover {
  color: var(--primary-dark);
  background: #eef4ff;
}
.doc-card {
  display: block;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(15, 23, 42, .12);
}
.doc-card h2 { margin-bottom: 10px; }
.doc-card p { color: var(--muted); line-height: 1.7; }
.doc-card-grid .doc-card.wide { grid-column: 1 / -1; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .connection-grid, .model-row, .sync-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-actions { justify-content: flex-start; }
  .main-grid { grid-template-columns: 1fr; }
  .guide-hero, .guide-two-col, .doc-layout { grid-template-columns: 1fr; }
  .doc-sidebar { position: static; }
  .guide-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mindmap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .output-panel { min-height: 520px; }
  #output, .preview { min-height: 420px; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; }
  .workspace { padding: 18px; }
  .topbar, .panel-head, summary, .group-head { align-items: flex-start; flex-direction: column; }
  .group-head span { text-align: left; }
  .config-grid, .connection-grid, .model-row, .sync-grid, .metrics, .diagnosis-lists { grid-template-columns: 1fr; }
  .guide-grid, .guide-flow, .mindmap { grid-template-columns: 1fr; }
  .guide-shell { width: min(100% - 24px, 1180px); padding-top: 16px; }
  .guide-hero > div, .guide-card { padding: 18px; }
  .guide-nav { align-items: flex-start; flex-direction: column; }
  .actions, .split-actions, .split-actions > div, .model-actions, .output-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .config-actions .hint { max-width: none; text-align: left; }
  button { width: 100%; }
  .guide-link, .guide-nav a { width: 100%; }
}

