/* 24/7 market agent: recipe-specific styles (tokens from shared/kit.css) */

.ma { display: grid; gap: 0; }
.ma-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.ma-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ma-title > div { display: grid; line-height: 1.3; min-width: 0; }
.ma-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: radial-gradient(circle at 30% 30%, var(--green-face), var(--green-base) 60%, var(--green-ink));
  box-shadow: 0 0 0 3px var(--green-wash);
  display: grid; place-items: center; color: var(--green-ink);
}
.ma-avatar svg { width: 20px; height: 20px; }
.ma-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }

.ma-qs { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.ma-q {
  font: 500 14px/1.3 var(--font); color: var(--fg-2); background: var(--bg-2);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 8px 14px; cursor: pointer; text-align: left;
}
.ma-q:hover { color: var(--fg); border-color: rgba(92, 206, 20, 0.4); }
.ma-q[aria-pressed="true"] { color: var(--green-ink); background: var(--green-face); border-color: var(--green-face); }

/* Desktop: the row is at least a viewport-sized height, or taller if the side cards need it. The feed is
   size-contained, so its long content never sets the height: it fills whatever the row gives it and scrolls. */
.ma-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(clamp(520px, 74vh, 720px), auto); min-width: 0; }
.ma-main { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; border-right: 1px solid var(--border); grid-column: 1; grid-row: 1; }
.ma-side { display: grid; gap: 14px; align-content: start; padding: 16px; min-width: 0; grid-column: 2; grid-row: 1; }
@media (max-width: 900px) {
  .ma-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .ma-main { border-right: 0; border-bottom: 1px solid var(--border); grid-column: 1; grid-row: 1; }
  .ma-side { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-column: 1; grid-row: 2; }
}

/* transcript */
.ma-feed {
  display: grid; gap: 12px; align-content: start; padding: 18px 20px;
  overflow-y: auto; min-width: 0; min-height: 0; contain: size;
}
@media (max-width: 900px) {
  /* stacked: no row to fill, so the feed gets its own height */
  .ma-feed { contain: none; height: min(70vh, 620px); }
}
.ma-feed:focus-visible { outline-offset: -2px; }
/* chat bubbles, matching the agent preview card on the home page */
.ma-user {
  justify-self: end; max-width: 85%; background: var(--green-face); color: var(--green-ink);
  border-radius: 12px 12px 4px 12px; padding: 9px 13px; font-weight: 600; line-height: 1.45;
}
.ma-think { display: flex; gap: 10px; align-items: flex-start; color: var(--fg-2); font-size: 15px; min-width: 0; }
.ma-think::before {
  content: ""; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--purple); box-shadow: 0 0 0 3px var(--purple-wash);
}
.ma-think.pending { color: var(--muted); }
.ma-think.pending::before { animation: ma-pulse 1s ease-in-out infinite; }
@keyframes ma-pulse { 50% { opacity: .35; } }
.ma-dots::after { content: "…"; }

.ma-tool { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.ma-tool-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; font-size: 14px; }
.ma-tool-head .ma-tname { font: 600 12px/1 var(--mono); color: var(--green-hi); background: var(--green-wash); padding: 5px 7px; border-radius: 4px; }
.ma-tool-head .ma-tinput { font: 400 12px/1.3 var(--mono); color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.ma-tool-head .spacer { flex: 1; }
.ma-tool-head .ma-tstate { font: 500 11px/1 var(--mono); color: var(--muted); }
.ma-tool.pending .ma-tstate { color: var(--amber); }
.ma-tool.failed .ma-tstate { color: var(--red); }
.ma-calls { border-top: 1px solid var(--border); }
.ma-call { border-top: 1px solid var(--border); min-width: 0; }
.ma-call:first-child { border-top: 0; }
.ma-call summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 7px 12px; cursor: pointer;
  font: 400 12px/1.4 var(--mono); color: var(--fg-2); list-style: none; min-width: 0;
}
.ma-call summary::-webkit-details-marker { display: none; }
.ma-call summary::before { content: "▸"; color: var(--faint); }
.ma-call[open] summary::before { content: "▾"; }
.ma-cid { font-weight: 600; color: var(--bg); background: var(--fg-2); border-radius: 4px; padding: 1px 5px; }
.ma-m { color: var(--blue); }
.ma-path { overflow-wrap: anywhere; word-break: break-all; min-width: 0; flex: 1 1 200px; }
.ma-cmeta { color: var(--muted); white-space: nowrap; }
.ma-call.err .ma-cmeta { color: var(--red); }
.ma-call pre {
  margin: 0; padding: 10px 12px; max-height: 260px; overflow: auto; background: var(--bg);
  font: 400 11.5px/1.5 var(--mono); color: var(--fg-2); border-top: 1px dashed var(--border);
}
.ma-call.flash { animation: ma-flash 1.6s ease-out; }
@keyframes ma-flash { 0%, 30% { background: var(--green-wash); box-shadow: inset 3px 0 0 var(--green-hi); } 100% { background: transparent; box-shadow: none; } }

/* brief */
.ma-brief {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--fg-2);
  border-radius: 14px 14px 14px 4px; padding: 16px 18px; display: grid; gap: 12px; min-width: 0;
}
.ma-brief h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.ma-brief p, .ma-brief ul { margin: 0; color: var(--fg); }
.ma-brief ul { padding-left: 20px; display: grid; gap: 8px; }
.ma-brief li::marker { color: var(--green-hi); }
.ma-brief .ma-note { color: var(--muted); font-size: 13px; }
.ma-brief strong { color: var(--fg); }
.ma-ref {
  font: inherit; font-weight: 600; color: var(--green-face); background: var(--green-wash);
  border: 0; border-bottom: 1px dashed rgba(128, 224, 56, 0.6); border-radius: 3px; padding: 0 3px; cursor: pointer;
}
.ma-ref:hover, .ma-ref:focus-visible { background: rgba(92, 206, 20, 0.22); color: #fff; }

.ma-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.ma-controls .spacer { flex: 1; }
.ma-honest { max-width: 420px; }

/* side cards */
.ma-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; min-width: 0;
}
.ma-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ma-total { font: 700 24px/1.1 var(--font); letter-spacing: -0.02em; }
.ma-rows { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ma-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; font-size: 14px; align-items: baseline; }
.ma-rows .sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-rows .val { font-family: var(--mono); font-size: 13px; }
.ma-rows .chg { font-family: var(--mono); font-size: 12px; min-width: 62px; text-align: right; }
.up { color: var(--green-hi); }
.down { color: var(--red); }
.ma-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.ma-dl dt { color: var(--muted); }
.ma-dl dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

/* BYOK */
.ma-byok { padding: 56px 0 8px; display: grid; gap: 24px; }
.ma-byok-intro { display: grid; gap: 8px; max-width: 760px; }
.ma-byok-intro h2 { font-size: clamp(24px, 3.4vw, 32px); margin: 0; }
.ma-byok-intro p { margin: 0; }
.ma-byok-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: stretch; }
@media (max-width: 900px) { .ma-byok-grid { grid-template-columns: minmax(0, 1fr); align-items: start; } }
.ma-form { padding: 18px; gap: 14px; background: var(--surface); }
.ma-field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.ma-field input, .ma-field textarea, .ma-field select {
  width: 100%; font: 400 14px/1.4 var(--font); color: var(--fg); background: var(--bg-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 10px 12px; min-width: 0;
}
.ma-field input { font-family: var(--mono); font-size: 13px; }
.ma-field textarea { resize: vertical; }
.ma-field select { color-scheme: dark; cursor: pointer; text-overflow: ellipsis; }
.ma-field > label { font: inherit; }
.ma-modelnote { font-weight: 400; }
.ma-field input:focus, .ma-field textarea:focus, .ma-field select:focus { outline: 2px solid var(--green-hi); outline-offset: 0; border-color: transparent; }
.ma-keynote { margin: -6px 0 0; }
.ma-suggest .chip { cursor: pointer; font-family: var(--font); font-size: 12.5px; white-space: normal; text-align: left; }
.ma-suggest .chip:hover { color: var(--fg); border-color: rgba(92, 206, 20, 0.4); }
.ma-form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ma-error { color: var(--red); margin: 0; }
.ma-live { padding: 0; gap: 0; background: var(--surface); grid-template-rows: auto minmax(0, 1fr); }
.ma-live .ma-card-head { padding: 12px 16px; border-bottom: 1px solid var(--border); }
/* desktop: as tall as the form beside it (the grid row stretches both); stacked: its own height */
.ma-feed-live { min-height: 360px; }
@media (max-width: 900px) { .ma-feed-live { height: min(65vh, 540px); min-height: 0; } }
.ma-empty { margin: 0; }
.ma-warn { border: 1px solid rgba(245, 177, 61, 0.35); background: var(--amber-wash); color: var(--fg); border-radius: var(--r); padding: 10px 12px; font-size: 14px; }

@media (max-width: 640px) {
  .ma-head, .ma-qs, .ma-controls { padding-left: 14px; padding-right: 14px; }
  .ma-feed { padding: 14px; }
  .ma-side { padding: 14px; }
  .ma-q { font-size: 13px; padding: 7px 12px; }
  .ma-user { max-width: 100%; }
}

/* endpoint links and tool result visuals */
.ma-eps { padding: 0 12px 8px; font: 400 11.5px/1.5 var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ma-ep { color: var(--fg-2); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; overflow-wrap: anywhere; }
.ma-ep:hover { color: var(--green-face); }
.ma-tv-wrap:empty { display: none; }
.ma-tv-wrap { padding: 2px 12px 10px; display: grid; gap: 8px; min-width: 0; }
.ma-tv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font: 500 12px/1.3 var(--mono); }
.ma-tv-big { font: 700 18px/1 var(--font); color: var(--fg); }
.ma-tv-note { margin: 0; font-size: 13px; color: var(--fg-2); overflow-wrap: anywhere; }
.ma-tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.ma-tchip {
  display: inline-flex; align-items: center; gap: 5px; font: 500 11.5px/1 var(--mono); color: var(--fg-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 8px 4px 4px;
}
.ma-tchip:not(:has(img, .ma-logo)) { padding-left: 8px; }
.ma-tchip b { color: var(--fg); font-weight: 600; }
.ma-tchip.up span:last-child, .ma-tchip.up b:last-child { color: var(--green-hi); }
.ma-tchip.down span:last-child, .ma-tchip.down b:last-child { color: var(--red); }
.ma-tchip.hit { border-color: rgba(92, 206, 20, 0.45); background: var(--green-wash); }

/* logos */
.ma-logo { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: var(--surface-2); }
.ma-logo.sm { width: 16px; height: 16px; }
.ma-logo-f { display: inline-grid; place-items: center; font: 700 8px/1 var(--mono); color: var(--muted); border: 1px solid var(--border); }
.ma-logo-f.sm { font-size: 6px; }

/* charts */
.ma-chart { width: 100%; display: block; }
.ma-fig { margin: 0; display: grid; gap: 6px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.ma-fig-head, .ma-fig-foot { display: flex; justify-content: space-between; gap: 8px; font: 500 11px/1.3 var(--mono); color: var(--muted); }
.ma-fig-head b { font-weight: 600; color: var(--fg); }
.ma-fig-head b.up { color: var(--green-hi); } .ma-fig-head b.down { color: var(--red); }
.ma-fig > * { min-width: 0; }
.ma-fig-head > *, .ma-fig-foot > * { flex-shrink: 0; }
.ma-fig-head > span:first-child { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-fig-foot span:nth-child(2) { flex: 1 1 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ma-tv-wrap .ma-fig { padding: 8px 10px; }

/* headline cards in the brief */
.ma-heads { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.ma-head-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.ma-hc-top { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.ma-hc-top .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ma-chg { margin-left: auto; font: 600 12px/1 var(--mono); }
.ma-hc-title { margin: 0; color: var(--fg); font-size: 14px; line-height: 1.45; }
.ma-hc-title a { color: var(--fg); }
.ma-hc-title a:hover { color: var(--green-face); }
.ma-hc-src { margin: 0; font: 400 12px/1.4 var(--mono); color: var(--muted); }

/* bars and coin lists */
.ma-bars, .ma-coins { display: grid; gap: 6px; }
.ma-bar, .ma-coin { display: grid; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.ma-bar { grid-template-columns: 22px 64px minmax(0, 1fr) auto; }
.ma-coin { grid-template-columns: 22px minmax(0, 1.3fr) minmax(40px, 1fr) auto; }
.ma-bar .sym { font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; }
.ma-coin .nm { display: grid; min-width: 0; color: var(--fg); line-height: 1.25; }
.ma-coin .nm small { font: 400 11px/1.3 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ma-bar .track, .ma-coin .track { position: relative; height: 10px; border-radius: 3px; background: rgba(223, 229, 236, 0.05); }
.ma-bar .track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }
.ma-bar .track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.ma-coin .track i { display: block; height: 100%; border-radius: 3px; }
.track i.pos { background: linear-gradient(90deg, var(--green-base), var(--green-face)); }
.track i.neg { background: linear-gradient(90deg, #c43c48, var(--red)); }
.ma-bar .val, .ma-coin .val { font: 600 12px/1.3 var(--mono); text-align: right; white-space: nowrap; }
.ma-bar .val small { display: block; font-weight: 400; color: var(--muted); }

/* market tiles */
.ma-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.ma-stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 4px; }
.ma-stat span { font: 500 11px/1.2 var(--mono); color: var(--muted); }
.ma-stat b { font: 700 18px/1.1 var(--font); color: var(--fg); }
.ma-stat b .ma-ref { font-weight: 700; }
.ma-stat b.down .ma-ref { color: var(--red); } .ma-stat b.up .ma-ref { color: var(--green-face); }

/* portfolio side card */
.ma-sub { margin: 0; }
.ma-rows li { grid-template-columns: 22px minmax(0, 1fr) auto auto; align-items: center; }

@media (max-width: 640px) {
  .ma-bar { grid-template-columns: 22px 48px minmax(0, 1fr) auto; }
  .ma-heads { grid-template-columns: minmax(0, 1fr); }
}

/* .btn sets display, which would override the hidden attribute */
.ma-byok [hidden] { display: none !important; }
