/* Bansun: application workspace. */

.app .stage-canvas { opacity: 0.4; }
.app-tag { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; margin-left: 4px; }

.status {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(8, 20, 11, 0.6); backdrop-filter: blur(14px);
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status[data-state='ok'] i { background: var(--accent); box-shadow: 0 0 10px var(--glow); }
.status[data-state='warn'] i { background: var(--warn); }
.status[data-state='off'] i { background: var(--danger); }

/* ---------- rail ---------- */

.rail {
  position: fixed; z-index: 54; top: calc(var(--frame-inset) + 88px); left: calc(var(--frame-inset) + 18px); width: 214px;
  padding: 8px; display: grid; gap: 2px; max-height: calc(100vh - 2 * var(--frame-inset) - 120px); overflow-y: auto;
}
.rail button {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 0; border-radius: 12px; background: none;
  color: var(--text-2); font-size: 13.5px; cursor: pointer; text-align: left; transition: background 0.3s, color 0.3s;
}
.rail button svg { width: 17px; height: 17px; flex: none; color: var(--muted); transition: color 0.3s; }
.rail button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.rail button.is-active { color: var(--text); background: rgba(141, 255, 74, 0.09); }
.rail button.is-active svg { color: var(--accent); filter: drop-shadow(0 0 6px var(--glow)); }
.rail .rail-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.rail .rail-group { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 4px; opacity: 0.8; }
.rail .rail-group:first-child { padding-top: 4px; }
.rail .tag { margin-left: auto; font-family: var(--font-mono); font-size: 9.5px; color: var(--accent); letter-spacing: 0.1em; opacity: 0.8; }

/* ---------- workspace ---------- */

.workspace { position: relative; z-index: 3; min-height: 100vh; padding: calc(var(--frame-inset) + 96px) 6vw 140px calc(var(--frame-inset) + 270px); }
.view { max-width: 940px; margin: 0 auto; animation: view-in 0.6s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }
.view-head { display: grid; gap: 12px; margin-bottom: 26px; }
.view-head .h2 { font-size: clamp(32px, 4vw, 54px); }
.view-head p { margin: 0; max-width: 640px; }

.panel { padding: 20px; display: grid; gap: 14px; }
.panel + .panel { margin-top: 14px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

label.field { display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.input, textarea.input, select.input {
  width: 100%; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.32);
  padding: 11px 13px; font-size: 14px; outline: none; transition: border-color 0.3s, box-shadow 0.3s;
}
textarea.input { resize: vertical; min-height: 110px; line-height: 1.55; }
.input:focus { border-color: rgba(141, 255, 74, 0.5); box-shadow: 0 0 0 3px rgba(141, 255, 74, 0.08); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input[type='range'] { accent-color: var(--accent); width: 100%; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.3); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 9px; font-size: 12.5px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.seg button svg { width: 14px; height: 14px; }
.seg button[aria-pressed='true'] { background: rgba(141, 255, 74, 0.13); color: var(--accent); }

.chip.is-on { color: var(--accent); border-color: rgba(141, 255, 74, 0.5); background: rgba(141, 255, 74, 0.08); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line-strong); color: var(--text-2); }
.badge.ok { color: var(--accent); border-color: rgba(141, 255, 74, 0.4); }
.badge.warn { color: var(--warn); border-color: rgba(255, 207, 74, 0.4); }
.badge.bad { color: var(--danger); border-color: rgba(255, 107, 90, 0.4); }
.note { border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.55; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.025); color: var(--text-2); }
.note.warn { border-color: rgba(255, 207, 74, 0.35); background: rgba(255, 207, 74, 0.06); color: #ffe6a3; }
.note.bad { border-color: rgba(255, 107, 90, 0.35); background: rgba(255, 107, 90, 0.07); color: #ffc3ba; }
.note.ok { border-color: rgba(141, 255, 74, 0.35); background: rgba(141, 255, 74, 0.06); color: #d6ffbf; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 13.5px; }
.empty svg { width: 34px; height: 34px; margin: 0 auto 12px; color: var(--accent); opacity: 0.8; filter: drop-shadow(0 0 10px var(--glow)); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(141, 255, 74, 0.25); border-top-color: var(--accent); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); box-shadow: 0 0 10px var(--glow); transition: width 0.4s var(--ease-out); }

/* ---------- chat ---------- */

.thread { display: grid; gap: 14px; margin-bottom: 14px; }
.msg { display: grid; gap: 10px; animation: view-in 0.5s var(--ease-out); }
.msg.user { justify-self: end; max-width: 80%; padding: 11px 15px; border-radius: 16px 16px 4px 16px; background: rgba(141, 255, 74, 0.1); border: 1px solid rgba(141, 255, 74, 0.25); white-space: pre-wrap; font-size: 14.5px; }
.msg.ai { padding: 18px 20px; }
.msg-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.msg-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.composer { display: grid; gap: 10px; padding: 12px; position: sticky; bottom: calc(var(--frame-inset) + 16px); z-index: 4; }
.composer textarea { min-height: 54px; max-height: 240px; border: 0; background: transparent; padding: 6px 8px; box-shadow: none !important; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.confidence { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.confidence-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.confidence-head strong { font-family: var(--font-display); font-weight: 400; font-size: 26px; letter-spacing: -0.03em; color: var(--text); }
.confidence .progress i { background: var(--c, var(--accent)); }

.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.compare .glass { padding: 16px; display: grid; gap: 10px; align-content: start; }

/* ---------- rendered markdown ---------- */

.md { font-size: 14.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.02em; margin: 16px 0 8px; font-size: 18px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--accent); }
.md code { font-family: var(--font-mono); font-size: 0.88em; background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; }
.md pre { background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.md blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 2px solid var(--accent); color: var(--text-2); }
.md-table { overflow-x: auto; margin: 0 0 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.md th { color: var(--accent); font-weight: 500; font-size: 12px; letter-spacing: 0.04em; }

/* ---------- receipts & key-values ---------- */

.receipt { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.7; border-radius: 12px; padding: 14px; background: rgba(0, 0, 0, 0.35); border: 1px dashed var(--line-strong); color: var(--text-2); overflow-wrap: anywhere; }
.receipt .r-head { display: flex; justify-content: space-between; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }
.big-stat { font-family: var(--font-display); font-weight: 400; font-size: 54px; letter-spacing: -0.03em; line-height: 1; }
.big-stat small { font-size: 16px; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.day { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); display: grid; gap: 4px; font-size: 13px; }

/* ---------- scam gauge ---------- */

.gauge { position: relative; width: 150px; height: 150px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { stroke: rgba(255, 255, 255, 0.07); }
.gauge .val { stroke: var(--c, var(--accent)); filter: drop-shadow(0 0 6px var(--c, var(--glow))); transition: stroke-dashoffset 0.9s var(--ease-out); }
.gauge .g-num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .g-num strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 40px; letter-spacing: -0.03em; line-height: 1; }
.gauge .g-num span { font-size: 11px; color: var(--muted); }
.reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reasons li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.reasons li svg { width: 16px; height: 16px; margin-top: 2px; color: var(--warn); }
.reasons li.bad svg { color: var(--danger); }
.reasons li.good svg { color: var(--accent); }

/* ---------- notes, shares, ledger ---------- */

.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); align-items: center; }
.item h4 { margin: 0; font-weight: 500; font-size: 14px; }
.item p { margin: 0; grid-column: 1 / -1; font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.share { font-family: var(--font-mono); font-size: 11px; overflow-wrap: anywhere; color: var(--text); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 400; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.check-list label { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check-list input { accent-color: var(--accent); margin-top: 4px; }

@media (max-width: 1000px) {
  .rail {
    top: auto; bottom: 14px; left: 50%; transform: translateX(-50%); width: auto; max-width: calc(100vw - 20px);
    display: flex; overflow-x: auto; scrollbar-width: none; padding: 5px; border-radius: 16px;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail button { flex-direction: column; gap: 4px; padding: 7px 10px; font-size: 10.5px; min-width: 66px; }
  .rail .rail-sep, .rail .tag, .rail .rail-group { display: none; }
  .workspace { padding: 88px 18px 150px; }
  .composer { bottom: 92px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar .status span { display: none; }
  .app-tag { display: none; }
  .days { grid-template-columns: 1fr; }
  .msg.user { max-width: 92%; }
}

/* ---------- in-page dialog ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); animation: view-in 0.3s var(--ease-out); }
.modal { width: min(420px, 100%); padding: 20px; display: grid; gap: 14px; }
.modal-text { margin: 0; font-size: 14.5px; line-height: 1.55; }
.pill.danger { border-color: rgba(255, 107, 90, 0.5); color: #ffc3ba; }

.preview-note { max-width: 940px; margin: 0 auto 18px; }

/* ---------- Ethereum tools ---------- */

.mono-input { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.01em; }
.mono-cell, .mono-line { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.mono-line { color: var(--text-2); margin: 2px 0; }
.up { color: var(--accent); }
.down { color: var(--danger); }
.lead-text { margin: 0; font-size: 16px; line-height: 1.55; color: var(--text); }

.addr { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 12px; }
.addr a { color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--line-strong); }
.addr a:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 12px; line-height: 1; }
.copy-btn:hover { color: var(--accent); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat-grid > div { display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); }
.stat-grid strong { font-family: var(--font-display); font-weight: 400; font-size: 22px; letter-spacing: -0.02em; }

.risk-dial { --v: 0; position: relative; width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-items: center; text-align: center;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), rgba(255, 255, 255, 0.07) 0); }
.risk-dial::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg, #020704); }
.risk-dial strong, .risk-dial span { position: relative; display: block; line-height: 1; }
.risk-dial strong { font-family: var(--font-display); font-weight: 400; font-size: 26px; }
.risk-dial span { font-size: 10px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: -18px; }

.reasons li.info svg { color: var(--muted); }

.spark { display: block; overflow: visible; }
.table.market td { vertical-align: middle; }

details.receipt > summary { list-style: none; cursor: pointer; }
details.receipt > summary::-webkit-details-marker { display: none; }
details.receipt:not([open]) > summary { margin-bottom: 0; }

.alloc { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.alloc.tall { height: 18px; }
.alloc i { display: block; min-width: 3px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend b { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.check-inline input { accent-color: var(--accent); }

/* agent steps */
.steps { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(0, 0, 0, 0.22); }
.steps > summary { cursor: pointer; list-style: none; }
.steps > summary::-webkit-details-marker { display: none; }
.steps ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; position: relative; }
.steps li:not(:last-child)::after { content: ''; position: absolute; left: 6px; top: 16px; bottom: -10px; width: 1px; background: var(--line-strong); }
.step-dot { width: 13px; height: 13px; border-radius: 50%; margin-top: 3px; border: 2px solid var(--accent); box-shadow: 0 0 8px var(--glow); }
.steps li.bad .step-dot { border-color: var(--danger); box-shadow: none; }

/* token page */
.token-alert { display: grid; grid-template-columns: 22px 1fr; gap: 10px; margin-bottom: 14px; }
.token-alert svg { width: 20px; height: 20px; color: var(--danger); }
.token-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.token-card { padding: 18px; display: grid; gap: 8px; align-content: start; }
.token-card svg { width: 24px; height: 24px; color: var(--accent); filter: drop-shadow(0 0 8px var(--glow)); }
.token-card .h3 { margin: 0; font-size: 18px; }
.token-card p { margin: 0; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.flow li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); font-size: 13.5px; color: var(--text-2); }
.flow b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(60, 246, 40, 0.12); color: var(--accent); font-weight: 500; font-size: 13px; }
.roadmap { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.roadmap li { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: baseline; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); }
.roadmap li p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.roadmap li.done { border-color: rgba(60, 246, 40, 0.4); background: rgba(60, 246, 40, 0.05); }
.roadmap li.done .index { color: var(--accent); }

@media (max-width: 1000px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .roadmap li { grid-template-columns: 1fr; gap: 4px; }
}
.panel > .badge { justify-self: start; }

/* ---------- responsive hardening ---------- */
.view, .panel, .glass, .item, .stack, .row > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
.panel, .item, .kv dd, .msg, .token-card, .stat-grid > div, .note, .badge { overflow-wrap: anywhere; }
.panel:has(> .table), .panel:has(> table) { overflow-x: auto; }
.table { display: block; overflow-x: auto; max-width: 100%; }
.table tbody, .table thead { white-space: nowrap; }
.addr { max-width: 100%; flex-wrap: wrap; overflow-wrap: anywhere; word-break: break-all; }
.mono-input { min-width: 0; }
.thread { scroll-margin-bottom: 200px; }
.composer { background: linear-gradient(160deg, rgba(20, 44, 26, 0.85), rgba(6, 16, 9, 0.9)); }
@media (max-width: 1000px) {
  .rail { z-index: 56; bottom: max(10px, env(safe-area-inset-bottom)); }
  .rail button { min-height: 48px; }
  /* composer sits above the 64px+ rail with clear gap */
  .composer { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .workspace { padding: 84px 14px calc(170px + env(safe-area-inset-bottom)); }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .panel { padding: 14px; }
  .topbar .status span { display: inline; font-size: 10px; }
  .stage-canvas { opacity: 0.45; }
  .view[data-tool='ask'] .tool-host { display: flex; flex-direction: column; }
  .view[data-tool='ask'] .composer { order: 1; position: relative; bottom: auto; margin: 14px 0; }
  .view[data-tool='ask'] .thread { order: 2; }
  .composer-bar { flex-direction: column; align-items: stretch; }
  .composer-bar .pill { justify-content: space-between; }
  .composer textarea { max-height: 120px; }
  .row.between > .seg { width: 100%; }
  .seg button { flex: 1 1 auto; justify-content: center; }
  .item { grid-template-columns: 1fr; }
  .big-stat { font-size: 40px; }
  select.input { min-width: 0 !important; max-width: 100% !important; }
  .compare { grid-template-columns: 1fr; }
}
@media (hover: none) { .rail button:hover { background: none; } }
