
:root{--navy:#082e55;--red:#b20f25;--gold:#d7b45b;--ink:#1d3047;--muted:#64748b;--line:#dce5ef}
*{box-sizing:border-box}body{margin:0;background:#f3f6fa;color:var(--ink);font-family:Arial,Tahoma,sans-serif}
header{background:var(--navy);color:#fff;padding:18px 5%}header .head{max-width:1120px;margin:auto;display:flex;align-items:center;justify-content:space-between;gap:15px;flex-wrap:wrap}
.brand{color:#fff;text-decoration:none;font-weight:800;letter-spacing:.5px}
main{max-width:1120px;margin:32px auto;padding:0 18px 50px}
.panel{background:#fff;border:1px solid var(--line);border-radius:16px;padding:26px;box-shadow:0 8px 24px rgba(8,46,85,.06);margin-bottom:20px}
h1,h2{color:var(--navy);margin-top:0}h1{font-size:30px}p{line-height:1.8;color:#52647a}
label{display:block;font-weight:700;color:#29415e;margin:0 0 7px}
input,textarea,select{width:100%;padding:12px;border:1px solid #cbd6e2;border-radius:8px;font:inherit;background:#fff;color:#1d3047}
textarea{min-height:125px;resize:vertical}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.wide{grid-column:1/-1}.field{min-width:0}
.btn{border:0;background:var(--red);color:#fff;padding:12px 22px;border-radius:28px;font-weight:700;cursor:pointer;text-decoration:none;display:inline-block}
.btn.secondary{background:var(--navy)}.btn.light{background:#e9eff6;color:var(--navy)}
.actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}
.note{padding:13px 15px;border-radius:9px;background:#fff7e6;border:1px solid #efdca9;color:#70551e;line-height:1.7;margin-top:16px}
.hidden{display:none!important}.status{font-weight:700;margin-top:12px}
.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}
.card{background:#fff;border:1px solid var(--line);border-radius:14px;overflow:hidden;box-shadow:0 6px 18px rgba(8,46,85,.05);display:flex;flex-direction:column}
.card img{width:100%;height:190px;object-fit:cover;background:#edf2f7}
.card-body{padding:18px;display:flex;flex-direction:column;gap:10px;flex:1}
.card h2{font-size:20px;margin:0}.card p{margin:0;white-space:pre-wrap;line-height:1.7}.card .btn{align-self:flex-start;margin-top:auto}
.empty{background:#fff;border:1px dashed #b8c6d6;border-radius:14px;padding:35px;text-align:center;color:var(--muted)}
.login{max-width:430px;margin:70px auto}.topline{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.small{font-size:13px;color:var(--muted)}
@media(max-width:800px){.cards{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:560px){.grid,.cards{grid-template-columns:1fr}.wide{grid-column:auto}.panel{padding:19px}h1{font-size:25px}}

.book-open{background:#d7b45b!important;color:#082e55!important}
.book-modal{display:none;position:fixed;inset:0;z-index:9999;background:rgba(3,18,35,.88);padding:18px;align-items:center;justify-content:center}
.book-modal.visible{display:flex}
.book-shell{width:min(1100px,100%);height:min(92vh,900px);background:#edf2f7;border-radius:16px;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 24px 80px rgba(0,0,0,.35)}
.book-toolbar{background:#082e55;color:#fff;padding:12px 18px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.book-controls{display:flex;align-items:center;gap:10px}
.book-control,.book-close{border:0;border-radius:8px;background:#fff;color:#082e55;font-size:22px;font-weight:bold;min-width:38px;height:36px;cursor:pointer}
.book-close{background:#b20f25;color:#fff}
#pageCounter{font-weight:bold;min-width:55px;text-align:center}
#bookStage{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:12px;overflow:hidden}
#book{margin:auto}
.page{background:#fff;display:flex;align-items:center;justify-content:center;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.12)}
.page canvas{display:block;max-width:100%;max-height:100%;object-fit:contain}
.book-loading{color:#082e55;text-align:center;padding:18px;font-weight:bold}
@media(max-width:600px){.book-modal{padding:5px}.book-shell{height:96vh;border-radius:10px}.book-toolbar{padding:9px}.book-toolbar strong{font-size:14px}#bookStage{padding:3px}}

/* Complete-page book fit: never crop the PDF page to the viewport */
#bookStage{overflow:auto;align-items:center;justify-content:center}
#book{max-width:100%;max-height:100%;margin:auto}
#book .page{display:flex!important;align-items:center;justify-content:center;overflow:hidden;background:#fff}
#book .page canvas{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain}
.book-shell{height:min(96vh,980px)}


/* Research cards: show the entire uploaded cover image and align all actions */
.card > img{
  width:100%;
  height:240px;
  padding:10px;
  object-fit:contain !important;
  object-position:center;
  background:#f7f9fc;
  display:block;
}
.card-body{gap:12px}
.card .actions{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  width:100%;
  margin-top:auto;
  padding-top:8px;
}
.card .actions .btn,
.card .actions button,
.card .actions a{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:48px;
  margin:0;
  padding:12px 16px;
  text-align:center;
  line-height:1.25;
  white-space:normal;
  border-radius:26px;
  box-sizing:border-box;
}
.card .actions .book-open{order:1}
.card .actions a[id^="research-open-"]{order:2}
.card .actions a[id^="research-download-"]{order:3}
@media(max-width:560px){
 .card > img{height:220px}
 .card .actions .btn,.card .actions button,.card .actions a{min-height:46px}
}
