/* AgentFM playground — radar scan, live agent cards, sandbox chat. */

.pg-main { position: relative; z-index: 1; min-height: calc(100dvh - 64px); }
.pg-view[hidden] { display: none; }
.pg-topbar { padding-top: 20px; }
.pg-topbar[hidden] { display: none; }
.pg-home {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-1);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.pg-home:hover { color: var(--amber); border-color: var(--amber-line); }

.pg-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ok);
}
.pg-live[hidden] { display: none; }
.pg-live.stale { color: var(--text-2); }
.pg-live.stale .pg-live-dot { background: var(--text-2); animation: none; }
.pg-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  animation: pg-live-pulse 2.2s ease-in-out infinite;
}
@keyframes pg-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ------------------------------------------------------------- radar */
.pg-radar-view {
  min-height: calc(100dvh - 128px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 44px;
  padding: 40px 24px;
  overflow: hidden;
}
.radar {
  position: relative;
  width: min(340px, 72vw);
  aspect-ratio: 1;
}
.radar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.radar-ring.r1 { inset: 0; border-color: var(--amber-line); }
.radar-ring.r2 { inset: 17%; }
.radar-ring.r3 { inset: 34%; }
.radar-cross {
  position: absolute; inset: 0;
  background:
    linear-gradient(var(--line) 0 0) center / 100% 1px no-repeat,
    linear-gradient(var(--line) 0 0) center / 1px 100% no-repeat;
}
.radar-sweep {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(240, 161, 46, 0.4), rgba(240, 161, 46, 0.05) 70deg, transparent 90deg);
  animation: radar-spin 3.2s linear infinite;
}
.radar-pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(240, 161, 46, 0.55);
  transform: scale(0.05);
  opacity: 0;
  animation: radar-pulse 4s ease-out infinite;
}
.radar-pulse.p2 { animation-delay: 2s; }
@keyframes radar-pulse {
  0% { transform: scale(0.05); opacity: 0.85; }
  70% { opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}
@keyframes radar-spin { to { transform: rotate(360deg); } }
.radar-core {
  position: absolute; left: 50%; top: 50%;
  width: 10px; height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(240, 161, 46, 0.8);
}
.radar-blip {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  transform: rotate(var(--a)) translateY(calc(var(--r) * -1)) ;
  opacity: 0;
  animation: radar-blip 2.4s ease-out infinite;
  animation-delay: var(--d);
}
.radar-blip::after {
  content: "";
  position: absolute; inset: -7px;
  border-radius: 50%;
  border: 1px solid var(--amber);
  opacity: 0;
  animation: radar-ping 2.4s ease-out infinite;
  animation-delay: var(--d);
}
@keyframes radar-blip { 0%, 8% { opacity: 0; } 12% { opacity: 1; } 55% { opacity: 0.75; } 90%, 100% { opacity: 0; } }
@keyframes radar-ping { 10% { opacity: 0.8; transform: scale(0.4); } 45% { opacity: 0; transform: scale(1.7); } 100% { opacity: 0; } }

.radar-log {
  width: min(460px, 88vw);
  min-height: 108px;
  font-size: 12.5px;
  line-height: 2;
  color: var(--text-1);
}
.radar-log .ln { display: block; white-space: nowrap; overflow: hidden; }
.radar-log .ok { color: var(--ok); }
.radar-log .err { color: #e5645a; }
.radar-log .cursor {
  display: inline-block;
  width: 7px; height: 13px;
  margin-left: 2px;
  background: var(--amber);
  vertical-align: -2px;
  animation: cursor-blink 1.1s steps(2) infinite;
}
.radar-retry { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  .radar-sweep { animation: none; opacity: 0.4; }
  .radar-blip, .radar-blip::after { animation: none; opacity: 0.8; }
  .radar-pulse { animation: none; }
  .pg-live-dot { animation: none; }
}

/* ------------------------------------------------------------- agents */
.pg-agents-view { padding: 44px 24px 110px; }
.pg-head h1 {
  font-size: clamp(34px, 4.6vw, 54px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-top: 10px;
}
.pg-head .kicker { display: block; }
.pg-sub {
  margin-top: 14px;
  color: var(--text-1);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.agent-grid {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}
.agent-card {
  text-align: left;
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  padding: 22px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease;
}
.agent-card:hover:not(.disabled) { transform: translateY(-4px); border-color: var(--amber-line); }
.agent-card:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.agent-card.disabled { cursor: not-allowed; opacity: 0.55; }
.ac-head { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.ac-avatar {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  font-size: 17px;
}
.ac-id { min-width: 0; flex: 0 1 auto; max-width: 100%; }
.ac-id h3 {
  font-size: 17.5px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-cap {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  border: 1px solid var(--amber-line);
  border-radius: var(--r-sm);
  padding: 1px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ac-status {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.ac-status.ok { color: var(--ok); }
.ac-status.busy { color: var(--amber); }
.ac-status.full { color: #e5645a; }
.ac-desc {
  margin-top: 14px;
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.55;
  min-height: 44px;
}
.ac-desc.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ac-more {
  margin-top: 7px;
  padding: 0;
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--amber);
  cursor: pointer;
}
.ac-more:hover { text-decoration: underline; text-underline-offset: 3px; }
.ac-meters { margin-top: 16px; display: grid; gap: 9px; }
.meter {
  display: grid;
  grid-template-columns: 34px 1fr 84px;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}
.meter b { font-weight: 400; color: var(--text-1); text-align: right; }
.meter .bar {
  height: 5px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter .bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--amber), rgba(240, 161, 46, 0.55));
  transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.meter.gpu .bar i { background: linear-gradient(90deg, #3fce8b, rgba(63, 206, 139, 0.5)); }
.meter .none { color: var(--text-2); opacity: 0.6; }
.ac-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-1);
}
.ac-chip {
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  padding: 3px 9px;
  white-space: nowrap;
}
.ac-chip.warn { border-color: rgba(229, 100, 90, 0.5); color: #e5645a; }
.ac-open { margin-left: auto; color: var(--amber); letter-spacing: 0.08em; }

/* --------------------------------------------------------------- chat */
.pg-chat-view { padding: 34px 24px 40px; }
.chat-shell {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 140px);
  min-height: 480px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--bg-1);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.chat-back {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-1);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 6px 11px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.chat-back:hover { color: var(--amber); border-color: var(--amber-line); }
.chat-head .ac-avatar { width: 34px; height: 34px; font-size: 14px; }
.chat-id h2 { font-size: 16px; letter-spacing: -0.01em; }
.chat-id .mono { font-size: 10.5px; color: var(--amber); }
.chat-tele {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-2);
  text-align: right;
  line-height: 1.7;
  white-space: nowrap;
}
.chat-tele .ok { color: var(--ok); }
.chat-tele .full { color: #e5645a; }

.chat-rep {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  font-size: 11px;
  line-height: 1.95;
  color: var(--text-2);
}
.chat-rep[hidden] { display: none; }
.chat-rep .rep-head { color: var(--text-1); letter-spacing: 0.07em; display: block; }
.chat-rep .rep-row {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-rep .rep-score { color: var(--ok); }
.chat-rep .rep-score.neg { color: #e5645a; }
.chat-rep .rep-quote { color: var(--text-1); }
.chat-rep .rep-note a { color: var(--amber); }
.chat-rep .rep-note a:hover { text-decoration: underline; text-underline-offset: 3px; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg-user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  border-radius: var(--r-md) var(--r-md) 4px var(--r-md);
  padding: 10px 15px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-agent {
  align-self: flex-start;
  width: min(100%, 640px);
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-agent.streaming::after {
  content: "";
  display: inline-block;
  width: 7px; height: 12px;
  margin-left: 3px;
  background: var(--amber);
  vertical-align: -2px;
  animation: cursor-blink 1.1s steps(2) infinite;
}
.msg-meta {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.msg-meta.err { color: #e5645a; }
.artifact-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--amber-line);
  border-radius: var(--r-sm);
  background: var(--amber-soft);
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-0);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.artifact-chip:hover { border-color: var(--amber); transform: translateY(-1px); }
.artifact-chip svg { width: 15px; height: 15px; stroke: var(--amber); }
.artifact-chip b { color: var(--amber); font-weight: 600; }
.artifact-progress {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
}

.chat-form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text-0);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  padding: 11px 14px;
  max-height: 130px;
}
.chat-form textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.chat-form .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.chat-note {
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  padding: 10px 16px 0;
}

@media (max-width: 640px) {
  .agent-grid { grid-template-columns: 1fr; gap: 14px; margin-top: 32px; }
  .pg-agents-view { padding: 52px 16px 80px; }
  .chat-shell { height: calc(100dvh - 108px); min-height: 420px; border-radius: var(--r-md); }
  .chat-tele { display: none; }
  .pg-chat-view { padding: 14px 10px 20px; }
  .chat-head { padding: 11px 13px; gap: 10px; }
  .chat-log { padding: 16px 13px; }
  .chat-rep { padding: 9px 13px; }
  .chat-rep .rep-row { white-space: normal; overflow: visible; }
  .chat-form { padding: 11px 12px; }
  .msg-user { max-width: 90%; }
  .radar-log { font-size: 11.5px; }
}
