/* --------------------------------------------------
   RESET
-------------------------------------------------- */
:root {
  --shell-panel: #0b0d15;
  --shell-border: #333a4b;
  --shell-text: #f5f5f7;
  --shell-muted: #9ca3b8;
  --shell-chip: #111826;
  --shell-chip-border: #2a3552;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #05060a;
  color: #f5f5f7;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Generic fade-in helper – any element that gets .fade-in will animate */
.fade-in {
  opacity: 0;
  animation: fadeInAnswer 1s ease-out forwards;
}

@keyframes fadeInAnswer {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Spinner animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------
   LAYOUT
-------------------------------------------------- */
.app-root {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 120px; /* bottom padding so Send clears the banner */
}


.app-root.full-width{
  max-width: 100%;
  width: 100%;
  padding-left: 24px;
  padding-right: 24px;
}

/* Two-column main content: left = chat + input, right = sources */
.main-layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(260px, 1.2fr); /* ~80 / 20 */
  column-gap: 24px;
  align-items: start;
}

.main-layout.single-column {
  grid-template-columns: 1fr;
}

/* Titles above each column */
.columns-header {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(260px, 1.2fr);
  column-gap: 24px;
  align-items: baseline;
  margin-top: 12px;
  color: #e5e7eb;
  font-weight: 700;
  font-size: 18px;
}

.column-title-right {
  text-align: left;
}

/* Left column */
.chat-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  position: relative; /* anchor subtle divider */
}

/* Right column */
.side-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  position: relative; /* anchor subtle divider */
}

/* Subtle vertical rails that gently separate chat and sources */
.chat-column::after,
.side-column::before {
  content: "";
  position: absolute;
  top: -12px;
  bottom: -12px;
  width: 8px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(36, 42, 60, 0.65) 18%,
    rgba(36, 42, 60, 0.75) 50%,
    rgba(36, 42, 60, 0.65) 82%,
    transparent
  );
  opacity: 0.35;
  filter: blur(0.3px);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.chat-column::after {
  right: -12px;
}

.side-column::before {
  left: -12px;
}

.main-layout:hover .chat-column::after,
.main-layout:hover .side-column::before {
  opacity: 0.48;
}

/* Stack layout on small screens */
@media (max-width: 900px) {
  .columns-header {
    grid-template-columns: 1fr;
    row-gap: 6px;
  }
  .main-layout {
    display: block;
  }
  .side-column {
    margin-top: 20px;
  }
  .chat-column::after,
  .side-column::before {
    display: none;
  }
}

/* --------------------------------------------------
   HEADER
-------------------------------------------------- */
.app-header h1 {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 28px;
  color: #9ca3b8;
  font-size: 14px;
}

/* --------------------------------------------------
   HEADER LAYOUT (with right-side CTA)
-------------------------------------------------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.app-header-main h1 {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 700;
}

.app-header-main .subtitle {
  margin: 0;
  color: #9ca3b8;
  font-size: 14px;
}

/* --------------------------------------------------
   PDI TOP NAV
-------------------------------------------------- */
.pdi-topbar{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:20px;
  margin-bottom:10px;
  padding:10px 20px;
  border-bottom:1px solid rgba(148,163,184,0.25);
  position:sticky;
  top:0;
  z-index:1000;
  background:rgba(5,6,10,0.92);
  width:100vw;
  margin-left: calc(50% - 50vw);
}

.pdi-brand{
  display:flex;
  align-items:flex-start;
  gap:14px;
}
.pdi-logo{
  width:44px;
  height:44px;
  border-radius:12px;
  background:linear-gradient(135deg, #1d4ed8, #60a5fa);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  letter-spacing:0.08em;
  font-size:12px;
  color:#ffffff;
}
.pdi-brand-text{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.pdi-section{
  text-transform:uppercase;
  letter-spacing:0.2em;
  font-size:11px;
  color:#9ca3b8;
}
.pdi-tool{
  font-size:22px;
  font-weight:700;
}
.pdi-desc{
  font-size:13px;
  color:#b0b6c8;
  max-width:380px;
}
.pdi-nav{
  display:flex;
  gap:12px;
}
.nav-group{
  position:relative;
}
.nav-title{
  border:1px solid rgba(148,163,184,0.35);
  background:#0f1220;
  color:#e5e7eb;
  border-radius:999px;
  padding:8px 14px;
  font-size:13px;
  cursor:pointer;
}
.nav-menu{
  position:absolute;
  top:44px;
  right:0;
  min-width:220px;
  padding:8px;
  border-radius:12px;
  background:#101427;
  border:1px solid rgba(148,163,184,0.25);
  display:flex;
  flex-direction:column;
  gap:6px;
  opacity:0;
  transform:translateY(-4px);
  pointer-events:none;
  transition:all 0.2s ease;
  z-index:10;
}
.nav-group.open .nav-menu,
.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu{
  opacity:1;
  transform:translateY(0);
  pointer-events:auto;
}
.nav-item{
  border:1px solid transparent;
  background:#13182c;
  color:#e5e7eb;
  text-align:left;
  padding:8px 10px;
  border-radius:10px;
  font-size:13px;
  cursor:pointer;
}
.nav-item:hover{
  border-color:#2563eb;
}
.nav-item.is-active{
  border-color:#3b82f6;
  background:rgba(59,130,246,0.15);
}

@media (max-width: 980px){
  .pdi-topbar{
    flex-direction:column;
    align-items:flex-start;
  }
  .pdi-nav{
    flex-wrap:wrap;
  }
}

/* Button that opens the Synthetic Case Builder */
.header-cta {
  border-radius: 999px;
  border: 1px solid #1d4ed8;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.35);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
  white-space: nowrap;
}

.header-cta:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 16px 35px rgba(37, 99, 235, 0.5);
}

/* --------------------------------------------------
   PATIENTS / VAULT UI
-------------------------------------------------- */
.timeline-search,
.recent-section,
.timeline-section {
  margin-top: 22px;
}

.vault-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.field-stack.compact {
  min-width: 150px;
}

.field-stack label {
  font-size: 12px;
  color: #9ca3b8;
  letter-spacing: 0.01em;
}

.vault-row input[type="text"],
.vault-row input[type="password"] {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #1f2535;
  background: #0b0d15;
  color: #e5e7eb;
  font-size: 13px;
}

.vault-row input::placeholder {
  color: #6b7280;
}

.vault-status {
  margin-top: 6px;
  font-size: 13px;
  color: #d1d5db;
}

.mini-help {
  font-size: 12px;
  color: #8b95b2;
}

.tab-strip {
  display: inline-flex;
  gap: 8px;
  margin: 14px 0;
}

.tab-btn {
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: #0b0d15;
  color: #cbd5f5;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.tab-btn.tab-active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.4);
}

.pane-grid {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 16px;
  align-items: start;
}

.pane-left {
  background: #0b0f1d;
  border: 1px solid #1f2535;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sort-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  border: 1px solid #1f2937;
  background: #0f1323;
  color: #cbd5f5;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.pill-btn.pill-active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  padding: 6px 0 12px;
  max-height: 260px;
  overflow-y: auto;
}

.chip-card {
  border: 1px solid #1f2535;
  background: #0d1122;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 64px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.chip-card:hover {
  border-color: #2563eb;
  background: #0f172a;
  transform: translateY(-1px);
}

.chip-card .title {
  font-weight: 600;
  font-size: 13px;
}

.chip-card .meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.pane-right {
  background: #0b0f1d;
  border: 1px solid #1f2535;
  border-radius: 14px;
  padding: 14px;
  min-height: 420px;
}

.list-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dark-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #1f2535;
  background: #0b0d15;
  color: #e5e7eb;
  font-size: 14px;
  box-sizing: border-box;
}

.dark-input::placeholder {
  color: #6b7280;
}

.dark-input.tall {
  min-height: 220px;
}
.dark-input.very-tall {
  min-height: 320px;
}

.detail-pane {
  min-height: 120px;
  border: 1px dashed #1f2937;
  border-radius: 12px;
  padding: 12px;
  background: #0d1020;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  background: #0b0f1d;
  border: 1px solid #1f2535;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #e5e7eb;
}

.stat-label {
  color: #9ca3af;
  font-size: 12px;
}

.federated-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.summary-text {
  margin-top: 8px;
  color: #cbd5f5;
  font-size: 13px;
  line-height: 1.45;
}

.pill.warn {
  background: #5b2b00;
  color: #fbbf24;
  border-color: #b45309;
}

.panel {
  background: #0b0d15;
  border: 1px solid #1f2535;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------
   MODE TOGGLE
-------------------------------------------------- */
.mode-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #050814;
  border: 1px solid #1f2937;
  margin-bottom: 8px;
  gap: 4px;
}

.mode-pill {
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  color: #cbd5f5;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.mode-pill-active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}

/* --------------------------------------------------
   QUERY SECTION (under chat)
-------------------------------------------------- */
.query-section {
  margin-top: 20px;
}

.query-label {
  color: #c3c8d9;
  font-size: 13px;
  margin-bottom: 6px;
  display: block;
}

#q {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #333a4b;
  background: #0b0d15;
  color: #fff;
  resize: vertical;
  font-size: 15px;
  line-height: 1.5;
}

#q::placeholder {
  color: #6b7280;
}

#q:focus {
  outline: none;
  border-color: #3d8bff;
  box-shadow: 0 0 0 1px #3d8bff55;
}

.query-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

/* --------------------------------------------------
   CLARIFIER TOGGLE
-------------------------------------------------- */
.clarify-toggle-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9ca3b8;
}

.clarify-toggle-row input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: #2563eb;
}

.clarify-toggle-row label {
  cursor: pointer;
}

/* --------------------------------------------------
   ASK BUTTON
-------------------------------------------------- */
.ask-btn {
  border: none;
  background: #3d8bff;
  padding: 10px 22px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 8px 22px rgba(61, 139, 255, 0.35);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ask-btn:hover {
  background: #2f74da;
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(61, 139, 255, 0.45);
}

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

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #3d8bff33;
  border-top-color: #3d8bff;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

/* --------------------------------------------------
   FOLLOW-UP SECTION (clarifiers)
-------------------------------------------------- */
.followup-section {
  margin-top: 16px;
}

.followup-inner {
  padding: 12px 14px;
  border-radius: 12px;
  background: #0b0c16;
  border: 1px solid #1f2937;
}

.followup-heading {
  font-size: 13px;
  margin-bottom: 8px;
  color: #9ca3b8;
}

.followup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.followup-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.followup-text {
  font-size: 13px;
  color: #e5e7eb;
}

.followup-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.followup-pill {
  border-radius: 999px;
  border: 1px solid #374151;
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  color: #d1d5db;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}

.followup-pill:hover {
  background: #111827;
}

.followup-pill.active {
  border-color: #e5e7eb;
  background: #e5e7eb;
  color: #05060a;
  transform: translateY(1px);
}

.followup-cta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.followup-hint {
  font-size: 11px;
  color: #9ca3b8;
}

.primary-cta {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #3d8bff;
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(61, 139, 255, 0.35);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.primary-cta:hover {
  background: #2f74da;
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(61, 139, 255, 0.45);
}

/* --------------------------------------------------
   ANSWER SECTION
-------------------------------------------------- */
.answer-section {
  background: #0b0d15;
  border: 1px solid #262b3b;
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.answer-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.answer-body {
  margin-top: 12px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
  overflow-y: auto; /* chat scrolls inside this panel */
}

/* bold headings inside the answer */
.answer-heading {
  font-weight: 700;
  color: #e5e7eb;
}

/* --------------------------------------------------
   ANSWER FOOTER (COPY / LIKE / DISLIKE)
-------------------------------------------------- */
.answer-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn {
  background: #161a28;
  color: #d8dbec;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: #1f2335;
}

.icon-btn.active {
  background: #2563eb;
  color: #ffffff;
}

/* --------------------------------------------------
   SOURCES SECTION (right column)
-------------------------------------------------- */
.sources-section {
  flex: 1;       /* <- this is what makes the panel extend downward */
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sources-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.sources-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.sources-hint {
  font-size: 12px;
  color: #7c8196;
}

/* Single vertical column of cards, scrollable */
.sources-grid {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------
   SOURCE CARDS
-------------------------------------------------- */
.card {
  position: relative;
  background: #0b0f1d;
  border: 1px solid #242a3c;
  border-radius: 14px;
  padding: 14px;
}

.card .title {
  font-size: 14px;
  margin-bottom: 6px;
  font-weight: 600;
}

.card .title a {
  color: #e4e8ff;
  text-decoration: none;
}

.card .title a:hover {
  text-decoration: underline;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.chip {
  background: #181d30;
  color: #b5bdd7;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.card a {
  font-size: 12px;
  color: #7ea2ff;
}

.card-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.card-warn {
  border-color: #d97706;
  background: #1d1204;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #151a29;
  color: #c9d1f0;
  font-size: 11px;
}

.identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #0f1729;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  font-size: 12px;
}

/* --------------------------------------------------
   LOCK OVERLAY
-------------------------------------------------- */
.full-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.overlay-card {
  background: #0b0f1d;
  border: 1px solid #1f2535;
  border-radius: 16px;
  padding: 22px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55);
}

.overlay-card h3 {
  margin: 0 0 10px;
}

.overlay-card p {
  margin: 0 0 14px;
  color: #cdd5f0;
}

.overlay-actions {
  display: flex;
  justify-content: center;
}

/* --------------------------------------------------
   “WHY THIS ARTICLE?” TOOLTIP
-------------------------------------------------- */
.why-link {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #d1d5db;
  text-decoration: underline;
  cursor: help;
}

.why-link.why-disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

.why-tooltip {
  position: absolute;
  max-width: 420px;
  background: #020617;
  color: #e5e7eb;
  border-radius: 10px;
  border: 1px solid #1e293b;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
  z-index: 50;
  pointer-events: none;
}

/* --------------------------------------------------
   INLINE FORMATTING
-------------------------------------------------- */
strong {
  font-weight: 600;
  color: #f0f2ff;
}

em {
  font-style: italic;
  color: #d0d3e0;
}

/* --------------------------------------------------
   FEEDBACK MODAL
-------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120; /* sits above lock overlay */
}

.modal {
  background: #0b0d15;
  border-radius: 16px;
  border: 1px solid #262b3b;
  padding: 18px 18px 16px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-subtitle {
  font-size: 12px;
  color: #9ca3b8;
}

.modal-close {
  background: transparent;
  border: none;
  color: #9ca3b8;
  cursor: pointer;
  font-size: 16px;
}

.modal-tags {
  margin: 10px 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  background: #15192a;
  color: #c9d1f0;
  transition: background 0.15s, transform 0.05s;
}

.tag-btn.active {
  background: #2563eb;
  color: #ffffff;
  transform: translateY(1px);
}

.modal textarea {
  width: 100%;
  min-height: 70px;
  border-radius: 10px;
  border: 1px solid #333a4b;
  background: #050712;
  color: #f5f5f7;
  font-size: 13px;
  padding: 8px 9px;
  resize: vertical;
}

.modal textarea::placeholder {
  color: #6b7280;
}

.modal textarea:focus {
  outline: none;
  border-color: #3d8bff;
  box-shadow: 0 0 0 1px #3d8bff55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.modal-btn {
  border-radius: 999px;
  border: none;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
}

.modal-btn.secondary {
  background: #161a28;
  color: #d8dbec;
}

.modal-btn.primary {
  background: #3d8bff;
  color: #ffffff;
}

/* --------------------------------------------------
   DISCLAIMER BANNER
-------------------------------------------------- */
.disclaimer-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #11131c;
  border-top: 1px solid #2a3145;
  padding: 10px 16px;
  font-size: 11px;
  color: #9ca3b8;
  text-align: center;
  z-index: 100;
}

/* --------------------------------------------------
   CHAT BUBBLES (Global mode)
-------------------------------------------------- */
.chat-row {
  display: flex;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-row-assistant {
  justify-content: flex-start;
}

.chat-row-system {
  justify-content: center;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.chat-bubble-user {
  background: #2563eb;
  color: #f9fafb;
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
  background: #0f172a;
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}

.chat-bubble-system {
  background: #111827;
  color: #e5e7eb;
}

/* Typing indicator for Global chat */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c8d0ea;
  opacity: 0.65;
  animation: typingPulse 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingPulse {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-2px); opacity: 1; }
}

/* Hide inner scrollbars for chat + sources but keep scrolling */
.answer-body,
.sources-grid {
  -ms-overflow-style: none;  /* IE/Edge */
  scrollbar-width: none;     /* Firefox */
}

.answer-body::-webkit-scrollbar,
.sources-grid::-webkit-scrollbar {
  width: 0;
  height: 0;
}


/* --------------------------------------------------
   THEME TOGGLE
-------------------------------------------------- */
.theme-footer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
}
.theme-toggle {
  border: 1px solid #2f3a55;
  background: #0f1322;
  color: #e5e7eb;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(5, 8, 20, 0.35);
}
.theme-toggle:hover {
  border-color: #3b82f6;
}

body[data-theme="light"] {
  --shell-panel: #ffffff;
  --shell-border: #cbd5e1;
  --shell-text: #0f172a;
  --shell-muted: #64748b;
  --shell-chip: #eef2ff;
  --shell-chip-border: #c7d2fe;
  background: #f8fafc;
  color: #0f172a;
}
body[data-theme="light"] .pdi-topbar {
  border-bottom-color: #e2e8f0;
}
body[data-theme="light"] .nav-title {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}
body[data-theme="light"] .nav-menu {
  background: #ffffff;
  border-color: #e2e8f0;
}
body[data-theme="light"] .nav-item {
  background: #f8fafc;
  color: #0f172a;
}
body[data-theme="light"] .nav-item.is-active {
  background: rgba(59, 130, 246, 0.12);
}
body[data-theme="light"] .panel {
  background: #ffffff;
  border-color: #e2e8f0;
}
body[data-theme="light"] #q {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
body[data-theme="light"] .columns-header {
  color: #0f172a;
}
body[data-theme="light"] .pdi-section {
  color: #64748b;
}
body[data-theme="light"] .pdi-desc {
  color: #475569;
}
body[data-theme="light"] .query-label {
  color: #475569;
}
body[data-theme="light"] #q::placeholder {
  color: #94a3b8;
}
body[data-theme="light"] .theme-toggle {
  background: #eef2ff;
  color: #1f2937;
  border-color: #c7d2fe;
  box-shadow: 0 12px 22px rgba(148, 163, 184, 0.35);
}


/* --------------------------------------------------
   PHI BANNER
-------------------------------------------------- */
.phi-banner{
  display:flex;
  align-items:center;
  gap:10px;
  margin:12px 0 16px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(234,179,8,0.45);
  background:rgba(234,179,8,0.14);
  color:#fde68a;
  font-size:12px;
  font-weight:600;
  letter-spacing:0.02em;
}
body[data-theme="light"] .phi-banner{
  border-color:#f59e0b;
  background:#fef3c7;
  color:#92400e;
}

body[data-theme="light"] .followup-inner{
  background:#ffffff;
  border-color:#e2e8f0;
}
body[data-theme="light"] .followup-heading{
  color:#64748b;
}
body[data-theme="light"] .followup-text{
  color:#0f172a;
}
body[data-theme="light"] .followup-pill{
  border-color:#cbd5e1;
  color:#334155;
}
body[data-theme="light"] .followup-pill:hover{
  background:#f1f5f9;
}
body[data-theme="light"] .followup-hint{
  color:#64748b;
}
body[data-theme="light"] .answer-section{
  background:#ffffff;
  border-color:#e2e8f0;
  color:#0f172a;
}
body[data-theme="light"] .answer-heading{
  color:#0f172a;
}
body[data-theme="light"] .icon-btn{
  background:#eef2ff;
  color:#1f2937;
}
body[data-theme="light"] .icon-btn:hover{
  background:#e0e7ff;
}
body[data-theme="light"] .sources-hint{
  color:#64748b;
}
body[data-theme="light"] .card{
  background:#ffffff;
  border-color:#e2e8f0;
}
body[data-theme="light"] .card .title a{
  color:#1d4ed8;
}
body[data-theme="light"] .card .meta{
  color:#64748b;
}


.disclaimer-banner ~ .theme-footer {
  bottom: 40px;
}


.pdi-subnav{
  justify-self:center;
}
.top-seg{
  display:flex;
  gap:6px;
  padding:6px;
  border-radius:999px;
  background:#0f1220;
  border:1px solid rgba(148,163,184,0.35);
}
.top-seg .seg{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:32px;
  border:0;
  background:transparent;
  padding:7px 12px;
  border-radius:999px;
  cursor:pointer;
  font-weight:600;
  font-size:13px;
  color:#e5e7eb;
  text-decoration:none;
}
.top-seg .seg.active{
  background:#1a2337;
  box-shadow: 0 0 0 1px rgba(120,136,255,0.25);
  color:#f8fbff;
}

.top-seg .nav-item.is-active{
  border-color:#3b82f6;
  background:rgba(59,130,246,0.15);
}
.pdi-nav-main{
  justify-self:end;
  display:flex;
  gap:10px;
}
.top-link{
  border:1px solid rgba(148,163,184,0.35);
  background:#0f1220;
  color:#e5e7eb;
  border-radius:999px;
  padding:7px 12px;
  font-size:12px;
  text-decoration:none;
  white-space:nowrap;
}
.top-link.active{
  border-color:#3b82f6;
  background:rgba(59,130,246,0.15);
}
body[data-theme="light"] .pdi-topbar{
  background:rgba(248,250,252,0.95);
}
body[data-theme="light"] .top-seg{
  background:#f1f5f9;
  border-color:#cbd5e1;
}
body[data-theme="light"] .top-seg .seg{
  color:#0f172a;
}
body[data-theme="light"] .top-seg .seg.active{
  background:#ffffff;
  box-shadow: 0 6px 16px rgba(15,20,35,0.08);
}
body[data-theme="light"] .top-link{
  background:#f1f5f9;
  color:#0f172a;
  border-color:#cbd5e1;
}
body[data-theme="light"] .top-link.active{
  background:rgba(59,130,246,0.12);
}
@media (max-width: 980px){
  .pdi-topbar{
    grid-template-columns: 1fr;
    justify-items:start;
  }
  .pdi-subnav{
    justify-self:start;
  }
  .pdi-nav-main{
    justify-self:start;
    flex-wrap:wrap;
  }
}

html[data-theme="light"] body{
  background:#f8fafc;
  color:#0f172a;
}

body[data-theme="light"] .shell-page .muted{
  color:#475569;
}

html[data-theme="light"]{
  background:#f8fafc;
  color:#0f172a;
}

body[data-theme="light"] .shell-page strong{
  color:#0f172a;
}

body[data-theme="light"] .shell-page p{
  color:#334155;
}
