/* postMessage XSS lab — shared styling
   Dark "security lab" theme: high contrast, monospace code, status colours. */

:root {
  --bg: #080b10;
  --bg-2: #0e131b;
  --panel: #111823;
  --panel-2: #161f2c;
  --line: #22303f;
  --line-soft: #1a2431;
  --fg: #e6edf5;
  --fg-dim: #9bb0c6;
  --fg-mute: #6d8299;
  --accent: #4cc2ff;
  --accent-dim: #1d3d52;
  --bad: #ff6b6b;
  --bad-dim: #46201f;
  --warn: #ffb454;
  --warn-dim: #443416;
  --good: #4ade80;
  --good-dim: #14361f;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(1100px 500px at 12% -8%, rgba(76, 194, 255, 0.07), transparent 60%),
    radial-gradient(900px 420px at 92% 0%, rgba(255, 107, 107, 0.05), transparent 60%);
  background-repeat: no-repeat;
  padding-bottom: 64px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd { font-family: var(--mono); }

/* ---------------------------------------------------------------- layout */

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 760px; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- top bar */

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 16, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.brand .dot { color: var(--accent); }
.brand small { color: var(--fg-mute); font-weight: 400; margin-left: 8px; font-size: 12px; }
.spacer { flex: 1; }

.origin-chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg-dim);
  white-space: nowrap;
}
.origin-chip b { color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------------- card */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 18px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

h1 { font-size: 24px; letter-spacing: -0.02em; margin: 10px 0 6px; }
h2 { font-size: 16px; letter-spacing: 0.01em; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--fg-dim); }
p { margin: 0 0 12px; }
.muted { color: var(--fg-mute); }
.dim { color: var(--fg-dim); }
.small { font-size: 13px; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-dim);
  background: var(--panel-2);
  vertical-align: middle;
}
.badge.bad { color: var(--bad); border-color: var(--bad-dim); background: rgba(255, 107, 107, 0.09); }
.badge.good { color: var(--good); border-color: var(--good-dim); background: rgba(74, 222, 128, 0.09); }
.badge.warn { color: var(--warn); border-color: var(--warn-dim); background: rgba(255, 180, 84, 0.09); }
.badge.info { color: var(--accent); border-color: var(--accent-dim); background: rgba(76, 194, 255, 0.09); }

/* --------------------------------------------------------------- button */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 550;
  color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; background: #1a2432; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06202e; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--bad-dim); color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: rgba(255, 107, 107, 0.08); }
.btn.sm { font-size: 12.5px; padding: 5px 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row + .row { margin-top: 10px; }

/* ----------------------------------------------------------------- code */

pre.code {
  background: #070a0f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.6;
  color: #cfe0ef;
  margin: 0 0 12px;
  position: relative;
}
pre.code[data-title]::before {
  content: attr(data-title);
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 10px;
}
pre.code .kw { color: #ff9ecb; }
pre.code .str { color: #9ee493; }
pre.code .com { color: #5d7086; font-style: italic; }
pre.code .fn { color: #82c9ff; }
pre.code .bad { color: var(--bad); }
pre.code .good { color: var(--good); }
pre.code .hl { background: rgba(255, 107, 107, 0.12); display: inline-block; width: 100%; }

code.inline {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
  color: #b9e6ff;
}

/* ---------------------------------------------------------------- table */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
/* the monitor has many long columns — give it fixed widths so it fits */
.table.fixed { table-layout: fixed; }
.table.fixed th:nth-child(1) { width: 84px; }
.table.fixed th:nth-child(2) { width: 72px; }
.table.fixed th:nth-child(3) { width: 78px; }
.table.fixed th:nth-child(4) { width: 130px; }
.table.fixed th:nth-child(6) { width: 200px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table.nowrap-first td:first-child { white-space: nowrap; }

/* ------------------------------------------------------------ callouts */

.note {
  border-left: 3px solid var(--accent);
  background: rgba(76, 194, 255, 0.05);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin: 0 0 14px;
  font-size: 14px;
}
.note.warn { border-color: var(--warn); background: rgba(255, 180, 84, 0.06); }
.note.bad { border-color: var(--bad); background: rgba(255, 107, 107, 0.06); }
.note.good { border-color: var(--good); background: rgba(74, 222, 128, 0.06); }
.note > :last-child { margin-bottom: 0; }
.note b { color: var(--fg); }

/* ---------------------------------------------------------------- flows */

.output {
  min-height: 90px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #070a0f;
  font-size: 14px;
}
.output:empty::after {
  content: "(waiting for a message …)";
  color: var(--fg-mute);
  font-style: italic;
}

.flow { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.flow-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-2);
}
.flow-item .arrow { grid-row: span 3; font-size: 16px; line-height: 1.2; }
.flow-item.in .arrow { color: var(--accent); }
.flow-item.out .arrow { color: var(--warn); }
.flow-origin { font-family: var(--mono); color: var(--fg-dim); word-break: break-all; }
.flow-decision { font-family: var(--mono); font-size: 11px; }
.flow-decision.accept { color: var(--good); }
.flow-decision.block { color: var(--bad); }
.flow-decision.note { color: var(--warn); }
/* inside a table the decision is just coloured text — the inline chip
   background steps badly when the text wraps */
.table .flow-decision { background: none; border: none; padding: 0; font-size: 12px; }
.flow-data {
  font-family: var(--mono);
  color: #9ee493;
  background: #060a0d;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 6px 8px;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 130px;
  overflow: auto;
}

/* --------------------------------------------------------------- widget */

.widget-frame {
  width: 100%;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  display: block;
}

/* -------------------------------------------------------------- payload */

.payload-list { display: grid; gap: 8px; margin: 0 0 12px; }
.payload {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}
.payload:hover { border-color: var(--line); background: #121a24; }
.payload.sel { border-color: var(--accent); background: rgba(76, 194, 255, 0.07); }
.payload .p-title { font-family: var(--mono); font-size: 12.5px; color: #9ee493; word-break: break-all; }
.payload .p-note { font-size: 12px; color: var(--fg-mute); margin-top: 3px; }

.switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.switch button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg-dim);
  cursor: pointer;
}
.switch button.on { border-color: var(--accent); color: var(--accent); background: rgba(76, 194, 255, 0.08); }
.switch button:hover { color: var(--fg); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--fg-mute); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }

.footer {
  max-width: 1180px;
  margin: 32px auto 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  color: var(--fg-mute);
  font-size: 12.5px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.status {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg-dim);
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.status.hit { border-color: var(--good-dim); color: var(--good); background: rgba(74, 222, 128, 0.07); }
