:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f6f8fb;
  --panel: #ffffff;
  --accent: #10d675;
  --accent-dark: #079956;
  --navy: #14152c;
  --warning: #b7791f;
  --danger: #c2413b;
  --shadow: 0 10px 32px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: #f4f6fa;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.topbar {
  height: 76px;
  display: grid;
  grid-template-columns: 240px minmax(520px, 1fr) 410px;
  align-items: center;
  padding: 0;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 0 18px;
  color: #ffffff;
  background: var(--navy);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.8px;
}
.brand::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: var(--navy);
}
.topbar-center, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-center { padding: 0 30px; }
.topbar-actions { justify-content: flex-end; color: #4b5563; font-size: 13px; }
.topbar-actions { padding-right: 24px; }
.topbar-actions a:hover { color: var(--accent-dark); }
.guest-auth-actions { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.guest-auth-actions > span { color: #c7cbd1; }
.guest-auth-actions .guest-register-button {
  border-radius: 7px;
  padding: 7px 14px;
  color: #fff;
  background: var(--accent);
}
.guest-auth-actions .guest-register-button:hover { color: #fff; background: var(--accent-dark); }
.product-title { font-weight: 700; }
.member-badge {
  border-radius: 999px;
  padding: 4px 9px;
  color: #07663b;
  background: #e8fff3;
  font-size: 11px;
  font-weight: 700;
}
.member-avatar-link {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.member-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.workbench {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: 240px minmax(520px, 1fr) 410px;
  width: 100%;
  max-width: none;
  margin: 0;
}
.library-panel, .workspace-panel, .output-panel { background: var(--panel); }
.library-panel {
  border-right: 1px solid rgba(255,255,255,.08);
  padding: 26px 18px;
  background: var(--navy);
  color: #ffffff;
}
.library-panel .panel-heading h1 { color: #ffffff; }
.library-panel .panel-heading p { color: #9ca3b8; }
.workspace-panel {
  padding: 28px 30px 56px;
  overflow: hidden;
}
.output-panel {
  border-left: 1px solid var(--line);
  padding: 28px 24px;
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow-y: auto;
}
h1, h2, h3, p { margin: 0; }
.panel-heading h1 { font-size: 18px; }
.panel-heading p, .section-title-row p, .task-switcher p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.search {
  display: block;
  margin: 20px 0 14px;
  color: var(--muted);
  font-size: 11px;
}
.search span { display: block; margin-bottom: 6px; }
.library-panel .search { color: #aeb4c4; }
.search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 11px;
  outline: none;
}
.library-panel .search input {
  color: #f9fafb;
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
}
.library-panel .search input::placeholder { color: #858da2; }
.search input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,214,117,.12); }
.library-nav { display: grid; gap: 4px; }
.library-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 9px 10px;
  color: #4b5563;
  text-align: left;
  cursor: pointer;
}
.library-panel .library-link { color: #d8dce6; }
.library-panel .library-link:hover,
.library-panel .library-link.active {
  color: #ffffff;
  background: rgba(0,214,111,.16);
}
.library-panel .library-link small { color: #858da2; }
.library-link:hover, .library-link.active { background: #ebfff4; color: #087744; }
.library-link small { color: #9ca3af; }
.library-edit-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  object-fit: contain;
}
.text-button {
  margin-top: 18px;
  width: 100%;
  border: 1px dashed #cfd5dd;
  background: transparent;
  border-radius: 8px;
  padding: 9px;
  color: var(--muted);
  cursor: pointer;
}
.library-panel .text-button {
  color: #aeb4c4;
  border-color: rgba(255,255,255,.2);
}
.library-panel .text-button:hover {
  color: #ffffff;
  border-color: rgba(0,214,111,.65);
  background: rgba(0,214,111,.1);
}

.workspace-header, .output-header, .section-title-row, .task-switcher, .section-title-row > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.workspace-header { margin-bottom: 22px; }
.workspace-slogan {
  margin: 34px 0 30px;
  color: var(--accent-dark);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: .04em;
}
.workspace-header h2, .output-header h2 { font-size: 23px; }
.eyebrow {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.7px;
  margin-bottom: 6px;
}
.workspace-actions { display: flex; gap: 10px; align-items: flex-end; margin-left: auto; }
.model-select span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 32px 0 10px;
  outline: none;
}
.task-switcher, .preset-section {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 17px;
  margin-bottom: 18px;
  background: #fff;
}
.task-switcher > div:first-child, .section-title-row > div { display: flex; align-items: center; gap: 12px; }
.step-number {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f0f3f7;
  color: #6b7280;
  font-weight: 700;
}
.task-tabs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.task-tab, .preset-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
}
.task-tab { padding: 9px 12px; color: #4b5563; }
.task-tab.active { color: #087744; border-color: var(--accent); background: #edfff5; font-weight: 700; }
.section-title-row { margin-bottom: 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.preset-card { padding: 12px; text-align: left; }
.preset-card:hover, .preset-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16,214,117,.09); }
.preset-card strong { display: block; margin-bottom: 5px; font-size: 13px; }
.preset-card span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.count-pill { padding: 5px 9px; border-radius: 999px; background: #eef1f5; color: var(--muted); font-size: 11px; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.module-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(17,24,39,.025);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.module-card.flagged { border-color: #edb85c; }
.module-card.is-focused,
.module-card.flagged.is-focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,214,111,.14), 0 6px 18px rgba(0,214,111,.08);
}
.module-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 13px 8px;
}
.module-card-title { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.required-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.module-tools { display: flex; gap: 5px; }
.module-tools button {
  border: 0;
  background: #f2f4f7;
  color: #6b7280;
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
  font-size: 10px;
}
.module-tools button:hover { background: #e7ebf0; color: #111827; }
.module-control { padding: 0 13px 13px; }
.module-control select { width: 100%; }
.module-help { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.5; min-height: 15px; }

.status-badge { border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 800; }
.status-good { background: #e8fff3; color: #087744; }
.status-warn { background: #fff7e5; color: #986412; }
.status-bad { background: #fff0ef; color: #b33832; }
.scan-summary {
  margin: 18px 0 10px;
  border-radius: 10px;
  padding: 12px;
  background: var(--soft);
  color: #4b5563;
  font-size: 12px;
  line-height: 1.7;
}
.warning-list { display: grid; gap: 7px; margin-bottom: 15px; }
.warning-item { border-left: 3px solid #e8ad46; background: #fffaf0; padding: 8px 10px; color: #805313; font-size: 11px; line-height: 1.55; }
.warning-item.danger { border-color: var(--danger); background: #fff4f3; color: #9d302b; }
.output-label { display: block; margin: 13px 0 7px; font-size: 12px; font-weight: 700; }
textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 12px;
  color: #374151;
  line-height: 1.75;
  outline: none;
}
.negative-output { min-height: 120px; }
.output-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.primary-button, .secondary-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 700;
}
.primary-button { border: 1px solid var(--navy); background: var(--navy); color: #fff; }
.secondary-button { border: 1px solid var(--line); background: #fff; color: #374151; }
.output-action-link {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
}
.primary-button:hover { background: #242647; }
.secondary-button:hover { border-color: #bfc6cf; background: #f9fafb; }
.wide { grid-column: 1 / -1; }
.output-note { margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.instruction-builder {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf9;
}
.instruction-builder-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 0; }
.instruction-input-wrap label { display: block; margin-bottom: 5px; color: var(--text); font-size: 13px; font-weight: 700; }
.instruction-builder-form textarea {
  width: 100%;
  height: 250px;
  min-height: 250px;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  color: #1f2937;
  background: #fff;
  font: inherit;
  line-height: 1.6;
  outline: none;
}
.instruction-builder-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,214,111,.1); }
.instruction-action-row { display: flex; justify-content: flex-start; gap: 10px; }
.instruction-action-row .primary-button,
.instruction-action-row .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 176px;
  min-width: 176px;
  min-height: 42px;
  box-sizing: border-box;
}
.smart-config-button,
.smart-config-button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.smart-config-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.smart-config-button.is-guest-locked,
.smart-config-button.is-guest-locked:hover {
  border-color: #c7cbd1;
  background: #c7cbd1;
  color: #fff;
  cursor: pointer;
  box-shadow: none;
}
.instruction-feedback {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 18px;
  margin-top: 8px;
}
.instruction-status { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.instruction-status.is-success {
  display: inline-block;
  min-height: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #12142d;
  color: #fff;
  font-weight: 700;
}
.section-group-title { margin: 0 0 10px; color: var(--text); font-size: 18px; }
.instruction-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.instruction-helper-text { color: #b3b8c0; font-size: 12px; font-weight: 400; line-height: 1.5; }
.custom-config-title { margin-top: 20px; }
.toast {
  display: none;
  width: fit-content;
  margin-top: 0;
  border: 1px solid #dc2626;
  background: #dc2626;
  color: #fff;
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(220, 38, 38, .24);
  font-weight: 700;
  pointer-events: none;
}
.toast.show {
  display: inline-block;
  animation: instruction-alert-in .2s ease-out;
}
@keyframes instruction-alert-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1280px) {
  .topbar { grid-template-columns: 200px minmax(480px, 1fr) 350px; }
  .workbench { grid-template-columns: 200px minmax(480px, 1fr) 350px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 20px; }
  .brand {
    align-self: auto;
    display: block;
    padding: 0;
    color: var(--ink);
    background: transparent;
    text-align: center;
  }
  .brand::after { display: none; }
  .topbar-actions { padding-right: 0; }
  .topbar-center { display: none; }
  .workbench { display: block; }
  .library-panel { display: none; }
  .output-panel { position: static; height: auto; border: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .instruction-builder-form { grid-template-columns: 1fr; }
  .instruction-action-row .primary-button,
  .instruction-action-row .secondary-button {
    width: 176px;
    min-width: 176px;
  }
}
@media (max-width: 640px) {
  .topbar { height: auto; min-height: 66px; padding: 12px 16px; }
  .brand { font-size: 20px; }
  .topbar-actions > a:not(.member-avatar-link) { display: none; }
  .guest-auth-actions { display: inline-flex; gap: 8px; }
  .workspace-panel, .output-panel { padding: 20px 15px 34px; }
  .workspace-slogan { margin: 26px 0 22px; font-size: 24px; }
  .workspace-header, .task-switcher { align-items: flex-start; flex-direction: column; }
  .workspace-actions { width: 100%; }
  .model-select { flex: 1; }
  .model-select select { width: 100%; }
  .task-tabs { justify-content: flex-start; }
  .preset-grid, .module-grid { grid-template-columns: 1fr; }
}
