:root {
  --navy: #2D3F4D;
  --blue-gray: #627381;
  --teal: #499993;
  --light-gray: #96A0A8;
  --text-dark: #33335A;
  --link-color: #003366;
  --bg: #e0e4e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', '微軟正黑體', 'Microsoft JhengHei', sans-serif;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--link-color); text-decoration: none; }
a:hover { color: var(--teal); text-decoration: underline; }

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  box-shadow: 0 0 24px rgba(0,0,0,0.25);
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  flex-direction: column;
}

@media (min-width: 769px) {
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

.sidebar-logo {
  background: #253545;
  padding: 8px 10px;
  border-bottom: 2px solid var(--teal);
}
.sidebar-logo a { display: block; }
.sidebar-logo img { width: 100%; display: block; }

.sidebar-photo {
  width: 100%;
  background: var(--blue-gray);
}
.sidebar-photo img {
  width: 100%;
  height: auto;
  display: block;
}

.sidebar-contact {
  padding: 14px 14px 10px;
}
.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 9px;
  font-size: 12px;
}
.contact-label {
  color: var(--teal);
  font-weight: bold;
  white-space: nowrap;
  min-width: 52px;
}
.contact-value {
  color: #ddd;
  line-height: 1.4;
}
.contact-value a { color: #fff; }
.contact-value a:hover { color: var(--teal); text-decoration: none; }

/* ── Sidebar Nav ── */
nav.sidebar-nav {
  background: var(--blue-gray);
}
nav.sidebar-nav a {
  display: block;
  padding: 11px 20px;
  color: #ddd;
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid rgba(255,255,255,0.08);
  transition: background 0.18s, color 0.18s, padding-left 0.18s;
  text-decoration: none;
}
nav.sidebar-nav a:hover {
  background: var(--teal);
  color: #fff;
  padding-left: 26px;
}
nav.sidebar-nav a.active {
  background: var(--teal);
  color: #fff;
  padding-left: 22px;
  border-left: 4px solid #fff;
}

.sidebar-footer {
  padding: 10px 14px;
  background: #4a5a67;
  color: #bbb;
  font-size: 11px;
  text-align: right;
  line-height: 1.5;
}
.sidebar-footer a {
  color: inherit;
  text-decoration: none;
}
.sidebar-footer a:hover {
  text-decoration: underline;
}

/* ── Site notice ── */
.site-notice {
  background: #fffbea;
  border-left: 4px solid #f0c040;
  padding: 9px 18px;
  font-size: 13px;
  color: #6b5700;
  line-height: 1.6;
  flex-shrink: 0;
}
.site-notice a {
  color: #6b5700;
  font-weight: bold;
}

/* ── Main content ── */
.content {
  flex: 1;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue-gray) 100%);
  color: #fff;
  padding: 14px 24px;
  font-size: 17px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 3px solid var(--teal);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.page-banner::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--teal);
  border-radius: 2px;
  flex-shrink: 0;
}

.content-inner {
  padding: 20px 24px 32px;
  flex: 1;
}

/* ── Section header ── */
.section-header {
  background: linear-gradient(to right, #e8ecf0, #f5f7f8);
  border-left: 4px solid var(--teal);
  padding: 9px 14px;
  margin: 22px 0 12px;
  font-size: 15px;
  font-weight: bold;
  color: #444;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header:first-child { margin-top: 0; }

/* ── Profile table ── */
.profile-table {
  width: 100%;
  border-collapse: collapse;
}
.profile-table tr {
  border-bottom: 1px solid #eee;
}
.profile-table td {
  padding: 9px 8px;
  vertical-align: middle;
  font-size: 14px;
}
.profile-table .label {
  font-weight: bold;
  color: var(--text-dark);
  white-space: nowrap;
  padding-right: 16px;
  width: 170px;
}

/* ── Research topics grid ── */
.research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0 6px;
}
.research-topic {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f0f4f8;
  border-radius: 6px;
  border-left: 4px solid var(--teal);
  color: var(--text-dark);
  font-weight: bold;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.18s, transform 0.18s;
  text-decoration: none;
}
.research-topic:hover {
  background: #d8e8f0;
  transform: translateX(4px);
  text-decoration: none;
  color: var(--text-dark);
}
.research-topic img {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

/* ── Grants / projects table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  background: #e8ecf0;
  padding: 7px 10px;
  text-align: center;
  font-weight: bold;
  border: 1px solid #ccc;
}
.data-table td {
  padding: 6px 10px;
  border: 1px solid #ddd;
  vertical-align: top;
}
.data-table tr:hover td {
  background: #f9f9f9;
}

/* ── Members table ── */
.member-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.member-table th {
  background: #e8ecf0;
  padding: 8px 12px;
  text-align: left;
  font-weight: bold;
  border-bottom: 2px solid #c0c8d0;
}
.member-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #eee;
}
.member-table tr:hover td { background: #f9f9f9; }

/* ── Alumni table ── */
.year-badge {
  color: #A80A0A;
  font-size: 18px;
  font-weight: bold;
}
.alumni-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.alumni-table th {
  background: #e8ecf0;
  padding: 7px 8px;
  border: 1px solid #ccc;
  font-weight: bold;
}
.alumni-table td {
  padding: 6px 8px;
  border: 1px solid #ddd;
  vertical-align: top;
}
.alumni-table .year-cell {
  color: #A80A0A;
  font-size: 17px;
  font-weight: bold;
  white-space: nowrap;
  width: 56px;
}

/* ── Education / experience ── */
.exp-section {
  margin-bottom: 6px;
}
.exp-section p {
  padding: 5px 0;
  line-height: 1.7;
  font-size: 13px;
}

/* ── Courses list ── */
.course-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.course-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.course-list li::before {
  content: '▸';
  color: var(--teal);
  font-size: 12px;
  flex-shrink: 0;
}

/* ── Links page ── */
.links-category {
  margin-bottom: 24px;
}
.links-category h3 {
  font-size: 15px;
  font-weight: bold;
  color: var(--navy);
  border-bottom: 2px solid var(--teal);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.links-category a {
  display: block;
  padding: 4px 0 4px 12px;
  color: var(--link-color);
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.links-category a:hover {
  color: var(--teal);
  border-left-color: var(--teal);
  text-decoration: none;
}

/* ── Photo gallery ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  margin: 8px 0;
}
.gallery-item {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  background: #ddd;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}
.gallery-item:hover img { transform: scale(1.09); }
.gallery-item .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item:hover .overlay {
  background: rgba(0,0,0,0.25);
}
.gallery-item .overlay::after {
  content: '🔍';
  font-size: 24px;
  opacity: 0;
  transition: opacity 0.2s;
}
.gallery-item:hover .overlay::after { opacity: 1; }

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.90);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-img-wrap {
  max-width: 90vw;
  max-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img {
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  display: block;
}
.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 18px;
}
.lb-btn {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: none;
  padding: 10px 26px;
  font-size: 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.lb-btn:hover { background: rgba(255,255,255,0.32); }
.lb-counter {
  color: #ccc;
  font-size: 13px;
  min-width: 70px;
  text-align: center;
}
.lb-close {
  position: absolute;
  top: 20px;
  right: 28px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.lb-close:hover { opacity: 1; }

/* ── Mobile bar (injected by JS) ── */
.mobile-bar {
  display: none;
  background: var(--navy);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--teal);
  position: sticky;
  top: 0;
  z-index: 400;
}
.mobile-bar a img { height: 36px; display: block; }
.burger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

/* ── Drawer overlay ── */
.drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.55);
  z-index: 250;
}
.drawer-overlay.open { display: block; }

/* ── Table scroll wrapper ── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-bar { display: flex; }

  .layout { flex-direction: column; }

  .sidebar-logo { display: none; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    z-index: 300;
    transition: left 0.26s ease;
    overflow-y: auto;
  }
  .sidebar.drawer-open { left: 0; }

  .content { min-width: 0; }

  .page-banner { font-size: 15px; padding: 12px 16px; }
  .content-inner { padding: 14px 14px 28px; }
  .section-header { font-size: 13px; }

  .research-grid { grid-template-columns: 1fr; }

  .profile-table td {
    display: block;
    width: 100%;
    padding: 4px 8px;
  }
  .profile-table tr {
    display: block;
    padding: 8px 0;
  }
  .profile-table .label {
    width: auto;
    white-space: normal;
    padding-right: 0;
    color: var(--teal);
    font-size: 12px;
  }

  .data-table, .alumni-table, .member-table { font-size: 11px; }
  .data-table td, .data-table th,
  .alumni-table td, .alumni-table th { padding: 5px 6px; }

  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
