:root{
  --ink:#1B1D16;
  --moss-deep:#232E22;
  --paper:#F6F1E4;
  --paper-dim:#EBE3CD;
  --teal:#1B8C82;
  --teal-deep:#146860;
  --teal-soft:#DCEEEA;
  --clay:#B5713F;
  --amber:#B5713F;
  --amber-soft:#F3E4D6;
  --muted:#5b5b4e;
  --faint:#9b9585;
}
*{box-sizing:border-box; margin:0; padding:0;}
body{
  font-family:'Stack Sans Text', sans-serif;
  background:var(--paper);
  color:var(--ink);
  line-height:1.5;
}
a{color:inherit; text-decoration:none;}
.mono{font-family:'IBM Plex Mono', monospace;}
img{max-width:100%; display:block;}

/* ---------- NAV ---------- */
nav.site-nav{
  display:flex; align-items:center; justify-content:space-between;
  padding:20px 44px;
}
.nav-left{display:flex; align-items:center; gap:11px;}
.logo-mark{width:30px; height:30px; flex-shrink:0;}
.logo-word{font-family:'Stack Sans Text', sans-serif; font-weight:600; font-size:17px;}
.logo-word .accent{font-family:'Fraunces', serif; font-style:italic; font-weight:400; color:var(--teal-deep);}
.brand{font-weight:600;}
.brand .brand-accent{font-family:'Fraunces', serif; font-style:italic; font-weight:400; color:var(--teal-deep);}

.nav-right{display:flex; align-items:center; gap:32px; font-size:14px;}
.dropdown{position:relative;}
.dropdown > span{cursor:pointer; display:flex; align-items:center; gap:5px;}
.dropdown > span::after{content:'▾'; font-size:10px; opacity:0.6; transition:transform .2s;}
.dropdown:hover > span::after{transform:rotate(180deg);}
.dropdown-menu{
  position:absolute; top:100%; left:50%; transform:translateX(-50%);
  padding-top:14px; /* invisible buffer so the hover area stays continuous down to the menu */
  min-width:250px;
  opacity:0; pointer-events:none; transition:all .18s ease;
  z-index:60;
}
.dropdown-menu-inner{
  background:#fff; border:1px solid var(--paper-dim); border-radius:8px;
  box-shadow:0 12px 28px rgba(27,29,22,0.1);
  padding:8px;
  transform:translateY(-6px); transition:transform .18s ease;
}
.dropdown:hover .dropdown-menu{opacity:1; pointer-events:auto;}
.dropdown:hover .dropdown-menu-inner{transform:translateY(0);}
.dropdown-menu a{
  display:flex; align-items:center; gap:9px;
  padding:9px 12px; border-radius:5px; font-size:13.5px; color:var(--ink);
}
.dropdown-menu a:hover{background:var(--teal-soft); color:var(--teal-deep);}
.dropdown-menu .dot{width:6px; height:6px; border-radius:50%; background:var(--teal); flex-shrink:0;}

/* ---------- HERO / SEARCH ---------- */
.hero{max-width:760px; margin:0 auto; padding:56px 24px 30px; text-align:center;}
.hero-mark{width:46px; height:46px; margin:0 auto 22px;}
.hero h1{font-family:'Stack Sans Text', sans-serif; font-weight:600; font-size:32px; letter-spacing:-0.3px; margin-bottom:12px;}
.hero h1 em{font-family:'Fraunces', serif; font-style:italic; font-weight:400; color:var(--teal-deep);}
.hero p.sub{font-size:15px; color:var(--muted); max-width:520px; margin:0 auto 34px;}

.search-wrap{position:relative; margin-bottom:18px;}
.search-box{
  width:100%; display:flex; align-items:center; gap:12px;
  background:#fff; border:1.5px solid var(--paper-dim);
  border-radius:12px; padding:16px 20px;
  box-shadow:0 2px 6px rgba(27,29,22,0.04);
  transition:border-color .2s, box-shadow .2s;
}
.search-box:focus-within{border-color:var(--teal); box-shadow:0 0 0 4px var(--teal-soft);}
.search-box svg{width:20px; height:20px; color:var(--teal); flex-shrink:0;}
.search-box input{border:none; outline:none; flex:1; font-family:'IBM Plex Mono', monospace; font-size:15px; color:var(--ink); background:transparent;}
.search-box input::placeholder{color:var(--faint);}
.search-count{font-size:12.5px; color:var(--faint); margin-top:8px; font-family:'IBM Plex Mono', monospace;}

.quick-tags{display:flex; flex-wrap:wrap; gap:8px; justify-content:center;}
.quick-tags span{
  font-family:'IBM Plex Mono', monospace; font-size:12.5px; cursor:pointer;
  color:var(--teal-deep); background:var(--teal-soft); padding:6px 12px; border-radius:999px;
}
.quick-tags span:hover{background:var(--teal); color:#fff;}

/* ---------- SEARCH RESULTS ---------- */
.results{max-width:920px; margin:0 auto; padding:0 24px 40px;}
.results-list{display:flex; flex-direction:column; gap:14px;}
.empty-state{text-align:center; color:var(--faint); font-size:14px; padding:40px 0;}

/* ---------- CATEGORIES GRID ---------- */
.categories{max-width:1080px; margin:0 auto; padding:60px 24px 30px;}
.categories .head{margin-bottom:28px;}
.categories h2{font-family:'Fraunces', serif; font-weight:500; font-size:24px; margin-bottom:8px;}
.categories .head p{color:var(--muted); font-size:14.5px;}
.cat-grid{display:grid; grid-template-columns:repeat(4, 1fr); gap:16px;}
.cat-card{background:#fff; border:1px solid var(--paper-dim); border-radius:10px; padding:22px 20px; transition:border-color .2s, transform .2s;}
.cat-card:hover{border-color:var(--teal); transform:translateY(-2px);}
.cat-card .icon{width:34px; height:34px; border-radius:8px; background:var(--teal-soft); display:flex; align-items:center; justify-content:center; margin-bottom:14px;}
.cat-card .icon svg{width:18px; height:18px; color:var(--teal-deep);}
.cat-card h3{font-size:14.5px; font-weight:600; margin-bottom:4px;}
.cat-card p{font-size:12.5px; color:var(--faint);}
.cat-card .count{font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--teal-deep); margin-top:8px; display:block;}

/* ---------- LAST INDEXED / RESULT CARDS ---------- */
.last-indexed{max-width:920px; margin:0 auto; padding:20px 24px 10px;}
.last-indexed .head{margin-bottom:22px; display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:8px;}
.last-indexed h2{font-family:'Fraunces', serif; font-weight:500; font-size:24px;}
.last-indexed .head p{color:var(--faint); font-size:12.5px; font-family:'IBM Plex Mono', monospace;}

/* Simple rectangular cards, used for "Last indexed papers" */
.square-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:12px;}
.square-card{
  background:#fff; border:1px solid var(--paper-dim); border-radius:10px;
  padding:16px 18px; display:flex; flex-direction:column; justify-content:space-between;
  min-height:100px; transition:border-color .15s, transform .15s;
}
.square-card:hover{border-color:var(--teal); transform:translateY(-2px);}
.square-card .sq-cat{
  font-family:'IBM Plex Mono', monospace; font-size:10px; text-transform:uppercase; letter-spacing:.05em;
  color:var(--amber); margin-bottom:8px;
}
.square-card .sq-title{
  font-family:'Fraunces', serif; font-weight:500; font-size:14.5px; line-height:1.35;
  margin-bottom:10px; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;
}
.square-card .sq-lang{font-family:'IBM Plex Mono', monospace; font-size:10.5px; color:var(--faint);}

@media (max-width:560px){
  .square-grid{grid-template-columns:repeat(2, 1fr);}
}

.card{
  background:#fff; border:1px solid var(--paper-dim); border-radius:12px;
  padding:20px 22px; transition:border-color .15s; margin-bottom:14px;
}
.card:hover{border-color:var(--teal);}
.card-head{margin-bottom:14px; display:flex; align-items:flex-start; justify-content:space-between; gap:14px;}
.card-head-main{flex:1; min-width:0;}
.card-title{
  font-family:'Fraunces', serif; font-weight:500; font-size:18px; line-height:1.35;
  margin-bottom:8px; display:inline-block;
}
.card-title:hover{color:var(--teal-deep); text-decoration:underline; text-decoration-color:var(--teal-soft);}
.tag-row{display:flex; gap:7px; flex-wrap:wrap;}
.tag{font-family:'IBM Plex Mono', monospace; font-size:10.5px; padding:3px 9px; border-radius:999px;}
.tag.cat{background:var(--amber-soft); color:var(--amber);}
.tag.oa{background:var(--teal-soft); color:var(--teal-deep);}
.tag.paywall{background:var(--amber-soft); color:var(--amber);}
.tag.journal{background:var(--teal-soft); color:var(--teal-deep);}
.tag.plain{background:var(--paper); color:var(--muted); border:1px solid var(--paper-dim);}

.card-body{
  display:grid; grid-template-columns:1fr 1.5fr auto;
  border-top:1px solid var(--paper-dim); padding-top:16px;
}
.card-body .col{padding:0 20px;}
.card-body .col:first-child{padding-left:0;}
.card-body .col:not(:last-child){border-right:1px solid var(--paper-dim);}
.meta-row{margin-bottom:10px;}
.meta-row:last-child{margin-bottom:0;}
.meta-row .k{font-family:'IBM Plex Mono', monospace; font-size:10px; text-transform:uppercase; letter-spacing:.06em; color:var(--faint); margin-bottom:2px;}
.meta-row .v{font-size:13px; font-weight:500; line-height:1.4;}
.summary-text{font-size:13.5px; color:var(--muted); line-height:1.6;}

.link-col{display:flex; flex-direction:column; gap:8px; min-width:150px;}
.link-btn{
  display:flex; align-items:center; gap:7px;
  font-family:'IBM Plex Mono', monospace; font-size:12px; font-weight:500;
  padding:7px 12px; border-radius:7px; border:1px solid var(--paper-dim);
  white-space:nowrap; background:none; cursor:pointer; text-align:left;
  color:var(--ink); width:100%;
}
.link-btn svg{width:13px; height:13px; flex-shrink:0;}
.link-btn:hover{border-color:var(--teal); color:var(--teal-deep);}
.link-btn.tutorial{background:var(--teal-soft); border-color:var(--teal-soft); color:var(--teal-deep);}
.link-btn.tutorial:hover{background:var(--teal); color:#fff;}

/* ---------- SAVE (bookmark) + CITE ---------- */
.save-btn{
  display:flex; align-items:center; gap:6px; flex-shrink:0;
  background:none; border:1px solid var(--paper-dim); border-radius:999px;
  padding:6px 11px; font-family:'IBM Plex Mono', monospace; font-size:11.5px;
  color:var(--muted); cursor:pointer; margin-top:1px;
}
.save-btn svg{width:13px; height:13px;}
.save-btn:hover{border-color:var(--teal); color:var(--teal-deep);}
.save-btn.saved{background:var(--ink); border-color:var(--ink); color:var(--paper);}

.nav-toolkit{
  display:flex; align-items:center; gap:6px;
  font-family:'IBM Plex Mono', monospace; font-size:12px;
  background:var(--ink); color:var(--paper); border:none;
  padding:7px 13px; border-radius:999px; cursor:pointer;
}
.nav-toolkit svg{width:13px; height:13px;}
.nav-toolkit .count{background:var(--teal); color:#fff; border-radius:999px; padding:1px 6px; font-size:10.5px;}

.cite-pop{
  position:absolute; background:var(--ink); color:var(--paper); border-radius:10px;
  padding:14px; width:300px; font-family:'IBM Plex Mono', monospace; font-size:11.5px;
  box-shadow:0 12px 30px rgba(0,0,0,0.25); z-index:200; display:none;
}
.cite-pop.show{display:block;}
.cite-pop pre{white-space:pre-wrap; margin:0 0 10px; line-height:1.5; opacity:.9;}
.cite-pop button{
  background:var(--teal); color:#fff; border:none; padding:6px 12px; border-radius:6px;
  font-family:'IBM Plex Mono', monospace; font-size:11px; cursor:pointer;
}
.cite-pop button:hover{background:var(--teal-deep);}

@media (max-width:760px){
  .card-body{grid-template-columns:1fr;}
  .card-body .col{padding:0 0 14px; border-right:none !important; border-bottom:1px solid var(--paper-dim);}
  .card-body .col:last-child{border-bottom:none; padding-bottom:0;}
}

/* ---------- TUTORIAL POPUP ---------- */
.overlay{
  display:none; position:fixed; inset:0; background:rgba(27,29,22,0.45);
  align-items:center; justify-content:center; padding:24px; z-index:100;
}
.overlay.open{display:flex;}
.popup{
  background:#fff; border-radius:14px; max-width:560px; width:100%;
  max-height:82vh; overflow-y:auto; padding:26px 28px; position:relative;
}
.popup-close{
  position:absolute; top:16px; right:16px; width:28px; height:28px; border-radius:50%;
  border:none; background:var(--paper); color:var(--muted); cursor:pointer;
  font-size:16px; line-height:1; display:flex; align-items:center; justify-content:center;
}
.popup-close:hover{background:var(--paper-dim); color:var(--ink);}
.popup-title{font-family:'Fraunces', serif; font-weight:500; font-size:17px; margin-bottom:4px; padding-right:30px;}
.popup-subtitle{font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--faint); margin-bottom:18px;}
.popup-section-label{
  font-family:'IBM Plex Mono', monospace; font-size:11px; text-transform:uppercase;
  letter-spacing:.06em; color:var(--teal-deep); margin-bottom:8px;
}
.popup-text{font-size:13.5px; color:var(--muted); line-height:1.7; margin-bottom:20px;}
.popup-text p{margin-bottom:10px;}
.popup-text ol, .popup-text ul{margin:0 0 10px 20px;}
.popup-text li{margin-bottom:7px;}
.popup-text strong{color:var(--ink); font-weight:600;}
.popup-text code{font-family:'IBM Plex Mono', monospace; font-size:12px; background:var(--paper); padding:1px 5px; border-radius:4px;}

/* ---------- SUGGEST A PAPER ---------- */
.suggest{max-width:920px; margin:0 auto; padding:36px 24px 60px;}
.suggest-card{
  background:var(--teal-soft); border-radius:14px; padding:26px 28px;
  display:flex; align-items:center; justify-content:space-between; gap:24px; flex-wrap:wrap;
}
.suggest-text h3{font-family:'Fraunces', serif; font-weight:500; font-size:17px; color:var(--teal-deep); margin-bottom:4px;}
.suggest-text p{font-size:13px; color:var(--teal-deep); opacity:0.85; max-width:360px;}
.suggest-form{display:flex; gap:8px; flex-wrap:wrap; flex:1; min-width:280px; max-width:460px;}
.suggest-form input{
  flex:1; min-width:120px; font-family:'IBM Plex Mono', monospace; font-size:13px;
  padding:11px 14px; border:1.5px solid transparent; border-radius:8px;
  background:#fff; color:var(--ink); outline:none;
}
.suggest-form input:focus{border-color:var(--teal-deep);}
.suggest-form button{
  font-family:'Stack Sans Text', sans-serif; font-weight:600; font-size:13.5px;
  color:#fff; background:var(--teal-deep); border:none; border-radius:8px;
  padding:11px 18px; cursor:pointer; white-space:nowrap;
}
.suggest-form button:hover{background:var(--ink);}
.suggest-note{width:100%; font-size:11.5px; font-family:'IBM Plex Mono', monospace; color:var(--teal-deep); opacity:0.75; margin-top:2px;}

@media (max-width:640px){
  .suggest-card{flex-direction:column; align-items:stretch;}
  .suggest-form{max-width:none;}
}

/* ---------- DETAIL PAGE ---------- */
.detail-main{max-width:1040px; margin:0 auto; padding:30px 24px 100px;}
.detail-header{margin-bottom:6px;}
.detail-grid{display:grid; grid-template-columns:1fr 300px; gap:44px; align-items:start;}
.detail-col-main{min-width:0;}
.detail-col-side{position:sticky; top:24px; display:flex; flex-direction:column;}
.detail-col-side .actions{flex-direction:column; margin-bottom:0;}
.detail-col-side .actions .link-btn{width:100%; justify-content:flex-start;}
.info-grid-side{grid-template-columns:1fr;}

@media (max-width:820px){
  .detail-grid{grid-template-columns:1fr; gap:0;}
  .detail-col-side{position:static; order:-1; margin-bottom:20px;}
  .detail-col-side .actions{flex-direction:row; flex-wrap:wrap;}
  .detail-col-side .actions .link-btn{width:auto;}
  .info-grid-side{grid-template-columns:repeat(auto-fill,minmax(170px,1fr));}
}
.back-link{
  display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--teal-deep);
  font-family:'IBM Plex Mono', monospace; margin-bottom:22px;
}
.back-link svg{width:13px; height:13px;}
.back-link:hover{text-decoration:underline;}

.detail-main h1{font-family:'Fraunces', serif; font-weight:500; font-size:28px; line-height:1.28; margin-bottom:10px;}
.detail-authors{font-size:13.5px; color:var(--muted); margin-bottom:14px;}

.actions{display:flex; gap:9px; flex-wrap:wrap; margin-bottom:30px;}
.actions .link-btn{background:#fff; width:auto;}
.link-btn.save.saved{background:var(--ink); border-color:var(--ink); color:var(--paper);}
.link-btn.primary{background:var(--teal-soft); border-color:var(--teal-soft); color:var(--teal-deep);}
.link-btn.primary:hover{background:var(--teal); color:#fff;}

.detail-section{border-top:1px solid var(--paper-dim); padding:24px 0;}
.section-label{
  font-family:'IBM Plex Mono', monospace; font-size:11px; text-transform:uppercase;
  letter-spacing:.06em; color:var(--teal-deep); margin-bottom:12px;
}

.info-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:16px;}
.info-item .k{font-family:'IBM Plex Mono', monospace; font-size:10px; text-transform:uppercase; letter-spacing:.06em; color:var(--faint); margin-bottom:3px;}
.info-item .v{font-size:13.5px; font-weight:500;}

.paper-embed{border:1px solid var(--paper-dim); border-radius:10px; padding:14px 16px; display:flex; gap:14px; background:#fff; align-items:center;}
.paper-embed .thumb{width:44px; height:58px; background:var(--teal-soft); border-radius:4px; flex-shrink:0; display:flex; align-items:center; justify-content:center; color:var(--teal-deep); font-size:10px; font-family:'IBM Plex Mono', monospace;}
.paper-embed .thumb svg{width:20px; height:20px;}
.paper-embed b{font-size:13.5px; display:block; margin-bottom:3px;}
.paper-embed span{font-size:12px; color:var(--muted);}
.paper-embed a.go{margin-left:auto; font-size:12px; color:var(--teal-deep); font-family:'IBM Plex Mono', monospace; white-space:nowrap;}
.abstract-text{font-size:13.5px; color:var(--muted); line-height:1.7; margin-top:14px; max-width:64ch;}

.sample-box{border:1px dashed var(--paper-dim); border-radius:10px; padding:14px 16px; display:flex; align-items:center; justify-content:space-between; gap:14px; background:var(--paper); flex-wrap:wrap;}
.sample-box .sd-text{font-size:12.5px; color:var(--muted);}
.sd-btn{font-family:'IBM Plex Mono', monospace; font-size:12px; font-weight:500; color:var(--teal-deep); border:1px solid var(--teal); border-radius:8px; padding:8px 14px; white-space:nowrap; background:#fff;}
.sd-btn:hover{background:var(--teal-soft);}

.related-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px;}
.related-card{border:1px solid var(--paper-dim); border-radius:10px; padding:14px; background:#fff; transition:border-color .15s; display:block;}
.related-card:hover{border-color:var(--teal);}
.related-card .rt{font-family:'Fraunces', serif; font-weight:500; font-size:14.5px; display:block; margin-bottom:5px; line-height:1.3;}
.related-card .rm{font-size:11px; color:var(--faint); font-family:'IBM Plex Mono', monospace;}
.empty-note{font-size:12.5px; color:var(--faint); font-style:italic;}

.tutorial-text{font-size:14px; color:var(--muted); line-height:1.75; max-width:64ch;}
.tutorial-text p{margin-bottom:12px;}
.tutorial-text ol, .tutorial-text ul{margin:0 0 12px 20px;}
.tutorial-text li{margin-bottom:8px;}
.tutorial-text strong{color:var(--ink); font-weight:600;}
.tutorial-text code{font-family:'IBM Plex Mono', monospace; font-size:12.5px; background:var(--paper-dim); padding:1px 5px; border-radius:4px;}
.cat-header{max-width:820px; margin:0 auto; padding:50px 24px 20px;}
.cat-header .icon-lg{width:44px; height:44px; border-radius:10px; background:var(--teal-soft); display:flex; align-items:center; justify-content:center; margin-bottom:16px;}
.cat-header .icon-lg svg{width:24px; height:24px; color:var(--teal-deep);}
.cat-header h1{font-family:'Fraunces', serif; font-weight:500; font-size:28px; margin-bottom:8px;}
.cat-header p{color:var(--muted); font-size:14.5px;}
.cat-header a.back{font-family:'IBM Plex Mono', monospace; font-size:12.5px; color:var(--teal-deep); display:inline-block; margin-bottom:18px;}

/* ---------- ABOUT ---------- */
.about-page{max-width:680px; margin:0 auto; padding:64px 24px 90px;}
.about-page h1{font-family:'Fraunces', serif; font-weight:500; font-size:28px; margin-bottom:20px;}
.about-page p{font-size:15px; color:#3f3f36; margin-bottom:14px;}
.about-page .sig{margin-top:24px; display:flex; align-items:center; gap:12px; font-family:'IBM Plex Mono', monospace; font-size:13px; color:var(--faint);}
.about-page .sig .logo-mark{width:22px; height:22px;}

/* ---------- FOOTER ---------- */
footer.site-footer{
  background:var(--moss-deep); color:rgba(246,241,228,0.55);
  padding:34px 44px; font-size:12.5px;
  display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:14px;
}
footer.site-footer .logo-word{color:var(--paper); font-size:14px;}
footer.site-footer .logo-word .accent{color:var(--teal);}
footer.site-footer .footer-links{display:flex; gap:20px;}
footer.site-footer .footer-links a{
  font-family:'IBM Plex Mono', monospace; color:rgba(246,241,228,0.7);
}
footer.site-footer .footer-links a:hover{color:var(--teal);}

@media (max-width:860px){
  .cat-grid{grid-template-columns:repeat(2, 1fr);}
  nav.site-nav{padding:16px 20px; flex-wrap:wrap; gap:12px;}
  .hero h1{font-size:26px;}
}
