:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #4f5b6b;
  --border: #d8dde4;
  --accent: #1f5fbf;
  --accent-dark: #174a96;
  --accent-soft: #e8f0fc;
  --error-bg: #fdecec;
  --error-text: #8a1c1c;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

main.container { flex: 1; padding-bottom: 40px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--surface);
  color: var(--accent-dark);
  padding: 8px 12px;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { left: 8px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
  margin-bottom: 24px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
}

.subtitle { margin: 0; color: var(--muted); max-width: 60ch; }

.section-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.suggestions {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.suggestion {
  width: 100%;
  height: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
}
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); }

.ask-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  border: 1px solid #9aa5b4;
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 84px;
}
textarea:focus { border-color: var(--accent); }

.form-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
}

.help { margin: 0; font-size: 0.85rem; color: var(--muted); }
.count { white-space: nowrap; }

.primary {
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  cursor: pointer;
  min-height: 44px;
}
.primary:hover { background: var(--accent-dark); }
.primary:disabled { background: #7d93b5; cursor: progress; }

.result { margin-top: 24px; }
.result:focus { outline: none; }

.status {
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.status.error { background: var(--error-bg); color: var(--error-text); }
.status.loading::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 8px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .status.loading::before { animation: none; }
}

#answer-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.answer { margin-bottom: 20px; }
.answer p { margin: 0 0 10px; }
.answer ul { margin: 0 0 10px; padding-left: 22px; }
.answer li { margin-bottom: 4px; }
.answer code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  background: #eef1f5;
  border-radius: 4px;
  padding: 1px 5px;
}

.cite {
  font-size: 0.8em;
  vertical-align: super;
  line-height: 0;
  color: var(--accent-dark);
  text-decoration: none;
  padding: 0 1px;
}
.cite:hover, .cite:focus { text-decoration: underline; }

.sources { margin: 0 0 12px; padding-left: 24px; }
.sources li { margin-bottom: 8px; scroll-margin-top: 16px; }
.sources li:target { background: var(--accent-soft); border-radius: 6px; }
.sources a { color: var(--accent-dark); }
.source-type {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  margin-left: 6px;
  white-space: nowrap;
}
.source-section { display: block; font-size: 0.85rem; color: var(--muted); }

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 0.9rem;
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-links a { color: var(--accent-dark); }
.disclaimer { margin: 0; color: var(--muted); }

@media (max-width: 560px) {
  h1 { font-size: 1.55rem; }
  .suggestions { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 2px; }
  .primary { width: 100%; }
}
