:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #5e6b64;
  --line: #dce4df;
  --brand: #006b57;
  --brand-dark: #06483e;
  --accent: #b24b32;
  --soft: #e8f2ee;
  --shadow: 0 18px 42px rgba(24, 48, 40, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.5;
}

body.rtl {
  direction: rtl;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 56px);
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.language-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.language-switcher button,
.actions button,
.tool-actions button,
.search-row button,
.copy-citation,
.copy-summary {
  min-height: 42px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
}

.language-switcher button {
  min-height: 36px;
  background: transparent;
  color: var(--brand-dark);
}

.language-switcher button.active {
  background: var(--brand);
  color: #fff;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 26px auto 56px;
}

.search-panel,
.tool-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(300px, 1.4fr);
  gap: 28px;
  padding: clamp(20px, 4vw, 36px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-copy p,
.tool-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.search-copy .source-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 15px;
}

body.rtl .search-copy .source-note {
  border-left: 0;
  border-right: 4px solid var(--brand);
}

.source-note a {
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.search-form label,
.filters span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(0, 107, 87, 0.16);
  border-color: var(--brand);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.filters label {
  min-width: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.stats article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats strong {
  display: block;
  font-size: 30px;
}

.stats span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.catalog-panel,
.results-panel,
.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.catalog-panel {
  position: sticky;
  top: 16px;
  padding: 20px;
}

.latest-heading {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.latest-heading h2 {
  margin: 0;
}

.latest-heading button {
  min-height: 40px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.refresh-status {
  min-height: 22px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.latest-articles {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-inline-end: 4px;
}

.latest-article {
  width: 100%;
  text-align: start;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
}

.latest-article strong {
  display: block;
  line-height: 1.35;
}

.latest-article span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.results-panel {
  min-width: 0;
  padding: 20px;
}

.results-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.results-heading select {
  width: 160px;
}

.results {
  display: grid;
  gap: 14px;
}

.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 260px);
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.result-main {
  min-width: 0;
}

.result-card h3 {
  margin-bottom: 4px;
  font-size: 21px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.result-meta,
.localized-title,
.summary,
.journal-metrics {
  color: var(--muted);
}

.summary {
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.result-meta,
.localized-title {
  overflow-wrap: anywhere;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tags span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: #385048;
  font-size: 12px;
  font-weight: 700;
}

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

.actions a,
.actions button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 12px;
  text-decoration: none;
}

.actions a {
  border: 1px solid var(--line);
  color: var(--brand-dark);
  font-weight: 800;
}

.missing-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  background: #f1f1f1;
  font-weight: 800;
}

.actions a.disabled {
  pointer-events: none;
  color: var(--muted);
  background: #f1f1f1;
}

.copy-summary {
  background: transparent;
  color: var(--brand-dark);
}

.journal-metrics {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #f7faf8;
}

.journal-metrics div + div {
  margin-top: 10px;
}

.journal-metrics dt {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-dark);
}

.journal-metrics dd {
  margin: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.doi-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.doi-status a {
  color: var(--brand-dark);
  font-weight: 700;
}

.doi-lookup {
  min-height: 30px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: #fff;
  color: var(--brand-dark);
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 800;
}

.doi-missing {
  color: var(--muted);
}

.citation {
  grid-column: 1 / -1;
  max-width: 100%;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: auto;
  background: #17201c;
  color: #eef9f5;
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
}

.tool-panel {
  margin-top: 18px;
}

.paraphrase-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pdf-tool {
  display: grid;
  gap: 12px;
}

.pdf-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr) auto auto;
  gap: 10px;
  align-items: center;
}

.pdf-controls button {
  min-height: 42px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 12px;
}

.tool-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fafafa;
}

@media (max-width: 880px) {
  .topbar,
  .results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-panel,
  .tool-panel,
  .workspace,
  .result-card,
  .paraphrase-grid,
  .pdf-controls {
    grid-template-columns: 1fr;
  }

  .catalog-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .search-row,
  .filters,
  .stats,
  .tool-actions {
    grid-template-columns: 1fr;
  }

  .search-row button,
  .tool-actions button {
    width: 100%;
  }
}
