:root {
  --bg-body: #ffffff;
  --bg-section: #f9f9f9;
  --text-main: #333333;
  --text-muted: #666666;
  --primary: #2962ff;
  --border-light: #e0e0e0;
  --radius-md: 8px;
  --container-width: 900px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
  --bg-body: #121212;
  --bg-section: #1e1e1e;
  --text-main: #e0e0e0;
  --text-muted: #aaaaaa;
  --primary: #82b1ff;
  --border-light: #333333;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg-body); color: var(--text-main); line-height: 1.6; transition: background 0.3s, color 0.3s; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--container-width); margin: 0 auto; padding: 0 20px; }

/* Nav */
nav { position: sticky; top: 0; z-index: 100; background: var(--bg-body); border-bottom: 1px solid var(--border-light); opacity: 0.95; }
.nav-container { display: flex; justify-content: space-between; align-items: center; height: 60px; }
.logo-text { font-weight: bold; font-size: 1.2rem; color: var(--text-main); }

.nav-actions { display: flex; align-items: center; gap: 20px; }
.nav-links { display: none; } /* Show in desktop */
@media (min-width: 768px) {
  .nav-links { display: flex; gap: 24px; align-items: center; }
  .nav-links a { color: var(--text-main); font-weight: 500; font-size: 0.95rem; text-decoration: none; transition: color 0.2s; }
  .nav-links a:hover { color: var(--primary); }
}
.nav-controls { display: flex; align-items: center; gap: 12px; }
.control-btn { 
  background: transparent; border: 1px solid var(--border-light); color: var(--text-main); 
  padding: 4px 10px; border-radius: var(--radius-md); font-size: 0.85rem; font-weight: 600; 
  cursor: pointer; display: flex; align-items: center; gap: 6px; height: 32px; transition: all 0.2s;
}
.control-btn:hover { border-color: var(--primary); color: var(--primary); }

.github-btn { background: var(--text-main); color: var(--bg-body); border-color: var(--text-main); text-decoration: none !important; }
.github-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none !important; }
[data-theme="dark"] .github-btn:hover { color: #121212; }
.gh-text { display: none; }
@media (min-width: 768px) { .gh-text { display: inline; } }

.theme-toggle { border: none; font-size: 1.2rem; padding: 0; width: 32px; justify-content: center; }
.theme-toggle:hover { border-color: transparent; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: none; }

/* Layout Grid */
.page-body { padding-top: 40px; padding-bottom: 60px; }
.section-row { display: flex; flex-direction: column; padding: 40px 0; border-bottom: 1px solid var(--border-light); }
@media (min-width: 768px) {
  .section-row { flex-direction: row; gap: 40px; }
  .section-row.align-center { justify-content: center; text-align: center; }
  .section-title { width: 25%; flex-shrink: 0; }
  .section-content { flex: 1; }
}
.section-title h2 { font-size: 1.8rem; margin-bottom: 20px; font-weight: 600; }
.pb-80 { padding-bottom: 80px; }

/* Biography */
.profile-header { max-width: 800px; margin: 0 auto; }
.avatar-large { width: 180px; height: 180px; border-radius: 50%; object-fit: cover; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.name-title { font-size: 1.8rem; margin-bottom: 5px; font-weight: 700; }
.role-title { font-size: 1.1rem; color: var(--text-muted); font-weight: normal; margin-bottom: 20px; }
.bio-desc { font-size: 1.05rem; margin-bottom: 30px; text-align: left; }

.profile-details { display: grid; grid-template-columns: 1fr; gap: 30px; text-align: left; margin-top: 40px; }
@media (min-width: 768px) { .profile-details { grid-template-columns: repeat(3, 1fr); gap: 30px; } }
.profile-block { background: var(--bg-section); padding: 25px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: transform 0.2s; border: 1px solid var(--border-light); }
.profile-block:hover { transform: translateY(-3px); }
.profile-block h4 { margin-bottom: 20px; font-size: 1.15rem; color: var(--text-main); border-bottom: 2px solid var(--border-light); padding-bottom: 10px; display: inline-block; }
.profile-block ul { list-style: none; padding: 0; }
.profile-block li { margin-bottom: 12px; display: flex; align-items: center; gap: 12px; font-size: 0.95rem; }
.profile-block i { width: 20px; text-align: center; color: var(--primary); font-size: 1.1rem; }
.edu-item { display: flex; gap: 12px; margin-bottom: 15px; align-items: flex-start !important; }
.edu-item i { margin-top: 4px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.contact-list a { color: var(--text-main); text-decoration: none; transition: color 0.2s; }
.contact-list a:hover { color: var(--primary); text-decoration: none; }

.profile-mini-cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .profile-mini-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.mini-link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-section);
  color: var(--text-main);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mini-link-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.mini-link-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  flex-shrink: 0;
}

.mini-link-logo.robocon-logo {
  width: 98px;
  height: 38px;
  padding: 3px 6px;
  background: #1f2430;
  border-radius: 6px;
}

.mini-link-card span {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Timeline (Experience & Awards) */
.vertical-timeline {
  position: relative;
  padding-left: 28px;
}

.vertical-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), var(--border-light));
}

.vertical-timeline .tl-item, .vertical-timeline .award-item {
  position: relative;
  margin-bottom: 22px;
}

.vertical-timeline .tl-item:last-child, .vertical-timeline .award-item:last-child {
  margin-bottom: 0;
}

.vertical-timeline .tl-item::before, .vertical-timeline .award-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 12px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-body);
  border: 2px solid var(--primary);
}

.tl-card {
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tl-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.tl-date {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: rgba(41, 98, 255, 0.12);
  border: 1px solid rgba(41, 98, 255, 0.28);
}

.tl-title {
  margin-bottom: 6px;
  font-size: 1.08rem;
  line-height: 1.35;
}

.tl-org {
  margin-bottom: 8px;
  font-size: 1.12rem;
  color: var(--text-main);
  font-weight: 700;
}

.tl-role {
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tl-org a {
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 1px solid rgba(41, 98, 255, 0.35);
}

.tl-org a:hover {
  color: var(--primary);
}

.tl-desc {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.75;
}

.tl-link {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.tl-link:hover {
  border-color: var(--primary);
  text-decoration: none;
}

@media (max-width: 767px) {
  .vertical-timeline {
    padding-left: 22px;
  }

  .vertical-timeline .tl-item::before,
  .vertical-timeline .award-item::before {
    left: -20px;
  }
}

/* Clickable Cards */
#projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.proj-card {
  cursor: pointer;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
  display: grid;
  grid-template-columns: 1fr;
  color: inherit;
  overflow: hidden;
  background: var(--bg-section);
}

.proj-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

@media (min-width: 768px) {
  .proj-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 260px;
  }
}

.proj-info {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.proj-info h4 {
  margin-bottom: 12px;
  color: var(--primary);
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1.35;
}

.proj-info p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.75;
}

.proj-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.proj-cta i {
  transition: transform 0.2s ease;
}

.proj-card:hover .proj-cta i {
  transform: translateX(4px);
}

.proj-cover {
  width: 100%;
  overflow: hidden;
  background: var(--bg-body);
  border-top: 1px solid var(--border-light);
}

@media (min-width: 768px) {
  .proj-cover {
    border-top: none;
    border-left: 1px solid var(--border-light);
  }
}

.proj-cover img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.proj-card:hover .proj-cover img {
  transform: scale(1.04);
}

.proj-card:hover .proj-info h4 {
  text-decoration: underline;
}
.btn-link { display: inline-block; margin-top: 15px; font-weight: bold; color: var(--primary); }

/* Gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.gallery-item { cursor: pointer; transition: transform 0.2s; border-radius: var(--radius-md); overflow: hidden; }
.gallery-item:hover { transform: translateY(-3px); }
.img-wrap { width: 100%; aspect-ratio: 3/2; overflow: hidden; background: var(--bg-section); }
.img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.gallery-item:hover .img-wrap img { transform: scale(1.05); }
.gallery-item h5 { padding: 10px 0; text-align: center; }

/* Contacts & Footer */
.social-links a { color: var(--text-muted); font-size: 1.5rem; margin-right: 15px; transition: color 0.2s; }
.social-links a:hover { color: var(--primary); }
.mt-20 { margin-top: 20px; }
.site-footer { text-align: center; padding: 20px; color: var(--text-muted); border-top: 1px solid var(--border-light); }

/* Modal System */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-container { background: var(--bg-body); width: 90%; max-width: 800px; max-height: 90vh; border-radius: var(--radius-md); overflow-y: auto; position: relative; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); transform: translateY(20px); transition: transform 0.3s; }
.modal-overlay.active .modal-container { transform: translateY(0); }
.modal-close { position: absolute; top: 15px; right: 15px; background: transparent; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-main); line-height: 1; }
.modal-close:hover { color: var(--primary); }
.detail-art h1, .project-detail-header h1 { margin-bottom: 10px; font-size: 2rem; }
.detail-art p, .project-detail-header p { margin-bottom: 20px; }
.detail-art img, .project-detail-header img { max-width: 100%; border-radius: var(--radius-md); margin-top: 20px; margin-bottom: 20px; display: block; }

.nav-back a { color: var(--text-main); font-weight: 500; text-decoration: none; }
.nav-back a:hover { color: var(--primary); }
