:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --accent: #0369a1;
  --success: #15803d;
  --danger: #b91c1c;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", Times, serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none !important;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-title span {
  color: var(--primary);
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-ghost:hover {
  background: var(--surface-alt);
  border-color: #cbd5e1;
  text-decoration: none;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.hero {
  text-align: center;
  padding: 1.5rem 0 1.25rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.hero p {
  max-width: 660px;
  margin: 0 auto 1.75rem;
  color: var(--text-muted);
  font-size: 1.04rem;
}

.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
  padding: 0.85rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 12px 28px -6px rgba(29, 78, 216, 0.16);
}

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.search-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  min-height: 44px;
  max-height: 160px;
  padding: 0.35rem 0.25rem;
}

.btn-search {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-search:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-search:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.filters-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  text-align: left;
}

.filters-panel.hidden {
  display: none;
}

.filter-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.filter-select {
  width: 100%;
  padding: 0.52rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-hint {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.chips-row {
  margin-top: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
}

.suggestion-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.58rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.suggestion-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.status-banner {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.status-banner.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.status-banner.hidden {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(29, 78, 216, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.article-card {
  margin-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: clamp(1.25rem, 3vw, 2.25rem);
}

.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.35rem;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.badge-pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
}

.article-title {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  margin: 0;
  line-height: 1.3;
}

.article-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.synthesis-body {
  font-size: 1.04rem;
  line-height: 1.78;
  color: #1e293b;
}

.synthesis-body h3 {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  margin: 1.5rem 0 0.6rem;
  color: var(--text);
}

.synthesis-body p {
  margin: 0 0 1.05rem;
}

/* Badges de citação inline + balão informativo ao passar o mouse */
.cite-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.02rem 0.42rem;
  margin: 0 0.14rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  vertical-align: baseline;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cite-badge:hover,
.cite-badge:focus-visible {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  z-index: 50;
}

.hover-title-tip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 220px;
  max-width: 310px;
  width: max-content;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.55rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  z-index: 60;
}

.hover-title-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

.cite-badge:hover .hover-title-tip,
.cite-badge:focus-visible .hover-title-tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  .hover-title-tip {
    max-width: 240px;
    font-size: 0.74rem;
  }
}

.sources-section {
  margin-top: 2rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}

.sources-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.source-chip-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.source-chip-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.source-chip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.source-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.84rem;
}

.source-author {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.source-work {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.source-ref {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.debate-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.debate-turn {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.debate-question {
  font-weight: 700;
  color: var(--primary-hover);
  margin-bottom: 0.65rem;
}

.debate-form {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.debate-input {
  flex: 1;
  min-width: 240px;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.94rem;
}

.catalog-section {
  margin-top: 3rem;
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.catalog-header h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0;
}

.studies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}

.study-link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
  color: var(--text);
  text-decoration: none !important;
}

.study-link-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.study-link-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--primary-hover);
}

.study-link-excerpt {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Modal de Fonte Original & Alinhamento Paralelo */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  background: var(--surface);
  border-radius: 18px;
  max-width: 1040px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.08rem;
  color: var(--text);
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.modal-close {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.sync-guide-bar {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
}

.parallel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.parallel-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.9rem;
}

@media (max-width: 820px) {
  .parallel-grid,
  .parallel-grid-3 {
    grid-template-columns: 1fr;
  }
}

.text-pane {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  font-size: 0.95rem;
  line-height: 1.7;
  max-height: 58vh;
  overflow-y: auto;
}

.text-pane-orig {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.pane-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 0.55rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.sync-seg {
  cursor: pointer;
  border-radius: 5px;
  padding: 0.06rem 0.18rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.sync-seg:hover {
  background: #dbeafe;
}

.sync-seg.active {
  background: #fef08a;
  color: #0f172a;
  box-shadow: 0 0 0 1px #eab308;
}

.sync-seg-empty {
  color: #94a3b8;
  cursor: default;
}

.footer-lgpd {
  margin-top: 3rem;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
