/* ===== CSS Variables ===== */
:root {
  --color-bg: #0f0f0f;
  --color-bg-card: #1a1a1a;
  --color-bg-card-hover: #222;
  --color-text: #f5f5f5;
  --color-text-muted: #888;
  --color-primary: #6366f1;
  --color-primary-hover: #818cf8;
  --color-gift: #10b981;
  --color-pay: #f59e0b;
  --color-barter-safe: #3b82f6;
  --color-barter-unsafe: #ef4444;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

/* Global scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

::-webkit-scrollbar-corner {
  background: var(--color-bg);
}

/* Resize handle styling */
::-webkit-resizer {
  background: linear-gradient(135deg, transparent 50%, #444 50%, #444 60%, transparent 60%, transparent 70%, #444 70%, #444 80%, transparent 80%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 1rem 0;
  height: 60px;
  border-bottom: 1px solid #222;
  background: var(--color-bg);
  transition: transform 0.3s ease;
}

.header.compact .logo {
  font-size: 1.25rem;
}

.header.compact .tagline {
  display: none;
}

.header.hidden {
  transform: translateY(-100%);
}

.header .container {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  transition: font-size 0.3s ease;
}

.logo span {
  color: var(--color-primary);
  margin-left: 0.5rem;
}

.tagline {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.connection-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error);
  transition: var(--transition);
}

.connection-status.connected .status-dot {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.status-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.status-ping {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Mobile Status Bar (below header) */
.mobile-status-bar {
  display: none;
  position: sticky;
  top: 60px;
  z-index: 999;
  background: var(--color-bg-card);
  border-bottom: 1px solid #222;
  padding: 0.5rem 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mobile-status-bar .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error);
}

.mobile-status-bar.connected .status-dot {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.mobile-status-bar.scrolled {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

/* Header inline status (replaces tagline on scroll - mobile only) */
.header-status-mobile {
  display: none;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  margin-left: auto;
  margin-right: auto;
}

.header-status-mobile .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-error);
}

.header-status-mobile.connected .status-dot {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.header-status-mobile .status-text {
  color: var(--color-text-muted);
}

.header-status-mobile .status-ping {
  color: var(--color-text-muted);
  font-size: 0.7rem;
}

/* When scrolled: show inline status, hide tagline */
.header.scrolled .tagline {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  pointer-events: none;
}

.header.scrolled .header-status-mobile {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1079px) {
  .mobile-status-bar {
    display: flex;
  }
  
  .header-status-mobile {
    display: flex;
  }
  
  .header .connection-status {
    display: none;
  }
  
  .tagline {
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
}

/* ===== Hero ===== */
.hero {
  padding: 4rem 0;
  text-align: center;
  background: linear-gradient(180deg, var(--color-bg) 0%, #151515 100%);
}

.hero h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

/* ===== Section Titles ===== */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* ===== Flow Cards Grid ===== */
.flows {
  padding: 3rem 0;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.flow-card {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  border: 1px solid #333;
  position: relative;
  overflow: hidden;
  /* Business card ratio ~3.5:2 (1.75:1) */
  aspect-ratio: 1.75 / 1;
  display: flex;
  flex-direction: column;
}

.flow-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  transition: box-shadow 0.3s ease, height 0.3s ease;
}

.flow-card:hover::before {
  height: 2px;
  box-shadow: 0 0 6px currentColor;
}

/* Flow card colors */
.flow-gift::before { background: var(--color-gift); box-shadow: 0 0 0 var(--color-gift); }
.flow-pay::before { background: var(--color-pay); box-shadow: 0 0 0 var(--color-pay); }
.flow-barter-safe::before { background: var(--color-barter-safe); box-shadow: 0 0 0 var(--color-barter-safe); }
.flow-barter-unsafe::before { background: var(--color-barter-unsafe); box-shadow: 0 0 0 var(--color-barter-unsafe); }

.flow-gift:hover::before { box-shadow: 0 0 12px var(--color-gift); }
.flow-pay:hover::before { box-shadow: 0 0 12px var(--color-pay); }
.flow-barter-safe:hover::before { box-shadow: 0 0 12px var(--color-barter-safe); }
.flow-barter-unsafe:hover::before { box-shadow: 0 0 12px var(--color-barter-unsafe); }

.flow-icon {
  font-size: 1.25rem;
  opacity: 0.8;
  flex-shrink: 0;
}

.flow-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.flow-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.flow-subtitle {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.75rem;
}

/* ===== Flow Diagrams ===== */
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  min-height: 70px;
  margin-top: 1.5rem;
}

.flow-party {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.party-icon {
  font-size: 1.25rem;
}

.party-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
}

.party-note {
  font-size: 0.55rem;
  color: var(--color-warning);
  font-style: italic;
}

.flow-party.escrow .party-icon {
  background: rgba(245, 158, 11, 0.2);
  padding: 0.5rem;
  border-radius: 50%;
}

/* Arrows */
.flow-arrow {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
  position: relative;
}

.arrow-line {
  width: 40px;
  height: 2px;
  background: var(--color-text-muted);
}

.arrow-line.dashed {
  background: repeating-linear-gradient(
    90deg,
    var(--color-text-muted) 0px,
    var(--color-text-muted) 4px,
    transparent 4px,
    transparent 8px
  );
  width: 60px;
}

.arrow-head {
  color: var(--color-text-muted);
  font-size: 1rem;
}

.arrow-head-triangle {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid var(--color-text-muted);
}

.arrow-head-triangle.left {
  border-left: none;
  border-right: 12px solid var(--color-text-muted);
}

.arrow-label {
  position: absolute;
  top: -18px;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.arrow-label.bottom {
  top: auto;
  bottom: -18px;
}

.arrow-label.center {
  position: static;
  margin-top: 0.5rem;
}

.flow-arrow-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

/* Pay diagram specific */
.pay-diagram .flow-arrow-stack {
  gap: 0.5rem;
}

.pay-diagram .flow-arrow-stack .flow-arrow {
  flex: 0;
}

.flow-arrow-stack.bidirectional {
  gap: 0.25rem;
}

/* Pay diagram Y-branch arrow */
.flow-arrow-y {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 50px;
}

.y-branch {
  position: absolute;
  width: 20px;
  height: 2px;
  background: var(--color-text-muted);
  right: 0;
}

.y-branch.top {
  top: 8px;
  transform: rotate(-30deg);
  transform-origin: right center;
}

.y-branch.bottom {
  bottom: 8px;
  transform: rotate(30deg);
  transform-origin: right center;
}

.y-branch::after {
  content: '';
  position: absolute;
  right: -8px;
  top: -5px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid var(--color-text-muted);
}

.flow-arrow.reverse .arrow-label {
  top: auto;
  bottom: -18px;
}

/* Three-party escrow diagram */
.flow-diagram.three-party {
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.flow-escrow-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.escrow-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(59, 130, 246, 0.15);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-barter-safe);
}

.escrow-box .party-icon {
  font-size: 1.5rem;
}

.flow-arrow.down-right,
.flow-arrow.down-left {
  font-size: 0.6rem;
}

/* ===== Flow Description & Features ===== */
.flow-description {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
  flex: 1;
}

.flow-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
}

.feature-tag {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  color: var(--color-success);
}

.feature-tag.warning {
  color: var(--color-warning);
  background: rgba(245, 158, 11, 0.1);
}

.feature-tag.neutral {
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.05);
}

/* ===== API Tester Section ===== */
.api-tester {
  padding: 3rem 0;
  background: #151515;
}

.tester-connection {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--color-bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid #333;
}

.connection-info {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.connection-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-ping {
  background: transparent;
  border: 1px solid #444;
  color: var(--color-text-muted);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-ping:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.flow-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid #333;
}

.flow-toggles.hidden {
  display: none;
}

/* Mobile: flow toggles go full width */
@media (max-width: 767px) {
  .tester-connection {
    flex-direction: column;
    align-items: stretch;
  }
  
  .connection-info {
    justify-content: space-between;
    width: 100%;
  }
  
  .connection-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .connection-buttons > .btn {
    width: 100%;
  }
  
  .flow-toggles {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    padding-top: 0.5rem;
    border-top: 1px solid #333;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .btn-flow-toggle {
    flex: 1 1 calc(50% - 0.5rem);
    max-width: calc(50% - 0.25rem);
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.7rem;
  }
}

.btn-flow-toggle {
  background: transparent;
  border: 1px solid #333;
  color: var(--color-text-muted);
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-flow-toggle:hover {
  border-color: #555;
  color: var(--color-text);
}

.btn-flow-toggle.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-flow-toggle[data-flow="gift"].active {
  background: var(--color-gift);
  border-color: var(--color-gift);
}

.btn-flow-toggle[data-flow="pay"].active {
  background: var(--color-pay);
  border-color: var(--color-pay);
}

.btn-flow-toggle[data-flow="barter-safe"].active {
  background: var(--color-barter-safe);
  border-color: var(--color-barter-safe);
}

.btn-flow-toggle[data-flow="barter-unsafe"].active {
  background: var(--color-barter-unsafe);
  border-color: var(--color-barter-unsafe);
}

.tester-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.tester-grid:empty {
  display: none;
}

.tester-card {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid #333;
  border-top: 3px solid #555;
  max-width: 700px;
  width: 100%;
}

.tester-card.hidden {
  display: none;
}

/* Tester Flow Layout - mirrors flow diagrams */
.tester-flow-layout {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tester-party {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.party-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #333;
}

.party-header .party-icon {
  font-size: 1.5rem;
}

.party-header .party-name {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.tester-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  min-width: 80px;
}

.tester-arrow .arrow-line-container {
  display: flex;
  align-items: center;
}

.tester-arrow .arrow-line {
  width: 50px;
  height: 2px;
  background: var(--color-text-muted);
}

.tester-arrow .arrow-head-triangle {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid var(--color-text-muted);
}

.tester-arrow .arrow-label {
  position: static;
  margin-top: 0.5rem;
  font-size: 0.7rem;
}

.tester-gift .tester-arrow .arrow-line { background: var(--color-gift); }
.tester-gift .tester-arrow .arrow-head-triangle { border-left-color: var(--color-gift); }
.tester-gift .tester-arrow .arrow-label { color: var(--color-gift); }

.tester-card.tester-gift {
  max-width: 800px;
}

.tester-gift { border-top-color: var(--color-gift); }

/* Gift Items Section */
.gift-items-section {
  margin-bottom: 0.75rem;
}

.gift-items-section > label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.gift-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  max-height: 192px;
  overflow-y: auto;
}

.gift-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.gift-item-row .item-name {
  flex: 1;
}

.gift-item-row .item-fmv {
  color: var(--color-gift);
  font-family: 'SF Mono', Monaco, monospace;
}

.gift-item-row .btn-remove-item {
  background: transparent;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 1rem;
  line-height: 1;
}

.add-item-row {
  display: flex;
  gap: 0.35rem;
}

.add-item-row input[type="text"] {
  flex: 1;
}

.add-item-row input[type="number"] {
  width: 80px;
}

.add-item-row input {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
}

.btn-add-item {
  background: var(--color-gift);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: var(--transition);
}

.btn-add-item:hover {
  background: #0d9668;
}

.gift-total {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.gift-total span:last-child {
  color: var(--color-gift);
  font-family: 'SF Mono', Monaco, monospace;
}

.btn-gift {
  background: var(--color-gift);
  width: 100%;
}

.btn-gift:hover {
  background: #0d9668;
}

/* ========== Pay Flow Tester ========== */
.tester-card.tester-pay {
  max-width: 900px;
}

.tester-pay { border-top-color: var(--color-pay); }

.tester-pay .tester-arrow .arrow-line { background: var(--color-pay); }
.tester-pay .tester-arrow .arrow-head-triangle { border-left-color: var(--color-pay); }
.tester-pay .tester-arrow .arrow-head-triangle.left { border-left-color: transparent; border-right-color: var(--color-pay); }
.tester-pay .tester-arrow .arrow-label { color: var(--color-pay); }

/* Store Section */
.store-section,
.cart-section,
.payment-section {
  margin-bottom: 0.75rem;
}

.store-section > label,
.cart-section > label,
.payment-section > label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.store-inventory,
.payment-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px dashed #444;
}

.store-item,
.payment-inv-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.store-item:hover,
.payment-inv-item:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--color-pay);
}

.store-item .item-price,
.payment-inv-item .item-price {
  color: var(--color-pay);
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

/* Cart Items */
.cart-items,
.payment-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 40px;
  max-height: 100px;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 0.35rem;
}

.cart-items .empty-state,
.payment-items .empty-state {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

.cart-item,
.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  background: rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.cart-item .item-name,
.payment-item .item-name {
  flex: 1;
}

.cart-item .item-price,
.payment-item .item-price {
  color: var(--color-pay);
  font-family: 'SF Mono', Monaco, monospace;
  margin-right: 0.5rem;
}

.cart-item .btn-remove,
.payment-item .btn-remove {
  background: transparent;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 0.9rem;
  line-height: 1;
}

.cart-total,
.payment-total {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  background: rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.cart-total span:last-child,
.payment-total span:last-child {
  color: var(--color-pay);
  font-family: 'SF Mono', Monaco, monospace;
}

/* Value Matcher */
.value-matcher {
  margin: 0.75rem 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

.matcher-bar {
  position: relative;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: visible;
  margin-bottom: 0.35rem;
}

.matcher-fill {
  height: 100%;
  background: var(--color-error);
  border-radius: 4px;
  transition: width 0.3s, background 0.3s;
  width: 0%;
}

.matcher-fill.matched {
  background: var(--color-success);
}

.matcher-fill.close {
  background: var(--color-pay);
}

.matcher-target {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: white;
  border-radius: 2px;
  left: 100%;
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.matcher-status {
  font-size: 0.7rem;
  text-align: center;
  color: var(--color-text-muted);
}

.matcher-status.matched {
  color: var(--color-success);
  font-weight: 600;
}

.matcher-status.over {
  color: var(--color-error);
}

/* Pay Button */
.btn-pay {
  background: var(--color-pay);
  width: 100%;
}

.btn-pay:hover:not(:disabled) {
  background: #d97706;
}

.btn-pay:disabled {
  background: #666;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Seller States */
.seller-state {
  text-align: center;
  padding: 1rem;
}

.seller-state.hidden {
  display: none;
}

.seller-empty {
  opacity: 0.5;
}

.seller-empty .empty-hint {
  font-style: italic;
  color: var(--color-text-muted);
}

.seller-state .state-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.seller-state p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.received-details,
.transaction-summary {
  background: rgba(245, 158, 11, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.7rem;
  text-align: left;
}

.received-details .detail-row,
.transaction-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
}

.btn-confirm {
  background: var(--color-success);
  width: 100%;
}

.btn-confirm:hover {
  background: #059669;
}

.btn-new-pay {
  background: var(--color-pay);
  width: 100%;
}

.btn-new-pay:hover {
  background: #d97706;
}

/* Pay Arrow Stack */
.tester-arrow-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
  min-width: 80px;
}

.tester-arrow-stack .tester-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.arrow-payment,
.arrow-goods {
  opacity: 0.4;
  transition: opacity 0.3s;
}

.arrow-payment.active,
.arrow-goods.active {
  opacity: 1;
}

/* Gift Animation */
.gift-animation-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Processing State */
.tester-party.processing {
  opacity: 0.6;
  pointer-events: none;
}

.tester-party.processing::after {
  content: 'Processing...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-bg-card);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-gift);
}

.tester-party {
  position: relative;
}

/* Tax Receipt */
.tax-receipt {
  margin-top: 1rem;
  background: #fffef5;
  border: 1px dashed #ccc;
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: #333;
}

.tax-receipt.hidden {
  display: none;
}

.receipt-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed #ccc;
}

.receipt-header .receipt-icon {
  font-size: 1.25rem;
}

.receipt-header h5 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

.receipt-thank-you {
  text-align: center;
  padding: 0.5rem;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.receipt-thank-you p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: #92400e;
}

.receipt-details {
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px dotted #ddd;
}

.receipt-items {
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
}

.receipt-items .receipt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.25rem;
  border-radius: 2px;
}

.receipt-item .item-name {
  flex: 1;
}

.receipt-item .item-fmv {
  font-weight: 600;
  color: #10b981;
  min-width: 60px;
  text-align: right;
}

.receipt-item .item-fmv.fmv-pending {
  color: #888;
  font-style: italic;
  font-weight: normal;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  margin-top: 0.5rem;
  background: #10b981;
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
}

.receipt-total .item-fmv {
  color: white;
}

.receipt-footer {
  text-align: center;
  margin-top: 0.5rem;
  color: #666;
  font-size: 0.65rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Recipient States */
.tester-party.disabled {
  opacity: 0.5;
}

.tester-party.disabled .party-header {
  opacity: 0.7;
}

.tester-giver.locked {
  opacity: 0.4;
  pointer-events: none;
}

.tester-giver.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

/* Pay flow buyer locked state */
.tester-buyer.locked {
  opacity: 0.4;
  pointer-events: none;
  position: relative;
}

.tester-buyer.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.tester-recipient.active {
  opacity: 1;
}

.recipient-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
}

.recipient-state.hidden {
  display: none;
}

.recipient-state .state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.recipient-state p {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0;
}

/* Bounce animation */
.state-icon.bounce {
  animation: bounce 0.6s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Spin animation */
.state-icon.spin {
  animation: spin 1s linear infinite;
}

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

/* Processing bar */
.processing-bar {
  width: 100%;
  max-width: 150px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  margin-top: 1rem;
  overflow: hidden;
}

.processing-fill {
  height: 100%;
  width: 0%;
  background: var(--color-gift);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.processing-fill.animate {
  animation: processingBar 1.5s ease-out forwards;
}

@keyframes processingBar {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* Receipt animation */
.tax-receipt.printing {
  animation: printReceipt 0.5s ease-out forwards;
}

@keyframes printReceipt {
  0% {
    opacity: 0;
    transform: translateY(-20px) scaleY(0.3);
    transform-origin: top center;
  }
  50% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

.btn-new-gift {
  margin-top: 1rem;
  width: 100%;
  background: var(--color-gift);
}

.btn-new-gift:hover {
  background: #0d9668;
}

/* ========== Direct Flow Tester ========== */
.tester-card.tester-barter-unsafe {
  max-width: 1000px;
}

.tester-barter-unsafe .tester-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  text-align: center;
}

.direct-flow-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}

.direct-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid #333;
  transition: var(--transition);
}

.direct-panel.party-a {
  border-top: 3px solid var(--color-pay);
}

.direct-panel.party-b {
  border-top: 3px solid var(--color-barter-unsafe);
}

.direct-panel.locked {
  opacity: 0.5;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #444;
}

.panel-icon {
  font-size: 1.25rem;
}

.panel-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.panel-section {
  margin-bottom: 0.75rem;
}

.panel-section .section-title {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.offering-total {
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

.party-a .offering-total {
  color: var(--color-pay);
}

.party-b .offering-total {
  color: var(--color-barter-unsafe);
}

.direct-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-height: 100px;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px dashed #444;
}

.direct-inventory .inv-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
}

.party-a .inv-item {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.party-a .inv-item:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--color-pay);
}

.party-b .inv-item {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.party-b .inv-item:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--color-barter-unsafe);
}

.inv-item .item-price {
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

.party-a .inv-item .item-price {
  color: var(--color-pay);
}

.party-b .inv-item .item-price {
  color: var(--color-barter-unsafe);
}

.direct-offering {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 50px;
  max-height: 80px;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
}

.direct-offering .empty-state {
  color: var(--color-text-muted);
  font-size: 0.65rem;
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

.direct-offering .offer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
}

.party-a .offer-item {
  background: rgba(245, 158, 11, 0.15);
}

.party-b .offer-item {
  background: rgba(239, 68, 68, 0.15);
}

.offer-item .item-name {
  flex: 1;
}

.offer-item .item-price {
  font-family: 'SF Mono', Monaco, monospace;
  margin-right: 0.4rem;
}

.party-a .offer-item .item-price {
  color: var(--color-pay);
}

.party-b .offer-item .item-price {
  color: var(--color-barter-unsafe);
}

.offer-item .btn-remove {
  background: transparent;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.85rem;
  line-height: 1;
}

/* Direct Center */
.direct-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  min-width: 120px;
}

.exchange-arrows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.exchange-arrow {
  display: flex;
  align-items: center;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.exchange-arrow.active {
  opacity: 1;
}

.exchange-arrow .arrow-track {
  width: 70px;
  height: 24px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exchange-arrow .arrow-total {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  transition: color 0.3s;
}

.arrow-left .arrow-total {
  color: var(--color-barter-unsafe);
}

.arrow-right .arrow-total {
  color: var(--color-pay);
}

.exchange-arrow.active .arrow-total {
  animation: pulseTotalText 0.5s ease;
}

@keyframes pulseTotalText {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.exchange-arrow .arrow-items {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  padding: 0 4px;
  font-size: 0.65rem;
  white-space: nowrap;
}

.arrow-left .arrow-items {
  animation: none;
  right: 100%;
}

.arrow-right .arrow-items {
  animation: none;
  left: 100%;
}

.arrow-left.active .arrow-items {
  animation: slideLeft 1s ease-out forwards;
}

.arrow-right.active .arrow-items {
  animation: slideRight 1s ease-out forwards;
}

@keyframes slideLeft {
  0% { right: 100%; }
  100% { right: -100%; }
}

@keyframes slideRight {
  0% { left: 100%; }
  100% { left: -100%; }
}

.exchange-arrow .arrow-head {
  color: #666;
  font-size: 1rem;
  transition: color 0.3s;
}

.arrow-left .arrow-head {
  color: var(--color-barter-unsafe);
}

.arrow-right .arrow-head {
  color: var(--color-pay);
}

.exchange-arrow.active .arrow-head {
  animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.btn-barter {
  background: linear-gradient(135deg, var(--color-pay), var(--color-barter-unsafe));
  color: white;
  font-weight: 700;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.btn-barter:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-barter:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-barter.processing {
  animation: barterPulse 0.8s ease infinite;
}

@keyframes barterPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.barter-status {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

.barter-status.ready {
  color: var(--color-success);
}

/* Direct Completed */
.direct-completed {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  animation: fadeIn 0.5s ease;
}

.direct-completed.hidden {
  display: none;
}

.direct-completed .completed-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.direct-completed h5 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--color-success);
}

.completed-summary {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  text-align: left;
}

.completed-summary .summary-section {
  margin-bottom: 0.75rem;
}

.completed-summary .summary-section:last-child {
  margin-bottom: 0;
}

.completed-summary .summary-label {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  margin-bottom: 0.25rem;
}

.completed-summary .summary-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.completed-summary .summary-item {
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
}

.completed-summary .summary-item.from-a {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-pay);
}

.completed-summary .summary-item.from-b {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-barter-unsafe);
}

/* Direct Flow Responsive */
@media (max-width: 1079px) {
  .direct-flow-container {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .direct-center {
    flex-direction: column;
    padding: 0.75rem;
    order: 1;
    min-width: 100%;
  }
  
  .direct-panel.party-a {
    order: 0;
  }
  
  .direct-panel.party-b {
    order: 2;
  }
  
  .exchange-arrows {
    flex-direction: row;
    margin-bottom: 0.5rem;
    margin-right: 0;
    gap: 1rem;
  }
  
  .exchange-arrow {
    flex-direction: column;
  }
  
  .exchange-arrow .arrow-track {
    width: 60px;
    height: 24px;
  }
  
  .exchange-arrow .arrow-head {
    transform: rotate(90deg);
  }
  
  .arrow-left .arrow-head {
    transform: rotate(-90deg);
  }
}

/* ========== Escrow Flow Tester ========== */
.tester-card.tester-barter-safe {
  max-width: 1000px;
}

.tester-barter-safe .tester-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  text-align: center;
}

.escrow-flow-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}

.escrow-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid #333;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.escrow-panel.escrow-party-a {
  border-top: 3px solid var(--color-barter-safe);
}

.escrow-panel.escrow-party-b {
  border-top: 3px solid var(--color-primary);
}

.escrow-panel.locked {
  opacity: 0.5;
  pointer-events: none;
}

.escrow-panel.sent {
  opacity: 0.6;
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--color-success);
}

.escrow-panel.sent::after {
  content: '✓ Sent to Escrow';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-success);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
}

.escrow-panel {
  position: relative;
}

.escrow-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-height: 100px;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px dashed #444;
}

.escrow-inventory .inv-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
}

.escrow-party-a .inv-item {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.escrow-party-a .inv-item:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--color-barter-safe);
}

.escrow-party-b .inv-item {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.escrow-party-b .inv-item:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--color-primary);
}

.escrow-party-a .inv-item .item-price {
  color: var(--color-barter-safe);
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

.escrow-party-b .inv-item .item-price {
  color: var(--color-primary);
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

.escrow-party-a .offering-total {
  color: var(--color-barter-safe);
}

.escrow-party-b .offering-total {
  color: var(--color-primary);
}

.escrow-offering {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 50px;
  max-height: 80px;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.escrow-offering .empty-state {
  color: var(--color-text-muted);
  font-size: 0.65rem;
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

.escrow-offering .offer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
}

.escrow-party-a .offer-item {
  background: rgba(59, 130, 246, 0.15);
}

.escrow-party-b .offer-item {
  background: rgba(99, 102, 241, 0.15);
}

.escrow-offering .offer-item .item-name {
  flex: 1;
}

.escrow-offering .offer-item .item-price {
  font-family: 'SF Mono', Monaco, monospace;
  margin-right: 0.4rem;
}

.escrow-party-a .offer-item .item-price {
  color: var(--color-barter-safe);
}

.escrow-party-b .offer-item .item-price {
  color: var(--color-primary);
}

.escrow-offering .offer-item .btn-remove {
  background: transparent;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.85rem;
  line-height: 1;
}

.btn-escrow-send {
  background: var(--color-barter-safe);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: auto;
}

.btn-escrow-send:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.02);
}

.btn-escrow-send:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-escrow-send.sent {
  background: var(--color-success);
  pointer-events: none;
}

/* Escrow Center */
.escrow-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  min-width: 140px;
  gap: 0.5rem;
}

.escrow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.3s, transform 0.3s;
}

.escrow-arrow.active {
  opacity: 1;
}

.escrow-arrow.sending {
  animation: arrowPulse 0.5s ease infinite;
}

@keyframes arrowPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

.escrow-arrow .arrow-label {
  font-size: 1.5rem;
  color: var(--color-barter-safe);
}

.escrow-box {
  background: rgba(59, 130, 246, 0.15);
  border: 2px dashed var(--color-barter-safe);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  min-width: 120px;
  transition: var(--transition);
}

.escrow-box.holding {
  border-style: solid;
  background: rgba(59, 130, 246, 0.25);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.escrow-box.releasing {
  animation: escrowRelease 1s ease-out;
}

@keyframes escrowRelease {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(16, 185, 129, 0.5); }
  100% { transform: scale(1); }
}

.escrow-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.escrow-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.escrow-held {
  min-height: 40px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.escrow-held .escrow-empty {
  color: var(--color-text-muted);
  font-size: 0.65rem;
  font-style: italic;
}

.escrow-held .held-item {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  margin: 0.15rem 0;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
}

.escrow-held .held-item.from-a {
  background: rgba(59, 130, 246, 0.2);
  color: var(--color-barter-safe);
}

.escrow-held .held-item.from-b {
  background: rgba(99, 102, 241, 0.2);
  color: var(--color-primary);
}

.escrow-status {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.escrow-status.ready {
  color: var(--color-success);
  font-weight: 600;
}

/* Escrow Completed */
.escrow-completed {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  animation: fadeIn 0.5s ease;
}

.escrow-completed.hidden {
  display: none;
}

.escrow-completed .completed-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.escrow-completed h5 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--color-success);
}

/* Escrow Flow Responsive */
@media (max-width: 1079px) {
  .escrow-flow-container {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .escrow-center {
    flex-direction: column;
    padding: 0.75rem;
    order: 1;
  }
  
  .escrow-panel.escrow-party-a {
    order: 0;
  }
  
  .escrow-panel.escrow-party-b {
    order: 2;
  }
  
  .escrow-arrow {
    transform: rotate(90deg);
  }
  
  .escrow-box {
    min-width: 100%;
  }
}

.tester-pay { border-top-color: var(--color-pay); }
.tester-barter-safe { border-top-color: var(--color-barter-safe); }
.tester-barter-unsafe { border-top-color: var(--color-barter-unsafe); }

.tester-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.tester-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.form-group label small {
  opacity: 0.7;
}

.form-group input {
  background: var(--color-bg);
  border: 1px solid #444;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--color-text);
  font-size: 0.85rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-group input::placeholder {
  color: #555;
}

.tester-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.btn-action {
  background: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-action:hover {
  background: var(--color-primary-hover);
}

.btn-action.secondary {
  background: transparent;
  border: 1px solid #444;
  color: var(--color-text-muted);
}

.btn-action.secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.tester-log {
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  max-height: 80px;
  overflow-y: auto;
  min-height: 40px;
}

.tester-log:empty::before {
  content: 'No activity yet...';
  opacity: 0.5;
}

.tester-log .log-entry {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tester-log .log-entry:last-child {
  border-bottom: none;
}

.tester-log .log-entry.success {
  color: var(--color-success);
}

.tester-log .log-entry.error {
  color: var(--color-error);
}

/* Event Log Panel */
.event-log-panel {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border: 1px solid #333;
  margin-bottom: 1.5rem;
  position: relative;
}

.event-log-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
}

.event-log-wrapper {
  position: relative;
}

.event-log {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  height: 150px;
  min-height: 50px;
  max-height: 450px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.7rem;
  position: relative;
}

/* Subtle glow overlay when new entry arrives while scrolled */
.event-log-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 25px;
  background: linear-gradient(to bottom, rgba(99, 102, 241, 0.5) 0%, transparent 100%);
  pointer-events: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  z-index: 10;
  opacity: 0;
}

.event-log-glow.visible {
  animation: glowPulse 1.5s ease-out forwards;
}

@keyframes glowPulse {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.event-log-resize-bar {
  height: 8px;
  background: linear-gradient(to bottom, transparent 0%, #333 50%, #444 100%);
  cursor: ns-resize;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: background 0.15s;
  position: relative;
}

.event-log-resize-bar::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 3px;
  background: #555;
  border-radius: 2px;
}

.event-log-resize-bar:hover,
.event-log-resize-bar.dragging {
  background: linear-gradient(to bottom, transparent 0%, #444 50%, #555 100%);
}

.event-log-resize-bar:hover::before,
.event-log-resize-bar.dragging::before {
  background: var(--color-primary);
}

/* Event log scrollbar */
.event-log::-webkit-scrollbar {
  width: 8px;
}

.event-log::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.event-item {
  padding: 0.25rem 0;
  border-bottom: 1px solid #222;
  display: flex;
  gap: 0.5rem;
}

.event-item:last-child {
  border-bottom: none;
}

.event-item.muted {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.event-item .event-time {
  color: var(--color-text-muted);
  min-width: 60px;
}

.event-item .event-type {
  color: var(--color-primary);
  min-width: 90px;
}

.event-item .event-direction {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.7rem;
  min-width: 80px;
  white-space: nowrap;
}

.event-item .event-direction.send {
  color: var(--color-pay);
}

.event-item .event-direction.receive {
  color: var(--color-gift);
}

.event-item .event-details {
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-item.event-gift .event-type { color: var(--color-gift); }
.event-item.event-pay .event-type { color: var(--color-pay); }
.event-item.event-barter .event-type { color: var(--color-barter-safe); }
.event-item.event-direct .event-type { color: var(--color-barter-unsafe); }
.event-item.event-system .event-type { color: var(--color-text-muted); }
.event-item.event-error .event-type { color: var(--color-error); }

/* Legacy status styles (keep for compatibility) */
.status-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.status-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.status-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.85rem;
}

.status-value.connected {
  color: var(--color-success);
}

.status-value.disconnected {
  color: var(--color-error);
}

/* Responsive tester */
@media (max-width: 1079px) {
  .tester-grid {
    grid-template-columns: 1fr;
  }
  
  .tester-connection {
    flex-direction: column;
    gap: 1rem;
  }
  
  .connection-info {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }
  
  .connection-buttons {
    width: 100%;
    justify-content: center;
  }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-connect {
  background: var(--color-primary);
  color: white;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
}

.btn-connect:hover {
  background: var(--color-primary-hover);
}

.btn-connect.connected {
  background: var(--color-error);
}

.btn-connect.connected:hover {
  background: #dc2626;
}

/* ===== Footer ===== */
.footer {
  padding: 2rem 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  border-top: 1px solid #222;
}

.footer hr{
    border: none;
    border-top: 1px solid #333;
    margin: auto;
    width: 69%;
}

.footer blockquote {
  font-size: xx-large;
}

.footer a {
  color: var(--color-primary);
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}

/* ===== Large Screen Scaling ===== */
@media (min-width: 1600px) {
  html {
    font-size: 20px;
  }
  
  .container {
    max-width: 1500px;
  }
  
  .hero h2 {
    font-size: 3.5rem;
  }
  
  .hero p {
    font-size: 1.3rem;
  }
  
  .flow-grid {
    gap: 2rem;
  }
  
  .flow-card {
    padding: 2rem 2.5rem;
  }
  
  .tester-card {
    padding: 2rem;
  }
  
  .tester-card.tester-gift {
    max-width: 950px;
  }
  
  .tester-card.tester-pay {
    max-width: 1050px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 1150px;
  }
}

@media (min-width: 2000px) {
  html {
    font-size: 24px;
  }
  
  .container {
    max-width: 1800px;
  }
  
  .hero h2 {
    font-size: 4rem;
  }
  
  .flow-grid {
    gap: 2.5rem;
  }
  
  .flow-card {
    padding: 2.5rem 3rem;
  }
  
  .tester-card.tester-gift {
    max-width: 1100px;
  }
  
  .tester-card.tester-pay {
    max-width: 1200px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 1400px;
  }
}

@media (min-width: 2560px) {
  html {
    font-size: 28px;
  }
  
  .container {
    max-width: 2200px;
  }
  
  .hero {
    padding: 5rem 0;
  }
  
  .hero h2 {
    font-size: 4.5rem;
  }
  
  .flows {
    padding: 4rem 0;
  }
  
  .flow-grid {
    gap: 3rem;
  }
  
  .flow-card {
    padding: 3rem 3.5rem;
  }
  
  .api-tester {
    padding: 4rem 0;
  }
  
  .tester-card {
    padding: 2.5rem;
  }
  
  .tester-card.tester-gift {
    max-width: 1300px;
  }
  
  .tester-card.tester-pay {
    max-width: 1500px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 1700px;
  }
}

/* 4K screens */
@media (min-width: 3840px) {
  html {
    font-size: 40px;
  }
  
  .container {
    max-width: 3200px;
  }
  
  .hero {
    padding: 6rem 0;
  }
  
  .hero h2 {
    font-size: 5.5rem;
  }
  
  .flows {
    padding: 5rem 0;
  }
  
  .flow-grid {
    gap: 3.5rem;
  }
  
  .flow-card {
    padding: 3.5rem 4rem;
  }
  
  .api-tester {
    padding: 5rem 0;
  }
  
  .tester-card {
    padding: 3rem;
  }
  
  .tester-card.tester-gift {
    max-width: 1800px;
  }
  
  .tester-card.tester-pay {
    max-width: 2000px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 2400px;
  }
}

/* 5K screens */
@media (min-width: 5120px) {
  html {
    font-size: 56px;
  }
  
  .container {
    max-width: 4200px;
  }
  
  .hero {
    padding: 8rem 0;
  }
  
  .hero h2 {
    font-size: 7rem;
  }
  
  .flows {
    padding: 6rem 0;
  }
  
  .flow-grid {
    gap: 4rem;
  }
  
  .flow-card {
    padding: 4rem 5rem;
  }
  
  .api-tester {
    padding: 6rem 0;
  }
  
  .tester-card {
    padding: 3.5rem;
  }
  
  .tester-card.tester-gift {
    max-width: 2400px;
  }
  
  .tester-card.tester-pay {
    max-width: 2800px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 3200px;
  }
}

/* 8K screens */
@media (min-width: 7680px) {
  html {
    font-size: 80px;
  }
  
  .container {
    max-width: 6400px;
  }
  
  .hero {
    padding: 10rem 0;
  }
  
  .hero h2 {
    font-size: 10rem;
  }
  
  .flows {
    padding: 8rem 0;
  }
  
  .flow-grid {
    gap: 5rem;
  }
  
  .flow-card {
    padding: 5rem 6rem;
  }
  
  .api-tester {
    padding: 8rem 0;
  }
  
  .tester-card {
    padding: 4rem;
  }
  
  .tester-card.tester-gift {
    max-width: 3600px;
  }
  
  .tester-card.tester-pay {
    max-width: 4000px;
  }
  
  .tester-card.tester-barter-safe,
  .tester-card.tester-barter-unsafe {
    max-width: 4800px;
  }
}

/* ===== Responsive ===== */
@media (max-width: 1079px) {
  .header .container {
    flex-wrap: wrap;
  }
  
  .connection-status {
    width: 100%;
    margin-top: 1rem;
    justify-content: center;
  }
  
  .hero h2 {
    font-size: 1.75rem;
  }
  
  .flow-grid {
    grid-template-columns: 1fr;
  }
  
  .flow-card {
    aspect-ratio: auto;
    min-height: 280px;
  }
  
  .flow-diagram {
    padding: 1rem;
  }
}

/* ===== Mobile Tester Flow Layouts ===== */
@media (max-width: 1079px) {
  /* Gift & Pay flows: Stack vertically */
  .tester-flow-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  
  .tester-party {
    width: 100%;
  }
  
  /* Arrow rotates to point down */
  .tester-arrow,
  .tester-arrow-stack {
    flex-direction: row;
    justify-content: center;
    padding: 0.75rem 0;
    min-width: auto;
    width: 100%;
  }
  
  .tester-arrow .arrow-line-container {
    flex-direction: column;
    align-items: center;
  }
  
  .tester-arrow .arrow-line {
    width: 2px;
    height: 40px;
  }
  
  .tester-arrow .arrow-head-triangle {
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
    border-top: 10px solid var(--color-gift) !important;
    border-bottom: none !important;
  }
  
  .tester-pay .tester-arrow .arrow-head-triangle {
    border-top-color: var(--color-pay) !important;
  }
  
  .tester-arrow .arrow-head-triangle.left {
    border-top: none !important;
    border-bottom: 10px solid var(--color-pay) !important;
  }
  
  .tester-arrow .arrow-label {
    margin-top: 0;
    margin-left: 0.5rem;
  }
  
  /* Pay flow arrow stack on mobile */
  .tester-arrow-stack {
    flex-direction: row;
    gap: 1.5rem;
  }
  
  .tester-arrow-stack .tester-arrow {
    width: auto;
    padding: 0;
  }
}