:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2530;
  --border: #2a313c;
  --text: #e6edf3;
  --subtle: #8b949e;
  --accent: #58a6ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

h1, h2, h3 {
  margin: 0 0 0.5rem;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.05em; }
h3 { font-size: 0.95rem; }

.subtle { color: var(--subtle); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }

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

code {
  font-family: var(--mono);
  background: var(--panel-2);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

button:hover:not([disabled]) {
  border-color: var(--accent);
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: #0e1116;
  border-color: var(--accent);
  font-weight: 600;
}

button.ghost {
  background: transparent;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topbar-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.heartbeat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 0.8rem;
  color: var(--subtle);
}
.heartbeat-label {
  margin-right: 0.5rem;
}
.heartbeat-toggle button {
  background: var(--panel-2);
  color: var(--subtle);
  border: 1px solid var(--border);
  border-right-width: 0;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 80ms, color 80ms;
}
.heartbeat-toggle button:first-of-type { border-radius: 4px 0 0 4px; }
.heartbeat-toggle button:last-child   { border-radius: 0 4px 4px 0; border-right-width: 1px; }
.heartbeat-toggle button:hover { color: var(--text); }
.heartbeat-toggle button.active {
  background: var(--accent);
  color: #0e1116;
  border-color: var(--accent);
}

.heartbeat-countdown {
  font-variant-numeric: tabular-nums;
  margin-left: 0.25rem;
}

.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-good { background: rgba(63,185,80,0.15); color: var(--good); border: 1px solid rgba(63,185,80,0.4); }
.badge-warn { background: rgba(210,153,34,0.15); color: var(--warn); border: 1px solid rgba(210,153,34,0.4); }
.badge-bad  { background: rgba(248,81,73,0.15); color: var(--bad); border: 1px solid rgba(248,81,73,0.4); }

.checklist {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.checklist h2 { margin-bottom: 0.5rem; }

#integration-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.4rem 1rem;
}

#integration-checklist li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.9rem;
}

#integration-checklist li::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--subtle);
}

#integration-checklist li.done::before {
  content: "✓";
  color: var(--good);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem 1.5rem;
}

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

.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 400px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed rgba(139,148,158,0.15);
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--subtle); font-size: 0.85rem; }
.kv .v { font-weight: 600; text-align: right; word-break: break-all; }

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.big-cookie {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0.75rem;
  text-align: center;
  background: rgba(88,166,255,0.08);
  border-radius: 4px;
  transition: background 0.4s;
}

.big-cookie.flash {
  background: rgba(63,185,80,0.3);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.steps li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
}

.steps li.active { border-color: var(--accent); }
.steps li.done   { border-color: var(--good); }

.steps .step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.steps .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.steps li.done .step-num { background: var(--good); color: var(--bg); border-color: var(--good); }

.steps .step-explainer {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--subtle);
}

.steps .step-detail {
  display: none;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.steps li.done .step-detail,
.steps li.active .step-detail {
  display: block;
}

.events {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 70vh;
  overflow-y: auto;
}

.events li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--subtle);
  border-radius: 3px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.events li.kind-cookie-rotated      { border-left-color: var(--good); }
.events li.kind-registration-verified { border-left-color: var(--good); }
.events li.kind-refresh-verified    { border-left-color: var(--good); }
.events li.kind-registration-rejected,
.events li.kind-refresh-rejected,
.events li.kind-tamper-replay,
.events li.kind-tamper-cookie-stolen { border-left-color: var(--bad); }
.events li.kind-challenge-issued,
.events li.kind-refresh-no-challenge { border-left-color: var(--warn); }

.events .ev-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.events .ev-kind {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--subtle);
}

.events .ev-detail {
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--subtle);
  white-space: pre-wrap;
  word-break: break-all;
}

.break-it {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.break-it button {
  background: rgba(248,81,73,0.1);
  border-color: rgba(248,81,73,0.4);
  color: #ff8985;
  text-align: left;
}

footer {
  padding: 1rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
}
