/* ============================================================
   Light theme with dark accents — glossy, modern
   ============================================================ */

:root {
  --bg:            #f3f4f6;
  --bg-grad:       radial-gradient(900px 500px at 50% -10%, #ffffff 0%, #f3f4f6 50%, #e7e9ee 100%);
  --surface:       #ffffff;
  --surface-soft:  #fafafa;
  --border:        rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text:          #0b0f1a;
  --text-soft:     #1f2937;
  --muted:         #6b7280;

  /* Accent palette — maroon primary + gold secondary, dark for text */
  --accent:        #0a0a0a;        /* dark text/headings */
  --accent-soft:   #1f1f1f;
  --maroon:        #7b0f2b;
  --maroon-dark:   #570b1e;
  --maroon-light:  #a1163a;
  --gold:          #f5b921;
  --gold-soft:     #fde68a;
  --gold-dark:     #c2901a;
  --accent-grad:   linear-gradient(180deg, #a1163a 0%, #7b0f2b 100%);
  --accent-grad-h: linear-gradient(180deg, #b71f47 0%, #8a1232 100%);
  --gold-grad:     linear-gradient(180deg, #f5b921 0%, #d99a13 100%);
  --maroon-gold-grad: linear-gradient(90deg, #7b0f2b 0%, #a1163a 55%, #f5b921 100%);

  --danger:        #dc2626;
  --danger-soft:   rgba(220, 38, 38, 0.08);
  --success-soft:  rgba(34, 197, 94, 0.10);

  --radius:        14px;
  --radius-sm:     9px;
  --shadow-card:   0 1px 0 rgba(255,255,255,0.9) inset,
                   0 1px 2px rgba(15,23,42,0.04),
                   0 10px 30px rgba(15,23,42,0.06);
  --shadow-hover:  0 1px 0 rgba(255,255,255,0.9) inset,
                   0 18px 40px rgba(15,23,42,0.10);
  --transition:    180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
}

::selection { background: #0a0a0a; color: #fff; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ============================================================
   Header (clean glass, dark accent line)
   ============================================================ */
.site-header {
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  box-shadow: 0 1px 0 rgba(15,23,42,0.04), 0 2px 0 var(--gold);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--maroon);
}
.header-actions { display: flex; gap: 0.5rem; }

.subtle-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.6;
  transition: opacity var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.subtle-link:hover { opacity: 1; color: var(--text-soft); }
.print-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.45rem;
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
}
.print-btn:hover { color: var(--maroon); background: rgba(123,15,43,0.08); }
.print-btn svg { display: block; }

/* ============================================================
   Footer (dark accent stripe)
   ============================================================ */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  background: linear-gradient(180deg, #1a1a1a 0%, #050505 100%);
  color: #d1d5db;
  text-align: center;
  font-size: 0.85rem;
  border-top: 3px solid var(--maroon);
  box-shadow: inset 0 3px 0 var(--gold);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 2.75rem 1.75rem;
  margin: 1.75rem 0 1.5rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(250,247,243,0.75) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--maroon-gold-grad);
}
.hero-info { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 0.3rem; }
.profile-photo {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow:
    0 0 18px 2px rgba(123, 15, 43, 0.35),
    0 0 40px 8px rgba(245, 185, 33, 0.18),
    0 12px 32px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}
.hero h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--maroon);
  line-height: 1.15;
}
.position {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}
.org {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-soft);
}
.address {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0.65rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  color: var(--text-soft);
  font-size: 0.92rem;
}
.contact-list li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.contact-icon {
  color: var(--maroon);
  opacity: 0.85;
  flex-shrink: 0;
}

/* Research identifier pills */
.research-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
}
.research-id {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition);
}
.research-id:hover {
  border-color: var(--maroon);
  color: var(--maroon);
  box-shadow: 0 4px 12px rgba(123,15,43,0.12);
  transform: translateY(-1px);
}
.research-id-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.research-id-badge.orcid   { background: #A6CE39; }
.research-id-badge.scholar { background: #4285F4; }
.research-id-badge.rg      { background: #00CCBB; }
.research-id-badge.scopus  { background: #E9711C; }
.contact-list a {
  color: var(--maroon);
  text-decoration: none;
  border-bottom: 1px solid rgba(123,15,43,0.3);
  transition: border-color var(--transition), color var(--transition);
}
.contact-list a:hover { border-bottom-color: var(--gold); color: var(--maroon-dark); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(250,247,243,0.75) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-card);
  position: relative;
}
.card h2 {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.section-title {
  font-style: italic;
  font-weight: 700;
  color: var(--maroon);
  position: relative;
  padding-bottom: 0.65rem;
  margin: 0 0 1.25rem;
}
.section-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 3px;
  background: var(--maroon-gold-grad);
  border-radius: 3px;
}

/* ============================================================
   Education group headings
   ============================================================ */
.edu-group { margin-bottom: 1.5rem; }
.edu-group:last-child { margin-bottom: 0; }
.edu-group h3 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.bionote {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-wrap;
  text-align: justify;
  hyphens: auto;
}
.bionote::first-letter {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--maroon);
}

.edu-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}
.edu-row-body { flex: 1; min-width: 0; }
.edu-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--gold);
  box-shadow: 0 0 0 1px var(--maroon), 0 2px 8px rgba(123,15,43,0.15);
  padding: 3px;
  flex-shrink: 0;
}
.edu-logo-placeholder { background: transparent; border: none; }

/* ============================================================
   Timeline (education, work, affiliations)
   ============================================================ */
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.timeline li {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: none; }
.timeline .item-title { font-weight: 600; color: var(--accent); }
.timeline .item-title .muted { color: var(--muted); font-weight: 400; }
.timeline .item-meta { color: var(--muted); font-size: 0.875rem; margin: 0.2rem 0 0.4rem; }
.timeline .item-desc { margin: 0; color: var(--text-soft); }

/* ============================================================
   Generic entry list (trainings, conferences, consultancies, extensions)
   ============================================================ */
.entry-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.entry-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.entry-list li:last-child { border-bottom: none; }
.entry-list .entry-title { font-weight: 700; color: var(--accent); }
.entry-list .entry-meta { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0; }
.entry-list .entry-detail { margin: 0.25rem 0 0; color: var(--text-soft); font-size: 0.93rem; }
.entry-list .entry-detail strong { color: var(--accent); font-weight: 600; }
.entry-list .entry-detail a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(10,10,10,0.3); }
.entry-list .entry-detail a:hover { text-decoration-color: var(--accent); }
.entry-list .award {
  display: inline-block;
  margin-top: 0.5rem;
  background: var(--gold-grad);
  color: #4a2f00;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 2px 6px rgba(245,185,33,0.35);
}
.empty-note {
  color: var(--muted);
  font-style: italic;
  padding: 0.5rem 0;
}

/* ============================================================
   Skill tags
   ============================================================ */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
  background: var(--accent-grad);
  border: 1px solid rgba(0,0,0,0.4);
  color: #fff;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 1px 2px rgba(123,15,43,0.25);
}

/* ============================================================
   Project grid
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.project-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 30px rgba(15,23,42,0.10);
}
.project-card h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--accent); }
.project-card p { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.88rem; }
.project-card a {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(10,10,10,0.3);
  padding-bottom: 1px;
}
.project-card a:hover { border-bottom-color: var(--accent); }

/* ============================================================
   Social links
   ============================================================ */
.social-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.social-list a {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-soft);
  background: var(--surface);
  transition: all var(--transition);
}
.social-list a:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--accent-grad);
  color: #ffffff;
  border-color: var(--maroon-dark);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 4px 12px rgba(123,15,43,0.25);
}
.btn-primary:hover {
  background: var(--accent-grad-h);
  box-shadow: 0 1px 0 rgba(255,255,255,0.22) inset, 0 6px 18px rgba(123,15,43,0.35);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* ============================================================
   Login / auth
   ============================================================ */
.centered-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--maroon-gold-grad);
}
.auth-card h1 { margin: 0.2rem 0 0.3rem; font-size: 1.5rem; color: var(--maroon); text-align: center; }
.auth-logo {
  display: block;
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin: 0 auto 0.75rem;
  filter: drop-shadow(0 4px 10px rgba(123,15,43,0.25));
}
.muted { color: var(--muted); }
.center { text-align: center; }
.auth-card a { color: var(--accent); }
.auth-card a:hover { text-decoration: underline; }
.auth-card form button[type="submit"] { width: 100%; margin-top: 0.5rem; padding: 0.7rem; }

/* ============================================================
   Forms
   ============================================================ */
form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
form label span { font-weight: 500; color: var(--text-soft); }
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="url"],
textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: #9ca3af; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
textarea { resize: vertical; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}
.form-grid label { margin: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.5rem; }

.photo-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0;
}
.photo-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  flex-shrink: 0;
}
.photo-preview:not([src]), .photo-preview[src=""] { visibility: hidden; }
.photo-row-actions { flex: 1; }
.photo-upload-label { gap: 0.35rem; }
.photo-upload-label small { font-size: 0.78rem; }
.photo-upload-label input[type="file"] {
  font-size: 0.85rem;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  color: var(--text-soft);
}

.error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(220, 38, 38, 0.25);
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
}
.status {
  background: var(--success-soft);
  color: #166534;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(34, 197, 94, 0.25);
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

/* ============================================================
   Admin layout — sidebar + content
   ============================================================ */
.admin-layout {
  display: flex;
  gap: 1.75rem;
  margin: 1.5rem 0;
  align-items: flex-start;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 5rem;
}
.admin-content { flex: 1; min-width: 0; }

.tab {
  background: transparent;
  border: none;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-soft);
  font-family: inherit;
  text-align: left;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.tab:hover { background: var(--surface-soft); color: var(--maroon); }
.tab.active {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 2px 8px rgba(123,15,43,0.25);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0.25rem;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.sidebar-action:hover { background: var(--surface-soft); color: var(--accent); }
.sidebar-action svg { flex-shrink: 0; opacity: 0.8; }
.sidebar-action:hover svg { opacity: 1; }
#logout-btn.sidebar-action:hover { color: var(--danger); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel h2 { margin: 0 0 1rem; font-size: 1.15rem; font-weight: 700; color: var(--accent); }

@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar .tab { flex: 1 1 auto; min-width: 110px; }
  .sidebar-divider { display: none; }
  .sidebar-action { flex: 1 1 auto; min-width: 120px; justify-content: center; }
}

/* ============================================================
   Admin list (CRUD entries)
   ============================================================ */
.admin-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.admin-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.admin-list li:hover {
  border-color: var(--border-strong);
  box-shadow: 0 6px 16px rgba(15,23,42,0.06);
}
.admin-list .item-body { flex: 1; min-width: 0; }
.admin-list .item-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.admin-list .item-title { font-weight: 600; color: var(--accent); }
.admin-list .item-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.admin-list .item-desc { margin-top: 0.3rem; color: var(--text-soft); font-size: 0.9rem; word-break: break-word; }
.admin-list .item-meta a { color: var(--text-soft); }
.admin-list .item-meta a:hover { color: var(--accent); }
.admin-list .empty {
  color: var(--muted);
  font-style: italic;
  padding: 1.25rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

/* ============================================================
   Publications
   ============================================================ */
.publications {
  margin: 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  color: var(--text-soft);
}
.publications li { line-height: 1.7; }
.publications li::marker { color: var(--muted); font-weight: 600; }
.publications em { font-style: italic; color: var(--accent); font-weight: 500; }
.publications .doi {
  color: var(--accent);
  word-break: break-all;
  text-decoration-color: rgba(10,10,10,0.3);
}
.publications .doi:hover { text-decoration-color: var(--accent); }

/* ============================================================
   Mobile — tablet portrait + below
   ============================================================ */
@media (max-width: 640px) {
  .container { padding: 0 1rem; }

  /* Hero stacks and centers */
  .hero {
    padding: 1.75rem 1.25rem;
    margin: 1rem 0;
    gap: 1.25rem;
    justify-content: center;
    text-align: center;
  }
  .hero-info {
    min-width: 100%;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
  }
  .hero h1 { font-size: 1.6rem; line-height: 1.2; }
  .position { font-size: 0.95rem; }
  .org { font-size: 0.85rem; }
  .profile-photo {
    width: 130px;
    height: 130px;
    border-width: 2px;
  }
  .address,
  .contact-list,
  .research-ids { justify-content: center; }
  .contact-list { gap: 0.85rem 1rem; row-gap: 0.5rem; }

  /* Cards */
  .card { padding: 1.25rem; margin: 1rem 0; }
  .card h2,
  .section-title { font-size: 1.05rem; }

  /* Forms */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 1.25rem;
  }

  /* Admin list rows stack content + buttons */
  .admin-list li { flex-direction: column; align-items: stretch; }
  .admin-list .item-actions {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
    margin-top: 0.4rem;
  }

  /* Sidebar tabs slightly tighter */
  .sidebar { gap: 0.3rem; padding: 0.5rem; }
  .sidebar .tab {
    font-size: 0.82rem;
    padding: 0.5rem 0.7rem;
    min-width: 96px;
  }
  .sidebar-action { font-size: 0.82rem; padding: 0.45rem 0.7rem; }

  /* Admin photo row stacks */
  .photo-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.85rem;
  }
  .photo-row-actions { width: 100%; }
  .photo-upload-label > span { text-align: left; }

  /* Education logo a bit smaller */
  .edu-logo { width: 40px; height: 40px; padding: 2px; }

  /* Long links / URLs wrap properly */
  .entry-list .entry-detail a,
  .admin-list .item-meta a,
  .project-card a { word-break: break-word; overflow-wrap: anywhere; }

  /* Hero card top ribbon a touch shorter */
  .hero::before { height: 3px; }
}

/* Very narrow phones */
@media (max-width: 400px) {
  .container { padding: 0 0.85rem; }
  .hero { padding: 1.5rem 1rem; }
  .hero h1 { font-size: 1.4rem; }
  .profile-photo { width: 110px; height: 110px; }
  .contact-list { flex-direction: column; gap: 0.4rem; }
  .research-id { font-size: 0.78rem; padding: 0.25rem 0.6rem 0.25rem 0.3rem; }
  .research-id-badge { width: 20px; height: 20px; font-size: 0.6rem; }
  .card { padding: 1rem; }
  .form-grid { padding: 1rem; }
  .sidebar .tab,
  .sidebar-action { min-width: 84px; }
  .timeline .item-title,
  .entry-list .entry-title { font-size: 0.95rem; }
  .auth-card { padding: 1.5rem; }
  .auth-logo { width: 70px; height: 70px; }
}

/* ============================================================
   Print — CV layout
   ============================================================ */
@media print {
  @page { margin: 1in 1in 1in 1in; }

  body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
    font-size: 9.5pt;
    line-height: 1.35;
  }

  .site-header,
  .site-footer,
  .header-actions,
  .print-btn,
  .subtle-link { display: none !important; }

  .container { max-width: none; padding: 0; }

  .hero,
  .card {
    background: #fff !important;
    box-shadow: none !important;
    border: none !important;
    border-bottom: 1px solid #ccc !important;
    border-radius: 0 !important;
    margin: 0 0 0.6rem !important;
    padding: 0.8rem 0 !important;
  }
  .hero { border-bottom: 2px solid #000 !important; padding-bottom: 0.9rem !important; margin-bottom: 0.9rem !important; }
  .hero::before,
  .card::before { display: none !important; }

  .hero h1,
  .section-title,
  .position,
  .item-title,
  .entry-title,
  .edu-group h3 {
    color: #000 !important;
    background: none !important;
    -webkit-text-fill-color: #000 !important;
  }
  .section-title::after {
    background: #000 !important;
    width: 36px !important;
    height: 2px !important;
  }
  .section-title { padding-bottom: 0.35rem !important; margin-bottom: 0.6rem !important; }

  .profile-photo {
    width: 110px !important;
    height: 110px !important;
    border: 1px solid #888 !important;
    box-shadow: none !important;
  }

  .award {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #888 !important;
    box-shadow: none !important;
  }
  .tag {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #888 !important;
    box-shadow: none !important;
  }

  .edu-logo {
    width: 34px !important;
    height: 34px !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  a,
  .contact-list a,
  .publications .doi,
  .entry-list .entry-detail a {
    color: #000 !important;
    text-decoration: none !important;
    border-bottom: none !important;
  }

  .contact-icon { color: #000 !important; opacity: 1 !important; }

  .bionote::first-letter { color: #000 !important; }
}

/* ============================================================
   Business Card (admin tab) — 3.5" x 2" standard card
   ============================================================ */
.bcard-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  flex-wrap: wrap;
}
.bcard-count-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.bcard-count-label input {
  width: 4.2rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  text-align: center;
}
.bcard-count-label input:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(123, 15, 43, 0.12);
}
#bcard-print-sheet { display: none; }

.bcard-stage {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.bcard {
  width: 3.5in;
  height: 2in;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18),
              0 2px 6px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  position: relative;
  color: #0b0f1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.bcard *,
.bcard *::before,
.bcard *::after {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Thin gold/maroon accent stripe on the left edge */
.bcard-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #7b0f2b 0%, #a1163a 45%, #f5b921 100%);
  z-index: 2;
}

.bcard-header {
  display: flex;
  align-items: center;
  gap: 0.11in;
  padding: 0.07in 0.14in 0.06in 0.18in;
  background: linear-gradient(180deg, #fbf7f0 0%, #f5efe1 100%);
  color: var(--maroon-dark);
  border-bottom: 1.5px solid #e7dec5;
  flex-shrink: 0;
  position: relative;
}

.bcard-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1.5px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, #f5b921 30%, #c2901a 60%, transparent 100%);
}

.bcard-logo {
  width: 0.5in;
  height: 0.5in;
  object-fit: contain;
  flex-shrink: 0;
}

.bcard-org { min-width: 0; line-height: 1.18; }

.bcard-org-name {
  font-size: 7.2pt;
  font-weight: 700;
  letter-spacing: 0.015em;
  color: var(--maroon-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bcard-org-addr {
  font-size: 5.8pt;
  color: #6b5a3d;
  margin-top: 1pt;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bcard-body {
  display: flex;
  align-items: center;
  gap: 0.12in;
  padding: 0.08in 0.14in 0.06in 0.18in;
  flex: 1;
  min-height: 0;
}

.bcard-info { flex: 1; min-width: 0; }

.bcard-name {
  font-size: 9.5pt;
  font-weight: 700;
  color: var(--maroon-dark);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.04in;
  letter-spacing: -0.005em;
}

.bcard-unit {
  font-size: 7.5pt;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.3;
  letter-spacing: 0.005em;
}

.bcard-designation {
  font-size: 7pt;
  font-style: italic;
  color: var(--maroon);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bcard-designation + .bcard-unit { margin-top: 0.02in; }

.bcard-qr {
  width: 0.66in;
  height: 0.66in;
  flex-shrink: 0;
  padding: 2px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bcard-qr svg,
.bcard-qr img,
.bcard-qr canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bcard-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.16in;
  padding: 0.05in 0.14in 0.08in 0.18in;
  border-top: 1px solid #ecedef;
  background: #fafbfc;
  flex-shrink: 0;
}

.bcard-line {
  display: inline-flex;
  align-items: center;
  gap: 0.05in;
  font-size: 6.8pt;
  color: #374151;
  line-height: 1.3;
  white-space: nowrap;
}

.bcard-icon {
  color: var(--maroon);
  font-size: 7.5pt;
  display: inline-block;
}

@media (max-width: 640px) {
  .bcard-stage { padding: 0.75rem; overflow-x: auto; }
}

/* ============================================================
   Floating category menu (Table of Contents FAB)
   ============================================================ */
html { scroll-behavior: smooth; }

[data-toc] { scroll-margin-top: 5rem; }

.toc-fab {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 0.6rem;
}

.toc-fab-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(123, 15, 43, 0.35),
              0 2px 5px rgba(15, 23, 42, 0.15);
  transition: transform var(--transition), box-shadow var(--transition);
}

.toc-fab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(123, 15, 43, 0.4),
              0 3px 6px rgba(15, 23, 42, 0.18);
}

.toc-fab-btn[aria-expanded="true"] {
  background: var(--maroon-dark);
}

.toc-fab-btn svg { display: block; }

.toc-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15),
              0 4px 12px rgba(15, 23, 42, 0.08);
  min-width: 230px;
  max-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.55rem;
  animation: toc-fade-in 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes toc-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toc-menu-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.35rem 0.7rem 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.3rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toc-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.toc-list a::before {
  content: '';
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.toc-list a:hover {
  background: var(--surface-soft);
  color: var(--maroon);
}
.toc-list a:hover::before { background: var(--maroon); }

.toc-list a.active {
  background: rgba(123, 15, 43, 0.08);
  color: var(--maroon-dark);
  font-weight: 600;
  border-left-color: var(--maroon);
}
.toc-list a.active::before {
  background: var(--gold);
  transform: scale(1.4);
}

@media (max-width: 640px) {
  .toc-fab { left: 0.9rem; bottom: 0.9rem; }
  .toc-fab-btn { width: 2.75rem; height: 2.75rem; }
  .toc-menu { min-width: 200px; max-width: calc(100vw - 1.8rem); }
}

/* Wide desktop: TOC sits in the left gutter beside the 1000px content — always visible. */
@media (min-width: 1240px) {
  .toc-fab {
    left: calc(50vw - 500px - 232px);
    top: 5rem;
    bottom: auto;
    flex-direction: column;
    align-items: flex-start;
  }
  .toc-fab-btn { display: none; }
  .toc-menu,
  .toc-menu[hidden] {
    display: block !important;
    position: static;
    animation: none;
    box-shadow: 0 1px 0 rgba(255,255,255,0.9) inset,
                0 8px 24px rgba(15, 23, 42, 0.08);
  }
}

/* Hide the FAB when printing */
@media print {
  .toc-fab { display: none !important; }
}

/* ============================================================
   Extension page — matrix, presented output, publications
   ============================================================ */
.extension-matrix {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ext-project {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.ext-project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.ext-project-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--maroon);
  letter-spacing: 0.005em;
}

.ext-role-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent-grad);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}

.evidence-grid {
  display: grid;
  grid-template-columns: minmax(180px, 11rem) 1fr;
  gap: 0.55rem 1rem;
  margin: 0;
}

.evidence-grid dt {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding-top: 0.18rem;
}

.evidence-grid dd {
  margin: 0;
  font-size: 0.88rem;
}

.evidence-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.evidence-links a {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.8rem;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.evidence-links a:hover {
  background: #fff;
  border-color: var(--maroon-light);
  color: var(--maroon);
}

/* Presented Output */
.presented-output {
  list-style: none;
  counter-reset: presented;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.presented-item {
  counter-increment: presented;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 0.9rem 1rem 1rem;
  position: relative;
  padding-left: 2.6rem;
}

.presented-item::before {
  content: counter(presented);
  position: absolute;
  left: 0.9rem;
  top: 0.95rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.presented-title {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.35;
}

.presented-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.ext-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  letter-spacing: 0.01em;
}

.ext-pill a { color: inherit; text-decoration: none; }
.ext-pill a:hover { color: var(--maroon); }

.ext-pill-project { color: var(--maroon-dark); border-color: rgba(123, 15, 43, 0.25); }
.ext-pill-date { color: #6b5a3d; background: #fdf6e3; border-color: #f3e2b6; }
.ext-pill-level { color: #1e3a8a; background: #eef2ff; border-color: #c7d2fe; }
.ext-pill-level.level-international { color: #064e3b; background: #ecfdf5; border-color: #a7f3d0; }

.ext-award {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  color: #78350f;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
}

.presented-venue {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin: 0.25rem 0 0.45rem;
}

.presented-members {
  margin: 0.3rem 0 0.5rem;
  font-size: 0.85rem;
}
.presented-members summary {
  cursor: pointer;
  color: var(--maroon);
  font-weight: 600;
  padding: 0.2rem 0;
  outline: none;
}
.presented-members ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  color: var(--text-soft);
  line-height: 1.6;
}

.presented-proofs {
  font-size: 0.88rem;
  color: var(--text-soft);
}
.presented-proofs strong { color: var(--accent); margin-right: 0.3rem; }
.presented-proofs a {
  margin-right: 0.45rem;
  color: var(--maroon);
  text-decoration: underline;
  text-decoration-color: rgba(123, 15, 43, 0.3);
}
.presented-proofs a:hover { text-decoration-color: var(--maroon); }

.pub-meta {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .evidence-grid { grid-template-columns: 1fr; gap: 0.25rem 0; }
  .evidence-grid dt { padding-top: 0.55rem; }
  .ext-project-head { flex-direction: column; align-items: flex-start; }
  .presented-item { padding-left: 1rem; padding-top: 2.2rem; }
  .presented-item::before { top: 0.7rem; left: 0.9rem; }
}

/* ----- Print: render only the card, at exact card size ----- */
@media print {
  body.printing-bcard {
    background: #fff !important;
    background-image: none !important;
  }
  body.printing-bcard .site-header,
  body.printing-bcard .sidebar,
  body.printing-bcard #admin-status,
  body.printing-bcard .bcard-toolbar,
  body.printing-bcard #tab-business_card > h2,
  body.printing-bcard #tab-business_card > p {
    display: none !important;
  }
  /* Show only the business card panel; hide all the other CRUD panels */
  body.printing-bcard .tab-panel { display: none !important; }
  body.printing-bcard #tab-business_card { display: block !important; }

  body.printing-bcard .container { padding: 0 !important; max-width: none !important; }
  body.printing-bcard main { padding: 0 !important; margin: 0 !important; }
  body.printing-bcard .admin-layout {
    display: block !important;
    margin: 0 !important;
    gap: 0 !important;
  }
  body.printing-bcard .admin-content { padding: 0 !important; margin: 0 !important; }
  /* Hide the on-screen preview; the cloned sheet handles the printout. */
  body.printing-bcard #tab-business_card { display: none !important; }

  body.printing-bcard #bcard-print-sheet {
    display: grid !important;
    grid-template-columns: repeat(2, 3.5in);
    grid-auto-rows: 2in;
    width: 7.1in;
    margin: 0;
    padding: 0;
    gap: 0.1in;
  }
  body.printing-bcard #bcard-print-sheet .bcard {
    width: 3.5in;
    height: 2in;
    margin: 0 !important;
    box-shadow: none !important;
    border: 1px dashed rgba(0, 0, 0, 0.2) !important;
    border-radius: 0 !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
