:root {
  --bg: #f5f7f8;
  --bg-elev: #ffffff;
  --ink: #152028;
  --muted: #5a6670;
  --line: #d8e0e6;
  --accent: #1a5f7a;
  --accent-deep: #0f3f52;
  --accent-soft: #e7f2f6;
  --badge-bg: #eaf2f8;
  --badge-ink: #18526b;
  --max: 46rem;
  --header-max: 72rem;
  --pad: 1.25rem;
  --serif: "Source Serif 4", "Noto Serif", Georgia, serif;
  --sans: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 0.4rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.68;
  color: var(--ink);
  background-color: var(--bg);
  min-height: 100dvh;
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-deep);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.75rem;
  z-index: 100;
}

.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.wrap {
  width: min(100% - 2 * var(--pad), var(--max));
  margin-inline: auto;
}

/* Header & Nav — Spacious & Right-Aligned */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 248, 0.96);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.site-header .wrap {
  width: min(100% - 2 * var(--pad), var(--header-max));
}

.header-inner {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 2rem;
  padding: 0.85rem 0;
  min-height: 4.2rem;
}

.brand {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.95rem;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
  padding: 0.2rem 0;
  transition: opacity 0.15s ease;
}

.brand:hover {
  opacity: 0.9;
}

.brand-mark {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--ink);
}

.brand-sub {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.15rem;
  letter-spacing: 0.01em;
}

.nav {
  margin-left: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.96rem;
  font-weight: 550;
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
  font-weight: 600;
}

/* Main content */
main {
  padding: 2rem 0 3.5rem;
}

/* Intro / Hero */
.intro {
  display: grid;
  gap: 1.35rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
  animation: rise 0.55s ease both;
}

@media (min-width: 680px) {
  .intro {
    grid-template-columns: 8.5rem 1fr;
    align-items: start;
  }
}

.portrait {
  width: 8.5rem;
  height: 8.5rem;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid var(--line);
  background: var(--accent-soft);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.3rem);
  margin: 0 0 0.55rem;
}

.intro h1 {
  font-size: clamp(1.65rem, 3.8vw, 2.15rem);
}

h2 {
  font-size: 1.4rem;
  margin: 0;
}

.lead {
  font-size: 1.1rem;
  color: var(--ink);
  font-weight: 500;
  margin: 0;
  max-width: 38rem;
  line-height: 1.55;
}

.meta-line {
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.meta-line strong {
  color: var(--ink);
}

/* Post list */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.text-link {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post {
  border-bottom: 1px solid var(--line);
}

.post a {
  display: block;
  padding: 1.25rem 0;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.2s ease, color 0.2s ease;
}

.post a:hover {
  color: var(--accent-deep);
}

@media (prefers-reduced-motion: no-preference) {
  .post a:hover {
    transform: translateX(3px);
  }
}

.post h2,
.post h3 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.2rem, 2.7vw, 1.45rem);
}

.post.featured h2 {
  font-size: clamp(1.35rem, 3.2vw, 1.75rem);
}

.post.featured a {
  padding-top: 1.35rem;
  padding-bottom: 1.45rem;
}

.dek {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 42rem;
  line-height: 1.55;
}

.post-meta {
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.category-tag {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-right: 0.4rem;
}

/* Callout Box / Action strip */
.howto-strip {
  margin-top: 2.2rem;
  padding: 1.15rem 1.3rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  border: 1px solid #cfe0e8;
}

.howto-strip p {
  margin: 0;
  line-height: 1.6;
}

/* Page content & Prose */
.page-head {
  margin-bottom: 1.75rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin: 0.35rem 0 0.5rem;
}

.prose {
  max-width: 42rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.15rem;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.75rem;
  padding-top: 0.5rem;
}

.prose h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

/* Timeline & Credentials */
.cv-section {
  margin: 2rem 0;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.cv-section:last-child {
  border-bottom: none;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.timeline-item {
  position: relative;
  padding-left: 1.5rem;
  padding-bottom: 1.25rem;
  border-left: 2px solid var(--line);
}

.timeline-item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: 0.35rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
}

.timeline-date {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent);
  display: block;
}

.timeline-title {
  font-weight: 650;
  font-size: 1.05rem;
  margin: 0.15rem 0;
  color: var(--ink);
}

.timeline-org {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.skill-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.skill-card strong {
  display: block;
  color: var(--accent-deep);
  margin-bottom: 0.2rem;
}

/* Article Components */
.article-head {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.article-head h1 {
  margin: 0.35rem 0 0.75rem;
}

.byline {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-top: 1.15rem;
}

.byline-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--accent-soft);
}

.byline strong {
  display: block;
  font-size: 0.95rem;
}

.byline span {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
}

.article-figure {
  margin: 1.5rem 0 1.75rem;
}

.article-figure img, .article-figure svg {
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.article-figure figcaption {
  max-width: 38rem;
  margin: 0.55rem auto 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}

.note-box {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.note-box h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.note-box p {
  margin: 0;
  font-size: 0.95rem;
}

/* Medical Disclaimer */
.medical-disclaimer {
  margin: 2.2rem 0 0;
  padding: 0.95rem 1.15rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid #e08b28;
  border-radius: var(--radius);
}

.medical-disclaimer p {
  margin: 0;
}

.medical-disclaimer strong {
  color: var(--ink);
}

/* CTA */
.article-cta {
  max-width: 42rem;
  margin: 1.85rem 0 0;
  padding: 1rem 1.2rem;
  background: var(--accent-soft);
  border: 1px solid #cfe0e8;
  border-radius: var(--radius);
}

.article-cta p {
  margin: 0;
}

/* Related */
.related {
  margin-top: 2.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.related h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.related ul {
  padding-left: 1.2rem;
  margin: 0;
}

.related li {
  margin: 0.45rem 0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0 3rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.site-footer .wrap {
  width: min(100% - 2 * var(--pad), var(--header-max));
}

.site-footer p {
  margin: 0.35rem 0;
}

/* Animations */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .intro {
    animation: none;
  }
  .post a:hover {
    transform: none;
  }
}

/* Small Mobile Screen Only (< 540px) */
@media (max-width: 540px) {
  .header-inner {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.65rem !important;
  }
  .nav {
    margin-left: 0 !important;
    justify-content: center !important;
    gap: 0.25rem !important;
  }
  .nav a {
    padding: 0.35rem 0.55rem;
    font-size: 0.88rem;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181c;
    --bg-elev: #1a2228;
    --ink: #e8edf0;
    --muted: #a3b0b9;
    --line: #2c383f;
    --accent: #7fc4dd;
    --accent-deep: #a8dcef;
    --accent-soft: #1b2b33;
    --badge-bg: #1e333d;
    --badge-ink: #9de0f8;
  }

  .site-header {
    background: rgba(18, 24, 28, 0.96);
  }

  .howto-strip,
  .article-cta {
    border-color: #2f4550;
  }

  .portrait,
  .byline-avatar {
    filter: brightness(0.95);
  }

  .skip {
    color: #12181c;
  }
}
