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

:root {
  --bg:         #f5f5f7;
  --surface:    #ffffff;
  --border:     rgba(0,0,0,0.08);
  --text:       #1d1d1f;
  --text-2:     #6e6e73;
  --text-3:     #aeaeb2;
  --accent:     #0071e3;
  --accent-h:   #0077ed;
  --radius:     20px;
  --radius-sm:  12px;
  --shadow:     0 2px 20px rgba(0,0,0,0.06);
  --shadow-md:  0 8px 40px rgba(0,0,0,0.10);
  --font:       'DM Sans', -apple-system, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav ─────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245,245,247,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 960px; margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo {
  width: 30px; height: 30px;
  background: var(--text);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.nav-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.3px;
}
.nav-title em { font-style: italic; font-weight: 400; font-family: var(--font-serif); }
.nav-badge {
  font-size: 11px; font-weight: 500;
  color: var(--text-2);
  background: rgba(0,0,0,0.06);
  padding: 4px 10px; border-radius: 20px;
}

/* ── Hero ────────────────────────────────────────────── */
.hero {
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 80px 24px 64px;
  text-align: center;
}
.hero-inner { max-width: 700px; margin: 0 auto; }
.hero-tag {
  display: inline-block;
  font-size: 12px; font-weight: 500;
  color: var(--accent);
  background: rgba(0,113,227,0.08);
  padding: 5px 14px; border-radius: 20px;
  margin-bottom: 24px;
  letter-spacing: 0.3px;
}
.hero-title {
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -2px;
  color: var(--text);
  margin-bottom: 20px;
}
.hero-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}
.hero-sub {
  font-size: 17px; color: var(--text-2);
  line-height: 1.6; max-width: 520px;
  margin: 0 auto 40px;
}
.hero-stats {
  display: flex; align-items: center;
  justify-content: center; gap: 32px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num {
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.8px; color: var(--text);
}
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-div { width: 1px; height: 36px; background: var(--border); }

/* ── Main ────────────────────────────────────────────── */
.main { max-width: 960px; margin: 0 auto; padding: 48px 24px 80px; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s ease both;
}
.card:nth-child(2) { animation-delay: 0.1s; }

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

.card-header {
  display: flex; align-items: flex-start;
  gap: 16px; margin-bottom: 28px;
}
.step-badge {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: var(--text);
  color: white;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; letter-spacing: 0.5px;
}
.card-title { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 4px; }
.card-sub { font-size: 14px; color: var(--text-2); }

/* ── Upload ──────────────────────────────────────────── */
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}
.upload-zone:hover { border-color: var(--accent); background: rgba(0,113,227,0.02); }
.upload-zone.drag-over { border-color: var(--accent); background: rgba(0,113,227,0.04); }
.upload-content {
  padding: 48px 24px;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  text-align: center;
}
.upload-icon { color: var(--text-3); margin-bottom: 4px; }
.upload-text { font-size: 15px; color: var(--text-2); }
.upload-link { color: var(--accent); cursor: pointer; }
.upload-hint { font-size: 13px; color: var(--text-3); }
.upload-preview {
  padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
}
.upload-preview img {
  width: 80px; height: 80px;
  object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border);
}
.preview-info { display: flex; flex-direction: column; gap: 4px; }
.preview-name { font-size: 14px; font-weight: 500; }
.preview-change { font-size: 13px; color: var(--accent); cursor: pointer; }

/* ── Form ────────────────────────────────────────────── */
.form-grid { display: flex; flex-direction: column; gap: 8px; }
.form-group-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3);
  margin-top: 20px; margin-bottom: 8px;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px; font-weight: 500; color: var(--text-2);
}
.field-hint { font-size: 11px; color: var(--text-3); font-weight: 400; }
.field input, .field select {
  height: 42px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 14px; font-family: var(--font);
  color: var(--text);
  transition: all 0.2s;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

/* ── Toggles ─────────────────────────────────────────── */
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.toggle-field { cursor: pointer; }
.toggle-field input { display: none; }
.toggle-box {
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: all 0.2s;
  display: flex; align-items: center; gap: 8px;
}
.toggle-box::before {
  content: '';
  width: 16px; height: 16px; flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  transition: all 0.2s;
}
.toggle-field input:checked + .toggle-box {
  border-color: var(--accent);
  background: rgba(0,113,227,0.05);
}
.toggle-field input:checked + .toggle-box::before {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-label { font-size: 13px; color: var(--text-2); }

/* ── Submit ──────────────────────────────────────────── */
.submit-row { display: flex; justify-content: center; padding: 16px 0 0; }
.btn-analyze {
  height: 52px; padding: 0 40px;
  background: var(--text);
  color: white;
  border: none; border-radius: 100px;
  font-size: 16px; font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: all 0.2s;
  letter-spacing: -0.2px;
}
.btn-analyze:hover { background: #3a3a3c; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-analyze:active { transform: translateY(0); }
.btn-icon { font-size: 18px; transition: transform 0.2s; }
.btn-analyze:hover .btn-icon { transform: translateX(3px); }

/* ── Loading ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(245,245,247,0.9);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
}
.loading-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 56px;
  text-align: center;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}
.loading-brain {
  color: var(--accent);
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.05); opacity: 0.7; }
}
.loading-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.3px; }
.loading-sub { font-size: 14px; color: var(--text-2); margin-bottom: 28px; }
.loading-steps { display: flex; flex-direction: column; gap: 8px; }
.loading-step {
  font-size: 13px; color: var(--text-3);
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s;
}
.loading-step.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
  font-weight: 500;
}
.loading-step.done {
  color: #34C759;
  font-weight: 500;
}

/* ── Results ─────────────────────────────────────────── */
.results { animation: fadeUp 0.6s ease both; }
.results-header { text-align: center; margin-bottom: 36px; }
.results-title { font-size: 34px; font-weight: 600; letter-spacing: -1px; margin-bottom: 6px; }
.results-sub { font-size: 15px; color: var(--text-2); }
.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.result-card-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.result-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); }
.result-badge {
  font-size: 12px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
}
.result-stage { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; margin-bottom: 10px; }
.result-desc { font-size: 14px; color: var(--text-2); line-height: 1.5; margin-bottom: 20px; }

/* Probability bars */
.prob-bars { display: flex; flex-direction: column; gap: 8px; }
.prob-item { display: flex; flex-direction: column; gap: 4px; }
.prob-row { display: flex; justify-content: space-between; }
.prob-name { font-size: 12px; color: var(--text-2); }
.prob-pct  { font-size: 12px; font-weight: 500; }
.prob-bar-bg { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.prob-bar-fill { height: 100%; border-radius: 2px; transition: width 1s ease; }

/* Gauge */
.risk-gauge { position: relative; margin: -8px auto 8px; width: 200px; }
.gauge-svg { width: 100%; }
.gauge-value {
  position: absolute;
  bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 32px; font-weight: 600; letter-spacing: -1px;
}

/* Report */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.report-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  font-size: 14px; font-weight: 600;
  color: var(--text-2);
}
.report-icon {
  width: 32px; height: 32px;
  background: var(--bg);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.report-text {
  font-size: 16px; line-height: 1.7;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 17px;
  margin-bottom: 16px;
}
.report-disclaimer {
  font-size: 12px; color: var(--text-3);
  background: rgba(255,159,10,0.08);
  border-left: 3px solid #FF9F0A;
  padding: 10px 14px; border-radius: 0 8px 8px 0;
}

.new-analysis { display: flex; justify-content: center; }
.btn-new {
  height: 44px; padding: 0 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px; font-weight: 500;
  font-family: var(--font);
  color: var(--text-2);
  cursor: pointer; transition: all 0.2s;
}
.btn-new:hover { border-color: var(--text); color: var(--text); }

/* ── Footer ──────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 680px) {
  .results-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 20px; }
  .card { padding: 24px; }
  .hero { padding: 48px 24px 40px; }
}