/* Small polish layer on top of Tailwind. */

html {
  scroll-behavior: smooth;
}

body {
  font-feature-settings: 'ss01', 'cv11';
}

.view {
  animation: fadein 240ms ease-out;
}

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

/* Range slider accent */
.range-accent {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(90deg, rgba(251, 179, 33, 0.8) var(--pct, 30%), rgba(100, 116, 139, 0.35) var(--pct, 30%));
  border-radius: 9999px;
  outline: none;
}

.range-accent::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: #fbb321;
  border: 3px solid #0f172a;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(251, 179, 33, 0.4);
  transition: transform 120ms ease;
}

.range-accent::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

.range-accent::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: #fbb321;
  border: 3px solid #0f172a;
  cursor: pointer;
}

/* Chat bubbles */
.bubble {
  max-width: 88%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.45;
  font-size: 0.925rem;
  box-shadow: 0 10px 30px -20px rgba(0, 0, 0, 0.6);
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-user {
  align-self: flex-end;
  background: linear-gradient(180deg, #fbb321, #ea8c0c);
  color: #0b1220;
  border: 1px solid rgba(251, 179, 33, 0.5);
}

.bubble-agent {
  align-self: flex-start;
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.bubble-system {
  align-self: center;
  font-size: 0.75rem;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.5);
  border: 1px dashed rgba(148, 163, 184, 0.3);
}

/* Market-check bubbles (AppstoreSpy uniqueness gate) */
.bubble-market {
  align-self: center;
  max-width: 92%;
  font-size: 0.72rem;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: none;
  animation: fadein 200ms ease-out;
}

.bubble-market-ok {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.bubble-market-warn {
  color: #fcd34d;
  background: rgba(251, 179, 33, 0.08);
  border: 1px solid rgba(251, 179, 33, 0.3);
}

.bubble-market-swap {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

/* Market ribbon inside doc cards */
.market-ribbon {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  animation: fadein 160ms ease-out;
}

.market-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 500;
  border: 1px solid currentColor;
  letter-spacing: 0.01em;
  background: rgba(15, 23, 42, 0.4);
}

.market-pill-checking {
  color: #94a3b8;
}

.market-pill-ok {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.08);
}

.market-pill-warn {
  color: #fcd34d;
  background: rgba(251, 179, 33, 0.08);
}

.market-pill-swap {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.1);
}

.market-pill-swap svg {
  opacity: 0.8;
}

.market-pill-swap strong {
  color: #ddd6fe;
  font-weight: 600;
}

/* Document card */
.doc-card {
  position: relative;
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.45));
  padding: 1.25rem;
  backdrop-filter: blur(8px);
  transition: border-color 200ms, transform 200ms;
}

.doc-card:hover {
  border-color: rgba(251, 179, 33, 0.35);
  transform: translateY(-2px);
}

.doc-card[data-state='completed'] {
  border-color: rgba(52, 211, 153, 0.35);
}

.doc-card[data-state='failed'],
.doc-card[data-state='needs_human_review'] {
  border-color: rgba(244, 63, 94, 0.4);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid currentColor;
  letter-spacing: 0.01em;
}

.badge-idle {
  color: #94a3b8;
}

.badge-running {
  color: #fcc949;
}

.badge-done {
  color: #34d399;
}

.badge-fail {
  color: #f87171;
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(251, 179, 33, 0.35);
  background: rgba(251, 179, 33, 0.08);
  color: #fcd889;
  font-size: 0.75rem;
}

/* Progress timeline */
.phase-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.phase-row.active {
  color: #fcd889;
}

.phase-row.done {
  color: #34d399;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0.4;
  flex-shrink: 0;
}

.phase-row.active .phase-dot {
  opacity: 1;
  animation: pulse 1.4s ease-in-out infinite;
}

.phase-row.done .phase-dot {
  opacity: 1;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(251, 179, 33, 0.6);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(251, 179, 33, 0);
  }
}

/* Subtle scrollbar */
#chat-log::-webkit-scrollbar {
  width: 6px;
}

#chat-log::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 9999px;
}

/* Review panel (collapsible summary inside doc cards) */
.review-panel {
  border-top: 1px dashed rgba(148, 163, 184, 0.2);
  padding-top: 0.6rem;
}

.review-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
  padding: 0.15rem 0;
  outline: none;
}

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

.review-chevron {
  transition: transform 160ms ease;
  color: #94a3b8;
  flex-shrink: 0;
}

.review-panel[open] .review-chevron {
  transform: rotate(90deg);
  color: #fcc949;
}

.review-body {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.review-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.review-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid currentColor;
  letter-spacing: 0.01em;
}

.review-score-pass {
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}

.review-score-warn {
  color: #fcc949;
  background: rgba(251, 179, 33, 0.08);
}

.review-meta {
  font-size: 0.65rem;
  color: #64748b;
  letter-spacing: 0.02em;
}

.review-subs {
  display: grid;
  gap: 0.3rem;
}

.review-sub {
  display: grid;
  grid-template-columns: minmax(7.5rem, auto) 1fr 2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
}

.review-sub-bar {
  position: relative;
  height: 4px;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.review-sub-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #fbb321, #fcc949);
  border-radius: inherit;
}

.review-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.review-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.review-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.review-list li {
  position: relative;
  padding-left: 0.85rem;
  font-size: 0.72rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.review-list li::before {
  content: '';
  position: absolute;
  left: 0.2rem;
  top: 0.5rem;
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0.5;
}

.review-sev {
  display: inline-flex;
  align-items: center;
  padding: 0 0.35rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.review-sev-high {
  color: #fecaca;
  background: rgba(244, 63, 94, 0.18);
}

.review-sev-medium,
.review-sev-mid {
  color: #fde68a;
  background: rgba(251, 179, 33, 0.18);
}

.review-sev-low {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.15);
}

.review-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.65rem;
  color: #94a3b8;
  margin-right: 0.35rem;
}

/* ---------- Market report (inline summary + modal) ---------- */

.market-report {
  border-top: 1px dashed rgba(148, 163, 184, 0.15);
  padding-top: 0.6rem;
}

.market-report-empty {
  font-size: 0.7rem;
  color: #64748b;
  font-style: italic;
}

.market-report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.market-report-summary {
  font-size: 0.72rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.market-report-btn {
  appearance: none;
  border: 1px solid rgba(251, 179, 33, 0.35);
  background: rgba(251, 179, 33, 0.08);
  color: #fcd889;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 160ms, color 160ms, border-color 160ms;
}

.market-report-btn:hover {
  background: rgba(251, 179, 33, 0.18);
  color: #fde68a;
  border-color: rgba(251, 179, 33, 0.55);
}

.market-verdict-ok {
  color: #6ee7b7;
  font-weight: 600;
}

.market-verdict-warn {
  color: #fcd34d;
  font-weight: 600;
}

/* Modal shell */
.market-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.market-modal.is-open {
  display: flex;
}

.market-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  animation: fadein 160ms ease-out;
}

.market-modal-dialog {
  position: relative;
  width: min(780px, 100%);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  animation: fadein 200ms ease-out;
}

.market-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.market-modal-eyebrow {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fcd889;
}

.market-modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f1f5f9;
  margin-top: 0.15rem;
}

.market-modal-meta {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.market-modal-close {
  appearance: none;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.market-modal-close:hover {
  color: #f8fafc;
}

.market-modal-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Timeline */
.market-timeline-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.market-timeline-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fcd889;
  letter-spacing: 0.02em;
  margin: 0;
}

.market-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.market-timeline-entry {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.85rem;
  padding: 0.75rem 0.85rem;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.market-timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.market-timeline-phrase {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.82rem;
}

.market-timeline-meta {
  font-size: 0.68rem;
  color: #94a3b8;
  letter-spacing: 0.01em;
}

.market-probes {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
  margin-top: 0.15rem;
}

.market-probes th,
.market-probes td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
  color: #cbd5e1;
}

.market-probes th {
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.6rem;
}

.market-probes code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fde68a;
  font-size: 0.65rem;
}
