:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1c1e2b;
  --muted: #6b7085;
  --border: #e4e6ef;
  --accent: #5b5bf0;
  --accent-hover: #4646d6;
  --error-bg: #fdecec;
  --error-text: #a12626;
  --success-bg: #e9f8ef;
  --success-border: #34a853;
  --success-text: #1d7a3e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131a;
    --card: #1b1d28;
    --text: #eceefa;
    --muted: #9a9fb8;
    --border: #2a2d3d;
    --accent: #7c7cff;
    --accent-hover: #9696ff;
    --error-bg: #3a1c1f;
    --error-text: #ff9b9b;
    --success-bg: #15281d;
    --success-border: #3ccf73;
    --success-text: #7ee2a2;
  }
}

* { box-sizing: border-box; }

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

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}
.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}
.logo span { color: var(--accent); }
nav a {
  margin-left: 0.5rem;
  padding: 0.4rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); background: var(--card); border: 1px solid var(--border); }

/* Layout */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}
.hero { text-align: center; padding: 2rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); line-height: 1.15; margin: 0 0 0.75rem; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.card h2 { margin-top: 0; }

/* Form */
label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
textarea {
  width: 100%;
  padding: 0.9rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Button centered in the middle column; the spinner sits in the right one, so the button never shifts */
.actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.75rem; margin-top: 1rem; }
.actions button { grid-column: 2; }
button {
  padding: 0.75rem 1.6rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.7; cursor: wait; }

/* Spinner next to the button, shown while the summary is being written */
.spinner {
  display: none;
  width: 1.4rem;
  height: 1.4rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* Result and error */
/* The summary is green and fades in, so it stands out from the other cards */
.result {
  background: var(--success-bg);
  border: 2px solid var(--success-border);
  animation: result-in 0.4s ease-out;
}
.result h2 { color: var(--success-text); }
.result h2::before { content: "✓ "; }
.result p { margin-bottom: 0; }
@keyframes result-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .result { animation: none; } }
.error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }

/* Homepage info and FAQ */
.info ol { padding-left: 1.25rem; }
.info p:last-child { margin-bottom: 0; }
.free h2 span { color: var(--accent); font-weight: 800; } /* "100%" in the accent color */
.faq h3 { font-size: 1.05rem; margin: 1.25rem 0 0.25rem; }
.faq p { margin: 0; }

/* Articles */
.toc h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.toc ol { margin: 0; padding-left: 1.25rem; }
.toc a, .article a { color: var(--text); text-decoration: underline; }
.article time { color: var(--muted); font-size: 0.9rem; }
.article h2 { margin: 0.25rem 0 0.75rem; }
.article h3 { font-size: 1.15rem; margin: 1.75rem 0 0.5rem; }
.article ul, .article ol { padding-left: 1.25rem; }
.article li { margin-bottom: 0.4rem; }
.article code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.article pre {
  overflow-x: auto;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.article p:last-child { margin-bottom: 0; }

/* Footer */
.site-footer {
  max-width: 760px; /* same width as main */
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}
.site-footer p { margin: 0 0 0.4rem; }
