:root {
  --ink: #111;
  --muted: #707075;
  --blue: #123f9f;
  --blue-dark: #0d327f;
  --blue-light: #e8f1fb;
  --blue-pale: #f3f7fc;
  --cream: #fff;
  --line: #e2e2e2;
  --white: #fff;
  --error: #9e3328;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--cream); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.topbar { height: 76px; padding: 0 max(24px, calc((100vw - 1140px) / 2)); display: flex; align-items: center; justify-content: space-between; border-top: 5px solid var(--white); border-bottom: 2px solid #e8e8e8; background: var(--white); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 38px; border-radius: 3px; color: var(--white); background: linear-gradient(135deg, #1d4199, #21489c); box-shadow: 0 3px 8px rgba(18,63,159,.2); font-size: 14px; font-weight: 850; letter-spacing: .04em; }
.brand-text { display: grid; gap: 1px; line-height: 1.1; }
.brand-text strong { font-size: 17px; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.privacy { font-size: 13px; color: var(--muted); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #4f7ddd; }
main { width: min(1140px, calc(100% - 40px)); margin: 0 auto; }
.hero { margin-top: 30px; padding: 44px 50px 48px; border-radius: 8px; color: var(--white); background: linear-gradient(135deg, #1d4199, #21489c); box-shadow: 0 5px 12px rgba(0,0,0,.18); }
.eyebrow { margin: 0 0 14px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: #dceaff; }
h1 { max-width: 940px; margin: 0; font-size: clamp(38px, 5.3vw, 62px); font-weight: 750; line-height: 1.04; letter-spacing: -.035em; }
.lede { max-width: 720px; margin: 22px 0 0; color: #eef6ff; font-size: 18px; line-height: 1.55; }
.workspace { padding: 26px 0 80px; }
.dropzone { display: grid; place-items: center; min-height: 280px; padding: 42px; text-align: center; border: 2px dashed #a8c5e6; border-radius: 8px; background: var(--white); box-shadow: 0 4px 8px rgba(0,0,0,.1); outline: none; cursor: pointer; transition: .2s ease; }
.dropzone:hover, .dropzone:focus, .dropzone.dragging { border-color: var(--blue); background: var(--blue-pale); box-shadow: 0 16px 38px rgba(30,66,154,.08); transform: translateY(-2px); }
.upload-icon { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 6px; color: var(--white); background: var(--blue); }
.upload-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.dropzone h2 { margin: 0 0 8px; font-size: 28px; font-weight: 750; }
.dropzone p { margin: 0 0 20px; color: var(--muted); }
.browse { color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.limits { font-size: 12px; color: #859189; }
.selection { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); box-shadow: 0 3px 7px rgba(0,0,0,.08); }
.selection strong { display: block; margin-bottom: 3px; }
.selection span { color: var(--muted); font-size: 13px; }
button { border: 0; font: inherit; font-weight: 750; cursor: pointer; }
.primary { flex: none; padding: 13px 19px; border-radius: 5px; color: var(--white); background: var(--blue); box-shadow: 0 3px 7px rgba(18,63,159,.2); }
.primary:hover { background: var(--blue-dark); }
.primary:disabled { opacity: .55; cursor: wait; }
.primary span { margin-left: 12px; color: inherit; font-size: 17px; }
.secondary { padding: 11px 15px; border: 1px solid #cfd5df; border-radius: 5px; color: var(--blue); background: var(--white); }
.secondary:hover { border-color: var(--blue); background: var(--blue-pale); }
.message { padding: 14px 17px; margin-top: 14px; border-radius: 10px; color: var(--error); background: #fae5df; }
.results-section { padding: 50px 0 90px; border-top: 2px solid var(--blue); }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font: 750 38px/1.1 inherit; }
.results { display: grid; gap: 18px; }
.paper-card { overflow: hidden; border: 1px solid #d8d8d8; border-radius: 8px; background: var(--white); box-shadow: 0 4px 8px rgba(0,0,0,.16); }
.paper-head { display: grid; grid-template-columns: 170px 1fr; gap: 22px; padding: 20px 24px; color: var(--white); background: linear-gradient(100deg, #1d4199 0%, #21489c 58%, #79b9ed 100%); border-bottom: 1px solid #143c8d; }
.paper-id { color: var(--white); font-weight: 850; font-size: 14px; letter-spacing: .04em; }
.filename { display: block; margin-top: 6px; color: #dceaff; font-size: 12px; overflow-wrap: anywhere; }
.paper-title { margin: 0; font-size: 23px; font-weight: 750; line-height: 1.25; }
.keyword-groups { border-bottom: 1px solid var(--line); background: var(--white); }
.keyword-row { display: grid; grid-template-columns: 170px 1fr; align-items: start; gap: 22px; min-height: 52px; padding: 12px 24px; }
.keyword-row + .keyword-row { border-top: 1px solid #edf1f9; }
.keyword-label { padding-top: 5px; color: var(--ink); font-size: 12px; font-weight: 800; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 8px; }
.keyword-chip { padding: 6px 10px; border: 1px dashed #aebbd6; border-radius: 5px; color: var(--muted); background: var(--white); font-size: 12px; font-weight: 700; transition: .15s ease; }
.keyword-chip:hover { border-color: var(--blue); color: var(--blue); }
.keyword-chip.selected { border-style: solid; border-color: #a9c0f2; color: var(--blue); background: var(--blue-light); box-shadow: inset 0 0 0 1px rgba(30,66,154,.04); }
.keyword-chip.selected::after { content: "✓"; margin-left: 7px; font-size: 10px; }
.keyword-chip.generated.selected { border-color: #f2aaa3; color: #b42318; background: #fee4e2; }
.keyword-chip.generated:hover { border-color: #d92d20; color: #b42318; }
.keyword-empty { color: var(--muted); font-size: 13px; font-style: italic; }
.authors-section { display: grid; grid-template-columns: 170px 1fr; gap: 22px; padding: 16px 24px; border-bottom: 1px solid var(--line); background: #f9fbff; }
.authors-heading strong { display: block; font-size: 13px; }
.authors-heading small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.author-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.author-chip { display: inline-flex; align-items: stretch; border: 1px solid #d6deed; border-radius: 5px; background: var(--white); font-size: 12px; }
.author-name { position: relative; padding: 7px 9px; color: var(--ink); font-weight: 750; outline: none; cursor: help; }
.author-name:focus { box-shadow: inset 0 0 0 2px rgba(30,66,154,.25); border-radius: 7px 0 0 7px; }
.author-country { padding: 7px 9px; border-left: 1px solid #e4e9f3; color: var(--blue); background: var(--blue-pale); font-weight: 700; }
.affiliation-tooltip { position: absolute; z-index: 5; left: 0; bottom: calc(100% + 8px); width: max-content; max-width: min(360px, 70vw); padding: 8px 10px; border-radius: 7px; color: var(--white); background: var(--ink); box-shadow: 0 8px 20px rgba(16,35,75,.2); font-size: 11px; font-weight: 500; line-height: 1.4; opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .15s ease, transform .15s ease; }
.affiliation-tooltip::after { content: ""; position: absolute; top: 100%; left: 18px; border: 5px solid transparent; border-top-color: var(--ink); }
.author-name:hover .affiliation-tooltip, .author-name:focus .affiliation-tooltip { opacity: 1; transform: translateY(0); }
.warning { margin: 0; padding: 10px 24px; color: #765914; background: #fff5ce; font-size: 12px; }
.error-card { padding: 22px 24px; border-left: 4px solid var(--error); }
.error-card strong { display: block; margin-bottom: 6px; }
.interactive-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 24px 8px; background: var(--white); }
.interactive-heading > div, .match-output-heading, .match-query label { display: flex; align-items: flex-start; gap: 12px; }
.interactive-heading strong, .match-panel strong { display: block; font-size: 14px; }
.interactive-heading small, .match-panel small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.step-number { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; color: var(--white); background: var(--blue); font-size: 11px; font-weight: 850; }
.keyword-tools { display: flex; align-items: center; gap: 14px; }
.keyword-legend { display: flex; gap: 10px; color: var(--muted); font-size: 10px; }
.keyword-legend span { display: flex; align-items: center; gap: 5px; }
.keyword-legend i { width: 8px; height: 8px; border-radius: 50%; }
.author-dot { background: var(--blue); }
.generated-dot { background: #d92d20; }
.generate-keywords { border-color: #f2aaa3; color: #b42318; background: #fee4e2; }
.generate-keywords:hover { border-color: #d92d20; color: #b42318; background: #fdd5d2; }
.generate-keywords:disabled { opacity: .58; cursor: wait; }
.ai-keyword-status { padding: 7px 24px 13px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--white); font-size: 11px; }
.ai-keyword-status.working { color: var(--blue); }
.ai-keyword-status.success { color: #b42318; }
.ai-keyword-status.error { color: var(--error); }
.match-panel { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); border-top: 1px solid var(--line); background: #fbfcff; }
.match-query, .match-output { padding: 24px; }
.match-query { border-right: 1px solid var(--line); }
.match-input-row { display: flex; align-items: stretch; gap: 10px; margin-top: 16px; }
.custom-match-input { width: 100%; min-height: 68px; resize: vertical; padding: 11px 12px; border: 1px solid #b8c5df; border-radius: 5px; color: var(--ink); background: var(--white); font: inherit; font-size: 13px; line-height: 1.45; outline: none; }
.custom-match-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,66,154,.1); }
.match-button { align-self: stretch; box-shadow: none; }
.match-output-heading { margin-bottom: 14px; }
.ae-matches.loading { opacity: .58; }
.ae-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ae-match { display: grid; grid-template-columns: 28px 1fr auto; gap: 11px; align-items: start; padding: 12px; border: 1px solid #e0e3e8; border-radius: 5px; background: var(--white); }
.match-rank { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; color: var(--white); background: var(--blue); font-size: 11px; font-weight: 850; }
.match-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.match-name-row > strong { font-size: 17px; line-height: 1.25; }
.match-country { padding: 3px 8px; border-radius: 5px; color: var(--blue); background: var(--blue-light); font-size: 12px; font-weight: 800; }
.match-evidence { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.match-evidence span { padding: 3px 7px; border-radius: 5px; color: #4f5e79; background: #f0f3f9; font-size: 10px; }
.match-evidence .matched-keyword { color: var(--blue); background: var(--blue-light); font-weight: 800; }
.match-evidence .matched-expertise { color: #4f5e79; background: #f0f3f9; }
.match-score { min-width: 48px; text-align: right; }
.match-score strong { color: var(--blue); font-size: 12px; }
.match-score span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.match-loading, .match-empty, .match-error { padding: 18px; border: 1px dashed #c9d2e4; border-radius: 10px; color: var(--muted); text-align: center; font-size: 12px; }
.match-error { color: var(--error); background: #fff7f5; }
footer { padding: 30px 20px 40px; border-top: 2px solid var(--blue); color: var(--muted); background: #f5f5f5; text-align: center; font-size: 12px; }
.hidden { display: none !important; }

@media (max-width: 700px) {
  .privacy { display: none; }
  .topbar { height: 68px; padding-inline: 20px; }
  .hero { margin-top: 18px; padding: 32px 24px 36px; }
  h1 { font-size: clamp(34px, 11vw, 46px); }
  .lede { font-size: 16px; }
  .dropzone { min-height: 250px; padding: 30px 18px; }
  .selection, .section-heading { align-items: stretch; flex-direction: column; }
  .paper-head { grid-template-columns: 1fr; }
  .interactive-heading, .keyword-tools { align-items: stretch; flex-direction: column; }
  .match-panel { grid-template-columns: 1fr; }
  .match-query { border-right: 0; border-bottom: 1px solid var(--line); }
  .match-input-row { flex-direction: column; }
  .authors-section { grid-template-columns: 1fr; gap: 10px; }
  .keyword-row { grid-template-columns: 1fr; gap: 7px; }
}
