/* ============================================================
   KreepCore - Diplomacy Panel (AAA Redesign)
   "Galactic Relations Console" aesthetic
   ============================================================ */

/* ── Panel layout ───────────────────────────────────────────── */
.diplomacy-panel {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 0 4px;
  overflow: visible;
  max-height: none;
}

/* ── Hero banner ─────────────────────────────────────────────
   Sets the frame for the whole section: who this is for and what
   the three sub-sections do. Sits above the Oath Breaker warning
   so the warning still reads as the urgent exception.           */
.diplo-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 4px;
  background:
    linear-gradient(135deg,
      rgba(var(--accent-rgb), 0.06) 0%,
      rgba(var(--accent-rgb), 0.01) 60%,
      transparent 100%
    ),
    rgba(6, 10, 22, 0.5);
  position: relative;
  overflow: hidden;
}
.diplo-hero::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg,
    rgba(var(--accent-rgb), 0.6),
    rgba(var(--accent-rgb), 0.05)
  );
}
.diplo-hero-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  color: var(--cyan);
  opacity: 0.85;
  filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.35));
}
.diplo-hero-icon svg { width: 100%; height: 100%; }
.diplo-hero-body { flex: 1; min-width: 0; }
.diplo-hero-title {
  margin: 0 0 3px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.25);
}
.diplo-hero-desc {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(200, 220, 240, 0.7);
  line-height: 1.45;
}

/* Per-section caption that sits right under each section title and
   explains what the section is for in one or two sentences. */
.diplo-section-desc {
  margin: -0.3rem 0 0.6rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(200, 220, 240, 0.55);
}

/* ── Section titles - scan-line headers ──────────────────────── */
.diplo-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
  position: relative;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.25);
}

/* Glowing underline */
.diplo-section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(var(--accent-rgb), 0.4),
    rgba(var(--accent-rgb), 0.08) 60%,
    transparent
  );
}

/* ── Reputation summary - dramatic display ──────────────────── */
.rep-summary {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.1rem 1.2rem 1.3rem;
  background:
    linear-gradient(135deg,
      rgba(var(--accent-rgb), 0.04) 0%,
      rgba(var(--accent-rgb), 0.01) 100%
    ),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.rep-summary-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.rep-summary-head-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.rep-spark {
  color: var(--cyan);
  opacity: 0.65;
  height: 22px;
  line-height: 0;
}
.rep-spark svg { display: block; }

/* ── Reputation gauge: horizontal segmented bar with a marker.
   7 coloured segments (one per tier), the active tier glows, and
   a caret sits over the exact score. Scale labels sit underneath. */
.rep-gauge {
  position: relative;
  padding-top: 4px;
  padding-bottom: 18px;
}
.rep-gauge-track {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(10, 16, 30, 0.65);
  border: 1px solid rgba(var(--accent-rgb), 0.12);
}
.rep-gauge-seg {
  height: 100%;
  background: rgba(148, 163, 184, 0.25);
  border-right: 1px solid var(--scrim-35);
  transition: filter 0.25s ease, opacity 0.25s ease;
  opacity: 0.55;
}
.rep-gauge-seg:last-child { border-right: 0; }
.rep-gauge-seg.outlaw    { background: #dc2626; }
.rep-gauge-seg.notorious { background: #ef4444; }
.rep-gauge-seg.suspect   { background: #eab308; }
.rep-gauge-seg.neutral   { background: rgba(148, 163, 184, 0.55); }
.rep-gauge-seg.reliable  { background: rgba(200, 220, 240, 0.55); }
.rep-gauge-seg.trusted   { background: #3b82f6; }
.rep-gauge-seg.paragon   { background: #22c55e; }
.rep-gauge-seg.is-active {
  opacity: 1;
  filter: saturate(1.2) brightness(1.1);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.25);
}
.rep-gauge-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 14px;
  background: #f8fafc;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.7);
  pointer-events: none;
}
.rep-gauge-marker::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, -1px);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #f8fafc;
}
.rep-gauge-scale {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: rgba(200, 220, 240, 0.35);
  font-family: var(--font-mono);
}

/* Corner decorations */
.rep-summary::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 12px;
  height: 12px;
  border-top: 1px solid rgba(var(--accent-rgb), 0.25);
  border-left: 1px solid rgba(var(--accent-rgb), 0.25);
}

.rep-summary::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.25);
  border-right: 1px solid rgba(var(--accent-rgb), 0.25);
}

.rep-score {
  font-size: 2.2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 4rem;
  text-align: center;
  text-shadow: 0 0 20px currentColor;
  line-height: 1;
}

/* ── Reputation tier badges ─────────────────────────────────── */
.rep-tier-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

.rep-tier-badge.paragon {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.1);
  text-shadow: 0 0 6px rgba(34, 197, 94, 0.3);
}
.rep-tier-badge.trusted {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}
.rep-tier-badge.reliable {
  background: rgba(200, 220, 240, 0.1);
  color: rgba(200, 220, 240, 0.8);
  border: 1px solid rgba(200, 220, 240, 0.2);
}
.rep-tier-badge.neutral {
  background: rgba(148, 163, 184, 0.1);
  color: rgba(148, 163, 184, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.rep-tier-badge.suspect {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.1);
  text-shadow: 0 0 6px rgba(234, 179, 8, 0.3);
}
.rep-tier-badge.notorious {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}
.rep-tier-badge.outlaw {
  background: rgba(220, 38, 38, 0.2);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.4);
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.15);
  text-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.rep-history-btn {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--cyan);
  cursor: pointer;
  background: none;
  border: 1px solid rgba(var(--accent-rgb), 0.12);
  border-radius: 3px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  transition: all 0.2s;
}

.rep-history-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  background: rgba(var(--accent-rgb), 0.06);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.06);
}

/* ── Reputation log ─────────────────────────────────────────── */
.rep-log {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.6rem;
  border: 1px solid rgba(var(--accent-rgb), 0.06);
  border-radius: 3px;
  background: var(--scrim-15);
}

.rep-log-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s;
}

.rep-log-entry:last-child { border-bottom: none; }
.rep-log-entry:hover { background: rgba(var(--accent-rgb), 0.03); }

.rep-log-delta {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 3rem;
  text-align: right;
}

.rep-log-delta.positive {
  color: #22c55e;
  text-shadow: 0 0 4px rgba(34, 197, 94, 0.3);
}
.rep-log-delta.negative {
  color: #ef4444;
  text-shadow: 0 0 4px rgba(239, 68, 68, 0.3);
}

.rep-log-body {
  flex: 1;
  margin-left: 0.5rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rep-log-reason {
  color: rgba(255, 255, 255, 0.7);
}
.rep-log-desc {
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.3;
}

.rep-log-date {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--font-mono);
}

/* ── Oath breaker badge ─────────────────────────────────────── */
.oath-breaker-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background:
    linear-gradient(135deg,
      rgba(220, 38, 38, 0.15) 0%,
      rgba(220, 38, 38, 0.06) 100%
    );
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 3px;
  color: #dc2626;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
  animation: oathBreakerPulse 3s ease-in-out infinite;
}

@keyframes oathBreakerPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(220, 38, 38, 0); }
  50% { box-shadow: 0 0 16px rgba(220, 38, 38, 0.15); }
}

/* ── Pact cards - Treaty style ──────────────────────────────── */
.pact-card {
  padding: 1rem;
  background:
    linear-gradient(135deg,
      rgba(var(--accent-rgb), 0.03) 0%,
      transparent 60%
    ),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 3px;
  margin-bottom: 0.6rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pact-card:hover {
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 2px 12px var(--scrim-15);
}

/* Top accent line */
.pact-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(var(--accent-rgb), 0.3),
    transparent 70%
  );
}

/* Trade agreement variant */
.pact-card.trade {
  border-color: rgba(16, 185, 129, 0.12);
}

.pact-card.trade::before {
  background: linear-gradient(90deg,
    rgba(16, 185, 129, 0.4),
    transparent 70%
  );
}

.pact-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.pact-card-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.pact-status {
  font-size: 0.65rem;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}

.pact-status.active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.1);
}
.pact-status.notice {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.1);
}
.pact-status.pending {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.1);
}

/* Live countdown badge (pact expiry, demand deadline, etc.) */
.countdown-live {
  display: inline-block;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  margin-left: 0.35rem;
  vertical-align: baseline;
  white-space: nowrap;
}
.countdown-live.tone-ok {
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
}
.countdown-live.tone-warn {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.countdown-live.tone-urgent {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  animation: countdown-pulse 1.6s ease-in-out infinite;
}
.countdown-live.tone-expired {
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.pact-card-info {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.pact-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* ── NAP / Trade propose forms ──────────────────────────────── */
.nap-form {
  padding: 1.1rem;
  background:
    linear-gradient(180deg,
      rgba(var(--accent-rgb), 0.03) 0%,
      transparent 50%
    ),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 3px;
  position: relative;
}

/* Corner brackets */
.nap-form::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-top: 1px solid rgba(var(--accent-rgb), 0.2);
  border-left: 1px solid rgba(var(--accent-rgb), 0.2);
}

.nap-form::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.2);
  border-right: 1px solid rgba(var(--accent-rgb), 0.2);
}

.nap-form label {
  display: block;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.3rem;
  margin-top: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

.nap-form label:first-child {
  margin-top: 0;
}

.nap-form input[type="text"],
.nap-form input[type="number"],
.nap-form textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--scrim-35);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.nap-form input:focus,
.nap-form textarea:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.06);
}

.nap-form textarea {
  resize: vertical;
  min-height: 3rem;
}

.nap-form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* ── Signal section ─────────────────────────────────────────── */
.signal-section {
  margin-top: 0.5rem;
}

.signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  transition: background 0.15s;
  border-radius: 2px;
}

.signal-row:last-child { border-bottom: none; }
.signal-row:hover { background: rgba(var(--accent-rgb), 0.03); }

/* ── Signal badges - frequency indicator style ──────────────── */
.signal-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.signal-badge.friendly {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.08);
}
.signal-badge.neutral {
  background: rgba(148, 163, 184, 0.1);
  color: rgba(148, 163, 184, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.15);
}
.signal-badge.warning {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.25);
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.08);
}
.signal-badge.hostile {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.08);
}
.signal-badge.open_trade {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.08);
}
.signal-badge.seek_alliance {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 0 6px rgba(168, 85, 247, 0.08);
}
.signal-badge.ceasefire {
  background: rgba(34, 211, 238, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.25);
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.08);
}

/* ── Signal send row ────────────────────────────────────────── */
.signal-send-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.signal-send-row select,
.signal-send-row input {
  padding: 0.45rem 0.6rem;
  background: var(--scrim-35);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.signal-send-row select:focus,
.signal-send-row input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.06);
}

.signal-send-row select {
  flex: 1;
}

.signal-send-row input,
.signal-send-row .signal-target-wrap {
  width: 40%;
}
.signal-send-row .signal-target-wrap > input {
  width: 100%;
}

/* ── Tech Sharing ──────────────────────────────────────────── */
.techshare-form {
  margin-top: 0.5rem;
}
.techshare-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.techshare-select {
  flex: 1;
  min-width: 120px;
  padding: 0.45rem 0.6rem;
  background: var(--scrim-35);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.techshare-select:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.06);
}
.techshare-preview {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-mono);
  padding: 0.3rem 0;
}

/* ── Contacts roster (Diplomacy overview) ─────────────────── */
/* Collapsed contact roster: avatar tiles, one expanded card below */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.contact-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 8px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.contact-tile:hover {
  background: rgba(var(--accent-rgb), 0.10);
}
.contact-tile.active {
  border-color: var(--contact-accent, var(--cyan));
  background: rgba(var(--accent-rgb), 0.14);
}
.contact-tile-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
}
.contact-tile-img--unknown {
  background: rgba(148, 163, 184, 0.12);
}
.contact-tile-img--unknown svg {
  width: 22px;
  height: 22px;
  color: #94a3b8;
}
.contact-tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 600;
}
.contact-tile-status {
  font-size: 0.58rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.contact-tile-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #f59e0b;
  color: #1a1206;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.contacts-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}
.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.8rem 0.95rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  border-radius: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.contact-card:hover {
  border-color: rgba(var(--accent-rgb), 0.22);
  box-shadow: 0 2px 12px var(--scrim-15);
}
.contact-card.has-emblem {
  border-color: color-mix(in srgb, var(--contact-accent, #22d3ee) 18%, rgba(255, 255, 255, 0.05));
}
.contact-card.has-emblem:hover {
  border-color: color-mix(in srgb, var(--contact-accent, #22d3ee) 38%, rgba(255, 255, 255, 0.05));
  box-shadow: 0 2px 18px color-mix(in srgb, var(--contact-accent, #22d3ee) 18%, transparent);
}

/* Header: square emblem + name / house / status pills */
.contact-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.contact-emblem {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--contact-accent, #22d3ee) 18%, rgba(0, 0, 0, 0.4)) 0%,
      rgba(0, 0, 0, 0.55) 100%);
  border: 1px solid color-mix(in srgb, var(--contact-accent, #22d3ee) 35%, transparent);
  position: relative;
  overflow: hidden;
}
.contact-emblem::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--contact-accent, #22d3ee) 25%, transparent) 0%, transparent 70%);
  pointer-events: none;
}
.contact-emblem img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--contact-accent, #22d3ee) 45%, transparent));
}
.contact-emblem--portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}
.contact-emblem--unknown {
  background: linear-gradient(135deg,
      rgba(148, 163, 184, 0.1) 0%,
      rgba(0, 0, 0, 0.5) 100%);
  border: 1px dashed rgba(148, 163, 184, 0.38);
  color: rgba(148, 163, 184, 0.75);
}
.contact-emblem--unknown::after {
  display: none;
}
.contact-emblem-icon {
  width: 28px;
  height: 28px;
  opacity: 0.82;
  filter: drop-shadow(0 0 4px rgba(148, 163, 184, 0.25));
}
.contact-house-name--unknown {
  color: rgba(148, 163, 184, 0.62);
}
.contact-identity {
  flex: 1;
  min-width: 0;
}
.contact-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0;
}
.contact-card.has-emblem .contact-card-body {
  padding-left: calc(52px + 0.75rem);
}
.contact-house-name {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: color-mix(in srgb, var(--contact-accent, #22d3ee) 65%, rgba(255, 255, 255, 0.55));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.3;
}
.contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.contact-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.25;
}
.contact-tags {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.contact-signals {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0;
  font-family: var(--font-mono);
}
.contact-signal-meta {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.contact-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}
.contact-actions .btn {
  flex: 0 1 auto;
}
.contact-needs-first-contact {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.92);
  line-height: 1.35;
  flex: 1 1 100%;
}
@media (max-width: 480px) {
  .contact-emblem {
    width: 44px;
    height: 44px;
  }
  .contact-card.has-emblem .contact-card-body {
    padding-left: calc(44px + 0.6rem);
  }
  .contact-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .contact-tags {
    justify-content: flex-start;
  }
  .contact-actions .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 7.5rem;
  }
}

.contact-detail {
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(var(--accent-rgb), 0.08);
  border-radius: 3px;
}
.contact-detail.demand {
  border-color: rgba(234, 179, 8, 0.18);
  background: rgba(234, 179, 8, 0.04);
}
.contact-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.78);
}
.contact-detail-info {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  font-family: var(--font-mono);
}
.contact-detail-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.diplo-actions-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.diplo-history-panel {
  margin: 0.75rem 0 1rem;
}
.diplo-history-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0.5rem;
}
.diplo-history-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 5px 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: 4px;
  background: none;
  color: var(--text-dim, rgba(255, 255, 255, 0.55));
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.diplo-history-tab:hover {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(var(--accent-rgb), 0.06);
}
.diplo-history-tab.active {
  color: var(--cyan, #22d3ee);
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.3);
}
.diplo-history-tab-count {
  font-size: 0.68rem;
  opacity: 0.75;
}
.diplo-history-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(var(--accent-rgb), 0.12);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}
.diplo-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}
.diplo-history-table th,
.diplo-history-table td {
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}
.diplo-history-table th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 400;
  white-space: nowrap;
}
.diplo-history-table tr:last-child td {
  border-bottom: none;
}
.diplo-history-table tbody tr:hover td {
  background: rgba(var(--accent-rgb), 0.04);
}
.diplo-history-table .pact-status {
  font-size: 0.68rem;
  white-space: nowrap;
}
.diplo-history-empty {
  padding: 0.65rem 0.55rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  font-family: var(--font-mono);
}
.diplo-history-pane[hidden] {
  display: none;
}

/* ── Demand compose form (modal) ──────────────────────────── */
.nap-form select,
.nap-form .techshare-select {
  width: 100%;
}
.demand-form select {
  margin-bottom: 0.2rem;
}
.demand-form-hint {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-mono);
}
.diplo-form-info {
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.75rem;
  background: rgba(var(--accent-rgb), 0.06);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 4px;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(220, 230, 245, 0.78);
}
.diplo-form-estimate {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.diplo-form-estimate-label {
  color: rgba(200, 220, 240, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.diplo-form-estimate-value {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--credits-color, #fde047);
  font-weight: 600;
}
.diplo-form-estimate-value .icon {
  width: 14px;
  height: 14px;
}
.demand-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(var(--accent-rgb), 0.08);
}
.demand-form-actions .btn { min-width: 7rem; }
@media (max-width: 420px) {
  .demand-form-actions { flex-direction: column-reverse; }
  .demand-form-actions .btn { width: 100%; }
}

.contact-distance {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ── Contactos subtab: known empires + colony carousel ── */
.contactos-panel { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.contactos-empty { text-align: center; padding: 24px 12px; font-size: 0.85rem; }
.contacto-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; text-align: left; cursor: pointer;
  background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text-primary); font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.contacto-row:hover { border-color: rgba(0, 240, 255, 0.35); }
.contacto-row.sel {
  border-color: rgba(0, 240, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.3) inset;
}
.contacto-ini {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 240, 255, 0.12); border: 1px solid rgba(0, 240, 255, 0.3);
  font-weight: 700; font-size: 0.95rem; color: var(--cyan);
}
.contacto-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contacto-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contacto-meta { font-size: 0.72rem; color: var(--text-secondary); }
.contacto-colonies { margin: -2px 0 4px; padding: 0 4px; }
.contacto-colonies-empty { text-align: center; padding: 10px; font-size: 0.8rem; }
.contacto-carousel { display: flex; align-items: center; gap: 8px; }
.contacto-nav { flex: none; min-width: 40px; }
.contacto-colony { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.contacto-colony-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.contacto-colony-meta { font-size: 0.7rem; color: var(--text-secondary); }

/* ── Expanded contact detail (Location / History / Diplomacy) ── */
.contacto-detail {
  display: flex; flex-direction: column; gap: 12px;
  margin: -2px 2px 6px; padding: 12px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.16);
}
.contacto-section { display: flex; flex-direction: column; gap: 6px; }
.contacto-section-title {
  font-size: 0.66rem; letter-spacing: 0.09em; text-transform: uppercase;
  font-weight: 700; color: var(--cyan);
  padding-bottom: 4px; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.contacto-map-btn {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin-top: 6px;
}
.contacto-map-ret { width: 15px; height: 15px; flex: none; }
.contacto-intel-hint { font-size: 0.72rem; margin-bottom: 2px; }
.contacto-intel-list { display: flex; flex-direction: column; gap: 6px; }
.contacto-intel-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(148, 163, 184, 0.14);
}
.contacto-intel-name { font-size: 0.8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* History timeline: icon + label + relative time (colorblind-safe: glyph+text lead) */
.contacto-history { display: flex; flex-direction: column; gap: 4px; }
.contacto-history-empty { text-align: center; padding: 8px; font-size: 0.8rem; }
.contacto-hist-item {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid rgba(148, 163, 184, 0.3);
  font-size: 0.8rem;
}
.contacto-hist-item.combat.win { border-left-color: #22d3ee; }
.contacto-hist-item.combat.loss { border-left-color: #f97316; }
.contacto-hist-item.pact { border-left-color: #a78bfa; }
.contacto-hist-item.rep.pos { border-left-color: #22d3ee; }
.contacto-hist-item.rep.neg { border-left-color: #f97316; }
.contacto-hist-item.signal { border-left-color: #38bdf8; }
.contacto-hist-icon { font-size: 0.95rem; text-align: center; line-height: 1; }
.contacto-hist-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacto-hist-when { font-size: 0.68rem; color: var(--text-secondary); white-space: nowrap; }
.contacto-diplo-card .contact-card { margin: 0; }

/* ── War layer (F4): active-wars panel ── */
.war-panel { margin-bottom:16px; padding:12px 14px; border:1px solid rgba(239,68,68,.4); border-radius:10px; background:rgba(40,10,12,.35); }
.war-panel-title { margin:0 0 10px; font-size:0.95rem; color:#fca5a5; }
.war-card { padding:11px 12px; border-radius:8px; background:rgba(8,12,22,.5); border:1px solid rgba(239,68,68,.25); margin-bottom:10px; }
.war-card:last-child { margin-bottom:0; }
.war-card-hd { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.war-foe { font-weight:700; color:var(--text); }
.war-cb { font-size:0.62rem; text-transform:uppercase; letter-spacing:.05em; padding:2px 7px; border-radius:999px; background:rgba(239,68,68,.16); color:#fca5a5; white-space:nowrap; }
.war-lbl { display:block; font-size:0.66rem; text-transform:uppercase; letter-spacing:.04em; color:var(--text-dim); margin-bottom:3px; }
.war-score-row { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:8px; margin-bottom:9px; }
.war-score-row .war-lbl { margin:0; }
.war-bar { position:relative; height:8px; border-radius:6px; background:rgba(148,163,184,.18); overflow:hidden; }
.war-bar-fill { position:absolute; left:0; top:0; bottom:0; background:#8fd3ff; border-radius:6px; }
.war-score-bar .war-bar-fill { background:linear-gradient(90deg,#f2c14e,#8fd3ff); }
.war-bar-mid { position:absolute; left:50%; top:-1px; bottom:-1px; width:1px; background:rgba(226,232,240,.55); }
.war-bar-fill.mine { background:#8fd3ff; }
.war-bar-fill.theirs { background:#f2c14e; }
.war-score-val { font-size:0.72rem; font-weight:700; white-space:nowrap; color:var(--text-dim); }
.war-score-val.up { color:#8fd3ff; }
.war-score-val.down { color:#f2c14e; }
.war-exh-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:9px; }
.war-claims { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:9px; }
.war-claim { font-size:0.68rem; font-family:var(--font-mono); padding:2px 7px; border-radius:6px; background:rgba(148,163,184,.14); color:var(--text-dim); }
.war-claim.is-satisfied { background:rgba(143,211,255,.18); color:#8fd3ff; }
.war-card-actions { display:flex; justify-content:flex-end; }
