/* =========================
   WhoAreYou · 样式表
   中英双语 + 简洁卡片式
   支持深浅主题切换
   ========================= */

:root {
  --bg: #f5f7fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f7;
  --text: #1a2233;
  --text-soft: #5a6478;
  --text-mute: #8a94a6;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-strong: #1d4ed8;
  --good: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elev: #131a2e;
  --bg-soft: #1a2238;
  --text: #e6ecf5;
  --text-soft: #a8b3c7;
  --text-mute: #6b7693;
  --border: #232c45;
  --accent: #60a5fa;
  --accent-soft: #1e3a8a;
  --accent-strong: #3b82f6;
  --code-bg: #05080f;
  --code-text: #cbd5e1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* =========================
   Top Bar
   ========================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand .logo {
  font-size: 24px;
  line-height: 1;
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.5px;
}

.brand .subtitle {
  color: var(--text-soft);
  font-size: 14px;
}

.controls {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ctrl-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.ctrl-btn.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: white;
}

/* =========================
   Container & Cards
   ========================= */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

.card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}

.card-label {
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.hidden { display: none !important; }

/* =========================
   Progress Card
   ========================= */
.progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.progress-list li {
  padding: 4px 0;
  transition: color 0.2s;
}

.progress-list li.active {
  color: var(--accent);
  font-weight: 600;
}

.progress-list li.done {
  color: var(--good);
}

.progress-list li.done::before {
  content: "✓ ";
}

.progress-list li.done > :not(::before) {
  text-decoration: line-through;
  opacity: 0.6;
}

/* =========================
   Result Grid
   ========================= */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.prediction-card,
.confidence-card {
  text-align: center;
  padding: 28px 20px;
}

.flag {
  font-size: 64px;
  line-height: 1;
  margin: 8px 0;
}

.country {
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0 4px 0;
  letter-spacing: -0.5px;
}

.country-en {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 12px;
}

.badges {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

[data-theme="dark"] .badge {
  color: var(--accent);
}

.confidence-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.confidence-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
  transition: width 0.8s ease;
  width: 0;
}

.confidence-level {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.meta {
  font-size: 12px;
  color: var(--text-mute);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* =========================
   Conflict Card
   ========================= */
.conflict-card {
  border-color: var(--warn);
  background: linear-gradient(0deg, var(--bg-elev), var(--bg-elev));
  position: relative;
}

.conflict-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--warn);
  border-radius: var(--radius) 0 0 var(--radius);
}

.conflict-card h3 {
  color: var(--warn);
}

#conflict-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

/* =========================
   Signals Panel (v2)
   ========================= */
.signals-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.signal-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 16px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-left: 3px solid var(--text-mute);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.signal-row.good { border-left-color: var(--good); }
.signal-row.warn { border-left-color: var(--warn); background: rgba(245, 158, 11, 0.06); }
.signal-row.danger { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.06); }
.signal-row.info { border-left-color: var(--accent); }

[data-theme="dark"] .signal-row.warn { background: rgba(245, 158, 11, 0.1); }
[data-theme="dark"] .signal-row.danger { background: rgba(239, 68, 68, 0.1); }

.signal-label {
  font-weight: 600;
  color: var(--text-soft);
  font-size: 12.5px;
}

.signal-value {
  font-size: 13.5px;
  color: var(--text);
  word-break: break-all;
}

.signal-value code {
  font-size: 12.5px;
}

.signal-detail {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mute);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.pill.good {
  background: rgba(16, 185, 129, 0.12);
  color: var(--good);
  border-color: rgba(16, 185, 129, 0.3);
}

.pill.warn {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.3);
}

.pill.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.pill.info {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.3);
}

/* v2 tag */
.version-tag {
  display: inline-block;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* =========================
   Breakdown Table
   ========================= */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.breakdown-table th,
.breakdown-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.breakdown-table th {
  color: var(--text-mute);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.breakdown-table td:nth-child(4),
.breakdown-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.breakdown-table .country-cell {
  font-weight: 600;
  color: var(--accent);
}

.breakdown-table .bar-cell {
  width: 120px;
}

.breakdown-table .bar-wrap {
  background: var(--bg-soft);
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
}

.breakdown-table .bar-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.breakdown-table tr.zero td {
  opacity: 0.35;
}

.breakdown-table tr.zero .bar-inner {
  background: var(--text-mute);
}

/* =========================
   Raw Data
   ========================= */
.raw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.raw-grid h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-mute);
  margin: 0 0 6px 0;
}

.raw-grid pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

details summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}

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

details summary::before {
  content: "▸ ";
  color: var(--text-mute);
  margin-right: 4px;
  transition: transform 0.2s;
  display: inline-block;
}

details[open] summary::before {
  content: "▾ ";
}

/* =========================
   Privacy
   ========================= */
.privacy {
  background: var(--bg-soft);
  border-style: dashed;
}

.privacy h3 { color: var(--text-soft); }

.privacy ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-soft);
  font-size: 13px;
}

.privacy li { margin: 4px 0; }

/* =========================
   Footer
   ========================= */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-mute);
  font-size: 12px;
}

/* =========================
   Animations
   ========================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card,
.card {
  animation: fadeIn 0.4s ease;
}
