:root {
  --color-primary: #1c2a59;
  --color-primary-hover: #142043;
  --color-secondary: #0c67df;
  --color-secondary-hover: #0a52b2;

  /* Page-level x-axis alignment unit — nav padding and main content padding both use
     this so their left/right edges stay in sync. Change here, everything realigns. */
  --spacing-page-x: 1.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 2rem auto;
  max-width: 1300px;
  padding: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, Roboto, sans-serif;
  color: #1a1a1a;
  background: #fff;
}

header {
  /* Cancels body's top margin so the nav sits flush at the very top of the viewport,
     then re-adds its own gap below before main content starts. */
  margin: -2rem 0 1.5rem;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--spacing-page-x);
  border-bottom: 1px solid #e5e5e5;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.nav__logo {
  height: 2rem;
  width: auto;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.nav__auth {
  color: var(--color-primary);
  text-decoration: none;
}

.nav__auth:hover {
  text-decoration: underline;
}

.nav__cta {
  padding: 0.40rem;
  border-radius: 2px;
  background: var(--color-secondary);
  color: #fff;
  text-decoration: none;
}

.nav__cta:hover {
  background: var(--color-secondary-hover);
}

main {
  padding: 0 var(--spacing-page-x) 3rem;
}

/* Responsive text utilities: show abbreviated content on small screens, full content on
   large. Usage: <span class="sm-only">Quad. Eq.</span><span class="lg-only">Quadratic
   Equations</span>. Default breakpoint is 600px — pick whichever 200px step (600, 800,
   1000, ...) fits the content, there's no single fixed project-wide breakpoint. */
.sm-only { display: inline; }
.lg-only { display: none; }

@media (min-width: 600px) {
  .sm-only { display: none; }
  .lg-only { display: inline; }
}

.auth-page {
  max-width: 20rem;
  margin: 3rem auto 0;
  font-size: 0.9rem;
}

.auth-page h1 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
  text-align: center;
}

.form {
  display: flex;
  flex-direction: column;
  max-width: 20rem;
}

.form label {
  font-size: 0.85em;
  margin-bottom: 0.15rem;
}

.form input {
  margin-bottom: 0.75rem;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 1px;
  font: inherit;
}

.form input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form button {
  margin-top: 0.3rem;
  padding: 0.4rem;
  border: 1px solid transparent; /* matches .form input's 1px border so heights line up exactly */
  border-radius: 2px;
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.form button:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.form button.btn-secondary {
  background: var(--color-secondary);
}

.form button.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-hover);
}

.form-error {
  color: #c0392b;
}

.form-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-sizing: border-box;
  max-width: 20rem;
  padding: 0.4rem;
  border: 1px solid #dadce0;
  border-radius: 2px;
  background: #fff;
  color: #3c4043;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
}

.form-google-btn:hover {
  border-color: #999;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
}

.form-google-btn svg {
  flex: none;
}

.dev-note {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #888;
}

.dev-note a {
  color: inherit;
}

.form-divider {
  max-width: 20rem;
  margin: 0.5rem 0;
  color: #888;
  text-align: center;
}

.form-link {
  max-width: 20rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.form-link a {
  color: var(--color-primary);
}

.flash-messages {
  max-width: 32rem;
  margin: 0 auto;
}

.flash {
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  border-radius: 2px;
  background: #eef4ff;
  border: 1px solid #cdddfa;
  color: #1a1a1a;
  font-size: 0.9rem;
}

.account-info {
  margin: 1.5rem 0;
}

.account-info dt {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #888;
}

.account-info dd {
  margin: 0;
  font-size: 0.9rem;
}

.account-section-title {
  margin-top: 2rem;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
  color: var(--color-primary);
}

.page-note {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: #888;
}

.btn-danger {
  padding: 0.4rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 2px;
  background: #c0392b;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.btn-danger:hover {
  background: #a5301f;
}

.card {
  border: 1px solid #e5e5e5;
  border-radius: 2px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  max-width: 32rem;
  font-size: 0.9rem;
}

.card label {
  display: block;
  margin-bottom: 0.5rem;
}

.card input[type="text"],
.card input[type="file"] {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 2px;
  font: inherit;
  width: 100%;
  margin-bottom: 0.75rem;
}

.card button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 2px;
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.card button:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.card button:disabled {
  opacity: 0.6;
  cursor: default;
}

.spinner {
  width: 1em;
  height: 1em;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.7;
  animation: spin 0.6s linear infinite;
}

.spinner[hidden] {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.math-container {
  min-height: 3rem;
  transition: opacity 0.15s ease-in-out;
}

.katex-line {
  margin-bottom: 0.4rem;
}

.score {
  font-size: 1.25rem;
  font-weight: bold;
}

@media (prefers-color-scheme: dark) {
  body {
    color: #eaeaea;
    background: #121212;
  }

  .nav {
    border-bottom-color: #2a2a2a;
  }

  .auth-page h1 {
    /* --color-primary is too dark to read against a dark background — lighten it. */
    color: #6d84cf;
  }

  .account-section-title {
    color: #6d84cf;
  }

  .nav__auth {
    /* --color-primary is too dark to read against a dark background — lighten it. */
    color: #6d84cf;
  }

  .form-link a {
    color: #6d84cf;
  }

  .flash {
    background: #17233f;
    border-color: #2a3a5c;
    color: #eaeaea;
  }

  .account-info dt {
    color: #999;
  }

  .form input {
    border-color: #3a3a3a;
    background: #1c1c1c;
    color: inherit;
  }

  .form-error {
    color: #ff6b5e;
  }

  .form-google-btn {
    border-color: #3a3a3a;
    background: #1c1c1c;
    color: inherit;
  }

  .form-google-btn:hover {
    border-color: #555;
  }

  .card {
    border-color: #2a2a2a;
  }

  .card input[type="text"],
  .card input[type="file"] {
    border-color: #3a3a3a;
    background: #1c1c1c;
    color: inherit;
  }

}
