/* PromptSentinel Portal — 淡色科技感主题(dependency-free)。 */
:root {
  --bg: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f6f9fd;
  --border: #e3e9f3;
  --border-strong: #d3dcec;
  --ink: #0c1a2b;
  --muted: #5d6e88;
  --faint: #8a99b3;
  --accent: #4f6ef7;
  --accent-2: #18b6cd;
  --accent-soft: #eaf0ff;
  --ok: #12a150;
  --ok-soft: #e7f7ee;
  --block: #e5484d;
  --block-soft: #fdecec;
  --warn: #d9892a;
  --warn-soft: #fbf2e3;
  --grad: linear-gradient(120deg, #4f6ef7 0%, #18b6cd 100%);
  --shadow-sm: 0 1px 2px rgba(16, 33, 64, .05), 0 1px 3px rgba(16, 33, 64, .06);
  --shadow: 0 6px 24px -8px rgba(24, 49, 96, .18);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(79, 110, 247, .12), transparent 60%),
    radial-gradient(800px 480px at 98% 4%, rgba(24, 182, 205, .12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 18px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm);
}
.brand .logo svg { width: 18px; height: 18px; }
.brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { color: var(--faint); font-weight: 500; font-size: 11px; letter-spacing: .04em; }

.nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.nav button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font: inherit; font-size: 14px; cursor: pointer;
  font-weight: 500; transition: .15s;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.status-pill {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--block); box-shadow: 0 0 0 3px var(--block-soft); }

/* ---------- layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: clamp(20px, 4vw, 40px); }
.view { display: none; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card, .grid { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; margin-bottom: 14px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 13px; }

/* ---------- hero ---------- */
.hero { position: relative; padding: 40px; overflow: hidden; }
.hero h1 { font-size: clamp(28px, 4.5vw, 44px); }
.hero h1 b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lede { font-size: 17px; color: var(--muted); max-width: 64ch; }
.tagchips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.stat-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; min-width: 120px;
}
.stat-chip .v { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.stat-chip .v.ok { color: var(--ok); } .stat-chip .v.accent { color: var(--accent); }
.stat-chip .k { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- defense pipeline ---------- */
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.line-card {
  position: relative; border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  background: var(--surface-2); transition: .25s;
}
.line-card .badge { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 13px; }
.line-card h4 { margin: 6px 0 4px; font-size: 15px; }
.line-card.hit { border-color: var(--block); background: var(--block-soft); box-shadow: 0 0 0 3px var(--block-soft); }
.line-card.pass { border-color: var(--ok); background: var(--ok-soft); }
.line-card .tag { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700; }
.line-card.hit .tag { color: var(--block); } .line-card.pass .tag { color: var(--ok); }

/* ---------- forms ---------- */
label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
textarea, input[type=text] {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 13px;
  font: inherit; font-size: 14px; background: var(--surface-2); color: var(--ink); resize: vertical;
  transition: .15s;
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 84px; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: .15s; color: #fff; background: var(--grad); box-shadow: var(--shadow-sm);
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.ghost { background: var(--surface); color: var(--accent); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

.examples { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); transition: .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.atk { border-color: #f1c3c4; color: var(--block); background: var(--block-soft); }
.chip.ben { border-color: #c2e6cf; color: var(--ok); background: var(--ok-soft); }

/* ---------- verdict ---------- */
.verdict { border-radius: 12px; padding: 16px; border: 1px solid var(--border); margin-top: 14px; display: none; }
.verdict.show { display: block; animation: fade .3s; }
.verdict.allow { background: var(--ok-soft); border-color: #bce6cd; }
.verdict.block { background: var(--block-soft); border-color: #f2c4c5; }
.verdict .head { display: flex; align-items: center; gap: 12px; }
.verdict .tag { font-weight: 800; font-size: 15px; letter-spacing: .02em; padding: 4px 12px; border-radius: 8px; color: #fff; }
.verdict.allow .tag { background: var(--ok); } .verdict.block .tag { background: var(--block); }
.reasons { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.reason { font-family: var(--mono); font-size: 12px; background: rgba(255,255,255,.7); border: 1px solid var(--border); padding: 3px 9px; border-radius: 7px; }
.kv { font-size: 13px; color: var(--muted); margin-top: 8px; }
.kv b { color: var(--ink); font-family: var(--mono); }

.canary-box { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 12px; margin-top: 10px; word-break: break-all; }
.hardened { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; background: #0d1b2a; color: #cfe0ff; border-radius: 10px; padding: 14px; margin-top: 10px; max-height: 220px; overflow: auto; }

/* risk gauge */
.gauge { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.gauge .track { width: 120px; height: 8px; border-radius: 999px; background: #e3e9f3; overflow: hidden; }
.gauge .fill { height: 100%; border-radius: 999px; background: var(--grad); transition: width .5s; }
.gauge .num { font-family: var(--mono); font-weight: 700; font-size: 14px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
td.mono, th.mono { font-family: var(--mono); }
.pill { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.pill.allow { color: var(--ok); background: var(--ok-soft); }
.pill.block { color: var(--block); background: var(--block-soft); }

/* ---------- metric cards ---------- */
.metric { text-align: center; padding: 18px; }
.metric .v { font-size: 30px; font-weight: 800; font-family: var(--mono); }
.metric .v.ok { color: var(--ok); } .metric .v.block { color: var(--block); } .metric .v.accent { color: var(--accent); }
.metric .k { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* confusion matrix */
.cmatrix { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; font-size: 13px; max-width: 380px; }
.cmatrix .cell { padding: 14px; border-radius: 10px; text-align: center; }
.cmatrix .lbl { color: var(--faint); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.cmatrix .tp, .cmatrix .tn { background: var(--ok-soft); color: var(--ok); }
.cmatrix .fp, .cmatrix .fn { background: var(--block-soft); color: var(--block); }
.cmatrix .cell b { font-family: var(--mono); font-size: 22px; display: block; }
.cmatrix .cell.zero { background: var(--surface-2); color: var(--faint); }

/* code tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 0; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
pre.code { margin: 0; background: #0d1b2a; color: #cfe0ff; border-radius: 0 0 12px 12px; padding: 16px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
pre.code .cm { color: #6b87b3; } pre.code .kw { color: #ff9ecb; } pre.code .st { color: #a6e3a1; }

/* steps */
.steps { counter-reset: s; display: grid; gap: 12px; }
.step { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.step .n { counter-increment: s; flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; }
.step .n::before { content: counter(s); }
.flow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; margin: 8px 0; }
.flow .node { flex: 1 1 150px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px; text-align: center; background: var(--surface-2); font-size: 13px; }
.flow .arr { display: grid; place-items: center; color: var(--accent); font-weight: 700; padding: 0 6px; }

/* callouts */
.callout { border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; padding: 12px 16px; font-size: 13.5px; color: #6b4d1f; }
.callout.info { border-color: var(--accent); background: var(--accent-soft); color: #2b3c6b; }
.callout b { color: inherit; }

/* misc */
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
.btn.ghost .spinner { border-color: var(--accent-soft); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.footer { max-width: 1120px; margin: 10px auto 40px; padding: 0 clamp(16px,4vw,40px); color: var(--faint); font-size: 12.5px; }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-row .lab { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.bar-row .fill { height: 100%; background: var(--grad); border-radius: 7px; transition: width .6s; }
.bar-row .val { font-family: var(--mono); text-align: right; color: var(--ink); }
.owasp td:first-child { font-family: var(--mono); color: var(--accent); white-space: nowrap; }
.ds td:nth-child(2) { font-family: var(--mono); color: var(--accent); white-space: nowrap; font-size: 12px; }
.ds td:nth-child(3) { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.ds a { word-break: break-word; }

/* ---------- full-link trace overlay ---------- */
.trace-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(18, 33, 64, .28); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.trace-overlay.open { opacity: 1; pointer-events: auto; }
.trace-card {
  position: relative; width: min(900px, 96vw); max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(20, 40, 90, .45); padding: 22px;
  transform: translateY(14px) scale(.985); transition: transform .3s;
}
.trace-overlay.open .trace-card { transform: none; }
.trace-close { position: absolute; top: 14px; right: 14px; border: 0; background: var(--surface-2); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 15px; }
.trace-close:hover { background: var(--block-soft); color: var(--block); }
.trace-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-right: 34px; }
.trace-title { font-weight: 700; font-size: 16px; }
.trace-id { margin-left: 8px; font-size: 12px; color: var(--faint); }
.trace-meta { display: flex; align-items: center; gap: 10px; }
.trace-meta .tag { padding: 3px 10px; border-radius: 7px; color: #fff; font-weight: 700; font-size: 12.5px; }
.trace-meta .tag.allow { background: var(--ok); } .trace-meta .tag.block { background: var(--block); }
.trace-meta .mono { font-size: 12px; color: var(--muted); }

.trace-topo { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 16px 0; padding: 18px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tr-node { flex: 0 0 auto; min-width: 104px; text-align: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); opacity: .38; transform: translateY(5px); transition: .35s; align-self: center; }
.tr-node.on { opacity: 1; transform: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tr-node.tr-verdict.on.allow { border-color: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.tr-node.tr-verdict.on.block { border-color: var(--block); box-shadow: 0 0 0 4px var(--block-soft); }
.tr-ico { width: 32px; height: 32px; margin: 0 auto 6px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; }
.tr-verdict.allow .tr-ico { background: var(--ok); } .tr-verdict.block .tr-ico { background: var(--block); }
.tr-name { font-weight: 600; font-size: 13px; } .tr-svc { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.tr-edge { flex: 0 0 30px; height: 3px; align-self: center; background: var(--border-strong); border-radius: 3px; position: relative; }
.tr-edge.done { background: var(--grad); }
.tr-edge::after { content: ""; position: absolute; top: 50%; left: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transform: translate(-4px, -50%) scale(0); }
.tr-edge.fire::after { animation: travel .42s ease forwards; }
@keyframes travel { 0% { left: 0; transform: translate(-4px, -50%) scale(1); } 100% { left: 100%; transform: translate(-4px, -50%) scale(1); } }
.tr-checks { flex: 1 1 230px; min-width: 210px; display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.tr-check { display: flex; gap: 9px; align-items: center; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); opacity: 0; transform: translateX(-7px); transition: .3s; }
.tr-check.reveal { opacity: 1; transform: none; }
.tr-cdot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; transition: .3s; }
.tr-check.triggered { border-color: #f1c3c4; background: var(--block-soft); }
.tr-check.triggered .tr-cdot { background: var(--block); box-shadow: 0 0 0 3px var(--block-soft); }
.tr-check.clear { border-color: #c2e6cf; }
.tr-check.clear .tr-cdot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.tr-check.skipped { opacity: .5 !important; }
.tr-check.skipped .tr-cdot { background: var(--border-strong); }
.tr-cl { font-size: 12.5px; font-weight: 600; } .tr-cs { font-size: 10px; color: var(--faint); font-family: var(--mono); }

.trace-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 14px 0 8px; font-weight: 700; }
.trace-wf { display: grid; gap: 8px; }
.wf-row { display: grid; grid-template-columns: 190px 1fr 70px; align-items: center; gap: 10px; font-size: 12px; }
.wf-row .wl { color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-track { height: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; position: relative; overflow: hidden; }
.wf-bar { position: absolute; top: 0; left: 0; height: 100%; width: 0; border-radius: 6px; background: var(--grad); transition: width .6s ease; }
.wf-bar.client { background: linear-gradient(90deg, #9db4f6, #7fd6e0); }
.wf-row .wv { font-family: var(--mono); text-align: right; color: var(--ink); }
.trace-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* clickable spans/checks + detail panel */
.tr-check { cursor: pointer; }
.tr-check.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.wf-row { cursor: pointer; border-radius: 8px; padding: 2px 4px; transition: background .15s; }
.wf-row:hover { background: var(--surface-2); }
.wf-row.sel { background: var(--accent-soft); }
.tr-detail { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); font-size: 13px; min-height: 44px; }
.tr-detail .dt-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tr-detail .dt-h .tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tr-detail .tag.triggered { color: var(--block); background: var(--block-soft); }
.tr-detail .tag.clear { color: var(--ok); background: var(--ok-soft); }
.tr-detail .tag.skipped { color: var(--faint); background: var(--surface); border: 1px solid var(--border); }
.tr-detail .dt-row { color: var(--muted); margin-top: 3px; }
.tr-detail .dt-row b { color: var(--ink); }
.tr-detail .mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* recent traces list (telemetry) */
.trace-list { display: grid; gap: 7px; }
.tr-item { display: grid; grid-template-columns: 64px 56px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); cursor: pointer; font-size: 12.5px; transition: .15s; }
.tr-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.tr-item .tid { font-family: var(--mono); color: var(--accent); }
.tr-item .tstage { color: var(--muted); }
.tr-item .tmeta { color: var(--faint); font-family: var(--mono); }
