main {
  background: var(--color-bg-tertiary);
}

article {
  width: calc(100% - 1.5em);
  background: var(--color-bg-primary);
  padding: 0.25em 0.75em;
  position: relative;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  font-size: 16px;
  color: var(--color-fg-primary);
}

@media screen and (max-width: 1023px) {
  main {
    padding: 0;
  }
}

@media screen and (min-width: 1024px) {
  article {
    max-width: 50em;
    padding: 0.25em 1.1em;
    box-shadow: 0 1px 4px 3px var(--color-shadow);
  }
}

article .p-name {
  color: var(--color-title-fg);
}

article p,
article ul,
article ol {
  /* font-family: Lora, "Palatino Linotype", "Book Antiqua", "New York", "DejaVu serif", serif; */
  font-family: Verdana, sans-serif;
  overflow-wrap: break-word;
  word-break: break-word;
}

@media screen and (min-width: 768px) {
  article p,
  article ul,
  article ol {
    text-align: justify;
  }
}

article img,
article video,
article audio {
  max-width: 100%;
  max-height: 75vh;
  display: block;
  margin: 0 auto;
}

article blockquote {
  font-style: italic;
  margin: 1em 0;
  border-left: 1px solid var(--color-border);
  padding: 0 1em;
}

article code, .codehilite {
  font-size: 0.9em;
}

article .raw-md-btn-container {
  position: absolute;
  right: 0.5em;
  top: 0.5em;
  font-size: 0.9em;
  color: var(--color-fg-tertiary);
}

a:hover {
  opacity: 0.7;
}

.description h3 {
  font-weight: normal;
  color: var(--color-fg-secondary);
  margin: -.5em auto .5em auto;
}

.meta {
  font-size: 0.75em;
  color: var(--color-fg-tertiary);
  margin-bottom: 2em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25em;
}

.meta .meta-row {
  display: inline-flex;
}

.meta .p-author {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  margin-right: 0.5em;
}

.meta .p-author img.u-photo {
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
}

.meta .tags {
  font-size: 1.25em;
}

.main-image-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-image-container img {
  width: 80%;
}

/* Replies */
.reply-backlink {
  font-size: 0.85em;
  margin-left: -0.5em;
  color: var(--color-fg-tertiary);
}

/* Tables */
article .content table {
  width: 100%;
  margin: 0.25em 0;
  border-collapse: collapse;
}

@media screen and (min-width: 768px) {
  article .content table {
    margin: 1em 0;
  }
}

article .content table thead {
  border-bottom: 2px solid var(--color-border);
}

article .content table tbody tr {
  border-bottom: 1px solid var(--color-border-tertiary);
}

article .content table tbody tr:nth-child(even) {
  background: var(--color-bg-secondary);
}

article .content table tbody td {
  padding: 0.25em 0.5em;
}

/* Code blocks */
.codehilite {
  position: relative;
  padding: 0 .5em;
  overflow: auto;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin: 1em 0;
}

.codehilite .copy-button {
  position: absolute;
  right: 0.5em;
  top: 0.5em;
  font-size: 0.9em;
  color: var(--color-fg-tertiary);
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0.8;
}

.codehilite .copy-button:hover {
  opacity: 1;
}

/* Mermaid diagrams */
.mermaid-wrapper {
  width: 100%;
  margin: 1.5em 0;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.mermaid-wrapper .mermaid-dark { display: none; }
.mermaid-wrapper .mermaid-light { display: block; }

.mermaid-wrapper svg {
  max-width: 100%;
  height: auto;
}

/* LaTeX images */
@media (prefers-color-scheme: dark) {
  .mermaid-wrapper .mermaid-dark { display: block; }
  .mermaid-wrapper .mermaid-light { display: none; }

  img.latex {
      filter: invert(1) hue-rotate(180deg);
  }
}

.latex-block {
  width: 100%;
  text-align: center;
  margin: 1em 0;
}

img.latex.block {
  max-width: 90%;
}

img.latex.inline {
  display: inline-block;
  vertical-align: text-bottom;
  margin: 0 .25em;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-bottom: 1.5em;
}
