:root {
  color-scheme: light;
  --bg-1: #f5f0ff;
  --bg-2: #efe6ff;
  --accent: #8b7cf6;
  --accent-2: #a78bfa;
  --accent-3: #f6a6ff;
  --text: #2f2a3d;
  --muted: #5c5470;
  --card: rgba(255, 255, 255, 0.72);
  --card-border: rgba(139, 124, 246, 0.18);
  --shadow: 0 18px 50px rgba(76, 64, 120, 0.12);
  --radius: 20px;
  --focus: 0 0 0 3px rgba(139, 124, 246, 0.35);
  --ring: 0 0 0 1px rgba(139, 124, 246, 0.22), 0 18px 60px rgba(76, 64, 120, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(165deg, var(--bg-1), var(--bg-2));
}

body {
  position: relative;
  line-height: 1.65;
  overflow-x: hidden;
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 50% at 10% 0%, rgba(255, 182, 255, 0.18), transparent 55%),
    radial-gradient(50% 40% at 90% 10%, rgba(167, 139, 250, 0.2), transparent 50%),
    radial-gradient(45% 45% at 60% 85%, rgba(139, 124, 246, 0.16), transparent 55%);
  z-index: 0;
}

.stars {
  position: absolute;
  inset: -20%;
  background-image: radial-gradient(rgba(255, 255, 255, 0.75) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.22;
  filter: blur(0.2px);
  animation: drift 22s linear infinite;
}

.glow-orb {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.26;
  mix-blend-mode: multiply;
}

.orb-1 {
  left: -120px;
  top: 40%;
  background: radial-gradient(circle at 30% 30%, rgba(246, 166, 255, 0.9), transparent 60%);
  animation: floaty 10s ease-in-out infinite;
}

.orb-2 {
  right: -160px;
  top: 15%;
  background: radial-gradient(circle at 30% 30%, rgba(139, 124, 246, 0.9), transparent 60%);
  animation: floaty 12s ease-in-out infinite reverse;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.35));
  border-bottom: 1px solid rgba(139, 124, 246, 0.16);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.65rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: #3b2f55;
  letter-spacing: 0.02em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139, 124, 246, 0.35), rgba(246, 166, 255, 0.22));
  border: 1px solid rgba(139, 124, 246, 0.22);
  box-shadow: 0 10px 24px rgba(139, 124, 246, 0.16);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pill-link {
  appearance: none;
  border: 1px solid rgba(139, 124, 246, 0.22);
  background: rgba(255, 255, 255, 0.75);
  color: #4c3f75;
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.pill-link:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 124, 246, 0.45);
  box-shadow: 0 12px 30px rgba(76, 64, 120, 0.12);
}

.site-header,
.main,
.compliance {
  position: relative;
  z-index: 1;
}

.site-header {
  padding: 2.5rem 1.25rem 1.25rem;
  text-align: center;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.35));
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  letter-spacing: 0.02em;
  color: #3b2f55;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.main {
  max-width: 880px;
  margin: 0 auto 4rem;
  padding: 0 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.card:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 124, 246, 0.28);
  box-shadow: var(--ring);
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.2rem;
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: #433560;
}

.accent-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 124, 246, 0.18), rgba(246, 166, 255, 0.12));
  border: 1px solid rgba(139, 124, 246, 0.18);
}

.title-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(139, 124, 246, 0.18);
  color: #5a4a84;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.hint {
  margin: 0 0 1rem;
}

.small {
  font-size: 0.88rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.label {
  font-weight: 600;
  font-size: 0.92rem;
  color: #4a3f63;
}

textarea,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(139, 124, 246, 0.35);
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .row {
    grid-template-columns: 1fr;
  }
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.actions-center {
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.55rem 1.15rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(139, 124, 246, 0.35);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(139, 124, 246, 0.45);
  color: #4c3f75;
}

.btn.secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn.ghost {
  background: transparent;
  border-color: rgba(76, 64, 120, 0.2);
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.loading-card {
  position: relative;
  overflow: hidden;
  text-align: center;
}

.loading-visual {
  position: relative;
  height: 64px;
  margin: 0.1rem auto 0.5rem;
}

.spark {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(167, 139, 250, 0.35));
  box-shadow: 0 12px 35px rgba(167, 139, 250, 0.25);
  opacity: 0.9;
}

.spark-a {
  left: 38%;
  top: 20%;
  animation: sparkle 1.8s ease-in-out infinite;
}
.spark-b {
  left: 52%;
  top: 44%;
  animation: sparkle 2.2s ease-in-out infinite 0.3s;
}
.spark-c {
  left: 60%;
  top: 18%;
  animation: sparkle 2.6s ease-in-out infinite 0.6s;
}

.shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 45%,
    transparent 90%
  );
  animation: shimmer 2.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-60%);
  }
  100% {
    transform: translateX(60%);
  }
}

.loading-text {
  margin: 0.25rem 0 0.35rem;
  font-weight: 600;
  color: #4a3f63;
}

.loading-sub {
  margin: 0;
}

.progress {
  margin: 0.95rem auto 0.5rem;
  max-width: 520px;
  height: 10px;
  border-radius: 999px;
  background: rgba(139, 124, 246, 0.12);
  border: 1px solid rgba(139, 124, 246, 0.18);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 12%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  filter: saturate(1.05);
  box-shadow: 0 12px 30px rgba(139, 124, 246, 0.25);
  transition: width 0.35s ease;
}

.loading-steps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
}

.loading-steps .step {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(139, 124, 246, 0.18);
  background: rgba(255, 255, 255, 0.55);
}

.loading-steps .step.on {
  border-color: rgba(139, 124, 246, 0.35);
  color: #4a3f63;
  background: rgba(255, 255, 255, 0.8);
}

.loading-steps .sep {
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.banner {
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}

.banner.error {
  background: #fff0f0;
  border: 1px solid #f3b4b4;
  color: #7a2f2f;
}

.banner.info {
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(139, 124, 246, 0.45);
  color: var(--muted);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fade-in {
  animation: fadein 0.45s ease-out both;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prose ul {
  margin: 0.35rem 0 0.6rem 1.1rem;
  padding: 0;
}

.prose p {
  margin: 0.35rem 0;
}

.quick-glance {
  text-align: left;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.4rem 0 0.6rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(139, 124, 246, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: #4c3f75;
  box-shadow: 0 12px 26px rgba(76, 64, 120, 0.1);
}

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
}

.panel {
  padding: 0;
}

.panel-summary {
  list-style: none;
  cursor: pointer;
  padding: 1.05rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.85rem;
  align-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.55));
  border-bottom: 1px solid rgba(139, 124, 246, 0.14);
}

.panel-summary::-webkit-details-marker {
  display: none;
}

.panel-title {
  font-weight: 800;
  color: #3f315c;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  letter-spacing: 0.01em;
  font-size: 1.05rem;
}

.panel-meta {
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0.9;
}

.panel-body {
  padding: 0.95rem 1.2rem 1.15rem;
}

.panel[open] .panel-summary {
  background: linear-gradient(
    135deg,
    rgba(139, 124, 246, 0.12),
    rgba(246, 166, 255, 0.08),
    rgba(255, 255, 255, 0.55)
  );
}

.panel:hover .panel-summary {
  border-bottom-color: rgba(139, 124, 246, 0.22);
}

.sym-item {
  padding: 0.65rem 0;
  border-bottom: 1px dashed rgba(139, 124, 246, 0.25);
}

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

.sym-name {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: #4b3d6d;
}

.markdown-body {
  font-size: 0.98rem;
}

.markdown-body h2,
.markdown-body h3 {
  color: #433560;
  margin-top: 1.1rem;
}

.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.bullets {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.compliance {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(520px, 92vw);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(40, 32, 64, 0.35);
  backdrop-filter: blur(4px);
}

.modal-form {
  padding: 1.25rem 1.25rem 1.35rem;
  background: #fff;
  border-radius: var(--radius);
}

.modal-title {
  margin: 0 0 0.35rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  margin-top: 0.8rem;
}

@media (max-width: 820px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.mini-title {
  margin: 0.2rem 0 0.55rem;
  font-size: 1rem;
  color: #433560;
}

.qa {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.5rem 0 0.85rem;
}

.qa-item {
  border: 1px solid rgba(139, 124, 246, 0.16);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.72);
}

.qa-q {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: #3f315c;
  font-size: 0.95rem;
}

.json-edit {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(139, 124, 246, 0.22);
}

.json-edit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

#extraction-json {
  margin-top: 0.55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.9rem;
}

@media print {
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
      "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }

  /* 打印兜底：避免浏览器因滤镜/混合/透明导致文字不渲染 */
  * {
    text-shadow: none !important;
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-text-fill-color: #111 !important;
    color: #111 !important;
  }

  .page-bg,
  .site-header,
  .form-card,
  .loading-card,
  .toolbar,
  .compliance,
  .no-print {
    display: none !important;
  }

  /* 打印时强制展示结果区（避免因 .hidden 导致空白 PDF） */
  #results {
    display: flex !important;
  }
  .results {
    display: flex !important;
  }
  .hidden {
    display: block !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    background: #fff;
  }

  .results {
    gap: 0.75rem;
  }

  /* 打印时把面板内容“摊开”，避免 details/summary 兼容性问题 */
  details.panel > summary {
    display: none !important;
  }
  details.panel > .panel-body {
    display: block !important;
    padding-top: 0.5rem;
  }

  /* 去掉装饰性图标，打印更干净 */
  .title-icon,
  .brand-mark {
    display: none !important;
  }
}

@keyframes drift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-80px, 40px, 0);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) translateX(0);
  }
  50% {
    transform: translateY(-18px) translateX(8px);
  }
}

@keyframes sparkle {
  0%,
  100% {
    transform: translateY(0) scale(0.98);
    opacity: 0.75;
  }
  50% {
    transform: translateY(-10px) scale(1.08);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stars,
  .glow-orb,
  .spark,
  .fade-in,
  .shimmer {
    animation: none !important;
  }
  .card,
  .pill-link,
  .btn {
    transition: none !important;
  }
}
