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

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1f2933;
  --muted: #64707d;
  --link: #2457a6;
  --border: #e6e8eb;
  --header-bg: #ffffff;
  --toggle-bg: #f8fafc;
  --toggle-border: #cfd6dd;
  --toggle-icon: #1f2933;
  --max-width: 700px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d0f12;
    --text: #e5e7eb;
    --muted: #a7b0bb;
    --link: #8bb8ff;
    --border: #262b31;
    --header-bg: #0d0f12;
    --toggle-bg: #171b20;
    --toggle-border: #3a4149;
    --toggle-icon: #e5e7eb;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1f2933;
  --muted: #64707d;
  --link: #2457a6;
  --border: #e6e8eb;
  --header-bg: #ffffff;
  --toggle-bg: #f8fafc;
  --toggle-border: #cfd6dd;
  --toggle-icon: #1f2933;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --text: #e5e7eb;
  --muted: #a7b0bb;
  --link: #8bb8ff;
  --border: #262b31;
  --header-bg: #0d0f12;
  --toggle-bg: #171b20;
  --toggle-border: #3a4149;
  --toggle-icon: #e5e7eb;
}

html {
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.7;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(100% - 2rem, var(--max-width));
  margin: 0 auto;
}

.site-header {
  background: var(--header-bg);
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--border);
}

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

.site-name {
  color: var(--text);
  flex: 0 1 auto;
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-header nav ul {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a:focus {
  color: var(--link);
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--toggle-border);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--toggle-icon);
  cursor: pointer;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

.theme-toggle-icon {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -0.35rem 0 0 currentColor;
}

:root[data-theme="dark"] .theme-toggle-icon,
:root:not([data-theme]) .theme-toggle-icon {
  box-shadow: inset 0.35rem 0 0 currentColor;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle-icon {
    box-shadow: inset -0.35rem 0 0 currentColor;
  }
}

.main-content {
  flex: 1;
  padding: 3.5rem 0 4rem;
}

.intro {
  margin-bottom: 3rem;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.25;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 7vw, 3rem);
  letter-spacing: 0;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.15rem;
}

h3 {
  margin: 1.5rem 0 0.25rem;
  font-size: 1rem;
}

p {
  margin: 1rem 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1.5;
}

.section {
  margin-top: 2.5rem;
}

.simple-list {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

.simple-list li {
  margin: 0.25rem 0;
}

.writing-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.writing-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.writing-list a {
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
}

.writing-list a:hover {
  color: var(--link);
  text-decoration: underline;
}

.featured-writing {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.featured-writing li {
  padding: 1.15rem 0;
}

.featured-writing a {
  font-size: 1.25rem;
  line-height: 1.35;
}

.date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.links a {
  color: var(--link);
}

.post-content {
  font-size: 1.05rem;
}

.post-content h1 {
  margin-top: 0.5rem;
  font-size: clamp(2rem, 6vw, 2.6rem);
}

.post-content h2 {
  margin-top: 2.25rem;
  font-size: 1.3rem;
}

.post-date {
  color: var(--muted);
  font-size: 0.95rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
}

.post-content hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.site-footer {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .nav-container {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .site-name {
    flex: 1 1 calc(100% - 60px);
  }

  .nav-actions {
    display: contents;
  }

  .site-header nav {
    order: 3;
    width: 100%;
  }

  .site-header nav ul {
    gap: 0.8rem;
  }

  .main-content {
    padding-top: 2.5rem;
  }

  .writing-list li {
    display: block;
  }

  .date {
    display: block;
    margin-top: 0.15rem;
  }
}
