:root {
  --paper: #fcfcfb;
  --ink: #17191c;
  --graphite: #5d636b;
  --faint: #868c94;
  --hairline: #e4e6e8;
  --mask: #eef0f1;
  --accent: #0d6b58;
  --accent-soft: rgba(13, 107, 88, 0.3);
  --accent-wash: rgba(13, 107, 88, 0.08);

  --serif: 'Spectral', Georgia, serif;
  --sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141719;
    --ink: #e7e9ea;
    --graphite: #a2a8ae;
    --faint: #7f868d;
    --hairline: #2a2f33;
    --mask: #1f2427;
    --accent: #63c2a6;
    --accent-soft: rgba(99, 194, 166, 0.35);
    --accent-wash: rgba(99, 194, 166, 0.1);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #141719;
  --ink: #e7e9ea;
  --graphite: #a2a8ae;
  --faint: #7f868d;
  --hairline: #2a2f33;
  --mask: #1f2427;
  --accent: #63c2a6;
  --accent-soft: rgba(99, 194, 166, 0.35);
  --accent-wash: rgba(99, 194, 166, 0.1);
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

a {
  color: var(--accent);
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--accent-soft);
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  column-gap: 104px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 0;
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portrait {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 24%;
  outline: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  outline-offset: -1px;
  box-shadow: 0 14px 30px -16px rgba(23, 25, 28, 0.45);
}

.name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 28px 0 2px;
}

.name-ko {
  color: var(--faint);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
}

.affiliation {
  color: var(--graphite);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
}

.social {
  display: flex;
  gap: 6px;
  margin-top: 18px;
}

.social a {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.social a:hover {
  background: var(--accent-wash);
  color: var(--accent);
}

.social svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.social svg.filled {
  fill: currentColor;
  stroke: none;
}

/* Causal attention map: decodes row by row, and can be inspected on hover. */
.attn {
  --base: 450ms;
  display: grid;
  grid-template-columns: repeat(10, 7px);
  grid-auto-rows: 7px;
  gap: 2px;
  margin-top: 30px;
  cursor: crosshair;
}

.attn i {
  border-radius: 1.5px;
  background: var(--mask);
  transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.attn i.w {
  background: var(--accent);
  opacity: var(--w);
}

.attn.replay {
  --base: 60ms;
}

.attn.play i.w {
  animation: attn-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--base) + var(--r) * 75ms + var(--c) * 14ms);
}

@keyframes attn-in {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
}

.attn.inspect i.w {
  opacity: calc(var(--w) * 0.22);
}

.attn.inspect i.q.w {
  opacity: var(--w);
}

.attn.inspect i.q:not(.w) {
  background: var(--hairline);
}

.attn i.k {
  transform: scale(1.4);
}

.attn-caption {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--graphite);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: 20px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--graphite);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
}

.track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--hairline);
  transition: background-color 0.25s ease;
}

.thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.theme-toggle[aria-checked="true"] .track {
  background: var(--accent);
}

.theme-toggle[aria-checked="true"] .thumb {
  transform: translateX(12px);
}

.copyright {
  color: var(--faint);
  font-size: 0.8rem;
  margin: 6px 0 0;
}

/* ---------- Content ---------- */

.content {
  max-width: 760px;
  padding: 112px 0 120px;
}

.content section {
  margin-bottom: 64px;
}

.content section:last-child {
  margin-bottom: 0;
}

.content h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.625rem;
  line-height: 1.25;
  margin: 0 0 20px;
}

.content a {
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}

.content a:hover {
  text-decoration-color: currentColor;
}

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

.dated li span {
  text-wrap: pretty;
}

.dated li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  padding: 6px 0;
}

.dated time {
  color: var(--faint);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.entry {
  margin-bottom: 28px;
}

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

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.entry h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}

.entry .date {
  color: var(--faint);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry .meta {
  color: var(--graphite);
  font-size: 0.95rem;
  margin: 2px 0 8px;
}

.entry p:last-child {
  margin-bottom: 0;
}

/* ---------- Entrance: one orchestrated moment ---------- */

.intro .profile > :not(.attn),
.intro .sidebar-foot {
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: var(--in, 0ms);
}

.intro .name {
  --in: 120ms;
}

.intro .name-ko {
  --in: 180ms;
}

.intro .affiliation {
  --in: 240ms;
}

.intro .social {
  --in: 320ms;
}

.intro .sidebar-foot {
  --in: 1100ms;
}

.intro .attn {
  animation: fade 0.5s ease 0.38s both;
}

.intro .content {
  animation: fade 0.6s ease 0.15s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 20px;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 56px 0 0;
  }

  .portrait {
    width: 120px;
    height: 120px;
  }

  .sidebar-foot {
    margin-top: 24px;
  }

  .content {
    max-width: none;
    padding: 56px 0 80px;
  }

  .content section {
    margin-bottom: 52px;
  }

  .dated li {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .entry-head {
    flex-direction: column;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .attn.play i.w {
    animation: none;
  }

  body,
  .track,
  .thumb,
  .social a,
  .content a {
    transition: none;
  }
}
