/**
 * Polymarket-style public profiles (/@handle, /agent/:handle).
 * Loaded only when layout activePage === 'public-profile'.
 */
:root {
  --pm-bg: #0b0f14;
  --pm-card: #111827;
  --pm-border: #1f2937;
  --pm-text: #e5e7eb;
  --pm-muted: #9ca3af;
  --pm-heading: #f3f4f6;
  --pm-accent: #06b6d4;
  --pm-green: #22c55e;
  --pm-red: #ef4444;
  --pm-purple: #8b5cf6;
}

.pm-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  background: var(--pm-bg);
  color: var(--pm-text);
}

.pm-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 960px) {
  .pm-top-grid {
    grid-template-columns: 1fr;
  }
}

.pm-card {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 20px;
  position: relative;
}

/* —— Header card —— */
.pm-header-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 280px;
}

.pm-header-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.pm-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, #374151, #1f2937);
}

.pm-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--pm-muted);
}

.pm-header-text {
  flex: 1;
  min-width: 0;
  padding-right: 88px;
}

.pm-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pm-display-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--pm-heading);
  margin: 0;
  line-height: 1.2;
}

.pm-agent-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(6, 182, 212, 0.2);
  color: var(--pm-accent);
  flex-shrink: 0;
  line-height: 1;
}

.pm-friend-msg-row {
  margin-top: 10px;
}

.agent-profile-send-msg-btn--inline {
  font-size: 12px;
  padding: 6px 14px;
}

.pm-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--pm-muted);
  line-height: 1.4;
}

.pm-online {
  color: var(--pm-green);
  font-weight: 600;
}

.pm-header-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.pm-icon-row {
  display: flex;
  gap: 8px;
}

.pm-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: #1f2937;
  color: var(--pm-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.pm-icon-btn:hover {
  background: #374151;
  color: var(--pm-text);
}

.pm-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pm-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 8px;
  margin-top: auto;
  padding-top: 20px;
  width: 100%;
  box-sizing: border-box;
}

.pm-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.pm-stat-val {
  font-size: 28px;
  font-weight: 600;
  color: var(--pm-heading);
  line-height: 1.1;
}

.pm-stat-lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--pm-muted);
  line-height: 1.3;
}

/* —— P&L card —— */
.pm-pnl-card {
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.pm-pnl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.pm-pnl-mid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.pm-pnl-value-block {
  flex: 1;
  min-width: 0;
}

.pm-pnl-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-heading);
}

.pm-pnl-heart {
  width: 18px;
  height: 18px;
  border: 2px solid var(--pm-red);
  border-radius: 4px;
  transform: rotate(-45deg);
  position: relative;
  flex-shrink: 0;
}

.pm-seg {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pm-seg button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--pm-border);
  background: transparent;
  color: var(--pm-muted);
  cursor: pointer;
  font-family: inherit;
}

.pm-seg button.on {
  background: var(--pm-accent);
  border-color: var(--pm-accent);
  color: #061016;
}

.pm-pnl-big {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.1;
}

.pm-pnl-big.pos {
  color: var(--pm-green);
}

.pm-pnl-big.neg {
  color: var(--pm-red);
}

.pm-pnl-period {
  font-size: 12px;
  color: var(--pm-muted);
  margin: 0;
}

.pm-pnl-venue {
  font-size: 11px;
  color: var(--pm-muted);
  margin: 0;
  flex-shrink: 0;
  align-self: center;
  white-space: nowrap;
}

.pm-chart-wrap {
  flex: 1;
  min-height: 160px;
  margin-top: auto;
  padding-top: 8px;
  position: relative;
}

.pm-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.pm-chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--pm-muted);
  pointer-events: none;
  text-align: center;
  padding: 12px;
}

/* —— Tabs —— */
.pm-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--pm-border);
  margin-bottom: 0;
}

.pm-tab {
  font-size: 14px;
  font-weight: 600;
  padding-bottom: 12px;
  background: none;
  border: none;
  color: var(--pm-muted);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

.pm-tab.on {
  color: var(--pm-text);
  border-bottom-color: var(--pm-accent);
}

.pm-panel[hidden] {
  display: none !important;
}

/* Positions toolbar */
.pm-pos-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 0;
}

.pm-panel[data-panel="positions"] {
  padding-top: 0;
}

.pm-subseg {
  display: flex;
  gap: 4px;
}

.pm-subseg button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--pm-border);
  background: #0f1419;
  color: var(--pm-muted);
  cursor: pointer;
  font-family: inherit;
}

.pm-subseg button.on {
  background: var(--pm-accent);
  border-color: var(--pm-accent);
  color: #061016;
}

.pm-search {
  flex: 1;
  min-width: 140px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f1419;
  border: 1px solid var(--pm-border);
  border-radius: 10px;
  padding: 8px 12px;
}

.pm-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--pm-text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.pm-sort-wrap {
  position: relative;
  margin-left: auto;
}

.pm-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: #1f2937;
  color: var(--pm-muted);
  cursor: pointer;
  font-family: inherit;
}

.pm-sort-pop {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: 10px;
  padding: 6px;
  z-index: 50;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pm-sort-pop[hidden] {
  display: none;
}

.pm-sort-pop button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--pm-text);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}

.pm-sort-pop button:hover {
  background: #1f2937;
}

/* Tables */
.pm-pos-head {
  display: grid;
  align-items: center;
  padding: 8px 14px;
  gap: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pm-muted);
  background: #0c1016;
  border-bottom: 1px solid var(--pm-border);
  user-select: none;
}

.pm-pos-head--active {
  grid-template-columns: 1fr 110px 110px 160px 40px;
}

.pm-pos-head--closed {
  grid-template-columns: 90px 1fr 140px 160px 40px;
}

.pm-pos-h-market {
  min-width: 0;
}

.pm-pos-h-num,
.pm-pos-h-val,
.pm-pos-h-res {
  text-align: right;
}

.pm-pos-h-res {
  text-align: left;
}

@media (max-width: 900px) {
  .pm-pos-head--active,
  .pm-pos-head--closed {
    display: none;
  }
}

.pm-table {
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  overflow: hidden;
}

.pm-row {
  display: grid;
  align-items: center;
  min-height: 72px;
  padding: 10px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--pm-border);
  cursor: pointer;
  transition: background 0.12s;
}

.pm-row:last-child {
  border-bottom: none;
}

.pm-row:nth-child(odd) {
  background: #111827;
}

.pm-row:nth-child(even) {
  background: #0f1419;
}

.pm-row:hover {
  background: #1f2937;
}

.pm-row-active {
  grid-template-columns: 1fr 110px 110px 160px 40px;
}

.pm-row-closed {
  grid-template-columns: 90px 1fr 140px 160px 40px;
}

@media (max-width: 900px) {
  .pm-row-active,
  .pm-row-closed {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.pm-mkt-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  background: #1f2937;
  flex-shrink: 0;
}

.pm-mkt-col {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.pm-mkt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-mkt-sub {
  font-size: 12px;
  color: var(--pm-muted);
  margin-top: 2px;
}

.pm-chip-yes {
  color: var(--pm-green);
  font-weight: 600;
}

.pm-chip-no {
  color: var(--pm-red);
  font-weight: 600;
}

.pm-cell-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-heading);
}

.pm-val-block .top {
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-heading);
}

.pm-val-block .sub {
  font-size: 12px;
  margin-top: 2px;
}

.pm-val-block .sub.pos {
  color: var(--pm-green);
}

.pm-val-block .sub.neg {
  color: var(--pm-red);
}

.pm-result-won {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--pm-green);
  font-size: 12px;
  font-weight: 700;
}

.pm-result-lost {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--pm-red);
  font-size: 12px;
  font-weight: 700;
}

.pm-result-ref {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(156, 163, 175, 0.15);
  color: var(--pm-muted);
  font-size: 12px;
  font-weight: 700;
}

/* Activity */
.pm-activity-list {
  border: 1px solid var(--pm-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--pm-card);
}

.pm-activity-list .feed-item {
  border-bottom: 1px solid var(--pm-border);
  padding: 12px 14px;
}

.pm-activity-list .feed-item:last-child {
  border-bottom: none;
}

.pm-empty {
  padding: 32px;
  text-align: center;
  color: var(--pm-muted);
  font-size: 14px;
}

.pm-skills-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 4px 0 16px;
}

.pm-skill-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--pm-border);
  background: var(--pm-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pm-skill-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border-color: rgba(0, 240, 255, 0.22);
}

.pm-skill-card-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pm-skill-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-text, #e5e7eb);
  line-height: 1.3;
  word-break: break-word;
}

.pm-skill-kind {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  width: fit-content;
  border: 1px solid transparent;
}

.pm-skill-kind-official {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}

.pm-skill-kind-partner {
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
}

.pm-skill-kind-community {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
}

.pm-skill-status-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
}

.pm-skill-status-dot.running {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.55);
}

.pm-skill-status-dot.err {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.45);
}

.pm-skills-empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--pm-muted);
}

.pm-skills-empty-msg {
  margin: 0 0 12px;
  font-size: 14px;
}

.pm-skills-browse-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-accent, #00f0ff);
  text-decoration: none;
}

.pm-skills-browse-link:hover {
  text-decoration: underline;
}
