:root {
  --primary: #8b6c5c;
  --secondary: #f0ead2;
  --bg: #211915;
  --modal-duration: .25s;
}

::backdrop {
  --modal-duration: .25s;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  font-family: monospace;
  font-size: 1rem;
  color: var(--secondary);
  background: var(--bg);
}

body {
  opacity: 0;
  transition: opacity .2s;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: .25rem 0;
}

[role=link] {
  text-decoration: underline;
  cursor: pointer;
}

body {
  margin: 5px;
}

body>header,
body>main {
  margin-inline: auto;
  max-inline-size: 680px;
  padding: .5rem;
}

body>header {
  border-bottom: 2px solid var(--primary);
}

body>header nav {
  display: flex;
  justify-content: space-between;
}

body>header nav a {
  cursor: pointer;
}

body>header nav a.brand img {
  display: inline-block;
  border-radius: 5px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 5px;
  height: 1.25rem
}

body>header nav a:only-child {
  text-align: center;
  flex: 1;
}

form {
  margin-bottom: 0;
}

:where(input, select, textarea) {
  font-family: inherit;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  margin-top: .2em;
}

:where(input, select, textarea, button, [role=button]) {
  padding: .5em;
  font-size: 1em;
  border-radius: 5px;
  border: 1px solid var(--primary);
}

:where(input, select, textarea, button, [role=button]):not([disabled], [readonly]):focus,
:where(input, select, textarea, button, [role=button]):not([disabled], [readonly]):hover {
  outline: 1px solid var(--secondary);
  box-shadow: 0 5px 10px 0 rgba(0, 0, 0, 0.75);
}

label:has(input, select, textarea),
label :where(input, select, textarea) {
  display: block;
  width: 100%;
}

label:has(input, select, textarea) {
  margin-bottom: 1em;
}

:where(button, [role=button]):not([disabled]) {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 1em;
  background: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--bg) !important;
  font-weight: bold;
  text-align: center;
}

:where(button, [role=button]).inline {
  display: inline-block;
  width: auto;
  min-width: 100px;
}

:where(input, select, textarea, button, [role=button]):is([disabled], [readonly]) {
  opacity: .75;
}

a {
  color: inherit;
}

.mb {
  margin-bottom: 1em;
}

.post-wrap {
  display: block;
  margin: 1em auto;
  padding: .5em;
  border-radius: 5px;
  position: relative;
  border: 2px solid var(--primary);
  box-shadow: 0 5px 20px 0 rgba(0, 0, 0, 0.75);
}

.post {
  position: relative;
  padding: .5em;
}

.post-wrap:has(.post[onclick]):hover {
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.post .header {
  font-size: 1em;
  display: flex;
  gap: .5em;
}

.post :where(.header, .metrics) {
  opacity: .8;
}

.post :where(.body, .metrics) {
  margin-top: .5em;
}

.post .body {
  font-size: 1.25em;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.post .body>pre {
  word-wrap: break-word;
  white-space: pre-wrap;
  margin-bottom: 0;
}

.post.parent {
  font-size: .8rem;
  font-style: italic;
  margin-left: 2em;
  margin-bottom: .5em;
  padding-left: 1.5em;
}

.post.parent:before {
  display: inline-block;
  position: absolute;
  content: '';
  top: 1em;
  left: -.5em;
  width: 1em;
  height: calc(100% - 15px);
  border-top: 2px solid var(--primary);
  border-left: 2px solid var(--primary);
}

.post.parent+.post {
  margin-top: 0;
}

dialog {
  margin: auto;
  color: var(--secondary);
  background: var(--bg);
  border: 2px solid var(--primary);
  border-radius: 5px;
  box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.75);
  opacity: 0;
  top: 2em;
  transition:
    display var(--modal-duration) allow-discrete,
    overlay var(--modal-duration) allow-discrete;
  animation: hide var(--modal-duration) ease normal forwards;

  &[open] {
    animation: show var(--modal-duration) ease normal forwards;
  }
}

@keyframes show {
  from {
    opacity: 0;
    top: 2em;
  }

  to {
    opacity: 1;
    top: 0;
  }
}

@keyframes hide {
  from {
    opacity: 1;
    top: 0;
  }

  to {
    opacity: 0;
    top: 2em;
  }
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  transition:
    display var(--modal-duration) allow-discrete,
    overlay var(--modal-duration) allow-discrete;
  animation: hide-bd var(--modal-duration) ease normal forwards;
}

dialog[open]::backdrop {
  transition:
    display var(--modal-duration) allow-discrete,
    overlay var(--modal-duration) allow-discrete;
  animation: show-bd var(--modal-duration) ease normal forwards;
}

@keyframes show-bd {
  from {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }

  to {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
  }
}

@keyframes hide-bd {
  from {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
  }

  to {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
}

dialog>header {
  font-size: 1.25em;
  font-weight: bold;
  margin-bottom: .5em;
}

dialog section {
  min-width: 300px;
}

.grid {
  display: flex;
  gap: .5em;
}

.grid>* {
  flex: 1;
}

[aria-busy] {
  pointer-events: none;
}

[aria-busy]:before {
  display: inline-block;
  content: '';
  height: 0.5em;
  width: 0.5em;
  border: 2px solid;
  border-radius: 50%;
  border-left-color: transparent;
  margin-right: 0.25em;
  animation: spinner .75s infinite linear;
}

@keyframes spinner {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

details {
  padding-bottom: 1em;
}

details summary {
  cursor: pointer;
  padding: .5em;
  border-top: 1px solid var(--primary);
}

hr {
  height: 2px;
  border: none;
  background: var(--primary);
  margin: 1em auto;
}

.post .body :where(img, iframe) {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 5px;
  overflow: hidden;
  object-fit: contain;
  background: rgba(0, 0, 0, .5);
  border: 1px solid var(--primary);
  max-height: 50dvh;
}

.bio {
  margin: 1rem 0;
}

.bio pre {
  white-space: pre-wrap;
}