:root {
  font-family: var(--font-family, 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.6;
  --content-width: 1200px;
  --gutter: 2rem;
  /* Base colors - these are overridden by themes.css when loaded */
  --bg-color: #ece4d7;
  --text-color: #111;
  --border-color: rgba(0, 0, 0, 0.08);
  --divider-color: rgba(0, 0, 0, 0.15);
  color: var(--text-color, #111);
  background-color: var(--bg-color, #ece4d7);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2.5rem var(--gutter) 3rem;
  max-width: var(--content-width);
  min-height: 100vh;
  margin-left: auto;
  margin-right: auto;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--link-underline, rgba(0, 0, 0, 0.25));
}

a:hover,
a:focus {
  text-decoration-color: var(--link-underline-hover, rgba(0, 0, 0, 0.65));
}

.site-header {
  border-bottom: 1px solid var(--divider-color, rgba(0, 0, 0, 0.15));
  padding-bottom: 1.5rem;
  margin-bottom: 1.0rem;
}

.eyebrow {
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin: 0 0 0.25rem;
  color: var(--text-muted, rgba(0, 0, 0, 0.65));
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-top h1 {
  margin: 0;
}

.lede {
  max-width: 42ch;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.social-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline, rgba(0, 0, 0, 0.2));
  padding-bottom: 1px;
  line-height: 1.2;
}

.icon {
  width: 0.875rem;
  height: 0.875rem;
  display: inline-flex;
  opacity: var(--icon-opacity, 0.8);
  line-height: 0;
  position: relative;
  top: 0.08rem;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--divider-color, rgba(0, 0, 0, 0.15));
  padding-top: 1.5rem;
  margin-bottom: 1rem;
}

main section:first-of-type .section-heading {
  border-top: none;
  padding-top: 0;
}

main section:first-of-type {
  margin-top: 0;
}

.projects {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.work-section {
  margin-bottom: 2.5rem;
}

.work-body {
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  padding: 1.5rem;
  background: var(--card-bg, rgba(255, 255, 255, 0.65));
}

.work-entry h3 {
  margin: 0;
}

.work-entry + .work-entry {
  margin-top: 1rem;
}

.work-meta {
  margin: 0.25rem 0 0.75rem;
  color: var(--text-subtle, rgba(0, 0, 0, 0.6));
  font-size: 0.95rem;
}

.work-entry ul {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
}

.work-entry li {
  margin-bottom: 0.45rem;
}

.cp-section {
  margin-top: 0;
}

.cp-body {
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  padding: 1.5rem;
  background: var(--card-bg, rgba(255, 255, 255, 0.65));
}

.cp-instructions {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--text-muted, rgba(0, 0, 0, 0.65));
}

.cp-body ul {
  margin-top: 0.75rem;
  padding-left: 1.25rem;
}

.cp-body li {
  margin-bottom: 0.5rem;
}

.project-card {
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--card-bg, rgba(255, 255, 255, 0.65));
}

.project-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.project-summary h3 {
  margin: 0;
  font-size: 1.25rem;
}

.project-description {
  margin: 0;
  opacity: 0.85;
}

.project-tags {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted, rgba(0, 0, 0, 0.55));
}

.project-detail {
  margin: 0.25rem 0 0;
  opacity: 0.78;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.project-links a {
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline, rgba(0, 0, 0, 0.25));
  padding-bottom: 1px;
}

.project-media {
  margin: 0;
}

.project-media video {
  width: 100%;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  background: var(--card-bg, #fff);
}

.project-media figcaption {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted, rgba(0, 0, 0, 0.65));
}

footer {
  margin-top: 3rem;
  border-top: 1px solid var(--divider-color, rgba(0, 0, 0, 0.15));
  padding-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-subtle, rgba(0, 0, 0, 0.6));
}

/* Header actions */
.header-actions {
  display: flex;
  gap: 0.5rem;
}

.theme-wrapper {
  position: relative;
}

/* Contact button */
.contact-button {
  padding: 0.5rem 1rem;
  background: #111;
  color: #ece4d7;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.contact-button:hover,
.contact-button:focus {
  background: rgba(17, 17, 17, 0.85);
}

/* Contact modal */
.contact-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.contact-modal[hidden] {
  display: none;
}

.contact-modal-content {
  background: #ece4d7;
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.contact-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.5);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.contact-close:hover,
.contact-close:focus {
  color: rgba(0, 0, 0, 0.8);
}

.contact-modal-content h2 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.65);
  border: var(--border);
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.contact-link:hover,
.contact-link:focus {
  background: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.contact-link .icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0.9;
}

@media (max-width: 640px) {
  body {
    padding: 1.5rem var(--gutter) 2rem;
  }

  .project-card {
    padding: 1.25rem;
  }

  .contact-button {
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
  }

  .contact-modal-content {
    padding: 1.5rem;
  }

  .contact-modal-content h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }
}

/* Codeforces rank colors */
.cf-purple {
  color: var(--cf-purple, #9c1fa4);
  font-weight: bold;
}
