:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1b1f27;
  --muted: #6b7280;
  --accent: #2f6feb;
  --accent-hover: #1f5fdb;
  --success: #1a7f37;
  --error: #cf222e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

/* Topbar / nav */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-decoration: none;
  color: inherit;
}

.brand:hover .brand-name {
  color: var(--accent);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.topnav a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 7px;
}

.topnav a:hover {
  color: var(--text);
  background: #eef1f5;
}

.topnav a.active {
  color: var(--accent);
  background: #eef4ff;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 0.75rem;
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--border);
  flex: none;
}

.status-dot.ok {
  background: var(--success);
}

.status-dot.bad {
  background: var(--error);
}

/* Inputs & buttons */
input,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-family: var(--mono);
}

.control-group input {
  width: 16rem;
  max-width: 40vw;
}

textarea {
  width: 100%;
  resize: vertical;
  font-size: 0.95rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, 0.15);
}

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

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

/* Main body */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}

.card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.field span {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

/* Result panes */
.result {
  margin: 0.75rem 0 0;
  padding: 0.85rem 1rem;
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.topbar .result {
  max-width: 980px;
  margin: 0 auto 0.75rem;
}

.result.success {
  border-color: var(--success);
  background: #eaf6ec;
}

.result.error {
  border-color: var(--error);
  background: #fdecee;
  color: #8a1a22;
}

/* Footer */
.page-footer {
  text-align: center;
  margin-top: 1.5rem;
}

.page-footer a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.page-footer a:hover {
  text-decoration: underline;
}

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

/* Status code reference page */
.code-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.code-item {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #fafbfc;
}

.code-item.ok {
  border-left-color: var(--success);
}

.code-item.bad {
  border-left-color: var(--error);
}

.code-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.code-num {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
}

.code-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.code-item p {
  margin: 0;
  font-size: 0.9rem;
}

.card h1 a {
  color: var(--accent);
}

/* Documentation page */
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.card + .card {
  margin-top: 1.25rem;
}

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

.toc a {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

.toc a:hover {
  border-color: var(--accent);
  background: #eef4ff;
}

.steps,
.bullets {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.steps li::marker {
  font-weight: 700;
  color: var(--accent);
}

.card p a,
.steps a,
.bullets a {
  color: var(--accent);
}

details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.6rem;
  background: #fafbfc;
}

details[open] {
  background: var(--surface);
}

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

details p {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--text);
}

/* 404 page */
.notfound {
  text-align: center;
}

.notfound-code {
  font-family: var(--mono);
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  line-height: 1;
}

.notfound h1 {
  margin: 0.5rem 0;
}

.notfound .actions {
  justify-content: center;
  margin-top: 1.25rem;
}

.notfound .actions .btn {
  text-decoration: none;
}

code {
  font-family: var(--mono);
  background: #f0f2f5;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

@media (max-width: 720px) {
  .topbar-inner {
    align-items: flex-start;
  }
  .control-group input {
    max-width: none;
    flex: 1;
  }
}
