/* ── CID Witness — Fresh Tech UI ──────────────────────────────
   Palette: 深蓝黑() + 青蓝(cyan-blue) + 暖白
   Register: Product (Restrained, with intentional accent usage)
   Scene: Builder in bright coworking room on laptop
   Scale: 4pt base, 6-step spacing
   Motion: 150-250ms, ease-out-quart, no bounce
   ───────────────────────────────────────────────────────────── */

:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --bg-page: oklch(12.5% 0.022 265);
  --bg-surface: oklch(16% 0.025 260);
  --bg-elevated: oklch(19.5% 0.03 258);
  --bg-inset: oklch(13.8% 0.024 262);

  --fg: oklch(93% 0.008 95);
  --fg-dim: oklch(60% 0.02 260);
  --fg-muted: oklch(47% 0.025 258);

  --accent: oklch(70% 0.16 235);
  --accent-hover: oklch(62% 0.16 235);
  --accent-soft: oklch(70% 0.16 235 / 0.12);
  --accent-glow: oklch(70% 0.16 235 / 0.18);

  --green: oklch(72% 0.14 155);
  --green-soft: oklch(72% 0.14 155 / 0.12);
  --amber: oklch(72% 0.12 75);
  --amber-soft: oklch(72% 0.12 75 / 0.12);
  --red: oklch(62% 0.15 24);
  --red-soft: oklch(62% 0.15 24 / 0.12);

  --border: oklch(35% 0.025 260 / 0.5);
  --border-light: oklch(40% 0.03 258 / 0.3);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --shadow-card: 0 1px 3px oklch(0% 0 0 / 0.2), 0 4px 16px oklch(0% 0 0 / 0.15);
  --shadow-elevated: 0 2px 8px oklch(0% 0 0 / 0.2), 0 12px 40px oklch(0% 0 0 / 0.18);
}

/* ── Reset & Base ────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background: var(--bg-page);
  background-image:
    radial-gradient(ellipse 600px 400px at 20% 15%, oklch(70% 0.12 250 / 0.04), transparent),
    radial-gradient(ellipse 500px 350px at 85% 85%, oklch(72% 0.1 200 / 0.03), transparent);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 150ms var(--ease-out);
}
a:hover { color: var(--fg); }

/* ── Layout ────────────────────────────────────────────── */

.site-header,
main,
footer {
  width: min(1160px, calc(100% - var(--space-7)));
  margin-inline: auto;
}

/* ── Header ────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  padding-block: var(--space-7) var(--space-5);
}

.site-header .eyebrow {
  margin-bottom: var(--space-1);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-header h1 {
  font-size: 2.75rem;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.lede {
  max-width: 68ch;
  color: var(--fg-dim);
  font-size: 1.02rem;
  line-height: 1.55;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Buttons ────────────────────────────────────────────── */

.button,
.quick-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 42px;
  padding-inline: var(--space-4);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition:
    background 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    color 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    transform 120ms var(--ease-out);
  user-select: none;
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.button.primary:active {
  transform: scale(0.97);
}

.button.secondary,
.quick-actions button {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--fg);
}
.button.secondary:hover,
.quick-actions button:hover {
  background: oklch(24% 0.04 260);
  border-color: oklch(48% 0.04 258 / 0.5);
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.button:focus-visible,
.quick-actions button:focus-visible,
.icon-button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 1.15rem;
  cursor: pointer;
  transition:
    background 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    transform 120ms var(--ease-out);
}
.icon-button:hover {
  background: oklch(24% 0.04 260);
  border-color: oklch(48% 0.04 258);
}
.icon-button:active {
  transform: scale(0.92);
}

/* ── Status Grid ────────────────────────────────────────── */

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
  transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.stat:hover {
  border-color: oklch(45% 0.05 258 / 0.5);
  box-shadow: var(--shadow-elevated);
}

.stat-label,
.stat-note {
  display: block;
  color: var(--fg-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.stat strong {
  display: block;
  margin-block: var(--space-3) var(--space-2);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

/* ── Workspace Layout ───────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: var(--space-4);
}

/* ── Panels ─────────────────────────────────────────────── */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.panel .eyebrow {
  margin-bottom: var(--space-1);
  color: var(--fg-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel h2 {
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.25;
}

/* ── Pill / API State ───────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: 999px;
  min-height: 26px;
  padding-inline: var(--space-3);
  font-size: 0.73rem;
  font-weight: 650;
  white-space: nowrap;
  transition: background 250ms var(--ease-out), color 250ms var(--ease-out);
}
.pill.muted {
  background: var(--bg-elevated);
  color: var(--fg-muted);
}
.pill.good {
  background: var(--green-soft);
  color: var(--green);
}
.pill.warn {
  background: var(--amber-soft);
  color: var(--amber);
}
.pill.bad {
  background: var(--red-soft);
  color: var(--red);
}

/* ── Form ────────────────────────────────────────────────── */

.lookup-form label {
  display: block;
  margin-bottom: var(--space-3);
  color: var(--fg-dim);
  font-size: 0.85rem;
  font-weight: 600;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  color: var(--fg);
  padding-inline: var(--space-4);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}
input::placeholder {
  color: var(--fg-muted);
}

/* ── Quick Actions ──────────────────────────────────────── */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block: var(--space-4) var(--space-5);
}
.quick-actions button {
  min-height: 32px;
  padding-inline: var(--space-3);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border-color: transparent;
  color: var(--fg-dim);
}
.quick-actions button:hover {
  background: oklch(24% 0.04 260);
  color: var(--fg);
  border-color: var(--border);
}

/* ── Empty State ────────────────────────────────────────── */

.empty-state {
  display: grid;
  gap: var(--space-2);
  border: 1px dashed oklch(50% 0.03 258 / 0.35);
  border-radius: var(--radius-md);
  background: oklch(14% 0.02 262);
  padding: var(--space-4);
  color: var(--fg-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}
.empty-state strong {
  color: var(--fg);
}

/* ── Result Summary ─────────────────────────────────────── */

.result-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: var(--space-4);
  color: var(--fg-dim);
  font-size: 0.9rem;
  transition: background 250ms var(--ease-out);
}
.result-summary p { margin: 0; }

.status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fg-muted);
  box-shadow: 0 0 0 4px oklch(60% 0.02 260 / 0.1);
  transition: background 300ms var(--ease-out), box-shadow 300ms var(--ease-out);
}

.result-summary.good {
  background: oklch(72% 0.14 155 / 0.06);
}
.result-summary.good .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.result-summary.warn {
  background: oklch(72% 0.12 75 / 0.06);
}
.result-summary.warn .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}

/* ── Deal Cards ─────────────────────────────────────────── */

.deal-list {
  display: grid;
  gap: var(--space-3);
  margin-block: var(--space-4);
}

.deal-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: var(--space-4);
  transition: border-color 200ms var(--ease-out);
  animation: card-enter 300ms var(--ease-out) both;
}
.deal-card:hover {
  border-color: oklch(48% 0.05 258 / 0.5);
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.deal-card:nth-child(1) { animation-delay: 0ms; }
.deal-card:nth-child(2) { animation-delay: 60ms; }
.deal-card:nth-child(3) { animation-delay: 120ms; }
.deal-card:nth-child(4) { animation-delay: 180ms; }
.deal-card:nth-child(5) { animation-delay: 240ms; }
.deal-card:nth-child(6) { animation-delay: 300ms; }

.deal-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.deal-title strong {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.deal-title .pill {
  flex-shrink: 0;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.kv span:first-child {
  display: block;
  color: var(--fg-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}

.kv strong,
.kv a {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.kv strong { color: var(--fg); }
.kv a { color: var(--accent); }

/* ── Report Block ───────────────────────────────────────── */

.report-block {
  overflow: hidden;
  border: 1px solid oklch(50% 0.04 258 / 0.3);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  margin-top: var(--space-4);
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  color: var(--fg-dim);
  font-size: 0.75rem;
  font-weight: 650;
}

pre {
  margin: 0;
  min-height: 160px;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: var(--space-4);
  font: 0.84rem/1.6 ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  color: oklch(88% 0.012 140);
}

/* ── Explain Panel ──────────────────────────────────────── */

.explain-panel {
  margin-block: var(--space-4) var(--space-7);
}

.explain-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.explain-grid strong {
  display: block;
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: var(--space-2);
}

.explain-grid p {
  color: var(--fg-dim);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ── Footer ──────────────────────────────────────────────── */

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-3) var(--space-7);
  color: var(--fg-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: var(--space-4);
}
footer a {
  color: var(--accent);
  font-weight: 600;
}
footer a:hover {
  color: var(--fg);
}

/* ── Copy toast ─────────────────────────────────────────── */

.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: oklch(22% 0.03 260);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  color: var(--fg);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-elevated);
  z-index: 100;
  animation: toast-in 250ms var(--ease-out), toast-out 250ms var(--ease-in) 1.8s forwards;
  pointer-events: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── Loading skeleton ────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    oklch(22% 0.03 260) 25%,
    oklch(26% 0.04 260) 50%,
    oklch(22% 0.03 260) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Reduced Motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .kv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 800px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .site-header h1 {
    font-size: 2.2rem;
  }
  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .explain-grid {
    grid-template-columns: 1fr;
  }
  .kv-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .site-header,
  main,
  footer {
    width: min(100% - var(--space-5), 1160px);
  }
  .site-header { padding-block: var(--space-5) var(--space-4); }
  .status-grid { grid-template-columns: 1fr; }
  .stat strong { font-size: 1.35rem; }
  .panel { padding: var(--space-4); }
  .input-row { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  footer {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}
