:root {
  --bg: #0d0e11;
  --bg-soft: #14161b;
  --card: #171a20;
  --card-2: #1c1f27;
  --line: #262a33;
  --line-soft: #20232b;
  --text: #ece9e3;
  --muted: #9b9a92;
  --muted-2: #75757040;
  --accent: #c8a45c;
  --accent-soft: #c8a45c22;
  --accent-line: #c8a45c55;
  --danger: #d98b6a;
  --highlight-bg: #c8a45c33;
  --highlight-text: #f6ecd6;
  --radius: 14px;
  --shadow: 0 1px 0 #ffffff08, 0 24px 60px -30px #000000cc;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 50% -10%, #1a1c24 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  letter-spacing: 0.1px;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 24px 96px;
}

/* --- Masthead ---------------------------------------------------------- */
.masthead {
  text-align: center;
  margin-bottom: 40px;
}

.kicker {
  font-size: 12.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
  font-weight: 500;
}

h1 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(46px, 9vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
}

.lede {
  max-width: 60ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16.5px;
}

.lede strong {
  color: var(--text);
  font-weight: 500;
}

.lede em {
  color: var(--text);
  font-style: italic;
}

/* --- Ask form ---------------------------------------------------------- */
.ask {
  display: flex;
  gap: 10px;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ask:focus-within {
  border-color: var(--accent-line);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}

textarea#question {
  flex: 1;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16.5px;
  padding: 10px 12px;
  outline: none;
  min-height: 46px;
}

textarea#question::placeholder {
  color: #6f6f68;
}

button#ask-btn {
  flex: 0 0 auto;
  align-self: stretch;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #241d0c;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 0 26px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.2s ease, opacity 0.2s ease;
}

button#ask-btn:hover {
  filter: brightness(1.06);
}

button#ask-btn:active {
  transform: translateY(1px);
}

button#ask-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* --- Example chips ----------------------------------------------------- */
.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 2px 0;
}

.examples-label {
  color: var(--muted);
  font-size: 13.5px;
  margin-right: 2px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 13px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--card);
}

/* --- Results ----------------------------------------------------------- */
.result {
  margin-top: 34px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.badge {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.answer-text {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

.answer-card.not-found {
  border-color: #3a2f24;
  background: linear-gradient(180deg, #1d1913, var(--card));
}

.answer-card.not-found .card-title {
  color: var(--danger);
}

.answer-card.error {
  border-color: #4a2a26;
  background: linear-gradient(180deg, #211514, var(--card));
}

.answer-card.error .card-title {
  color: var(--danger);
}

.error-detail {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-word;
}

/* Sources */
.sources-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 20px;
  margin: 6px 2px 0;
  color: var(--text);
}

.source {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 18px 20px;
}

.source-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.source-name {
  font-weight: 500;
  color: var(--text);
  font-size: 15px;
}

.source-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.lang-tag {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.score {
  color: var(--accent);
}

.source-text {
  color: #cfccc4;
  font-size: 15px;
  line-height: 1.72;
  margin: 0;
}

mark {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  padding: 1px 3px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  padding: 6px 2px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.foot {
  margin-top: 56px;
  text-align: center;
}

.foot p {
  color: #6c6c64;
  font-size: 13px;
  max-width: 52ch;
  margin: 0 auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .shell {
    padding: 48px 18px 72px;
  }
  .ask {
    flex-direction: column;
  }
  button#ask-btn {
    padding: 12px;
  }
}
