:root {
  --sidebar-width: 390px;
  --primary-blue: #0f4c81;
  --bg-light: #f3f6fb;
  --text-main: #334155;
  --border-color: #dbe3ee;
  --shadow: 0 6px 18px rgba(15, 76, 129, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  color: var(--text-main);
  background: #f2f2f5;
}

#app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#home-page {
  flex: 1;
  padding: 36px 54px 44px;
  background:
    radial-gradient(circle at 12% 4%, rgba(88, 128, 255, 0.14), transparent 44%),
    radial-gradient(circle at 92% 10%, rgba(255, 186, 120, 0.16), transparent 36%),
    linear-gradient(180deg, #f4f4f6 0%, #efeff2 100%);
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.home-header {
  width: min(920px, 100%);
  margin: 0 auto;
  text-align: center;
}

.home-title {
  margin: 0 0 12px;
  font-size: clamp(38px, 5.2vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #111827;
  font-weight: 700;
}

.home-subtitle {
  margin: 0 auto 18px;
  font-size: 16px;
  color: #596273;
  max-width: 700px;
  line-height: 1.6;
}

.home-search-wrap {
  position: relative;
  width: min(820px, 100%);
  margin: 0 auto;
}

.home-search-input {
  width: 100%;
  height: 56px;
  border-radius: 14px;
  border: 1px solid #d6d9e2;
  padding: 0 18px 0 50px;
  font-size: 16px;
  color: #1f2937;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.home-search-input:focus {
  border-color: #7b92ff;
  box-shadow: 0 0 0 3px rgba(123, 146, 255, 0.2);
}

.home-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #8b95a7;
  font-size: 18px;
  pointer-events: none;
}

.home-search-submit {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #8b95a7;
  font-size: 18px;
  cursor: pointer;
}

.home-search-results {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-radius: 12px;
  border: 1px solid #dce2ee;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
  max-height: 260px;
  overflow: auto;
  display: none;
}

.home-search-results li {
  border-bottom: 1px solid #edf1f8;
}

.home-search-results li:last-child {
  border-bottom: none;
}

.home-search-btn {
  width: 100%;
  border: none;
  text-align: left;
  padding: 12px 16px;
  cursor: pointer;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.home-search-btn:hover {
  background: #f4f7ff;
}

.home-search-name {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
}

.home-search-desc {
  font-size: 13px;
  color: #6b7280;
}

.home-content {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.home-manual-card {
  border-radius: 20px;
  min-height: 355px;
  position: relative;
  overflow: hidden;
  padding: 24px;
  display: flex;
  align-items: flex-end;
  color: #ffffff;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 255, 255, 0.52), transparent 42%),
    linear-gradient(140deg, #56a3ff 0%, #6d79f8 38%, #8f65de 64%, #f3a45f 100%);
  box-shadow: 0 20px 36px rgba(68, 89, 170, 0.28);
}

.home-manual-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 25%, rgba(17, 24, 39, 0.4) 100%);
  pointer-events: none;
}

.home-manual-content {
  position: relative;
  z-index: 1;
}

.home-manual-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.26);
}

.home-manual-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.home-manual-desc {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.95;
}

.home-topic-list {
  border-radius: 18px;
  border: 1px solid #dee3ee;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(6px);
  padding: 6px 20px;
}

.home-topic-item {
  width: 100%;
  border: none;
  background: transparent;
  border-bottom: 1px solid #e8edf5;
  padding: 18px 6px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.2s ease;
}

.home-topic-item:last-child {
  border-bottom: none;
}

.home-topic-item:hover {
  background: #f7f9ff;
  transform: translateX(2px);
}

.home-topic-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #cfd8ea;
  background: #ffffff;
  color: #2350a0;
  font-size: 24px;
  font-weight: 700;
}

.home-topic-title {
  margin: 0;
  font-size: 27px;
  line-height: 1.15;
  color: #101828;
  font-weight: 700;
}

.home-topic-desc {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 17px;
  line-height: 1.5;
}

.home-actions {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.home-ai-guide {
  width: min(1200px, 100%);
  margin: -8px auto 0;
  border: 1px solid #dbe3f0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
  padding: 14px 16px;
}

.home-ai-guide-title {
  margin: 0 0 6px;
  color: #0f4c81;
  font-size: 16px;
  font-weight: 800;
}

.home-ai-guide-desc {
  color: #55657d;
  font-size: 14px;
  line-height: 1.6;
}

.home-sample-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-sample-btn {
  border: 1px solid #c6d4ea;
  border-radius: 999px;
  background: #f7faff;
  color: #1f3d6c;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
}

.home-action-btn {
  border-radius: 10px;
  border: 1px solid #cdd5e5;
  background: rgba(255, 255, 255, 0.9);
  color: #1f2d4a;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.home-action-btn.primary {
  border-color: #0f4c81;
  background: #0f4c81;
  color: #ffffff;
}

#workspace {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.topbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 76, 129, 0.06);
  z-index: 3;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-blue);
  margin-bottom: 10px;
}

.filter-card {
  background: #f8fbff;
  border: 1px solid #d6e3f1;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.filter-label {
  font-size: 12px;
  color: #526e8a;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.business-switch {
  height: 38px;
  min-width: 196px;
  border: 1px solid #bfd0e3;
  border-radius: 8px;
  padding: 0 34px 0 12px;
  background-color: #ffffff;
  color: #1e3a5f;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #5d7897 50%),
    linear-gradient(135deg, #5d7897 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 14px,
    calc(100% - 10px) 14px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  outline: none;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.business-switch:hover {
  border-color: #93b6dc;
}

.business-switch:focus {
  border-color: #0f4c81;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}

.topbar-controls {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.xct-signer-label {
  display: none;
  font-size: 13px;
  font-weight: 700;
  color: #1e3a5f;
  white-space: nowrap;
}

.xct-capability-label {
  display: none;
}

.xct-signer-switch {
  display: none;
  min-width: 170px;
}

.xct-capability-switch {
  display: none;
  min-width: 210px;
}

.filter-action {
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--primary-blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.back-home-btn {
  background: #64748b;
}

.filter-action:hover {
  opacity: 0.9;
}

#main-layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

#chart-area {
  order: 0;
  flex: 1;
  position: relative;
  padding: 28px 24px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#chart-area .mermaid {
  width: 100%;
  min-width: 0;
}

#chart-area .mermaid svg {
  display: block;
  margin: 0 auto;
}

#chart-area .nodeLabel {
  font-size: 13px !important;
}

#detail-panel {
  order: 1;
  width: var(--sidebar-width);
  border-left: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.panel-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-color);
  background: #f8fbff;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--primary-blue);
}

.panel-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.empty-state {
  text-align: center;
  color: #94a3b8;
  margin-top: 70px;
}

.data-view {
  display: none;
}

.info-group { margin-bottom: 20px; }

.info-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.info-value { font-size: 15px; line-height: 1.7; }

#val-title.panel-node-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  color: #0f172a;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 13px;
  color: #0b3b63;
  background: #e6f2fc;
  font-weight: 600;
}

.material-list { margin: 6px 0 0; padding-left: 18px; }

.material-list li { margin-bottom: 6px; }

.action-btn {
  display: block;
  margin-top: 16px;
  text-align: center;
  text-decoration: none;
  background: var(--primary-blue);
  color: #fff;
  padding: 11px 12px;
  border-radius: 6px;
  font-weight: 700;
}

.action-btn.disabled {
  background: #93a8bd;
  pointer-events: none;
}

.faq-entry-btn {
  display: none;
  width: 100%;
  margin-top: 10px;
  border: 1px solid #bfd0e3;
  border-radius: 6px;
  background: #f8fbff;
  color: #0f4c81;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.faq-entry-btn:hover { background: #eef5ff; }

.faq-modal-mask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  z-index: 99;
  padding: 24px;
}

.faq-modal {
  width: min(760px, 100%);
  max-height: min(76vh, 720px);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 16px 36px rgba(15, 76, 129, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.faq-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: #f8fbff;
}

.faq-modal-title {
  margin: 0;
  font-size: 16px;
  color: #0f4c81;
}

.faq-modal-close {
  border: 1px solid #bfd0e3;
  background: #fff;
  color: #334155;
  font-size: 13px;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

.faq-modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: #334155;
}

.faq-item {
  margin-bottom: 14px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 10px;
}

.faq-item:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.faq-question {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.legend {
  position: fixed;
  left: 18px;
  bottom: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 12px;
  z-index: 20;
}

.legend-title { font-weight: 700; margin-bottom: 6px; color: #0f4c81; }

.legend-item { margin-bottom: 4px; }

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.mermaid svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
  overflow: visible;
}

.node rect,
.node polygon,
.node path,
.node .label-container {
  transition: fill 0.2s ease, transform 0.2s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.node:not(.decision):hover rect,
.node:not(.decision):hover polygon,
.node:not(.decision):hover path,
.node:not(.decision):hover .label-container {
  cursor: pointer;
  fill: #dbeafe !important;
  transform: scale(1.1);
}

.node:not(.decision):active rect,
.node:not(.decision):active polygon,
.node:not(.decision):active path,
.node:not(.decision):active .label-container {
  fill: #dbeafe !important;
  transform: scale(1.1);
}

.node.ai-located rect,
.node.ai-located polygon,
.node.ai-located path,
.node.ai-located .label-container {
  fill: #fde68a !important;
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  transform: scale(1.12);
}

#xct-placeholder {
  order: 0;
  display: none;
  flex: 1;
  background: transparent;
  overflow: auto;
  padding: 28px 24px;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

#xct-placeholder .mermaid {
  width: 100%;
  min-width: 0;
}

#xct-placeholder .mermaid svg {
  display: block;
  margin: 0 auto;
}

#xct-placeholder .nodeLabel {
  font-size: 13px !important;
}

#iot-subflow {
  order: 0;
  display: none;
  flex: 1;
  background: transparent;
  overflow: auto;
  padding: 28px 24px;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

#iot-subflow .mermaid {
  width: 100%;
  min-width: 0;
}

#iot-subflow .mermaid svg {
  display: block;
  margin: 0 auto;
}

.subflow-back-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  border: 1px solid #bfd0e3;
  background: #ffffff;
  color: #0f4c81;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 3;
}

.ai-answer-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 120;
  width: min(760px, calc(100vw - 48px));
  border: 1px solid #d8dfec;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
  padding: 18px 18px 16px;
  display: none;
}

.ai-answer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 110;
  display: none;
}

.ai-answer-title {
  margin: 0 0 8px;
  color: #0f4c81;
  font-size: 14px;
  font-weight: 800;
}

.ai-answer-question {
  margin: 0 0 10px;
  border: 1px solid #d7dfef;
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #1f2937;
}

.ai-answer-block {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
}

.ai-answer-key {
  color: #0f172a;
  font-weight: 700;
}

.ai-answer-steps {
  margin: 0;
  padding-left: 18px;
}

.ai-answer-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.ai-answer-btn {
  border: 1px solid #c3d0e6;
  border-radius: 6px;
  background: #f6f9ff;
  color: #0f4c81;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.ai-answer-btn.primary {
  background: #0f4c81;
  border-color: #0f4c81;
  color: #ffffff;
}

@media (max-width: 1100px) {
  #home-page {
    padding: 28px 24px 36px;
  }

  .home-content {
    grid-template-columns: 1fr;
  }

  .home-manual-card {
    min-height: 260px;
  }

  .home-topic-title {
    font-size: 24px;
  }

  .home-topic-desc {
    font-size: 15px;
  }

  .home-ai-guide {
    margin-top: -4px;
  }
}

@media (max-width: 768px) {
  .home-title {
    font-size: 34px;
  }

  .home-topic-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .home-topic-icon {
    width: 36px;
    height: 36px;
    font-size: 19px;
  }

  .home-topic-title {
    font-size: 20px;
  }

  .home-actions {
    justify-content: stretch;
  }

  .home-action-btn {
    flex: 1;
  }
}
