:root {
  --bg: #0b1020;
  --surface: #141a30;
  --surface-2: #1b2340;
  --border: #2a3357;
  --text: #e8ecf8;
  --muted: #9aa5c4;
  --accent: #6ea8fe;
  --accent-strong: #4f8ff8;
  --success: #5fd39a;
  --danger: #ff8b8b;
  --warning: #e8b339;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fd;
    --surface: #ffffff;
    --surface-2: #eef2fb;
    --border: #d7deef;
    --text: #131a2c;
    --muted: #5a6684;
    --accent: #2f6fe0;
    --accent-strong: #1f5bc4;
    --success: #1a8a5a;
    --danger: #c23b3b;
    --warning: #a06a00;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) 1rem calc(2rem + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main,
.site-header,
footer {
  max-width: 46rem;
  margin-inline: auto;
}

.test-banner {
  max-width: 46rem;
  margin: 1rem auto 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--warning) 55%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--text);
  font-size: 0.85rem;
}

.test-banner a {
  color: var(--accent);
}

.site-header {
  padding: 2.5rem 0 1.5rem;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0.28rem color-mix(in srgb, var(--accent) 22%, transparent);
  flex: none;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card h3 {
  margin: 1.25rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gate {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(color-mix(in srgb, var(--accent) 8%, transparent), transparent), var(--surface);
}

.hint,
footer p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
}

footer {
  padding-top: 1rem;
}

.steps {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

.steps li {
  margin-bottom: 0.35rem;
}

/* --- form --- */

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

input[type='text'] {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 1rem; /* < 16px makes iOS Safari zoom on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

input[type='text']:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
}

button[type='submit'] {
  padding: 0.7rem 1.2rem;
  border: 0;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 600;
}

button[type='submit']:hover:not(:disabled) {
  background: var(--accent);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary {
  padding: 0.6rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.link-btn {
  margin-top: 0.6rem;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn.danger {
  color: var(--danger);
  margin-top: 0;
}

.status {
  margin: 0.8rem 0 0;
  font-size: 0.9rem;
  min-height: 1.4em;
  color: var(--muted);
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

.status.diag {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* --- topics --- */

.topics,
.messages {
  list-style: none;
  margin: 0;
  padding: 0;
}

.topics li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.topics li:last-child {
  border-bottom: 0;
}

.topic-name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.chip {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

/* --- messages --- */

.messages li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.messages li:last-child {
  border-bottom: 0;
}

.msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.msg-head time {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.messages p {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
}

.messages a {
  font-size: 0.85rem;
  color: var(--accent);
  overflow-wrap: anywhere;
}

/* --- code --- */

pre {
  margin: 0;
  padding: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

:not(pre) > code {
  padding: 0.1rem 0.35rem;
  background: var(--surface-2);
  border-radius: 5px;
}

details {
  margin-top: 1.25rem;
}

.card > details:only-child {
  margin-top: 0;
}

summary + .hint {
  margin-top: 0.75rem;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.fields {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.fields td {
  padding: 0.4rem 0.5rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.fields td:first-child {
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
