:root {
  color-scheme: light dark;
  --paper: #fcfaf6;
  --ink: #202020;
  --muted: #60615e;
  --hover: #f5efec;
  --accent: #9b5752;
  --code-bg: #eae4dc;
  --code-ink: #33312f;
  --code-border: #b8aba0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191b1b; --ink: #e9e7e1; --muted: #aaa9a3;
    --hover: #272a29; --accent: #e2a5a0;
    --code-bg: #222829; --code-ink: #e6e6dd; --code-border: #536160;
  }
}

:root[data-theme="dark"] {
  --paper: #191b1b; --ink: #e9e7e1; --muted: #aaa9a3;
  --hover: #272a29; --accent: #e2a5a0;
  --code-bg: #222829; --code-ink: #e6e6dd; --code-border: #536160;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 5px; }

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 2;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--ink);
}
.skip-link:focus { top: 12px; }

.site {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ink);
}

.site-header,
.site-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-inline: clamp(24px, 2.8vw, 47px);
}

.site-header {
  min-height: 83px;
  flex: none;
  border-bottom: 1px solid var(--ink);
}

.name {
  font: 400 clamp(23px, 1.8vw, 30px)/1 Georgia, 'Times New Roman', serif;
  letter-spacing: -.025em;
  text-decoration: none;
  white-space: nowrap;
}

.site-header nav {
  display: block;
  margin-left: auto;
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: clamp(18px, 2.5vw, 38px); margin-left: auto; }
.header-actions nav { margin-left: 0; }
.theme-toggle {
  flex: none; border: 1px solid var(--ink); border-radius: 0;
  padding: 8px 10px; background: transparent; color: var(--ink);
  font: 12px/1.2 'Courier New', Courier, monospace; cursor: pointer;
}
.theme-toggle:hover { background: var(--hover); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.language-toggle { font: 12px/1.2 'Courier New', Courier, monospace; text-decoration: none; }
.article-language-toggle { display: inline-block; margin: 0 0 12px; padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; }
.article-language-toggle:hover { text-decoration: underline; text-underline-offset: 4px; }

.site-header nav a {
  display: inline-block;
  margin-left: clamp(25px, 3.2vw, 54px);
  font: 400 clamp(16px, 1.15vw, 20px)/1.3 Georgia, 'Times New Roman', serif;
  text-decoration: none;
}

.site-header a:hover,
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }

.hero {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 35px 42px;
}

.hero-inner {
  width: min(100%, 950px);
  display: flex;
  align-items: center;
  gap: clamp(45px, 7vw, 85px);
}

.intro {
  flex: 0 1 420px;
  font: 400 clamp(15px, 1.05vw, 18px)/1.52 'Courier New', Courier, monospace;
  letter-spacing: -.015em;
  transform: translateY(45px);
}

.intro h1 {
  margin: 0;
  font: inherit;
}

.intro p { margin: 0 0 26px; }
.intro p:last-child { margin-bottom: 0; }

.portrait {
  display: block;
  flex: 0 1 400px;
  width: 100%;
  max-width: 400px;
  height: auto;
  max-height: min(58svh, 570px);
  object-fit: contain;
  align-self: center;
  transform: translateY(10px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .portrait,
  :root:not([data-theme="light"]) .about-portrait { filter: drop-shadow(0 0 55px rgba(233, 231, 225, .23)); }
}
:root[data-theme="dark"] .portrait,
:root[data-theme="dark"] .about-portrait { filter: drop-shadow(0 0 55px rgba(233, 231, 225, .23)); }

.site-footer {
  min-height: 83px;
  flex: none;
  border-top: 1px solid var(--ink);
  font: 400 clamp(14px, .95vw, 17px)/1.4 'Courier New', Courier, monospace;
}

.site-footer a { text-decoration: none; }
.social-links { display: flex; align-items: center; gap: 16px; }
.social-links a { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; }
.social-links svg { width: 19px; height: 19px; fill: currentColor; }

@media (max-width: 900px) and (min-width: 651px) {
  .site-header nav a { margin-left: 18px; font-size: 16px; }
  .header-actions { gap: 15px; }
  .site-footer { flex-wrap: wrap; padding-block: 15px; }
}

@media (max-width: 980px) {
  .hero-inner { width: min(100%, 800px); gap: 50px; }
  .intro { flex-basis: 350px; transform: none; }
  .portrait { max-height: 54svh; }
}

@media (max-width: 800px) {
  .hero { display: block; padding: 65px 32px 50px; }
  .hero-inner { display: block; width: min(100%, 600px); margin: 0 auto; }
  .intro { width: min(100%, 520px); }
  .portrait { width: min(100%, 380px); margin: 28px auto 0; transform: none; }
}

@media (max-width: 650px) {
  .site { display: block; }
  .site-header { display: block; min-height: 0; padding: 20px 22px 18px; }
  .name { display: block; margin-bottom: 19px; }
  .header-actions { gap: 12px; justify-content: space-between; }
  .site-header nav { width: 100%; display: flex; justify-content: space-between; gap: 12px; margin-left: 0; }
  .site-header nav a { font-size: 15px; margin-left: 0; }
  .theme-toggle { font-size: 11px; padding: 6px; white-space: nowrap; }
  .language-toggle { font-size: 11px; }
  .hero { display: block; padding: 72px 25px 40px; }
  .hero-inner { display: block; width: min(100%, 430px); margin: 0 auto; }
  .intro { flex-basis: auto; font-size: clamp(15px, 3.5vw, 17px); }
  .portrait { display: block; width: 100%; max-width: 380px; max-height: none; margin: 35px auto 0; transform: none; }
  .site-footer { display: block; min-height: 0; padding: 16px 22px; }
  .social-links { margin-top: 9px; }
}

@media (max-width: 350px) {
  .site-header nav a { font-size: 13px; }
  .header-actions { align-items: flex-start; flex-wrap: wrap; }
  .intro { font-size: 14px; }
  .site-footer { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
