:root {
  --width: 720px;
  --font-main: Verdana, sans-serif;
  --font-secondary: Verdana, sans-serif;
  --font-scale: 1em;
  --background-color: #fff;
  --heading-color: #222;
  --text-color: #444;
  --link-color: #3273dc;
  --code-background-color: #f2f2f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #01242e;
    --heading-color: #eee;
    --text-color: #ddd;
    --link-color: #8cc2dd;
    --code-background-color: #000;
  }
}

body {
  font-family: var(--font-main);
  font-size: var(--font-scale);
  color: var(--text-color);
  background: var(--background-color);
  max-width: var(--width);
  margin: 0 auto;
  padding: 20px;
  line-height: 1.5;
  word-wrap: break-word;
}

main {
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--heading-color);
}

h1 {
  margin-bottom: 0.5rem;
}

h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

h3, h4, h5, h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

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

a:hover {
  text-decoration: underline;
}

nav {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
}

nav a {
  margin-right: 10px;
}

.lang-switch {
  margin-left: auto;
  font-size: 0.85em;
}

.lang-switch a, .lang-switch strong {
  margin-left: 6px;
}

.lang-switch strong {
  color: var(--heading-color);
}

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

pre {
  background: var(--code-background-color);
  padding: 15px;
  overflow-x: auto;
  border-radius: 3px;
  margin: 1rem 0;
}

code {
  font-family: monospace;
  font-size: 15px;
  background: var(--code-background-color);
  border-radius: 3px;
  padding: 2px;
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  border-left: 3px solid #999;
  padding-left: 20px;
  font-style: italic;
  margin: 1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

table td, table th {
  border: 1px solid var(--code-background-color);
  padding: 6px;
}

time {
  font-family: monospace;
  font-size: 15px;
}

ul.blog-posts {
  list-style-type: none;
  padding: unset;
}

ul.blog-posts li {
  display: flex;
}

ul.blog-posts li span {
  flex: 0 0 130px;
}

ul.blog-posts li a:visited {
  color: var(--link-color);
}

.post-meta {
  color: var(--text-color);
  font-size: 0.9em;
  margin-bottom: 1rem;
}

.post-tags {
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-block;
  background: var(--code-background-color);
  color: var(--link-color);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.85em;
  margin-right: 4px;
  margin-bottom: 4px;
}

.tag:hover {
  text-decoration: none;
  opacity: 0.8;
}

.tags-list {
  margin-top: 1rem;
  line-height: 2.2;
}

.toc {
  background: var(--code-background-color);
  border-radius: 3px;
  padding: 12px 16px;
  margin-bottom: 1.5rem;
}

.toc summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--heading-color);
  margin-bottom: 0.5rem;
}

.toc nav ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc nav ul ul {
  padding-left: 1.2rem;
}

.toc nav li {
  margin: 4px 0;
}

.toc nav a {
  font-size: 0.9em;
}

/* Giscus */
.giscus-container {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--code-background-color);
}

.giscus-frame {
  border: none;
}

.giscus .giscus-frame--loading {
  opacity: 0;
}

/* Gallery */
.gallery {
  columns: 3;
  column-gap: 10px;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 10px;
}

.gallery-item img {
  width: 100%;
  display: block;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.gallery-item img:hover {
  opacity: 0.85;
}

@media (max-width: 768px) {
  .gallery {
    columns: 2;
  }
}

@media (max-width: 480px) {
  .gallery {
    columns: 1;
  }
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 0;
}

footer {
  margin-top: 2rem;
  padding: 25px 0;
  text-align: center;
  color: var(--text-color);
  font-size: 0.85rem;
}
