:root {
  --bg: #eef3f9;
  --bg-strong: #e5edf6;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-muted: rgba(244, 248, 252, 0.9);
  --line: rgba(28, 53, 81, 0.1);
  --line-strong: rgba(28, 53, 81, 0.18);
  --ink: #112033;
  --muted: #5a6c80;
  --muted-soft: #7d8d9d;
  --nav-bg: #0f1c2f;
  --nav-surface: rgba(255, 255, 255, 0.06);
  --nav-line: rgba(255, 255, 255, 0.08);
  --nav-ink: #f5f8fb;
  --nav-muted: rgba(235, 242, 250, 0.68);
  --accent: #2463eb;
  --accent-strong: #194fbf;
  --accent-soft: rgba(36, 99, 235, 0.12);
  --teal: #0f766e;
  --amber: #c97a14;
  --rose: #be3d57;
  --danger: #cb445f;
  --shadow-lg: 0 30px 70px rgba(17, 32, 51, 0.14);
  --shadow-md: 0 16px 34px rgba(17, 32, 51, 0.08);
  --shadow-sm: 0 6px 18px rgba(17, 32, 51, 0.05);
  --radius-2xl: 30px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --font-sans: "Avenir Next", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(36, 99, 235, 0.11), transparent 24%),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.08), transparent 22%),
    linear-gradient(180deg, #f5f8fc 0%, var(--bg) 100%);
}

body::before {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(17, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 32, 51, 0.04) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.5;
  content: "";
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: block;
  height: 100vh;
  min-height: 100vh;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 22px 24px;
  color: var(--nav-ink);
  background:
    radial-gradient(circle at top right, rgba(36, 99, 235, 0.2), transparent 30%),
    linear-gradient(180deg, #0f1c2f 0%, #132743 100%);
  border-right: 1px solid var(--nav-line);
}

.brand-panel,
.side-card {
  border: 1px solid var(--nav-line);
  border-radius: var(--radius-xl);
  background: var(--nav-surface);
  backdrop-filter: blur(14px);
}

.brand-panel {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(36, 99, 235, 0.95), rgba(15, 118, 110, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.brand-copy h1,
.topbar-copy h2,
.panel-header h2,
.score-title-row h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.brand-copy h1 {
  font-size: 1.5rem;
  line-height: 1.15;
}

.brand-copy p {
  margin: 10px 0 0;
  color: var(--nav-muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-copy .eyebrow,
.topbar-copy .eyebrow {
  color: var(--accent);
}

.nav-group {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--nav-muted);
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.nav-item strong {
  display: block;
  color: var(--nav-ink);
  font-size: 0.96rem;
}

.nav-item small {
  display: block;
  margin-top: 4px;
  color: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.nav-item.static {
  cursor: default;
}

.nav-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.05);
}

.nav-item.active .nav-dot {
  background: #84c5ff;
}

.side-card {
  padding: 18px 18px 20px;
}

.card-label {
  display: block;
  color: var(--nav-muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1.55;
}

.side-card p {
  margin: 12px 0 0;
  color: var(--nav-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.side-card.compact {
  margin-top: auto;
}

.side-bullet {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--nav-muted);
  line-height: 1.75;
}

.main-stage {
  width: min(1680px, 100%);
  height: 100vh;
  margin: 0 auto;
  min-width: 0;
  padding: 12px 16px 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.topbar-copy h2 {
  font-size: clamp(2rem, 3vw, 3.05rem);
  line-height: 1.05;
}

.topbar-copy p:last-child {
  max-width: 52rem;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.topbar-panels {
  display: grid;
  gap: 14px;
}

.topbar-panel {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.topbar-panel span,
.score-caption,
.feature-head p,
.section-row p,
.panel-header p,
.empty-state p,
.engine-note p,
.bullet-list,
.field-card small {
  color: var(--muted);
}

.topbar-panel span {
  display: block;
  font-size: 0.84rem;
}

.topbar-panel strong {
  display: block;
  margin-top: 8px;
  line-height: 1.55;
}

.workspace {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(420px, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
  margin-top: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(270px, 0.9fr) minmax(300px, 1.1fr);
  grid-auto-rows: max-content;
  gap: 12px;
  align-content: start;
  align-items: start;
  overflow: auto;
  scrollbar-gutter: stable;
}

.results-panel {
  gap: 14px;
  justify-content: flex-start;
  overflow: auto;
  scrollbar-gutter: stable;
}

.controls-panel > .panel-header {
  grid-column: 1 / -1;
}

.panel-header,
.section-row,
.feature-head,
.score-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-header h2 {
  font-size: 1.3rem;
}

.panel-header p:last-child {
  max-width: 48rem;
  margin: 10px 0 0;
  line-height: 1.75;
}

.panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(36, 99, 235, 0.12);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(36, 99, 235, 0.08);
  font-size: 0.86rem;
  font-weight: 700;
}

.card-section,
.weights-card,
.prompt-card,
.breakdown-card,
.insight-card,
.feature-card,
.prompt-preview,
.engine-note,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.card-section {
  padding: 12px;
}

.section-row h3,
.feature-head h3,
.insight-card h3 {
  margin: 0;
  font-size: 0.9rem;
}

.section-row p,
.feature-head p {
  margin: 6px 0 0;
  font-size: 0.92rem;
  line-height: 1.65;
}

.sample-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.sample-chip {
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.sample-chip:hover,
.sample-chip.active {
  border-color: rgba(36, 99, 235, 0.28);
  background: #f7fbff;
  box-shadow: 0 14px 24px rgba(36, 99, 235, 0.08);
  transform: translateY(-1px);
}

.sample-chip-head {
  display: flex;
  justify-content: flex-start;
  gap: 0;
  align-items: center;
}

.sample-chip strong {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
}

.compare-form {
  display: grid;
  gap: 12px;
  align-items: start;
  padding-bottom: 2px;
}

.upload-grid,
.compact-grid,
.insight-grid,
.feature-grid {
  display: grid;
  gap: 10px;
}

.upload-grid,
.compact-grid,
.feature-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid-single {
  grid-template-columns: 1fr;
}

.upload-card {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(247, 250, 254, 0.96), rgba(255, 255, 255, 0.92));
  cursor: pointer;
}

.upload-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-label,
.field-label {
  display: block;
  font-weight: 700;
  font-size: 0.86rem;
}

.upload-card input {
  display: none;
}

.preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px dashed rgba(36, 99, 235, 0.22);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top left, rgba(36, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(249, 251, 255, 0.95), rgba(240, 246, 252, 0.95));
}

.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-placeholder {
  display: grid;
  gap: 6px;
  padding: 14px;
  text-align: center;
}

.preview-placeholder strong {
  font-size: 0.9rem;
}

.preview-placeholder span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.field-card,
.field {
  display: block;
}

.field-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
}

.field-card select,
.readonly-value,
.field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.55;
}

.readonly-value {
  line-height: 1.55;
  background: #f9fbff;
}

.weights-card {
  padding: 12px;
}

.slider-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 10px;
}

.slider-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: center;
}

.slider-row span,
.slider-row strong {
  font-size: 0.8rem;
}

.slider-row strong {
  text-align: right;
}

.slider-row input[type="range"] {
  accent-color: var(--accent);
}

.prompt-card {
  padding: 0 12px 12px;
}

.prompt-card summary,
.prompt-preview summary {
  padding: 12px 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.92rem;
}

.prompt-stack {
  display: grid;
  gap: 10px;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  position: sticky;
  bottom: -14px;
  z-index: 4;
  padding: 12px 0 2px;
  background: linear-gradient(180deg, rgba(245, 248, 252, 0), rgba(245, 248, 252, 0.92) 30%, rgba(245, 248, 252, 0.99) 100%);
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
  font-size: 0.86rem;
}

.primary-btn {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(36, 99, 235, 0.22);
}

.ghost-btn {
  border: 1px solid var(--line-strong);
  color: var(--accent-strong);
  background: #fff;
}

.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.72;
  box-shadow: none;
}

.empty-state,
.loading-state,
.engine-note,
.breakdown-card,
.prompt-preview {
  padding: 12px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 240px;
  text-align: center;
}

.loading-state {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.loading-state h3 {
  margin: 0;
  font-size: 1rem;
}

.loading-state p {
  max-width: 24rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(36, 99, 235, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.empty-state h3 {
  margin: 0;
  font-size: 1rem;
}

.empty-state p {
  max-width: 24rem;
  margin: 0;
  line-height: 1.65;
}

.empty-illustration {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 6px;
}

.empty-illustration span {
  display: block;
  width: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(36, 99, 235, 0.2), rgba(15, 118, 110, 0.45));
}

.empty-illustration span:nth-child(1) {
  height: 34px;
}

.empty-illustration span:nth-child(2) {
  height: 50px;
}

.empty-illustration span:nth-child(3) {
  height: 26px;
}

.result-shell.hidden,
.hidden {
  display: none;
}

.result-shell {
  --risk-line: var(--accent);
  --risk-soft: rgba(36, 99, 235, 0.12);
  --risk-ink: var(--accent-strong);
  display: grid;
  gap: 14px;
}

.result-shell[data-risk-tone="low"] {
  --risk-line: var(--teal);
  --risk-soft: rgba(15, 118, 110, 0.12);
  --risk-ink: #0d5c56;
}

.result-shell[data-risk-tone="mid"] {
  --risk-line: var(--amber);
  --risk-soft: rgba(201, 122, 20, 0.13);
  --risk-ink: #8b550d;
}

.result-shell[data-risk-tone="high"] {
  --risk-line: var(--rose);
  --risk-soft: rgba(190, 61, 87, 0.14);
  --risk-ink: #983147;
}

.score-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(17, 32, 51, 0.05);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, var(--risk-soft), rgba(255, 255, 255, 0.92) 48%),
    var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.score-copy {
  min-width: 0;
}

.score-title-row {
  align-items: center;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--risk-ink);
  background: var(--risk-soft);
  box-shadow: inset 0 0 0 1px rgba(17, 32, 51, 0.04);
  font-size: 1.25rem;
}

.score-caption {
  font-size: 0.9rem;
}

.result-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.score-orbit {
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 148px;
  height: 148px;
  border: 10px solid var(--risk-soft);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0%, rgba(250, 252, 255, 0.98) 58%, rgba(242, 247, 253, 0.96) 100%);
  color: var(--risk-ink);
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(17, 32, 51, 0.04);
}

.score-ring span {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.score-ring small {
  display: block;
  margin-top: 0;
  line-height: 1.2;
  color: var(--muted);
}

.engine-note strong {
  display: block;
  margin-bottom: 8px;
}

.engine-note p {
  margin: 0;
  line-height: 1.75;
}

.breakdown-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.breakdown-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 54px;
  gap: 14px;
  align-items: center;
}

.bar-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(17, 32, 51, 0.08);
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--risk-line), rgba(36, 99, 235, 0.95));
}

.insight-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.insight-card {
  padding: 12px;
}

.insight-card.full {
  grid-column: 1 / -1;
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.9rem;
  line-height: 1.65;
}

.feature-card {
  padding: 12px;
}

.feature-head span {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.palette-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
}

.swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(17, 32, 51, 0.08);
}

.feature-list {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 12px 0 0;
}

.feature-list dt {
  color: var(--muted);
  font-weight: 700;
}

.feature-list dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.62;
}

.prompt-preview pre {
  margin: 0;
  padding-top: 4px;
  white-space: pre-wrap;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.58;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

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

  .controls-panel,
  .compare-form,
  .slider-list,
  .sample-list {
    grid-template-columns: 1fr;
  }

  .score-hero,
  .feature-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .score-orbit {
    justify-content: flex-start;
  }
}

@media (max-width: 920px) {
  .main-stage {
    height: 100vh;
    padding: 18px;
  }

  .upload-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .section-row,
  .feature-head,
  .score-title-row {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .main-stage {
    height: 100vh;
    padding: 14px;
  }

  .panel,
  .card-section,
  .weights-card,
  .prompt-card,
  .breakdown-card,
  .insight-card,
  .feature-card,
  .prompt-preview,
  .engine-note,
  .empty-state {
    padding-left: 16px;
    padding-right: 16px;
  }

  .actions {
    flex-direction: column;
    bottom: -16px;
  }

  .slider-row,
  .breakdown-item,
  .feature-list {
    grid-template-columns: 1fr;
  }

  .preview-box {
    min-height: 196px;
  }

  .score-ring {
    width: 148px;
    height: 148px;
  }
}
