:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e6e6e2;
  --accent: #111111;
  --soft: #f0f0ec;
  --blue: #2563eb;
  --radius: 10px;
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 12px 12px 8px;
  gap: 10px;
}

.pane-header {
  padding: 2px 2px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}
.jdx-compact { position: relative; }
.jdx-trigger {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.country-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: min(280px, 86vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .4rem;
  max-height: 420px;
  overflow: auto;
}
.country-menu.open { display: block; }
.jdx-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: .45rem .5rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.jdx-item:hover,
.jdx-item.is-selected { background: var(--soft); }
.jdx-item:disabled { opacity: .45; cursor: not-allowed; }
.jdx-flag { width: 1.2rem; text-align: center; }
.jdx-name { flex: 1; }
.jdx-tag { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.jdx-tag-live { color: #15803d; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #111;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.composer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

textarea#prompt {
  width: 100%;
  border: none;
  resize: vertical;
  min-height: 88px;
  font: inherit;
  line-height: 1.45;
  color: var(--ink);
  background: transparent;
  outline: none;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mode-toggle {
  display: inline-flex;
  background: var(--soft);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.mode-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.submit-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.submit-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.sources, .answer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.sources-head, .answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sources-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--soft);
}

.file-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.src-title {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.src-title a {
  color: var(--ink);
  text-decoration: none;
}

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

.sources-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.answer-body {
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 12.5px;
  max-height: 280px;
  overflow: auto;
  color: #222;
}

.answer-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

button.primary, button.secondary, .footer-btn {
  font: inherit;
  cursor: pointer;
}

button.primary {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 600;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.badge.ok { color: #15803d; }
.badge.miss { color: #b45309; }

.pane-footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.footer-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  font-weight: 600;
}

.linkish {
  border: none;
  background: none;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.status-err {
  color: #b91c1c;
  font-size: 12px;
  margin: 4px 0 0;
}
