:root {
  --bg: #f3f6fb;
  --bg-strong: #e8edf9;
  --panel: #ffffff;
  --panel-2: #edf3ff;
  --text: #121b2c;
  --muted: #4b5d78;
  --nav-bg: #172033;
  --nav-text: #f5f9ff;
  --nav-muted: rgba(255,255,255,0.72);
  --accent: #68a6ff;
  --accent-strong: #3d7ae7;
  --accent-soft: rgba(104, 166, 255, 0.18);
  --link: #2d6fd3;
  --link-visited: #7651b8;
  --greeting: #007acc;
  --border: rgba(18, 27, 44, 0.12);
  --shadow: rgba(10, 15, 26, 0.18);
  --hr: rgba(18, 27, 44, 0.18);
}

body[data-theme="dark"] {
  --bg: #111315;
  --bg-strong: #181a1d;
  --panel: #1e2125;
  --panel-2: #282c31;
  --text: #f0f2f4;
  --muted: #b4bac1;
  --nav-bg: #25282d;
  --nav-text: #f3f4f5;
  --nav-muted: rgba(243,244,245,0.74);
  --accent: #79d6ff;
  --accent-strong: #4eb9ff;
  --accent-soft: rgba(121, 214, 255, 0.16);
  --link: #83d7ff;
  --link-visited: #c2a6ff;
  --greeting: #ce9178;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: rgba(0, 0, 0, 0.42);
  --hr: rgba(255, 255, 255, 0.16);
}

/* Sensible defaults that preserve browser-normal sizing on mobile. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  --page-gutter: clamp(1rem, 3vw, 2rem);
  padding: 0 var(--page-gutter) var(--page-gutter);
  min-width: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
  color: var(--text);
  font-family: "Fira Mono", monospace;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
  transition: background 220ms ease, color 220ms ease;
}

img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

input,
button,
select,
textarea {
  max-width: 100%;
  font: inherit;
}

hr {
  border: 0;
  border-top: 1px solid var(--hr);
  margin: 1.5rem 0;
}

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--nav-bg);
  border-radius: 0.75rem;
  box-shadow: 0 12px 28px var(--shadow);
}

.mobile-theme-panel {
  display: none;
}

.nav-toggle {
  display: none;
}

.nav-controls {
  position: relative;
  display: flex;
  align-items: center;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: transparent;
  color: var(--nav-text);
  cursor: pointer;
  line-height: 1;
  padding: 0 0 3px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.theme-toggle.is-open {
  transform: rotate(90deg);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 11rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--panel);
  box-shadow: 0 18px 32px var(--shadow);
}

.theme-menu[hidden] {
  display: none;
}

.theme-button {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  white-space: nowrap;
}

.theme-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

header {
  margin-top: 5rem;
}

#greeting {
  color: var(--greeting);
  font-weight: 700;
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

nav a {
  display: block;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  color: var(--nav-text);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
  position: relative;
}

nav a.current-page {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18);
}

nav a:hover,
nav a:focus-visible {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.link-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}

.link-list li + li {
  margin-top: 0.75rem;
}

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

main a,
footer a {
  color: var(--link);
}

main a:visited,
footer a:visited {
  color: var(--link-visited);
}

nav a:focus-visible,
.theme-toggle:focus-visible,
.theme-button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .nav-controls {
    display: none;
  }

  .mobile-theme-panel {
    display: none;
  }

  nav {
    top: 0.5rem;
    right: 0.5rem;
    left: auto;
    width: 3.25rem;
    height: 3.25rem;
    padding: 0;
    border-radius: 50%;
    transition: width 220ms ease, height 220ms ease, top 220ms ease, right 220ms ease, border-radius 220ms ease;
  }

  nav.is-open {
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0.75rem;
  }

  .nav-toggle {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    display: grid;
    width: 3.25rem;
    height: 3.25rem;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #f8fafc;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
  }

  .nav-toggle span {
    display: block;
    line-height: 1;
    transform: none;
  }

  .nav-toggle:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: -4px;
  }

  nav ul {
    display: none;
  }

  nav.is-open ul {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    height: auto;
    padding: 4rem 1rem 0;
  }

  nav.is-open a {
    padding: 0.75rem 1.25rem;
    font-size: 1.25rem;
  }

  nav.is-open .mobile-theme-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 15rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0 0 1rem;
  }

  .mobile-theme-panel hr {
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0;
  }

  .mobile-theme-panel .theme-button {
    width: 100%;
    max-width: 15rem;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    background: rgba(255,255,255,0.08);
    color: #ffffff;
    border-color: rgba(255,255,255,0.12);
  }
}

