:root {
  color-scheme: light;
  --background: #f3f7f8;
  --surface: #ffffff;
  --text: #17343b;
  --muted: #647b81;
  --line: #dce7e9;
  --accent: #087f8c;
  --accent-dark: #066773;
  --answered: #26734d;
  --answered-bg: #e8f6ee;
  --clarification: #8a6500;
  --clarification-bg: #fff4cc;
  --review: #a14343;
  --review-bg: #fbeaea;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(8, 127, 140, 0.11), transparent 32rem),
    var(--background);
}

.page-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.page-header {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(23, 52, 59, 0.06);
}

.question-card,
.answer-card,
.sources-card,
.debug-card,
.status-card {
  padding: 24px;
}

label,
h2 {
  display: block;
  margin-bottom: 12px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h3 {
  margin: 22px 0 8px;
  font-size: 0.92rem;
}

textarea {
  display: block;
  width: 100%;
  min-height: 168px;
  resize: vertical;
  border: 1px solid #bfd0d4;
  border-radius: 12px;
  padding: 15px 16px;
  color: var(--text);
  background: #fbfdfd;
  font: inherit;
  line-height: 1.55;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(8, 127, 140, 0.12);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

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

button {
  border: 0;
  border-radius: 11px;
  padding: 12px 20px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.error-message {
  margin: 16px 0 0;
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--review);
  background: var(--review-bg);
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.32fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.answer-card {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.debug-card {
  grid-column: 1 / -1;
}

.status-badge {
  display: inline-flex;
  margin: 0;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.status-answered {
  color: var(--answered);
  background: var(--answered-bg);
}

.status-needs-clarification {
  color: var(--clarification);
  background: var(--clarification-bg);
}

.status-needs-review {
  color: var(--review);
  background: var(--review-bg);
}

.answer-text {
  margin-bottom: 0;
  white-space: pre-wrap;
  line-height: 1.65;
}

.sources-card p,
.sources-card ul {
  margin-bottom: 0;
  color: var(--muted);
}

.sources-card ul {
  padding-left: 20px;
}

summary {
  font-weight: 800;
  cursor: pointer;
}

.debug-hint {
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

pre {
  overflow-x: auto;
  margin: 0;
  border-radius: 10px;
  padding: 14px;
  color: #d8f3f5;
  background: #17343b;
  font: 0.84rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[hidden] {
  display: none !important;
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 20px, 920px);
    padding-top: 36px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .answer-card,
  .debug-card {
    grid-column: 1;
    grid-row: auto;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
