/* ── Reset & base ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f0f2f5;
  min-height: 100vh;
}

#app {
  height: 100%;
}

/* ── Views ─────────────────────────────────────────────────────────────────── */
.view {
  display: none;
}
.view.active {
  display: block;
}

/* Welcome & results views get normal centered layout */
#welcome,
#results {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ── Typography ────────────────────────────────────────────────────────────── */
h1 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}
h2 {
  font-size: 1.1rem;
  margin-bottom: 0;
}
.subtitle {
  color: #555;
  margin-bottom: 1.5rem;
}
.hint {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.card ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}
.card li {
  margin-bottom: 0.4rem;
}

/* ── Target picker ─────────────────────────────────────────────────────────── */
.target-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.target-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  font-size: inherit;
}
.target-card:hover {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.target-card strong {
  font-size: 1.05rem;
}
.target-card span {
  color: #555;
  font-size: 0.9rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}
.btn-secondary {
  background: #e5e7eb;
  color: #1a1a2e;
}
.btn-secondary:hover {
  background: #d1d5db;
}
.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: #e5e7eb;
  color: #1a1a2e;
  border-radius: 4px;
  text-decoration: none;
}
.btn-full {
  width: 100%;
  text-align: center;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0 0.3rem;
}
.btn-icon:hover {
  color: #e11d48;
}

/* ── Actions bar ───────────────────────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── Split layout (explore view) ───────────────────────────────────────────── */
.split-layout {
  display: flex;
  height: 100vh;
  gap: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-app {
  flex: 1;
  border-right: 1px solid #ddd;
  background: #fff;
}

.panel-reports {
  width: 380px;
  min-width: 300px;
  background: #f8f9fa;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.panel-header h2 {
  margin: 0;
}

#target-frame {
  flex: 1;
  border: none;
  width: 100%;
}

/* ── Findings panel ────────────────────────────────────────────────────────── */
.findings-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.finding-card {
  background: #fff;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.finding-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2rem;
}
.finding-number {
  font-weight: 600;
  color: #555;
  font-size: 0.8rem;
}
.finding-text {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  line-height: 1.4;
}
.finding-text:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.report-actions {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#finding-count {
  color: #666;
  font-size: 0.85rem;
}

/* ── Loading ───────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Scorecard ─────────────────────────────────────────────────────────────── */
.score-summary {
  text-align: center;
}
.score-row {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}
.score-block {
  min-width: 100px;
}
.score-big {
  font-size: 2.4rem;
  font-weight: 700;
  color: #2563eb;
}
.score-label {
  font-size: 0.85rem;
  color: #666;
}

/* ── Result sections ───────────────────────────────────────────────────────── */
.result-section {
  margin-top: 2rem;
}

.report-detail {
  background: #fff;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.report-text {
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.report-match {
  font-size: 0.85rem;
}
.match-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.match-yes {
  background: #dcfce7;
  color: #166534;
}
.match-no {
  background: #fef2f2;
  color: #991b1b;
}
.confidence {
  opacity: 0.7;
  margin-left: 0.3rem;
}

.bug-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}
.bug-found {
  background: #dcfce7;
}
.bug-missed {
  background: #f9fafb;
}
.bug-id {
  font-weight: 600;
  min-width: 2.5rem;
  color: #555;
}
.bug-title {
  flex: 1;
}
.bug-cat {
  font-size: 0.8rem;
  color: #888;
}
.bug-pts {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2563eb;
}
.empty-state {
  color: #888;
  font-style: italic;
}

.missed-category {
  margin-bottom: 0.35rem;
}
.missed-category summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 6px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.missed-category summary:hover {
  background: #f9fafb;
}
.missed-count {
  font-weight: 400;
  color: #888;
  font-size: 0.85rem;
}
.missed-category[open] summary {
  border-radius: 6px 6px 0 0;
}

/* ── Live coverage strip (findings panel) ──────────────────────────────────── */
.coverage-live {
  flex-shrink: 0;
  padding: 0.5rem 1rem 0.6rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.cov-live-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.35rem;
}
#cov-live-msg {
  font-weight: 500;
  color: #374151;
}
.cov-msg-muted {
  font-weight: 400 !important;
  color: #999 !important;
  font-style: italic;
}
.cov-live-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}
.cov-reset {
  font-size: 0.72rem;
  color: #666;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
}
.cov-reset:hover {
  background: #f3f4f6;
  color: #374151;
}
#cov-hint-level {
  font-size: 0.72rem;
  color: #666;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
}
.cov-bar {
  height: 5px;
  background: #eef0f2;
  border-radius: 3px;
  overflow: hidden;
}
.cov-bar-fill {
  height: 100%;
  width: 0;
  background: #22c55e;
  border-radius: 3px;
  transition: width 0.25s ease;
}
.cov-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.45rem;
}
.cov-chip {
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  white-space: nowrap;
}
.cov-chip-hit {
  background: #dcfce7;
  color: #166534;
}
.cov-chip-typed {
  background: #fef3c7;
  color: #92400e;
}
/* `all` mode: the full checklist with copy-pasteable samples */
.cov-live-list {
  margin-top: 0.5rem;
  max-height: 42vh;
  overflow-y: auto;
  display: none;
}
.cov-live-row {
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.2rem;
  background: #f9fafb;
}
.cov-live-hit {
  background: #dcfce7;
}
.cov-live-typed {
  background: #fef3c7;
}
.cov-live-row-head {
  font-size: 0.78rem;
  color: #374151;
  margin-bottom: 0.2rem;
}
.cov-live-todo .cov-live-row-head {
  color: #6b7280;
}
.cov-sample {
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
}
.cov-sample code {
  flex: 1;
  font-size: 0.7rem;
  background: #fff;
  border: 1px solid #eef0f2;
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
  overflow-wrap: anywhere;
  color: #4b5563;
}
.cov-sample-note {
  font-size: 0.72rem;
  color: #888;
  font-style: italic;
}
.cov-copy {
  font-size: 0.68rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  background: #fff;
  color: #555;
  cursor: pointer;
  flex-shrink: 0;
}
.cov-copy:hover:not(:disabled) {
  background: #f3f4f6;
  color: #111;
}
.cov-copy:disabled {
  cursor: default;
  color: #bbb;
}
.cov-chip-empty {
  font-size: 0.75rem;
  color: #999;
  font-style: italic;
}

/* ── Input coverage ────────────────────────────────────────────────────────── */
.cov-group {
  font-size: 0.9rem;
  color: #555;
  margin: 1rem 0 0.4rem;
}
.cov-group:first-child {
  margin-top: 0;
}
.cov-badge {
  display: inline-block;
  width: 1.1rem;
  font-weight: 700;
}
.cov-hit summary {
  background: #dcfce7;
}
.cov-hit summary:hover {
  background: #cdf3dd;
}
.cov-typed summary {
  background: #fef3c7;
}
.cov-typed summary:hover {
  background: #fde9a9;
}
.cov-body {
  padding: 0.6rem 0.75rem 0.75rem;
  background: #fff;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.cov-why {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 0.4rem;
}
.cov-example code {
  background: #f3f4f6;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.cov-example {
  font-size: 0.85rem;
  color: #666;
  margin: 0;
}
.cov-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  background: #f9fafb;
  border: 1px solid #eef0f2;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .split-layout {
    flex-direction: column;
    height: auto;
  }
  .panel-app {
    height: 50vh;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }
  .panel-reports {
    width: 100%;
    min-height: 50vh;
  }
}
