@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');

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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --sidebar-bg: #000000;
  --sidebar-text: #e240ff;
  --sidebar-hover: #7b7b7b;
  --sidebar-active: #3c3d3e;
  --primary: #000000;
  --primary-hover: #d43aa6;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --danger: #dc3545;
  --green: #3eff05;
  --gold: #e6a817;
  --red: #dc3545;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html,
body,
#root {
  height: 100%;
}

body {
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* ── Layout ────────────────────────────────────────── */

.app {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 340px;
  min-width: 320px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main>p {
  margin: auto;
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Notebook List ─────────────────────────────────── */

.notebook-list {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.notebook-list h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #e240ff;
  margin-bottom: 12px;
}

.notebook-list ul {
  list-style: none;
  margin-bottom: 8px;
}

.notebook-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.notebook-list li:hover {
  background: var(--sidebar-hover);
}

.notebook-list li.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.notebook-list li .nb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-list li .nb-delete {
  opacity: 0;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
  transition: opacity 0.15s, color 0.15s;
}

.notebook-list li:hover .nb-delete {
  opacity: 1;
}

.notebook-list li .nb-delete:hover {
  color: var(--danger);
}

.btn-new-notebook {
  width: 100%;
  padding: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}

.btn-new-notebook:hover {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ── Source Panel ───────────────────────────────────── */

.source-panel {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

.source-panel h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #e240ff;
  margin-bottom: 12px;
}

.source-panel ul {
  list-style: none;
}

.source-panel li {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.75);
}

.source-panel li .source-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background 0.15s, color 0.15s;
}

.source-panel li {
  cursor: pointer;
  transition: color 0.15s;
}

.source-panel li:hover .source-number,
.source-panel li.source-highlighted .source-number {
  background: transparent;
  border-color: #04d9ff;
  color: #04d9ff;
}

.source-panel li:hover,
.source-panel li.source-highlighted {
  color: #04d9ff;
}

.source-upload-area {
  margin-top: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}

.source-upload-area.dragging {
  border-color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.05);
}

.btn-upload {
  width: 100%;
  padding: 8px;
  border: none;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13px;
  transition: color 0.15s;
}

.btn-upload:hover {
  color: #fff;
}

.btn-upload:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.drop-zone {
  padding: 0px 0px 12px 8px;
  text-align: center;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: default;
}

.source-url-form {
  display: flex;
  gap: 6px;
  padding: 8px 0 0;
  margin-top: 4px;
}

.source-url-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.source-url-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.source-url-input:focus {
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-add-url {
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.btn-add-url:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.btn-add-url:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.source-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 60, 60, 0.12);
  border: 1px solid rgba(255, 60, 60, 0.3);
  color: #ff6b6b;
  font-size: 12px;
  line-height: 1.4;
  animation: source-error-in 0.2s ease-out;
}

.source-error span {
  flex: 1;
}

.source-error-dismiss {
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.source-error-dismiss:hover {
  opacity: 1;
}

@keyframes source-error-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Document Buttons ─────────────────────────────── */

.document-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.btn-document {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-document:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-document:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-document.generating {
  border-color: #e240ff;
  color: #e240ff;
  opacity: 1;
}

/* ── Chat Panel ────────────────────────────────────── */

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 15px;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 16px 32px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input input:focus {
  border-color: var(--primary);
}

.chat-input button {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-input button:hover {
  background: var(--primary-hover);
}

.chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Chat Message ──────────────────────────────────── */

.chat-message {
  margin-bottom: 20px;
  max-width: 720px;
}

.chat-message.user {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius) var(--radius) var(--radius-sm) var(--radius);
  margin-left: auto;
  max-width: 480px;
  width: fit-content;
}

.chat-message.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius-sm) var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

.chat-message.assistant .answer-text {
  white-space: pre-wrap;
  line-height: 1.65;
  text-align: left;
}

.citation-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  vertical-align: super;
  margin: 0 1px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.citation-marker:hover,
.citation-marker.citation-highlighted {
  background: transparent;
  outline: 2px solid #04d9ff;
  color: #04d9ff;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── Groundedness Score ────────────────────────────── */

.groundedness-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
}

.groundedness-score.green {
  background: rgba(40, 167, 69, 0.1);
  color: var(--green);
}

.groundedness-score.gold {
  background: rgba(230, 168, 23, 0.1);
  color: var(--gold);
}

.groundedness-score.red {
  background: rgba(220, 53, 69, 0.1);
  color: var(--red);
}

/* ── Follow-up Questions ───────────────────────────── */

.follow-up-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.follow-up-header {
  margin-bottom: 8px;
  font-size: 1rem;
}

.follow-up-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.follow-up-chip:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Loading indicator ─────────────────────────────── */

.loading-dots::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0% {
    content: '';
  }

  25% {
    content: '.';
  }

  50% {
    content: '..';
  }

  75% {
    content: '...';
  }
}

.chat-message.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Modal ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 24px;
  width: 360px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  background: #2a2a2a;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.modal-input:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.modal-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

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

.modal-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.modal-btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
}

.modal-btn-confirm {
  background: #fff;
  color: #000;
}

.modal-btn-confirm:hover {
  opacity: 0.9;
}

.modal-btn-confirm:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Citation Detail Modal ────────────────────────── */

.citation-detail-loading {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  padding: 12px 0;
}

.citation-detail-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.citation-detail-section h4.citation-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #e240ff;
  margin-bottom: 6px;
}

.citation-detail-section p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.6;
}

.citation-detail-quote {
  border-left: 3px solid #e240ff;
  padding: 8px 14px;
  margin: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.6;
  font-style: italic;
}

.citation-detail-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation-detail-links a {
  color: #04d9ff;
  text-decoration: none;
  font-size: 13px;
  transition: opacity 0.15s;
}

.citation-detail-links a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ── Document Modal Content ───────────────────────── */

.doc-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.doc-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

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

.doc-section-heading {
  font-size: 15px;
  font-weight: 600;
  color: #e240ff;
}

.doc-subsection-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.doc-bullets {
  padding-left: 20px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.6;
}

.doc-bullets li {
  margin-bottom: 4px;
}

.doc-key-terms dl {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-term-pair {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.doc-term-pair dt {
  font-weight: 600;
  color: #04d9ff;
  min-width: 120px;
  flex-shrink: 0;
}

.doc-term-pair dd {
  color: rgba(255, 255, 255, 0.8);
}

.doc-review ol {
  padding-left: 20px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.6;
}

.doc-review ol li {
  margin-bottom: 4px;
}

.doc-faq-pair {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-faq-pair:last-child {
  border-bottom: none;
}

.doc-faq-question {
  font-size: 14px;
  font-weight: 600;
  color: #e240ff;
  margin-bottom: 4px;
}

.doc-faq-answer {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}

.doc-prose {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
  white-space: pre-wrap;
}