:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6b6b6b;
  --line: #ddddda;
  --surface: #ffffff;
  --surface-soft: #f4f4f1;
  --accent: #79263c;
  --accent-soft: #f7edf0;
  --success: #176b45;
  --shadow: 0 18px 48px rgba(28, 22, 24, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(121, 38, 60, 0.07), transparent 36rem),
    #eeeeeb;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(1080px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.9);
  border-inline: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: white;
  background: var(--accent);
  border-radius: 12px;
  font-family: Georgia, serif;
  font-size: 25px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.13em;
}

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

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 3vw, 27px);
  font-weight: 500;
}

.status {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 11px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #c59b31;
  border-radius: 50%;
}

.status.ready .status-dot {
  background: var(--success);
}

.status.error .status-dot {
  background: #b3261e;
}

.chat {
  overflow-y: auto;
  padding: 48px clamp(20px, 6vw, 74px) 32px;
}

.welcome {
  max-width: 720px;
  margin: 7vh auto 0;
  text-align: center;
}

.welcome-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 22px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(121, 38, 60, 0.2);
  border-radius: 18px;
  font-family: Georgia, serif;
  font-size: 34px;
}

.welcome h2 {
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.welcome > p:not(.eyebrow) {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.suggestions {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

.suggestion {
  padding: 13px 16px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.suggestion:hover,
.suggestion:focus-visible {
  border-color: rgba(121, 38, 60, 0.55);
  box-shadow: 0 8px 24px rgba(40, 20, 25, 0.07);
  transform: translateY(-1px);
}

.message {
  max-width: 850px;
  margin: 0 auto 24px;
}

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-user .bubble {
  max-width: 76%;
  padding: 13px 17px;
  color: white;
  background: var(--accent);
  border-radius: 18px 18px 4px 18px;
  line-height: 1.55;
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 14px;
}

.assistant-header h2 {
  margin-bottom: 4px;
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 500;
}

.assistant-header p,
.metrics,
.result-meta,
.empty-state {
  color: var(--muted);
}

.metrics {
  flex: 0 0 auto;
  padding: 7px 10px;
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 11px;
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.result-card-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.result-number {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}

.result-title {
  margin: 0 0 7px;
  font-size: 15px;
  line-height: 1.42;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0;
  font-size: 11px;
}

.badge {
  color: var(--accent);
  font-weight: 750;
}

details {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

summary {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.fragment-text {
  margin: 14px 0;
  color: #303030;
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.72;
}

.source-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.loading {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 16px 0;
  color: var(--muted);
}

.loading span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.1s infinite ease-in-out;
}

.loading span:nth-child(2) {
  animation-delay: 120ms;
}

.loading span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

.error-message {
  padding: 16px;
  color: #7b1c18;
  background: #fff0ee;
  border: 1px solid #f2c1bc;
  border-radius: 12px;
}

.composer-wrap {
  padding: 16px clamp(20px, 6vw, 74px) 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.composer {
  display: flex;
  gap: 10px;
  max-width: 850px;
  margin: 0 auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid #c9c9c5;
  border-radius: 16px;
  box-shadow: 0 9px 28px rgba(29, 24, 25, 0.07);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(121, 38, 60, 0.1);
}

textarea {
  flex: 1;
  min-height: 46px;
  max-height: 150px;
  padding: 11px 12px;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  line-height: 1.5;
}

.composer button {
  display: flex;
  gap: 9px;
  align-items: center;
  align-self: flex-end;
  height: 46px;
  padding: 0 17px;
  color: white;
  background: var(--accent);
  border: 0;
  border-radius: 11px;
  font-weight: 700;
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.disclaimer {
  margin: 8px auto 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: auto 1fr;
    padding: 15px 17px;
  }

  .status {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .chat {
    padding: 30px 16px 24px;
  }

  .welcome {
    margin-top: 3vh;
  }

  .message-user .bubble {
    max-width: 92%;
  }

  .assistant-header,
  .result-card-top {
    display: block;
  }

  .metrics,
  .result-number {
    display: inline-grid;
    margin-bottom: 9px;
  }

  .composer-wrap {
    padding: 12px 12px 16px;
  }

  .composer button span:first-child {
    display: none;
  }
}

