:root {
  color-scheme: dark;
  --bg: #050814;
  --panel: rgba(10, 16, 34, 0.78);
  --panel-strong: rgba(11, 18, 38, 0.94);
  --line: rgba(130, 177, 255, 0.14);
  --cyan: #42f5e6;
  --cyan-soft: rgba(66, 245, 230, 0.2);
  --blue: #4c8dff;
  --violet: #a673ff;
  --risk: #ff4d76;
  --warning: #ffbd5c;
  --text: #eef6ff;
  --muted: #7183a5;
  --muted-bright: #a7b8d6;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    radial-gradient(circle at 68% 10%, rgba(55, 105, 255, .1), transparent 34%),
    radial-gradient(circle at 30% 100%, rgba(95, 43, 186, .12), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  letter-spacing: .01em;
}
button, input, select { font: inherit; }
button { color: inherit; }
.mobile-only, .mobile-controls-button, .mobile-backdrop { display: none; }

.ambient { position: fixed; width: 42vw; height: 42vw; filter: blur(100px); opacity: .14; border-radius: 50%; pointer-events: none; }
.ambient-a { background: #145dff; right: -18vw; top: -20vw; }
.ambient-b { background: #6b21d6; left: 8vw; bottom: -34vw; }
.scanlines { position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .025; background: repeating-linear-gradient(0deg, transparent 0 3px, #fff 4px); }
.glass { background: linear-gradient(145deg, rgba(15, 24, 48, .86), rgba(7, 12, 27, .72)); border: 1px solid var(--line); box-shadow: 0 18px 70px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.035); backdrop-filter: blur(22px); }

.topbar { position: fixed; left: 18px; right: 18px; top: 14px; height: 64px; z-index: 20; border-radius: 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { position: relative; width: 36px; height: 36px; filter: drop-shadow(0 0 12px rgba(66,245,230,.35)); }
.brand-mark span { position: absolute; width: 9px; height: 9px; border: 2px solid var(--cyan); border-radius: 50%; }
.brand-mark span:nth-child(1) { left: 2px; top: 14px; }
.brand-mark span:nth-child(2) { right: 3px; top: 3px; }
.brand-mark span:nth-child(3) { right: 3px; bottom: 3px; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 10px; width: 21px; height: 1px; background: linear-gradient(90deg, var(--cyan), var(--blue)); transform-origin: left; }
.brand-mark::before { top: 17px; transform: rotate(-31deg); }
.brand-mark::after { top: 19px; transform: rotate(31deg); }
.brand-name { font-size: 18px; line-height: 1; font-weight: 800; letter-spacing: .12em; }
.brand-name span { color: var(--cyan); }
.brand-subtitle { color: var(--muted); font-size: 13px; letter-spacing: .16em; margin-top: 5px; }
.topbar-center { display: flex; align-items: center; gap: 9px; color: var(--muted-bright); font-size: 13px; letter-spacing: .12em; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(66,245,230,.08), 0 0 14px var(--cyan); animation: livePulse 1.8s infinite; }
.separator { width: 1px; height: 16px; background: var(--line); margin: 0 6px; }
.topbar-actions { justify-self: end; display: flex; gap: 8px; }
.icon-button { border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; transition: .2s; }
.icon-button:hover { border-color: rgba(66,245,230,.45); color: var(--cyan); transform: translateY(-1px); box-shadow: 0 0 18px rgba(66,245,230,.1); }
.icon-button.danger:hover { color: var(--risk); border-color: rgba(255,77,118,.5); }

.workspace { position: fixed; inset: 92px 18px 18px; display: grid; grid-template-columns: 292px minmax(420px, 1fr) 318px; gap: 14px; }
.control-panel, .detail-panel { position: relative; z-index: 8; border-radius: var(--radius); padding: 22px; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(80,120,180,.35) transparent; }
.control-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-kicker { color: var(--cyan); font-size: 13px; letter-spacing: .18em; font-weight: 700; margin-bottom: 8px; }
h1 { margin: 0; font-size: 25px; font-weight: 720; letter-spacing: -.03em; }
.panel-intro { color: var(--muted-bright); font-size: 13px; line-height: 1.8; margin: 10px 0 20px; }
.field-label { display: block; color: var(--muted); font-size: 13px; letter-spacing: .1em; margin: 0 0 7px; }
.address-field { height: 46px; border: 1px solid rgba(103,144,210,.23); background: rgba(3,7,18,.64); border-radius: 12px; display: flex; align-items: center; padding: 0 8px 0 12px; transition: .2s; }
.address-field:focus-within { border-color: rgba(66,245,230,.58); box-shadow: 0 0 0 3px rgba(66,245,230,.06), 0 0 24px rgba(66,245,230,.08); }
.field-icon { color: var(--cyan); margin-right: 8px; }
.address-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; }
.address-field input::placeholder { color: #405170; }
.mini-button { border: 0; border-radius: 7px; background: rgba(75,132,255,.12); color: #9bbcff; font-size: 13px; padding: 6px 8px; cursor: pointer; }
.mini-button.awaiting-paste { color: var(--cyan); background: rgba(66,245,230,.13); box-shadow: 0 0 14px rgba(66,245,230,.12); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
select { width: 100%; height: 40px; appearance: none; border: 1px solid rgba(103,144,210,.2); border-radius: 10px; background: rgba(3,7,18,.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237e91b4' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center; color: var(--text); padding: 0 30px 0 11px; font-size: 13px; outline: 0; }
.range-row { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; }
.range-row strong { color: var(--cyan); font-size: 13px; }
input[type="range"] { width: 100%; height: 3px; accent-color: var(--cyan); cursor: pointer; }
.primary-button { position: relative; overflow: hidden; width: 100%; height: 46px; margin-top: 18px; border: 1px solid rgba(66,245,230,.46); border-radius: 12px; background: linear-gradient(105deg, rgba(26,141,173,.72), rgba(45,88,209,.75)); box-shadow: 0 9px 32px rgba(34,117,190,.23), inset 0 1px 0 rgba(255,255,255,.17); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .08em; cursor: pointer; transition: .25s; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 13px 38px rgba(34,163,190,.28), 0 0 24px rgba(66,245,230,.12); }
.primary-button:disabled { opacity: .5; cursor: wait; transform: none; }
.button-shine { position: absolute; inset: -80% auto -80% -35%; width: 28%; transform: rotate(18deg); background: rgba(255,255,255,.2); filter: blur(4px); transition: .5s; }
.primary-button:hover .button-shine { left: 115%; }
.button-icon { margin-right: 7px; color: var(--cyan); }
.primary-button.compact { height: 40px; font-size: 13px; margin-top: 12px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.secondary-button { border: 1px solid rgba(103,144,210,.17); background: rgba(255,255,255,.025); color: var(--muted-bright); border-radius: 9px; height: 36px; font-size: 13px; cursor: pointer; transition: .2s; }
.secondary-button:hover { color: var(--cyan); border-color: rgba(66,245,230,.3); }
.legend { margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 12px 7px; }
.legend-title { grid-column: 1 / -1; color: var(--muted); font-size: 13px; letter-spacing: .16em; margin-bottom: 4px; }
.legend-row { display: flex; gap: 9px; align-items: center; color: var(--muted-bright); font-size: 13px; line-height: 1.35; }
.legend-node { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.legend-node.root { color: var(--cyan); background: var(--cyan); }
.legend-node.exchange { color: var(--violet); background: var(--violet); }
.legend-node.known { color: var(--blue); background: var(--blue); }
.legend-node.risk { color: var(--risk); background: var(--risk); }
.legend-node.unknown { color: #66789c; background: #66789c; }
.hint-card { display: flex; gap: 11px; margin-top: 20px; border: 1px solid rgba(108,118,255,.15); background: rgba(72,61,180,.07); border-radius: 12px; padding: 14px; }
.hint-icon { color: var(--violet); font-size: 15px; }
.hint-card strong { display: block; font-size: 13px; }
.hint-card p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.graph-stage { position: relative; border: 1px solid rgba(94,137,208,.12); border-radius: var(--radius); overflow: hidden; background: radial-gradient(circle at center, rgba(17,33,69,.5), rgba(3,7,18,.82) 68%); }
.graph-stage::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(66,245,230,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(66,245,230,.025) 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(circle, #000 25%, transparent 84%); }
#graphCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graphCanvas.dragging { cursor: grabbing; }
.graph-vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 100px rgba(0,0,0,.58); }
.coordinates { position: absolute; top: 82px; right: 14px; color: rgba(134,160,201,.38); font: 13px "Cascadia Code", monospace; letter-spacing: .1em; pointer-events: none; }
.data-volume { position: absolute; top: 14px; left: 50%; z-index: 6; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, minmax(118px, 1fr)); min-width: min(520px, calc(100% - 150px)); padding: 9px 14px; border-radius: 12px; pointer-events: none; }
.data-volume div { padding: 0 16px; text-align: center; border-right: 1px solid var(--line); }
.data-volume div:last-child { border-right: 0; }
.data-volume span { display: block; color: var(--muted); font-size: 13px; letter-spacing: .1em; }
.data-volume strong { display: block; margin-top: 4px; color: #d5e8ff; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.data-volume div:first-child strong { color: var(--cyan); }
.empty-state, .loading-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; transition: opacity .35s, transform .35s; }
.empty-state.hidden, .loading-state.hidden { opacity: 0; transform: scale(.94); }
.empty-state h2 { margin: 24px 0 5px; font-size: 15px; letter-spacing: .08em; }
.empty-state p { color: var(--muted); font-size: 13px; }
.radar { width: 132px; height: 132px; position: relative; border-radius: 50%; background: radial-gradient(circle, rgba(66,245,230,.08), transparent 60%); }
.radar-ring { position: absolute; border: 1px solid rgba(66,245,230,.2); border-radius: 50%; }
.ring-a { inset: 8px; }.ring-b { inset: 28px; }.ring-c { inset: 48px; }
.radar-ring::before, .radar-ring::after { content: ""; position: absolute; background: rgba(66,245,230,.1); }
.radar-sweep { position: absolute; inset: 4px; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 80%, rgba(66,245,230,.18) 98%, rgba(66,245,230,.7)); animation: rotate 3s linear infinite; mask-image: radial-gradient(circle, transparent 0 2%, #000 3%); }
.radar-core { position: absolute; inset: 48px; display: grid; place-items: center; border: 1px solid rgba(66,245,230,.5); border-radius: 50%; color: var(--cyan); font-weight: 800; box-shadow: 0 0 28px rgba(66,245,230,.22); }
.loading-state { background: rgba(4,8,20,.34); backdrop-filter: blur(2px); z-index: 7; }
.loader-orbit { width: 82px; height: 82px; position: relative; animation: rotate 2.8s linear infinite; }
.loader-orbit::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(66,245,230,.26); border-radius: 50%; }
.loader-orbit span { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.loader-orbit span:nth-child(1) { left: 4px; top: 36px; }.loader-orbit span:nth-child(2) { right: 12px; top: 10px; background: var(--blue); }.loader-orbit span:nth-child(3) { right: 7px; bottom: 12px; background: var(--violet); }
.loading-state strong { margin-top: 15px; font-size: 13px; letter-spacing: .08em; }
.loading-state small { color: var(--cyan); font-size: 13px; letter-spacing: .16em; margin-top: 7px; }
.stats-bar { position: absolute; left: 18px; right: 18px; bottom: 16px; min-height: 54px; z-index: 6; border-radius: 13px; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; padding: 8px 14px; pointer-events: none; }
.stat { border-right: 1px solid var(--line); padding: 0 14px; }
.stat:last-child { border: 0; }
.stat span { display: block; color: var(--muted); font-size: 13px; letter-spacing: .1em; }
.stat strong { display: block; margin-top: 3px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.accent strong { color: var(--cyan); font-size: 14px; margin-top: 6px; }

.detail-panel { transform: translateX(0); transition: transform .3s, opacity .3s; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 0; font-size: 16px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-empty { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.detail-empty p { max-width: 220px; line-height: 1.8; font-size: 13px; }
.detail-orbit { font-size: 38px; color: rgba(66,245,230,.4); animation: livePulse 2s infinite; }
.hidden { display: none !important; }
.risk-badge { display: inline-flex; align-items: center; margin: 18px 0 4px; height: 28px; padding: 0 10px; border: 1px solid rgba(108,132,176,.25); border-radius: 999px; color: var(--muted-bright); background: rgba(89,112,158,.08); font-size: 13px; letter-spacing: .1em; }
.risk-badge.high, .risk-badge.critical { color: #ff7998; border-color: rgba(255,77,118,.36); background: rgba(255,77,118,.09); box-shadow: 0 0 20px rgba(255,77,118,.08); }
.risk-badge.medium { color: var(--warning); border-color: rgba(255,189,92,.3); background: rgba(255,189,92,.08); }
.detail-section { margin-top: 18px; }
.detail-label { color: var(--muted); font-size: 13px; letter-spacing: .09em; }
.address-copy { margin-top: 8px; display: flex; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(3,7,18,.55); }
.address-copy code { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; color: #b8c9e7; font-size: 13px; }
.address-copy button { border: 0; background: transparent; color: var(--cyan); font-size: 13px; cursor: pointer; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tag { max-width: 100%; border: 1px solid rgba(76,141,255,.24); border-radius: 7px; padding: 6px 9px; background: rgba(76,141,255,.08); color: #a9c4ff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.tag.empty { color: var(--muted); border-color: var(--line); background: rgba(255,255,255,.02); }
.edge-route { margin: 18px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; }
.edge-route code { padding: 10px 9px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--muted-bright); }
.edge-route span { color: var(--cyan); font-size: 15px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(3,7,18,.4); }
.metric-grid .wide { grid-column: 1 / -1; }
.metric-grid span { color: var(--muted); font-size: 13px; }
.metric-grid strong { display: block; margin-top: 5px; font-size: 14px; color: #cfe0fb; overflow: hidden; text-overflow: ellipsis; }
.section-heading { display: flex; justify-content: space-between; }
#transactionStatus { color: var(--cyan); font-size: 13px; }
.transaction-list { margin-top: 10px; display: grid; gap: 8px; max-height: 39vh; overflow: auto; }
.transaction { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(3,7,18,.46); }
.transaction-top { display: flex; justify-content: space-between; gap: 8px; }
.transaction code { color: #91b6ff; font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }
.transaction strong { color: var(--cyan); font-size: 13px; line-height: 1.35; white-space: nowrap; }
.transaction small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 7px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; border: 1px solid rgba(66,245,230,.25); background: rgba(8,15,31,.94); color: #cae7ff; border-radius: 11px; padding: 10px 16px; box-shadow: 0 12px 38px rgba(0,0,0,.4); font-size: 13px; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255,77,118,.4); color: #ff9bb2; }

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.8); } }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 270px 1fr; }
  .detail-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 310px; z-index: 15; box-shadow: -18px 0 60px rgba(0,0,0,.4); }
  .detail-panel.collapsed { transform: translateX(calc(100% + 18px)); opacity: 0; pointer-events: none; }
}
@media (max-width: 760px), (max-height: 520px) and (max-width: 940px) {
  .topbar { left: 6px; right: 6px; top: 6px; height: 58px; grid-template-columns: minmax(0, 1fr) auto; padding: 0 10px; }
  .topbar-center { display: none; }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 16px; }
  .brand-subtitle { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions #pauseButton, .topbar-actions #clearButton { display: none; }
  .icon-button { width: 40px; height: 40px; }
  .mobile-controls-button { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; height: 40px; padding: 0 12px; border: 1px solid rgba(66,245,230,.28); border-radius: 10px; background: rgba(66,245,230,.08); color: var(--cyan); font-weight: 700; }
  .workspace { inset: 70px 6px 6px; display: block; }
  .graph-stage { width: 100%; height: 100%; border-radius: 14px; }
  .control-panel { position: absolute; inset: 0 auto 0 0; width: min(344px, calc(100vw - 24px)); max-height: none; padding: 18px; z-index: 30; opacity: 0; pointer-events: none; transform: translateX(calc(-100% - 14px)); transition: transform .25s ease, opacity .2s ease; }
  .control-panel.mobile-open { opacity: 1; pointer-events: auto; transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .panel-intro { margin: 8px 0 16px; line-height: 1.65; }
  .address-field { height: 48px; }
  select { height: 44px; }
  input[type="range"] { height: 28px; }
  .primary-button { height: 48px; }
  .secondary-button { min-height: 42px; }
  .hint-card { margin-bottom: 4px; }
  .detail-panel { position: absolute; left: 6px; right: 6px; top: auto; bottom: 0; width: auto; max-height: min(72vh, 620px); padding: 18px; z-index: 31; border-radius: 16px 16px 12px 12px; transform: translateY(0); opacity: 1; transition: transform .25s ease, opacity .2s ease; box-shadow: 0 -18px 60px rgba(0,0,0,.52); }
  .detail-panel.collapsed { transform: translateY(calc(100% + 14px)); opacity: 0; pointer-events: none; }
  .detail-empty { min-height: 180px; }
  .transaction-list { max-height: 34vh; }
  .mobile-backdrop { position: absolute; display: block; inset: 0; z-index: 24; border: 0; background: rgba(1,4,12,.58); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .mobile-backdrop.visible { opacity: 1; pointer-events: auto; }
  .coordinates { display: none; }
  .data-volume { top: 8px; bottom: auto; min-width: calc(100% - 16px); padding: 7px 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .data-volume div { min-width: 0; padding: 0 4px; }
  .data-volume span { font-size: 13px; letter-spacing: 0; white-space: nowrap; }
  .data-volume strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stats-bar { left: 8px; right: 8px; bottom: 8px; min-height: 52px; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 4px; }
  .stat { min-width: 0; padding: 0 6px; }
  .stat:nth-child(2) { border-right: 1px solid var(--line); }
  .stat span { letter-spacing: 0; white-space: nowrap; }
  .stat strong, .stat.accent strong { font-size: 14px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .graph-vignette { box-shadow: inset 0 0 50px rgba(0,0,0,.45); }
  .toast { top: 140px; bottom: auto; width: calc(100% - 28px); text-align: center; transform: translate(-50%, -12px); }
  .toast.show { transform: translate(-50%, 0); }
}
