/* Qrypt MCP Transaction Monitor — wireframe-first stylesheet.
   Two-column grid, dark theme, no decorative effects.
   The MCP transaction (right column) is the hero. */

:root {
  --bg: #0b0d12;
  --bg-elev-1: #131722;
  --bg-elev-2: #1a1f2d;
  --bg-elev-3: #232a3b;
  --border: #2a3142;
  --border-strong: #3b4459;
  --text: #e6e8ee;
  --text-muted: #98a0b3;
  --text-dim: #6b7388;
  --accent: #6a78ff;
  --accent-soft: rgba(106, 120, 255, 0.18);
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------- Header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  height: 28px;
  width: auto;
  display: block;
}

.brand-label h1 {
  font-size: 18px;
  line-height: 1.2;
}

.status {
  text-align: right;
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.status.is-ok .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

.status.is-error .status-dot {
  background: var(--err);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.status [data-mode-secondary] {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ---------- Layout ---------- */

.app-main {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.2fr);
  gap: 20px;
  padding: 20px 28px;
  align-items: start;
}

@media (max-width: 960px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 18px;
  margin-top: 4px;
}

.panel-header .lede {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 56ch;
}

.panel-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.panel-section:first-of-type {
  border-top: none;
}

.panel-subheader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.demo-tag {
  color: var(--warn);
  font-size: 11px;
  letter-spacing: 0.03em;
}

/* ---------- Tool picker ---------- */

.tool-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.tool-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    background 0.12s ease;
}

.tool-pill:hover {
  border-color: var(--border-strong);
}

.tool-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tool-pill-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.tool-pill-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Tool card (per-tool arguments + result) ---------- */

.tool-card {
  display: none;
  flex-direction: column;
}

.tool-card.is-active {
  display: flex;
}

.card-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.card-section:first-child {
  border-top: none;
}

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inputs input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-transform: none;
  letter-spacing: normal;
}

.inputs input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.inputs label.readonly input {
  color: var(--text-muted);
}

.run-button {
  width: 100%;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.run-button:hover:not(:disabled) {
  background: #7a87ff;
}

.run-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Result view ---------- */

.result-headline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.result-headline strong {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
}

.result-headline .d12-face {
  font-size: 36px;
}

.result-headline .uuid-face {
  font-size: 14px;
  word-break: break-all;
}

.result-headline small {
  color: var(--text-muted);
  font-size: 12px;
}

.result-json {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  max-height: 240px;
}

/* ---------- Observatory ---------- */

.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
  padding: 16px 20px;
  list-style: none;
  border-bottom: 1px solid var(--border);
}

.flow li {
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}

.flow li.is-running {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.flow li.is-complete {
  border-color: var(--ok);
}

.flow li.is-error {
  border-color: var(--err);
}

.flow-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.flow-detail {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Trace list ---------- */

.trace-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trace-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-strong);
}

.trace-list li.is-ok {
  border-left-color: var(--ok);
}

.trace-list li.is-error {
  border-left-color: var(--err);
}

.trace-list li.is-running {
  border-left-color: var(--accent);
}

.trace-list strong {
  font-size: 13px;
  font-weight: 600;
}

.trace-list small {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Protocol inspector ---------- */

.protocol {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  max-height: 320px;
}

/* ---------- Tool tags ---------- */

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-tags span {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

.tool-tag.muted {
  color: var(--text-muted);
}

/* ---------- Footer ---------- */

.app-footer {
  padding: 14px 28px 24px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

/* ---------- Design improvements ---------- */

/* 1. Flow node: arrow connectors between steps */
.flow {
  position: relative;
}
.flow li {
  position: relative;
}
.flow li::after {
  content: "→";
  position: absolute;
  right: -13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--border-strong);
  font-size: 11px;
  pointer-events: none;
  z-index: 1;
}
.flow li:last-child::after {
  display: none;
}

/* 1. Flow node: pulse glow while running */
@keyframes flow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(106, 120, 255, 0.45); }
  50%       { box-shadow: 0 0 0 6px rgba(106, 120, 255, 0); }
}
.flow li.is-running {
  animation: flow-pulse 1s ease-in-out infinite;
}

/* 2. Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.copy-btn.is-copied {
  color: var(--ok);
  border-color: var(--ok);
}
.copy-btn.is-failed {
  color: var(--err);
  border-color: var(--err);
}

/* Visible focus rings for keyboard navigation */
.tool-pill:focus-visible,
.run-button:focus-visible,
.copy-btn:focus-visible,
.history-list li.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 3. Result flash on new value */
@keyframes result-flash {
  0%   { background: rgba(106, 120, 255, 0.22); }
  100% { background: transparent; }
}
.result-flash {
  animation: result-flash 0.55s ease-out;
  border-radius: 4px;
}

/* 4. Pulsing status dot when connected */
@keyframes status-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(74, 222, 128, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0   rgba(74, 222, 128, 0); }
}
.status.is-ok .status-dot {
  animation: status-pulse 2.2s ease-out infinite;
}

/* 5. Call history */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.history-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.history-list li.is-ok   { border-left-color: var(--ok); }
.history-list li.is-error { border-left-color: var(--err); }
.history-list li.is-clickable {
  cursor: pointer;
}
.history-list li.is-clickable:hover {
  background: var(--bg-elev-3);
  border-color: var(--border-strong);
}
.history-tool {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}
.history-value {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-ms {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

/* 6. Entropy byte visualization */
.entropy-viz {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  padding: 4px 0 2px;
  overflow: hidden;
}
.entropy-bar {
  flex: 1;
  min-width: 3px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.75;
  transition: height 0.35s ease;
}

/* Hex preview of the first entropy bytes */
.entropy-hex {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  overflow-x: auto;
  white-space: pre;
}

/* 8. Responsive polish below 600px */
@media (max-width: 600px) {
  .tool-picker {
    grid-template-columns: 1fr;
  }
  .flow {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .flow li::after {
    display: none;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .status {
    text-align: left;
  }
}
