/* ── Custom properties ───────────────────────────────────────────────────── */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --header-bg: #0f172a;
  --header-text: #f8fafc;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Site header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--header-bg);
  padding: 0 2rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.site-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--header-text);
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* ── Site wrapper (sidebar + content) ────────────────────────────────────── */
.site-wrapper {
  display: flex;
  flex-direction: row;
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  align-items: start;
}

/* ── Sidebar navigation ──────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  width: 11rem;
  flex-shrink: 0;
  padding: 2rem 1rem;
  position: sticky;
  top: 0;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.site-nav a:hover {
  background: var(--border);
  color: var(--primary);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.site-main {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 1.5rem;
}

/* ── Narrow-screen: collapse sidebar to horizontal bar ───────────────────── */
@media (max-width: 640px) {
  .site-wrapper {
    flex-direction: column;
  }

  .site-nav {
    flex-direction: row;
    width: 100%;
    padding: 0.5rem 1rem;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    position: static;
    overflow-x: auto;
  }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--header-bg);
  color: var(--header-text);
  text-align: center;
  padding: 1.25rem 2rem;
  font-size: 0.8125rem;
  opacity: 0.7;
  margin-top: auto;

  & p {
    margin: 0;
  }
}

/* ── Error container ─────────────────────────────────────────────────────── */
#errors:not(:empty) {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

/* ── Page typography ─────────────────────────────────────────────────────── */
.page-title {
  margin: 0 0 0.375rem;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-subtitle {
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.site-form {
  display: flex;
  flex-direction: column;

  fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);

    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  legend {
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0 0.5rem;
    color: var(--text);
  }

  p {
    margin: 0;
    display: flex;
    flex-direction: column;

    &.short {
      flex-direction: row;
    }
  }

  label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
  }

  input[type="text"],
  input[type="url"],
  input[type="password"],
  textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) / 2);
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg);
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;

    &:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    }
  }

  textarea {
    resize: vertical;
    min-height: 5rem;

    &.json-input {
      min-height: 20rem;
    }
  }

  button[type="submit"] {
    margin-top: 1.25rem;
    padding: 0.5rem 1.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: calc(var(--radius) / 2);
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;

    &:hover {
      background: var(--primary-hover);
    }
  }
}

/* Adds a top border separator — for forms appended below page content */
.form-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
