/* ====== Base / Theme ====== */
:root{
  --bg: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --border: #e5e7eb;
  --shadow: 0 12px 30px rgba(0,0,0,0.12);
  --card: #ffffff;
  --abstract-bg: #f4f4f4;
  --abstract-border: #d9d9d9;
  --author: #737373;
}

:root.dark{
  --bg: #0b1220;
  --text: #e5e7eb;
  --muted: #a1a1aa;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --border: rgba(255,255,255,0.14);
  --shadow: 0 14px 38px rgba(0,0,0,0.5);
  --card: #0f172a;
  --abstract-bg: #111827;
  --abstract-border: #334155;
  --author: #a3a3a3;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  line-height: 1.6;
}

/* ====== Topbar Nav (shared across all pages) ====== */
.topbar{
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  z-index: 10;
}

.nav{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 22px;
  display: flex;
  justify-content: flex-end;
}

.nav-right{
  display: flex;
  align-items: center;
  gap: 22px;
}

.navlink{
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  font-size: 16px;
  line-height: 1;
}

.navlink:hover{ color: var(--link-hover); }

.navlink.active{
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 2px;
}

.iconbtn{
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 8px;
  border-radius: 10px;
}

.iconbtn:hover{ background: rgba(127,127,127,0.10); }

/* ====== Layout ====== */
.wrap{
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 22px 28px;
}

.hero{
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 64px;
  align-items: start;
  margin-top: 20px;
}

.name{
  font-size: 56px;
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
  font-weight: 800;
}

.welcome{
  margin: 0 0 26px 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-text p{
  margin: 0 0 18px 0;
  font-size: 18px;
  color: var(--text);
}

.hero-text strong{ font-weight: 700; }

a{
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover{ color: var(--link-hover); }

.hero-photo img{
  width: 100%;
  max-width: 360px;
  display: block;
  margin-left: auto;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: var(--card);
}

/* ====== Center mail icon ====== */
.mail{
  display: flex;
  justify-content: center;
  margin: 70px 0 28px;
}

.mailbtn{
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 22px;
  background: rgba(127,127,127,0.08);
}

.mailbtn:hover{ background: rgba(127,127,127,0.14); }

/* ====== Footer ====== */
.footer{
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 22px 0 10px;
}

/* ====== Teaching page ====== */
.teaching-wrap{
  padding-top: 46px;
  padding-bottom: 40px;
}

.teaching-title{
  font-size: 64px;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 6px 0 28px 0;
  line-height: 1.05;
}

.teach-section{ margin: 0 0 34px 0; }

.teach-subtitle{
  font-size: 34px;
  font-weight: 400;
  margin: 0 0 12px 0;
  line-height: 1.15;
}

.teach-list{
  margin: 0;
  padding-left: 28px;
}

.teach-list li{
  margin: 8px 0;
  font-size: 18px;
  line-height: 1.45;
  color: var(--text);
}

.teach-badge{
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(127,127,127,0.08);
  color: var(--muted);
}

/* ====== Shared inner pages (Code / Research / Teaching) ====== */
.page-narrow{ max-width: 1100px; }

.page-title{
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 4px 0 20px;
  font-weight: 700;
  color: var(--text);
}

.page-intro{
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 18px;
}

/* ====== Code page ====== */
.code-block{ margin: 0 0 26px; }

.section-heading{
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.item-title{
  margin: 8px 0 4px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
}

.item-meta{
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 16px;
}

.item-desc{
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
}

.item-tag{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* ====== Research page ====== */
.research-page .page-title{ margin-bottom: 30px; }

.research-section{ margin: 0 0 46px; }

.research-heading{
  margin: 0 0 18px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text);
}

.paper-entry{ margin: 0; }

.paper-title{
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 750;
  color: var(--text);
}

.paper-authors{
  margin: 4px 0 24px;
  color: var(--author);
  font-size: 22px;
  line-height: 1.45;
  font-weight: 400;
  font-style: italic;
}

.abstract-details summary{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--link);
  background: var(--bg);
  cursor: pointer;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
  list-style: none;
  user-select: none;
}

.abstract-details summary::-webkit-details-marker{ display: none; }

.abstract-details summary::after{
  content: "▾";
  font-size: 12px;
  transform: rotate(-90deg);
  transition: transform 160ms ease;
}

.abstract-details[open] summary::after{ transform: rotate(0deg); }

.abstract-details summary:hover{
  color: var(--link-hover);
  border-color: var(--link);
}

.abstract-card{
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid var(--abstract-border);
  border-radius: 10px;
  background: var(--abstract-bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.65;
}

.abstract-card p{ margin: 0; }

/* ====== Responsive ====== */
@media (max-width: 900px){
  .nav{ padding: 14px 16px; }

  .nav-right{
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .navlink{
    font-size: 15px;
    text-underline-offset: 4px;
  }

  .hero{
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero-photo img{
    margin: 0;
    max-width: 380px;
  }

  .name{ font-size: 44px; }

  .teaching-wrap{ padding-top: 28px; }
  .teaching-title{ font-size: 48px; margin-bottom: 20px; }
  .teach-subtitle{ font-size: 28px; }
  .teach-list li{ font-size: 17px; }

  .page-title{ font-size: 34px; }
  .section-heading{ font-size: 24px; }
  .item-title{ font-size: 20px; }
  .research-heading{ font-size: 27px; }
  .paper-title{ font-size: 21px; }
  .paper-authors{ font-size: 19px; }
  .abstract-card{ font-size: 17px; padding: 18px; }
}

@media (max-width: 560px){
  .wrap{ padding: 28px 16px 24px; }
  .research-section{ margin-bottom: 38px; }
  .abstract-card{ line-height: 1.58; }
}

/* ====== Ramos-style research page ====== */
.research-body{
  --research-page: var(--bg);
  --research-ink: var(--text);
  --research-meta: var(--muted);
  --research-link: var(--link);
  --research-link-hover: var(--link-hover);
  --research-abstract: var(--abstract-bg);
  --research-journal: #b22234;
  margin: 0;
  min-height: 100vh;
  background: var(--research-page);
  color: var(--research-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  font-size: 1.06rem;
  line-height: 1.5;
  text-align: justify;
}

.research-body .site-wrap a{ color: var(--research-link); text-decoration: none; }
.research-body .site-wrap a:hover{ color: var(--research-link-hover); text-decoration: underline; }

:root.dark .research-body{ --research-journal: #fb7185; }

.research-body .site-wrap{
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
  padding: 24px 16px 16px;
}

.research-body .research-row{ display: flex; flex-wrap: wrap; margin: 0 0 24px; }

.research-body .section-label{
  display: flex;
  align-items: flex-start;
  flex: 0 0 auto;
  width: 25%;
  padding: 4px;
}

.research-body .section-content{ flex: 0 0 auto; width: 75%; padding: 4px; }

.research-body .section-label h1{
  margin: 0;
  color: var(--research-ink);
  font-size: 1.42rem;
  font-weight: 600;
  line-height: 1.1;
}

.research-body .research-item{
  margin: 0 0 24px;
  padding-left: 0.9rem;
  border-left: 3px solid var(--border);
}

.research-body .research-item:last-child{ margin-bottom: 0; }

.research-body .research-item h2{
  margin: 0 0 4px;
  color: var(--research-ink);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.2;
}

.research-body .research-item h2 a{ color: var(--research-link); text-decoration: none; }
.research-body .research-item h2 a:hover{ color: var(--research-link-hover); text-decoration: underline; }

.research-body .small-meta{
  margin: 4px 0;
  color: var(--research-meta);
  font-size: 1rem;
  line-height: 1.5;
}

.research-body .coauthor{ font-style: italic; }
.research-body .journal{ color: var(--research-journal); font-weight: 600; }
.research-body .abstract-toggle{ margin-top: 7px; }

.research-body .abstract-toggle summary{
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 18px;
  list-style: none;
  user-select: none;
}

.research-body .abstract-toggle summary::-webkit-details-marker{ display: none; }
.research-body .abstract-toggle summary:hover{ background: var(--muted); color: var(--bg); }
.research-body .hide-label{ display: none; }
.research-body .abstract-toggle[open] .show-label{ display: none; }
.research-body .abstract-toggle[open] .hide-label{ display: inline; }

.research-body .abstract{
  margin-top: 0.6rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--abstract-border);
  border-left: 3px solid var(--author);
  border-radius: 6px;
  background: var(--research-abstract);
  color: var(--research-ink);
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.5;
  text-align: justify;
}

.research-body .abstract-toggle:not([open]) .abstract{ display: none; }
.research-body .abstract-toggle[open] .abstract{ display: block; }

.research-body .research-footer{
  padding: 16px 0;
  color: var(--research-ink);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 767.98px){
  .research-body .section-label,
  .research-body .section-content{ width: 100%; }
  .research-body .section-label{ margin-bottom: 10px; }
}

@media (max-width: 440px){
  .research-body{ font-size: 1rem; }
}
