hr {
  margin-top: 30px;
  margin-bottom: 20px;
}

/* Mobile safety net: stop the whole page from scrolling sideways,
   no matter what's causing it. Equations/code/tables still scroll
   internally via their own overflow-x:auto below. */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Wrapper added by math-scale.js around each display equation, so its
   scaled-down height can be set without affecting surrounding content.
   text-align: center keeps the equation centered, matching MathJax's
   normal look, whether or not it ends up needing to be scaled. */
.mjx-scale-wrapper {
  width: 100%;
  overflow: hidden;
  text-align: center;
}

/* Equations the JS has wrapped must render at their full natural width,
   unclipped, so the transform below shrinks the WHOLE equation rather
   than a portion of it already cropped to the container width.
   inline-block + the wrapper's text-align:center keeps it centered.
   This overrides the overflow-x/max-width fallback rule just below. */
.mjx-scale-wrapper mjx-container {
  display: inline-block !important;
  overflow: visible;
  max-width: none;
  margin: 0 !important;
}

/* Fallback in case an equation isn't caught by the JS scaling (e.g. JS
   disabled): still scroll instead of overflowing the page width.
   mjx-container is MathJax 3's output element for each equation. */
mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  display: block !important;
}

/* General safety net: anything else unexpectedly wide (long code blocks,
   tables) scrolls horizontally in its own box instead of breaking layout */
.post-content pre,
.post-content table {
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

.post-content {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Post navigation links */
.post_navi {
  display: flex;
}

.post_navi-label {
  font-size: 0.8em;
  opacity: 0.5;
}

.post_navi .post_navi-item {
  padding: 0 2.2em;
  width: 50%;
  position: relative;
  color: inherit !important;
}

.post_navi .nav_prev {
  text-align: left;
}

.post_navi .nav_next {
  text-align: right;
}

.post_navi .nav_prev .post_navi-arrow {
  left: 0;
}

.post_navi .nav_next .post_navi-arrow {
  right: 0;
}

.post_navi .post_navi-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5em;
  opacity: 0.3;
}

/* About section on the homepage */
.about {
  display: flex;
  align-items: center;
  gap: 2em;
  margin-bottom: 2.5em;
  flex-wrap: wrap;
}

.about-image {
  width: 220px;
  max-width: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.about-text {
  flex: 1;
  min-width: 260px;
}

/* Project grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5em;
  margin-top: 1.5em;
}

.project-card {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease;
}

.project-card:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.project-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.project-card-body {
  padding: 1em 1.2em 1.2em;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.project-card-date {
  margin-top: auto;
  padding-top: 0.8em;
  font-size: 0.8em;
  opacity: 0.55;
}

.project-card-title {
  margin: 0;
  padding: 0.8em 1.2em 0.6em;
  font-size: 1.2em;
  line-height: 1.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-body p {
  margin: 0.5em 0;
  font-size: 0.95em;
}

.project-card-tags {
  margin-bottom: 0.4em;
}

.project-tag {
  display: inline-block;
  font-size: 0.75em;
  opacity: 0.7;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  padding: 0.1em 0.7em;
  margin: 0 0.3em 0.3em 0;
}

.project-card-links a {
  margin-right: 1em;
  font-size: 0.9em;
}

.project-code-note {
  font-size: 0.9em;
  font-style: italic;
  opacity: 0.6;
}

.project-card-writeups {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin: 0.6em 0;
}

.project-card-writeups a {
  font-size: 0.9em;
}

/* Articles page */
.articles-list {
  margin-top: 1em;
}

.article-entry {
  padding: 0.9em 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.article-date {
  display: inline-block;
  font-size: 0.85em;
  opacity: 0.6;
  min-width: 6.5em;
}

.article-title {
  font-weight: 600;
}

.article-tags {
  margin-top: 0.3em;
}