/* Warden agent — full-screen window */

.agent {
  position: fixed !important;
  inset: 0 !important;
  z-index: 150 !important;
  display: grid !important;
  place-items: stretch !important;
  grid-template-columns: none !important;
  padding: 0 !important;
  overscroll-behavior: contain;
  background: var(--bg) !important;
  color-scheme: dark;
}

.agent[hidden] {
  display: none !important;
}

.agent-backdrop {
  display: none;
}

.agent-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(17rem, 20rem) minmax(0, 1fr);
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 100svh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
  overflow: hidden;
  color: var(--fg);
}

.agent-side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 1.15rem;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow: auto;
  min-width: 0;
}

.agent-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.agent-brand svg {
  width: 1.85rem;
  fill: var(--fg);
  flex-shrink: 0;
}

.agent-brand strong {
  display: block;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.agent-brand em {
  display: block;
  margin-top: 0.12rem;
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg-mute);
}

.agent-brand em[data-ok="true"] {
  color: var(--moon);
}

.agent-brand em[data-ok="false"] {
  color: var(--rose);
}

.side-new {
  width: 100%;
  margin-top: auto;
}

.side-label {
  margin: 0.15rem 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-family: var(--mono);
}

.side-chips {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.side-chips button {
  text-align: left;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg-dim);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.side-chips button:hover,
.side-chips button:focus-visible,
.side-chips button.is-on {
  border-color: rgba(215, 196, 164, 0.45);
  color: var(--fg);
  background: rgba(215, 196, 164, 0.08);
  outline: none;
}

.side-chips button:focus-visible {
  box-shadow: 0 0 0 3px rgba(215, 196, 164, 0.14);
}

.agent *,
.agent *::before,
.agent *::after {
  box-sizing: border-box;
}

.agent section,
.agent .agent-main,
.agent .wa-evidence {
  padding: 0;
  margin: 0;
}

.agent h3,
.agent h4 {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
}

.agent-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.agent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem clamp(1.1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.agent-top p {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

#agent-status {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg-mute);
}

#agent-status[data-ok="true"] {
  color: var(--moon);
}

#agent-status[data-ok="false"] {
  color: var(--rose);
}

.agent-thread {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem clamp(1rem, 2.5vw, 1.75rem) 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  scroll-behavior: smooth;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 0;
}

.agent-thread > * {
  position: relative;
  z-index: 0;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.agent-thread > .bubble.me {
  width: auto;
  max-width: min(40rem, 100%);
  align-self: flex-end;
}

.agent-foot {
  border-top: 1px solid var(--line);
  padding: 0.85rem clamp(1rem, 2.5vw, 1.75rem) calc(0.95rem + env(safe-area-inset-bottom));
}

.agent-foot .agent-compose {
  width: 100%;
  max-width: none;
  margin: 0;
}

.bubble {
  position: relative;
  z-index: 0;
  max-width: min(40rem, 100%);
  padding: 0.8rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  align-self: flex-start;
  flex: none;
}

.bubble.me {
  align-self: flex-end;
  border-color: rgba(215, 196, 164, 0.28);
  background: rgba(215, 196, 164, 0.09);
}

/* One card: Agent Loop + results */
.answer {
  position: relative;
  z-index: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-2);
  padding: 0.95rem 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  overflow: visible;
  isolation: isolate;
}

.answer > * {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.answer-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
}

.answer-badge {
  margin-left: auto;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--rose);
  border: 1px solid rgba(212, 161, 148, 0.4);
  background: rgba(212, 161, 148, 0.09);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-variant-numeric: tabular-nums;
}

.trace {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(22, 19, 16, 0.55);
  overflow: hidden;
  min-width: 0;
}

.trace-head {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--fg-mute);
  touch-action: manipulation;
}

.trace-head:hover {
  color: var(--fg-dim);
}

.trace-head:focus-visible {
  outline: 2px solid rgba(215, 196, 164, 0.55);
  outline-offset: 2px;
}

.trace-time {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.trace-caret {
  width: 10px;
  height: 10px;
  fill: currentColor;
  transition: transform 240ms var(--ease);
  flex-shrink: 0;
}

.trace[data-open="0"] .trace-caret {
  transform: rotate(-90deg);
}

.trace[data-open="0"] .steps {
  display: none;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0 0.8rem 0.7rem;
  display: grid;
  gap: 0;
}

.step {
  display: grid;
  grid-template-columns: 12px 4.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.32rem 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--fg-mute);
  opacity: 0.42;
  min-width: 0;
  transition:
    opacity 260ms var(--ease),
    color 260ms var(--ease);
}

.step.run,
.step.done {
  opacity: 1;
}

.step.run {
  color: var(--moon);
}

.step.done {
  color: var(--fg-dim);
}

.step i.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  justify-self: center;
}

.step.run i.dot {
  opacity: 1;
  animation: agent-pulse 1.1s var(--ease) infinite;
}

.step.done i.dot {
  opacity: 1;
  background: var(--moon);
  animation: none;
}

.step-name {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-rail {
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.step-rail i {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, transparent, var(--moon));
}

.step-val {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 9rem;
}

@keyframes agent-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step.run i.dot {
    animation: none;
  }
  .agent-thread {
    scroll-behavior: auto;
  }
}

/* Results body inside the answer card */
.wa-body,
.wa-answer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  width: 100%;
  overflow: visible;
  position: relative;
}

.wa-body > *,
.wa-answer > * {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.wa-answer {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-2);
  padding: 1rem;
  box-sizing: border-box;
}

.wa-summary {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--fg);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.wa-verdict {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  min-width: 0;
  width: 100%;
  overflow: hidden;
  clear: both;
  flex: none;
}

.wa-verdict[data-verdict="hold"] {
  border-color: rgba(156, 186, 164, 0.45);
}
.wa-verdict[data-verdict="watch"] {
  border-color: rgba(215, 196, 164, 0.4);
}
.wa-verdict[data-verdict="flag"] {
  border-color: rgba(212, 161, 148, 0.45);
}

.wa-gauge {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.wa-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  display: block;
}

.wa-track {
  fill: none;
  stroke: rgba(236, 231, 220, 0.08);
  stroke-width: 7;
}

.wa-fill {
  fill: none;
  stroke: var(--moon);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 232;
  stroke-dashoffset: 232;
  transition: stroke-dashoffset 1s var(--ease);
}

.wa-gauge-read {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.wa-gauge-read strong {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.wa-gauge-read span {
  font-size: 0.58rem;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wa-call {
  min-width: 0;
  overflow: hidden;
}

.wa-call h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.wa-call p {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--fg-dim);
  overflow-wrap: anywhere;
}

.wa-call p b {
  display: block;
  color: var(--fg);
  font-size: 0.95rem;
  margin: 0 0 0.2rem;
}

.wa-call .wa-why {
  margin: 0 0 0.7rem;
}

.wa-call b {
  color: var(--fg);
}

.wa-signals {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.wa-signal {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr) 2.4rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.72rem;
  color: var(--fg-mute);
  min-width: 0;
}

.wa-signal b {
  font-family: var(--mono);
  color: var(--fg-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wa-signal-bar {
  display: block;
  height: 4px;
  border-radius: 4px;
  background: rgba(236, 231, 220, 0.08);
  overflow: hidden;
  min-width: 0;
}

.wa-signal-bar i {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  background: var(--moon);
  transition: width 0.8s var(--ease);
}

.wa-signal.is-neg .wa-signal-bar i {
  background: var(--rose);
}

.wa-evidence {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c0a09;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  clear: both;
  flex: none;
}

.wa-ev-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.wa-ev-head h4 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 600;
}

.wa-ev-count {
  font-size: 0.72rem;
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
}

.wa-ev-nav {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.wa-ev-nav button {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.wa-ev-nav button:hover {
  border-color: rgba(215, 196, 164, 0.4);
  color: var(--fg);
}

.wa-ev-nav button:focus-visible {
  outline: 2px solid rgba(215, 196, 164, 0.55);
  outline-offset: 2px;
}

.wa-ev-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.wa-ev-nav svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.wa-deck {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 0.85rem;
  scrollbar-width: thin;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.wa-deck::-webkit-scrollbar {
  height: 6px;
}

.wa-deck::-webkit-scrollbar-thumb {
  background: rgba(243, 239, 232, 0.18);
  border-radius: 99px;
}

.wa-post {
  flex: 0 0 min(15.5rem, 78%);
  scroll-snap-align: start;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  text-decoration: none;
  color: inherit;
  min-width: 0;
  box-sizing: border-box;
}

.wa-post:hover {
  border-color: rgba(215, 196, 164, 0.35);
}

.wa-post:focus-visible {
  outline: 2px solid rgba(215, 196, 164, 0.55);
  outline-offset: 2px;
}

.wa-post-top {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
  min-width: 0;
}

.wa-av {
  --wa-hue: 32;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: hsl(var(--wa-hue) 28% 42%);
  color: #f3efe8;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--line);
  position: relative;
}

.wa-av img,
.wa-av [data-fb] {
  grid-area: 1 / 1;
}

.wa-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wa-av img[hidden] {
  display: none;
}

.wa-av [data-fb][hidden] {
  display: none;
}

.wa-post-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  overflow: hidden;
}

.wa-post-meta strong,
.wa-post-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-post-meta strong {
  font-size: 0.82rem;
}

.wa-post-meta span {
  font-size: 0.72rem;
  color: var(--fg-mute);
}

.wa-x {
  margin-left: auto;
  width: 14px;
  height: 14px;
  fill: var(--fg-mute);
  flex-shrink: 0;
}

.wa-post-text {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: var(--fg-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.wa-post-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--fg-mute);
}

.wa-post-eng {
  display: flex;
  gap: 0.55rem;
}

.wa-post-eng span {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.wa-post-eng svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.wa-lanes {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.wa-lane {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  min-width: 0;
  overflow: hidden;
}

.wa-lane > .avatar-slot {
  width: 36px;
  height: 36px;
  align-self: center;
}

.wa-lane-copy {
  min-width: 0;
  overflow: hidden;
}

.wa-lane h4 {
  margin: 0;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-ca {
  display: inline-flex;
  align-items: center;
  margin-top: 0.2rem;
  max-width: 100%;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(243, 239, 232, 0.04);
  color: var(--moon, #d7c4a4);
  cursor: pointer;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-ca:hover {
  border-color: rgba(215, 196, 164, 0.45);
  color: var(--bone, #f3efe8);
}

.wa-ca.is-miss {
  cursor: default;
  opacity: 0.55;
  border-style: dashed;
}

.wa-lane p {
  margin: 0.2rem 0 0;
  font-size: 0.74rem;
  color: var(--fg-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-lane .verdict {
  flex-shrink: 0;
}

.wa-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--fg-mute);
  line-height: 1.45;
}

.wa-demo {
  border-color: rgba(212, 161, 148, 0.35);
}

.wa-body.wa-demo {
  border: 0;
  padding-top: 0.15rem;
}

.agent-compose {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem 0.45rem 0.4rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(29, 25, 21, 0.85);
  transition:
    border-color 220ms var(--ease),
    box-shadow 220ms var(--ease);
}

.agent-compose:focus-within {
  border-color: rgba(215, 196, 164, 0.35);
  box-shadow: 0 0 0 3px rgba(215, 196, 164, 0.12);
}

.agent-compose input:focus-visible {
  outline: none;
}

.agent-compose input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0;
}

.agent-compose input::placeholder {
  color: var(--fg-mute);
}

.agent-compose .btn.primary {
  border-radius: 999px;
  padding-inline: 1.15rem;
}

.agent-compose .btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.wallet-card .btn {
  width: 100%;
}

.agent-side .wallet-card {
  margin-top: 0.1rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(243, 239, 232, 0.03);
}

@media (max-width: 860px) {
  .agent-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100svh;
    border-radius: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .agent-side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
  }

  .agent-main {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    min-height: min(72svh, 44rem);
    overflow: visible;
    height: auto;
  }

  .agent-thread {
    overflow: visible;
    flex: 1 0 auto;
  }

  .agent-foot {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    z-index: 2;
  }

  .wa-verdict {
    grid-template-columns: 1fr;
  }

  .wa-signal {
    grid-template-columns: 5.4rem minmax(0, 1fr) 2.2rem;
  }

  .step {
    grid-template-columns: 12px 4.2rem minmax(0, 1fr) auto;
    gap: 0.4rem;
    font-size: 0.7rem;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
