:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --accent-color: #4a90d9;
  --accent-hover: #3a7bc8;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
  --timeline-line: var(--accent-color);
  --timeline-dot: var(--accent-color);
  --header-bg: rgba(255, 255, 255, 0.85);
  --transition-theme: 0.3s ease;
  --skill-tag-bg: #e8f0fe;
  --skill-tag-text: #1a73e8;
}

[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16162a;
  --bg-card: #252542;
  --text-primary: #eaeaea;
  --text-secondary: #b0b0c0;
  --accent-color: #6ab0ff;
  --accent-hover: #8ac4ff;
  --border-color: #3a3a5c;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --timeline-line: var(--accent-color);
  --timeline-dot: var(--accent-color);
  --header-bg: rgba(26, 26, 46, 0.85);
  --skill-tag-bg: #2a3a5c;
  --skill-tag-text: #8ac4ff;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

li {
  margin-bottom: 0.5rem;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-theme);
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: transform 0.3s ease, background-color var(--transition-theme);
}

.theme-toggle:hover {
  background-color: var(--bg-secondary);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.pdf-button {
  background-color: var(--accent-color);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: background-color var(--transition-theme), transform 0.2s ease;
}

.pdf-button:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
}

.section {
  padding: 3rem 0;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.timeline {
  position: relative;
  padding-left: 40px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--timeline-line);
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -34px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--timeline-dot);
  border: 3px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

.timeline-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: box-shadow var(--transition-theme), background-color var(--transition-theme);
}

.timeline-card:hover {
  box-shadow: var(--shadow-md);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
  gap: 1rem;
}

.timeline-card-title {
  flex: 1;
}

.timeline-card-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.expand-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  transition: transform 0.3s ease, background-color var(--transition-theme);
  flex-shrink: 0;
}

.expand-indicator svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
}

.timeline-card.expanded .expand-indicator {
  transform: rotate(180deg);
}

.timeline-card-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
}

.timeline-card.expanded .timeline-card-content {
  max-height: 1000px;
  opacity: 1;
}

.timeline-card-details {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  margin-top: 1rem;
}

.timeline-card-details ul {
  list-style: none;
  padding-left: 0;
}

.timeline-card-details li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.timeline-card-details li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-color);
  font-weight: bold;
}

.skills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.skill-tag {
  background: var(--skill-tag-bg);
  color: var(--skill-tag-text);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.skill-category {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-theme), border-color var(--transition-theme);
}

.skill-category h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--accent-color);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.profile-section {
  text-align: center;
  padding: 2rem 0;
}

.summary-text {
  text-align: justify;
  line-height: 1.8;
}

.profile-name {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: center;
}

.profile-title {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-align: center;
}

.profile-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.profile-contact a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color var(--transition-theme);
}

.profile-contact a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.contact-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.contact-item svg {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .app-container {
    padding: 1rem;
  }

  .header {
    padding: 1rem;
  }

  .timeline {
    padding-left: 30px;
  }

  .timeline::before {
    left: 6px;
  }

  .timeline-item::before {
    left: -29px;
    width: 10px;
    height: 10px;
  }

  .timeline-card {
    padding: 1rem;
  }

  .timeline-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .expand-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
  }

  .profile-name {
    font-size: 2rem;
  }

  .profile-contact {
    flex-direction: column;
    gap: 0.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

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

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .timeline {
    padding-left: 24px;
  }

  .timeline::before {
    left: 2px;
  }

  .timeline-item::before {
    left: -27px;
  }

  .pdf-button {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .theme-toggle {
    padding: 0.4rem;
  }

  .theme-toggle svg {
    width: 20px;
    height: 20px;
  }
}

/* Experience Header */
.experience-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.experience-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.experience-company {
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent-color);
  margin-bottom: 0.25rem;
}

.experience-location {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.experience-date-range {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Programs List */
.programs-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.program-item {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  border-left: 3px solid var(--accent-color);
}

.program-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.program-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.program-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 200px;
}

.program-date-badge {
  background: var(--accent-color);
  color: #ffffff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.program-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0.5rem 0;
  text-align: justify;
}

.project-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0.5rem 0;
  text-align: justify;
}

.program-details {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.program-details.expanded {
  max-height: 2000px;
  opacity: 1;
}

.program-bullets {
  list-style: none;
  padding-left: 0;
  margin: 0.5rem 0 0 0;
}

.program-bullets li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: justify;
}

.program-bullets li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-color);
  font-size: 0.8rem;
}

.program-expand-btn {
  background: transparent;
  border: none;
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  text-align: left;
  transition: color 0.2s ease;
}

.program-expand-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Mobile Responsive for Programs */
@media (max-width: 600px) {
  .program-title-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .program-date-badge {
    align-self: flex-start;
  }

  .experience-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .experience-date-range {
    order: -1;
  }
}

/* Context Modal (Port 8081) */
.context-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.context-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.context-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 75vw;
  max-width: 900px;
  height: auto;
  max-height: 85vh;
  background: var(--bg-card);
  border: 2px solid var(--accent-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  flex-direction: column;
}

.context-modal.visible {
  opacity: 1;
  visibility: visible;
}

.context-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 10px 10px 0 0;
}

.context-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
  margin: 0;
}

.context-modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
}

.context-modal-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.context-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.context-content {
  font-size: 0.95rem;
  line-height: 1.7;
}

.context-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

.context-content figure {
  margin: 1rem 0;
}

.context-content figcaption {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 0.5rem;
  font-style: italic;
}

.context-content .video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1rem 0;
}

.context-content .video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.context-content h1,
.context-content h2,
.context-content h3 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem 0;
  color: var(--accent-color);
}

.context-content h1:first-child,
.context-content h2:first-child,
.context-content h3:first-child {
  margin-top: 0;
}

.context-content p {
  margin: 0.5rem 0;
  text-align: justify;
}

.context-content ul,
.context-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.context-content li {
  margin: 0.25rem 0;
  text-align: justify;
}

.context-content code {
  background: var(--bg-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.context-content pre {
  background: var(--bg-secondary);
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
}

.context-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
}

.context-content th,
.context-content td {
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.context-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.context-content.loading {
  color: var(--text-secondary);
  font-style: italic;
}

.context-hint {
  font-size: 0.75rem;
  opacity: 0.6;
  cursor: pointer;
  margin-left: 0.5rem;
}

.project-item,
.program-item {
  position: relative;
}

@media (max-width: 768px) {
  .context-modal {
    width: 95vw;
    max-height: 90vh;
  }

  .context-modal-header {
    padding: 0.75rem 1rem;
  }

  .context-modal-body {
    padding: 1rem;
  }
}
