:root {
  --graphite: #1d2128;
  --chalk: #f5f2ea;
  --basalt: #313843;
  --verdict: #295f4e;
  --refusal: #8c3a32;
  --bronze: #8a6742;
  --coal: #101317;
  --stone: #bfc5cd;
  --deep-verdict: #4e8b76;
  --bg: var(--chalk);
  --fg: var(--graphite);
  --muted: #4c5868;
  --line: #cfc7b8;
  --chip: #ebe4d6;
  --card: #f0ece2;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --sans: "DM Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
  position: relative;
}

a {
  color: var(--verdict);
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.banner {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.banner.warn {
  border-color: #c9a227;
  background: #f7f0dc;
}

.banner.ok {
  border-color: var(--deep-verdict);
  background: #e8f2ed;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.page-header .lead {
  margin: 0;
  color: var(--muted);
  max-width: 52rem;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin: 1rem 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 0.78rem;
}

.status-bar .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--chip);
  font-family: var(--mono);
}

.status-bar .pill.live {
  background: #dceee4;
  color: var(--verdict);
}

.status-bar .pill.latency {
  background: #e8edf5;
  color: #2a4a6b;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}

.nav-tabs button {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.nav-tabs button[aria-selected="true"] {
  background: var(--verdict);
  border-color: var(--verdict);
  color: #fff;
}

.panel-section {
  display: none;
}

.panel-section.active {
  display: block;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

.panel .hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--chalk);
}

textarea {
  min-height: 5rem;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--fg);
  cursor: pointer;
}

.btn.primary {
  background: var(--verdict);
  border-color: var(--verdict);
  color: #fff;
}

.btn.secondary {
  background: transparent;
}

.btn.danger {
  background: #f5e8e8;
  border-color: #d4a0a0;
  color: var(--refusal);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.result-box {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--chalk);
}

.result-box.ok {
  border-color: var(--deep-verdict);
  background: #e8f2ed;
}

.result-box.fail {
  border-color: #c49090;
  background: #f5e8e8;
}

.result-box pre {
  margin: 0.5rem 0 0;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: auto;
  max-height: 280px;
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.latency-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #e8edf5;
  color: #2a4a6b;
  margin-left: 0.35rem;
}

.qr-preview {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  text-align: center;
  background: #fff;
}

.qr-preview img,
.qr-preview svg {
  max-width: 220px;
  height: auto;
}

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.session-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}

.session-list li:last-child {
  border-bottom: none;
}

.merkle-root {
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
  padding: 0.65rem;
  background: var(--chalk);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.hidden {
  display: none !important;
}

.panel pre,
.panel pre.mono {
  margin: 0;
  padding: 0.65rem;
  background: var(--chalk);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.45;
}

.page-header .lead,
.banner,
.panel .hint {
  overflow-wrap: anywhere;
}

.status-bar .pill {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.session-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 640px) {
  .page,
  .site-chrome.page {
    padding: 1rem 0.85rem 3rem;
    overflow-x: clip;
  }

  .site-chrome .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .site-chrome-actions {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.45rem;
  }

  .site-chrome .btn {
    flex: 1 1 calc(50% - 0.25rem);
    text-align: center;
    min-width: 0;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

  .status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .status-bar .pill {
    width: fit-content;
    max-width: 100%;
  }

  .status-bar .btn {
    width: 100%;
  }

  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 0.3rem;
    padding-bottom: 0.5rem;
    margin-left: -0.15rem;
    margin-right: -0.15rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
  }

  .nav-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 0.85rem 0.9rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    text-align: center;
  }

  .result-box strong {
    display: block;
    margin-bottom: 0.35rem;
  }

  .result-box .latency-tag {
    margin-left: 0;
  }

  .footer,
  .site-chrome .footer {
    flex-direction: column;
    align-items: stretch;
  }

  .footer .mono,
  .site-chrome .footer .mono {
    width: 100%;
    overflow-wrap: anywhere;
  }
}
