:root {
  --bg: #0c0e12;
  --bg-elevated: #151820;
  --bg-card: #1a1f28;
  --border: #2a3142;
  --text: #e8eaed;
  --text-muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-hover: #6ba1ff;
  --accent-muted: rgba(79, 140, 255, 0.12);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --max-width: 640px;
  --max-width-wide: 720px;
}

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

body {
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 140, 255, 0.15), transparent);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  margin: 0 auto;
  max-width: var(--max-width-wide);
  padding: 1.25rem 1.5rem;
}

.site-header img {
  border-radius: 8px;
  height: 36px;
  width: 36px;
}

.site-header .brand {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-header .brand span {
  color: var(--text-muted);
  font-weight: 400;
}

.page {
  margin: 0 auto;
  max-width: var(--max-width-wide);
  padding: 0 1.5rem 3rem;
}

.page-narrow {
  max-width: var(--max-width);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.card-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.card-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}

.card-header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

p,
li,
label,
footer,
section {
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

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

.muted,
.info-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.main {
  color: var(--text);
  text-align: center;
}

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

.nav-item {
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.nav-item:hover {
  background: var(--accent-muted);
  border-color: rgba(79, 140, 255, 0.35);
}

.nav-item i {
  color: var(--accent);
  font-size: 1.1rem;
  text-align: center;
  width: 1.25rem;
}

.nav-item a {
  color: var(--text);
  flex: 1;
  font-weight: 500;
}

.nav-item a:hover {
  color: var(--accent-hover);
}

.nav-item .badge {
  background: var(--accent-muted);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  text-transform: uppercase;
}

.alert {
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-top: 1.5rem;
  padding: 0.875rem 1rem;
}

.alert-info {
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.25);
  color: var(--text-muted);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: var(--warning);
}

.alert-danger {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.alert p {
  margin: 0.35rem 0;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.field label {
  color: var(--text-muted);
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input,
button,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.875rem;
  resize: vertical;
  width: 100%;
}

textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

input[type="email"],
input[type="password"],
input[type="text"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.65rem 0.875rem;
  width: 100%;
}

input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.65rem 1.25rem;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

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

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

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1.25rem 0;
}

.btn-group form {
  flex: 1;
  min-width: 10rem;
}

.btn-group .btn {
  width: 100%;
}

.key-block {
  margin-top: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.key-block:last-of-type {
  border-bottom: none;
}

.key-block-label {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.key-actions form {
  margin: 0;
}

.key-actions .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  width: auto;
}

.logout-form {
  margin-top: 1.25rem;
}

.account-status {
  margin-bottom: 1.25rem;
}

.account-status-label {
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.75rem 0 0;
}

.status-item dt {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  margin: 0 0 0.2rem;
}

.status-item dd {
  font-size: 0.9rem;
  margin: 0;
}

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

.tool-item {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  padding: 1rem;
}

.tool-item-body {
  flex: 1;
  min-width: 12rem;
}

.tool-item-body p {
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

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

.tool-item-stack {
  align-items: stretch;
  flex-direction: column;
}

.tool-form {
  margin-top: 0.5rem;
  width: 100%;
}

.tool-form select,
.tool-form input[type="text"],
.tool-form input[type="number"] {
  width: 100%;
}

.tool-form-inline {
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tool-form-inline input[type="number"] {
  max-width: 5rem;
  width: auto;
}

.tool-item-danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.06);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}

.field-row input {
  flex: 1;
  min-width: 12rem;
}

.field-row .btn {
  width: auto;
  white-space: nowrap;
  padding: 0.65rem 1rem;
}

.account-check-status {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.account-check-status--success {
  color: #4ade80;
}

.account-check-status--error {
  color: #f87171;
}

.account-check-status--info {
  color: var(--text-muted);
}

.captcha-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.captcha-fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

.captcha-legend {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0;
}

.captcha-question {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.captcha-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.captcha-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.captcha-option:hover {
  border-color: var(--accent);
}

.captcha-option input {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--success);
  display: block;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8125rem;
  margin: 0.75rem auto 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  word-break: break-all;
}

.key-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--success);
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  word-break: break-all;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }

.link-muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.link-muted:hover {
  color: var(--accent);
}

.container ul {
  list-style: none;
  padding: 0;
}

.container li {
  margin: 0.5rem 0;
}

.container li a {
  font-weight: 500;
}

/* Legacy API doc syntax colors */
.name { color: #67e8f9; }
.string { color: #fde047; }
.ostring { color: #86efac; }
.example { color: #bef264; }
.returns { color: #e7e5e4; }
.parm { color: #5eead4; }
.parms { background-color: var(--bg-elevated); }
.type { color: #fca5a5; }
.get { color: #67e8f9; }
.post { color: #86efac; }
.put { color: #fde047; }
.delete { color: #f87171; }

img {
  border-radius: var(--radius);
  max-width: 100%;
  height: auto;
}

.grid-container {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

@media (max-width: 480px) {
  .card {
    padding: 1.5rem;
  }

  .site-header {
    padding: 1rem;
  }
}
