:root {
  --bg: #121212;
  --surface: #1a1a1a;
  --card: #1e1e1e;
  --text: #e8e8e8;
  --text-secondary: #a0a0a0;
  --accent: #38bdf8;
  --accent-badge: #0d9488;
  --border: rgba(255, 255, 255, 0.08);
  --link: #38bdf8;
  --header-bg: rgba(18, 18, 18, 0.92);
  --ascii-color: rgba(56, 189, 248, 0.65);
  --btn-overlay: rgba(0, 0, 0, 0.55);
  --media-fade: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #f0f0f0;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --accent: #0284c7;
  --accent-badge: #0d9488;
  --border: rgba(0, 0, 0, 0.08);
  --link: #0284c7;
  --header-bg: rgba(250, 250, 250, 0.92);
  --ascii-color: rgba(2, 132, 199, 0.6);
  --btn-overlay: rgba(255, 255, 255, 0.88);
  --media-fade: rgba(255, 255, 255, 0.15);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 10px 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus {
  left: 8px;
}

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

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.site-header__name:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 24px;
}

.site-nav__link {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.site-nav__link:hover,
.site-nav__link.is-active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-header__utils {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-toggle,
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.lang-toggle:hover,
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.lang-toggle [data-lang].is-active {
  color: var(--accent);
  font-weight: 600;
}
.theme-toggle {
  display: grid;
  place-items: center;
  padding: 6px 8px;
}

.theme-icon--moon {
  display: none;
}

[data-theme="light"] .theme-icon--sun {
  display: none;
}

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

/* ── Main ── */
.site-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

.page {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── About ── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 48px;
  align-items: start;
}

.about-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.about-affiliation {
  color: var(--text-secondary);
  margin: 0 0 4px;
  font-size: 15px;
}

.about-email {
  margin: 0 0 24px;
  font-size: 15px;
}
.about-email a {
  color: var(--link);
}

.about-bio {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 15px;
}

.about-subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 28px 0 12px;
}

.about-interests {
  margin: 0 0 28px;
  padding-left: 20px;
  font-size: 15px;
}
.about-interests li {
  margin-bottom: 8px;
}
.about-interests li strong {
  color: var(--text);
  font-weight: 600;
}

.about-status {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  margin: 32px 0 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.about-portrait {
  margin: 0;
  width: 240px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  display: grid;
  place-items: center;
}

.about-portrait__ascii {
  margin: 0;
  padding: 0;
  color: var(--ascii-color);
  font-family: "Courier New", Courier, monospace;
  font-size: 2.65px;
  line-height: 1.05;
  white-space: pre;
  user-select: none;
}

/* ── Contact ── */
.contact-section {
  margin-top: 56px;
  text-align: center;
}

.contact-section__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.contact-section__text {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto 28px;
}

.contact-icons {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.contact-icon {
  color: var(--text);
  transition: color 0.15s, transform 0.15s;
}
.contact-icon:hover {
  color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

/* ── CV ── */
.cv-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 40px;
  align-items: start;
}

.cv-sidebar {
  position: sticky;
  top: 80px;
}

.cv-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cv-sidebar__link {
  display: block;
  padding: 8px 0 8px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.cv-sidebar__link:hover,
.cv-sidebar__link.is-active {
  color: var(--text);
  border-left-color: var(--accent);
  text-decoration: none;
}

.cv-header {
  margin-bottom: 32px;
  position: relative;
}

.cv-header__title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.cv-header__subtitle {
  color: var(--text-secondary);
  margin: 0;
  font-size: 15px;
}

.cv-header__pdf {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.cv-header__pdf:hover {
  border-color: var(--accent);
  background: var(--card);
  text-decoration: none;
}
.cv-header__pdf-icon {
  flex-shrink: 0;
  color: var(--accent);
}
.cv-header__pdf-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.cv-header__pdf-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cv-header__pdf-hint {
  font-size: 11px;
  color: var(--text-secondary);
}

.cv-header__pdf--disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.cv-header__pdf--disabled .cv-header__pdf-icon {
  color: var(--text-secondary);
}
.cv-header__pdf--disabled .cv-header__pdf-hint {
  color: #f59e0b;
}
[data-theme="light"] .cv-header__pdf--disabled .cv-header__pdf-hint {
  color: #d97706;
}

.cv-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
}

.cv-card__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 24px;
}

.cv-entry {
  margin-bottom: 28px;
}
.cv-entry:last-child {
  margin-bottom: 0;
}

.cv-badge {
  display: inline-block;
  background: var(--accent-badge);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.cv-entry__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
}

.cv-entry__org {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 10px;
}

.cv-icon {
  flex-shrink: 0;
  color: var(--accent-badge);
}

.cv-entry__list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-secondary);
}
.cv-entry__list li {
  margin-bottom: 4px;
}

.cv-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  font-style: italic;
}

.cv-skills-group {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.cv-skills-group:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.cv-skills-group__title {
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 10px;
  color: var(--text);
}

.cv-skills-group__list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: disc;
}

/* ── Projects ── */
.projects-header {
  margin-bottom: 32px;
}

.projects-header__title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.projects-header__subtitle {
  color: var(--text-secondary);
  margin: 0;
  font-size: 15px;
}

.projects-block {
  width: 100%;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: normal;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}

.project-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: border-color 0.15s;
}
.project-card:hover {
  border-color: rgba(56, 189, 248, 0.25);
}

.project-media {
  position: relative;
  height: 180px;
  background: var(--surface);
  overflow: hidden;
}
.project-media--placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-bottom: 1px dashed var(--border);
}
.project-media__placeholder-icon {
  color: var(--accent);
  opacity: 0.5;
}
.project-media__placeholder-label {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 500;
}
.project-media__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.project-media__fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, var(--media-fade));
  pointer-events: none;
}

.project-nav {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  pointer-events: none;
}
.project-nav__btn {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--btn-overlay);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.15s;
}
.project-card:hover .project-nav__btn {
  opacity: 1;
}
.project-nav__btn[aria-hidden="true"] {
  display: none;
}

.project-content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.project-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.project-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tag {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.project-actions {
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-github,
.project-web {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.project-github:hover,
.project-web:hover {
  border-color: var(--accent);
  background: var(--card);
  text-decoration: none;
}

.project-github__icon {
  width: 16px;
  height: 16px;
}

[data-theme="light"] .project-github__icon {
  filter: invert(1);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .site-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .site-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 20px;
  }

  .site-main {
    padding: 32px 16px 64px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .about-portrait {
    order: -1;
    width: min(240px, 100%);
    margin: 0 auto;
  }

  .about-portrait__ascii {
    font-size: 2.65px;
  }

  .cv-layout {
    grid-template-columns: 1fr;
  }

  .cv-sidebar {
    position: static;
  }

  .cv-sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .cv-sidebar__link {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 6px 8px;
  }
  .cv-sidebar__link.is-active {
    border-left: none;
    border-bottom-color: var(--accent);
  }

  .cv-header__pdf {
    position: static;
    display: inline-flex;
    margin-top: 12px;
  }
}
