:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

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

.main {
  margin-top: 2rem;
}

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

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.form .field {
  margin-bottom: 1.25rem;
}

.form label,
.form legend {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

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

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25);
}

.checkbox-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checkbox {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  cursor: pointer;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.checkbox input {
  margin-top: 0.2rem;
}

.checkbox-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.checkbox-label small {
  color: var(--muted);
  font-size: 0.8rem;
}

.checkbox-label .caps {
  color: var(--warning);
}

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

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
  margin-top: 0.5rem;
}

.btn-secondary:hover {
  background: #3c444d;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 0;
  text-align: center;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--error);
  color: #ff7b72;
}

.alert-success {
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid var(--success);
  color: #56d364;
}

.alert-warning {
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid var(--warning);
  color: #e3b341;
}

.preview-box {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.preview-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.tool-list {
  margin: 0;
  padding-left: 1.25rem;
}

.tool-list.available li {
  color: var(--success);
}

.info-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.info-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.info-block h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.info-block dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.info-block dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.info-block dd {
  margin: 0;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.connection-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 3px;
  margin: 0.75rem 0 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.connection-toggle-btn {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.connection-toggle-btn:hover {
  color: var(--text);
}

.connection-toggle-btn.is-active {
  background: var(--border);
  color: var(--text);
}

.connection-panel {
  display: none;
}

.connection-panel.is-active {
  display: block;
}

#copy-connection-json {
  margin-top: 0.75rem;
}

.config-item.is-active {
  border-color: var(--accent);
}

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

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

.config-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.config-item-body .hint {
  margin: 0;
}

.config-activate-form {
  margin: 0;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.config-active-badge {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.landing-actions {
  margin-top: 1.5rem;
}

.setup-steps {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setup-steps li {
  padding-left: 0.25rem;
}

.landing-info {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.landing-info p {
  margin: 0 0 0.75rem;
}

.landing-info p:last-child {
  margin-bottom: 0;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.inline-link:hover {
  text-decoration: underline;
}

.academy-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.academy-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.academy-option.is-current {
  border-color: var(--accent);
}

.academy-option input {
  margin-top: 0.25rem;
}

.academy-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.academy-option-body small {
  color: var(--muted);
  font-size: 0.8rem;
}

.academy-chip.is-active {
  color: var(--accent);
  font-weight: 500;
}

.pairing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 0.75rem;
}

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

.pairing-cell {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.pairing-cell-full {
  grid-column: 1 / -1;
}

.pairing-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.pairing-label:not(:first-child) {
  margin-top: 1rem;
}

.pairing-value {
  margin: 0 0 0.25rem;
  line-height: 1.45;
}

.pairing-value .inline-link {
  margin-left: 0.35rem;
}

.config-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.config-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.config-option.is-current {
  border-color: var(--accent);
}

.config-option input {
  margin-top: 0.25rem;
}

.config-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.config-option-body small {
  color: var(--muted);
  font-size: 0.8rem;
}

.section-divider {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.form-inline .field {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

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

.footer a {
  color: var(--muted);
  font-size: 0.85rem;
}

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

.mode-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mode-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

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

.mode-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mode-option-body small {
  color: var(--muted);
}

.mode-switch-form {
  margin-top: 0.5rem;
}

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

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

/* OAuth consent page */
.oauth-card {
  max-width: 440px;
  margin: 0 auto;
}

.oauth-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.oauth-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.35);
  color: var(--accent);
}

.oauth-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.oauth-subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.oauth-detail {
  margin-bottom: 1rem;
}

.oauth-detail-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.oauth-resource {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  word-break: break-all;
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.scope-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.35);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.oauth-flow {
  margin-top: 1.5rem;
}

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

.oauth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.oauth-divider::before,
.oauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.oauth-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.oauth-form .btn-block {
  margin-top: 1rem;
}

.oauth-footnote {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.oauth-connect-banner h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.oauth-connect-banner .btn {
  margin-top: 0.75rem;
}

.oauth-connection-muted {
  opacity: 0.65;
}
