:root {
  color-scheme: light;
  --background: #fafafa;
  --foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --card: #ffffff;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --ring: #a1a1aa;
  --success: #15803d;
  --warning: #a16207;
  --danger: #b91c1c;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--foreground);
}

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

.app-shell {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover,
.secondary-button:hover {
  background: var(--secondary);
}

.hero {
  display: grid;
  justify-items: start;
  width: min(100%, 672px);
  margin: 0 auto;
  gap: 14px;
  padding: 11vh 0 28px;
}

.hero-label {
  margin: 0;
  color: #52525b;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.overline {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 680px;
  margin: 0;
  text-align: center;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.search-card {
  display: grid;
  grid-template-columns: minmax(0, 520px) 124px;
  width: min(100%, 672px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 20px 50px rgba(0, 0, 0, 0.06);
}

.search-card input {
  min-width: 0;
  height: 44px;
  border: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--foreground);
  font-size: 16px;
  outline: none;
}

.primary-button,
.secondary-button {
  height: 40px;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--secondary-foreground);
}

.log-card,
.report-card {
  width: min(100%, 860px);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.log-card {
  padding: 24px 24px 18px;
}

.log-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: #3f3f46;
  font-size: 20px;
  font-weight: 600;
}

.log-title span:last-child {
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
}

.log-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 22px;
  align-items: start;
}

.timeline {
  display: grid;
}

.timeline-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  min-height: 48px;
  animation: timeline-enter 0.2s ease-out both;
}

.timeline-rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.timeline-rail::after {
  content: "";
  position: absolute;
  top: 22px;
  bottom: -10px;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child .timeline-rail::after {
  display: none;
}

.step-dot {
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  margin-top: 9px;
  border-radius: 999px;
  background: #71717a;
  transition:
    width 0.16s ease,
    height 0.16s ease,
    margin 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.timeline-item.pending .step-dot {
  opacity: 0;
  transform: scale(0.72);
}

.timeline-item.current .step-dot,
.timeline-item.preview .step-dot {
  width: 16px;
  height: 16px;
  margin-top: 5px;
  border: 1px solid var(--border);
  background: var(--card);
}

.timeline-item.current .step-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid transparent;
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  border-radius: inherit;
  animation: step-spin 0.8s linear infinite;
}

.timeline-item.idle .step-dot {
  width: 8px;
  height: 8px;
  margin-top: 9px;
  border: 0;
  background: #71717a;
}

.timeline-item.complete .step-dot {
  width: 8px;
  height: 8px;
  margin-top: 9px;
  border: 0;
  background: #71717a;
}

.timeline-item.preview.complete .step-dot {
  width: 16px;
  height: 16px;
  margin-top: 5px;
  border: 1px solid var(--border);
}

.timeline-item.done .step-dot,
.timeline-item.complete.ok .step-dot {
  background: var(--success);
  border-color: var(--success);
}

.timeline-item.error .step-dot,
.timeline-item.complete.error .step-dot {
  background: var(--danger);
  border-color: var(--danger);
}

.timeline-item.error .timeline-title {
  color: var(--danger);
}

.thought-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfcfc;
}

.thought-panel-head {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.thought-stream {
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.thought-line {
  color: #52525b;
  font-size: 12px;
  line-height: 1.45;
}

.snap-char {
  display: inline-block;
  white-space: pre;
  animation: snap-in 0.72s cubic-bezier(0.18, 0.88, 0.28, 1) both;
  animation-delay: var(--delay);
}

.timeline-content {
  min-width: 0;
  padding: 0 0 20px 10px;
}

.timeline-title {
  color: var(--foreground);
  font-size: 16px;
  line-height: 1.45;
}

.timeline-subtitle {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.45;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.site-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 10px 5px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--muted);
  color: #52525b;
  font-size: 14px;
}

.site-chip.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.site-chip.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.chip-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 11px;
  font-weight: 700;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-left: 2px;
}

.typing i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.45;
  animation: pulse-dot 1.1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

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

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

@keyframes snap-in {
  from {
    opacity: 0;
    filter: blur(5px);
    transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(0.82);
  }
  62% {
    filter: blur(0.8px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translate(0, 0) rotate(0) scale(1);
  }
}

.report-card {
  margin-top: 24px;
  padding: 28px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.04);
}

.report-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.report-head h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.pdf-link {
  display: inline-grid;
  place-items: center;
  min-width: 62px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.verdict {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 16px 0 24px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--muted);
}

.verdict span,
.verdict small {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.verdict strong {
  font-size: 14px;
  line-height: 1.45;
}

.verdict.medium {
  border-color: #fde68a;
  background: #fffbeb;
}

.verdict.high,
.verdict.critical {
  border-color: #fecaca;
  background: #fef2f2;
}

.report-body {
  display: grid;
  gap: 22px;
}

.report-section {
  display: grid;
  gap: 10px;
}

.report-section h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.report-section p,
.report-section li {
  color: #3f3f46;
  font-size: 15px;
  line-height: 1.6;
}

.report-section ul {
  margin: 0;
  padding-left: 18px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kv-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfcfc;
}

.kv-grid span {
  color: var(--muted-foreground);
  font-size: 12px;
}

.kv-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
}

.risk-list {
  display: grid;
  gap: 10px;
}

.risk-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfcfc;
}

.risk-row div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.risk-row span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.risk-row strong,
.risk-row p,
.risk-row small,
.risk-row em {
  margin: 0;
  font-style: normal;
  line-height: 1.5;
}

.risk-row small,
.risk-row em {
  color: var(--muted-foreground);
}

.risk-row.medium {
  border-color: #fde68a;
  background: #fffbeb;
}

.risk-row.high,
.risk-row.critical {
  border-color: #fecaca;
  background: #fef2f2;
}

.sources {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.source-row {
  display: grid;
  grid-template-columns: 150px 80px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.source-row:last-child {
  border-bottom: 0;
}

.source-row p {
  margin: 0;
  color: #3f3f46;
}

.source-row .ok {
  color: var(--success);
}

.source-row .error {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 24, 27, 0.36);
}

.modal {
  display: grid;
  gap: 16px;
  width: min(900px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  outline: none;
}

.field select {
  height: 38px;
  padding: 0 10px;
}

.field textarea {
  min-height: 420px;
  resize: vertical;
  padding: 12px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.field select:focus,
.field textarea:focus,
.search-card:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.18);
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 860px);
  }

  .hero {
    padding-top: 8vh;
  }

  .search-card,
  .source-row,
  .kv-grid,
  .verdict {
    grid-template-columns: 1fr;
  }

  .search-card button {
    width: 100%;
  }

  .report-card,
  .log-card {
    padding: 18px;
  }

  .report-head {
    display: grid;
  }

  .log-body {
    grid-template-columns: 1fr;
  }

  .thought-panel {
    position: static;
  }
}
