:root {
  color-scheme: dark;
  font: 15px/1.4 system-ui, sans-serif;
  color: #e7e9ea;
  background: #000000;
  --line: #2f3336;
  --muted: #93999e;
  --blue: #4ba3ff;
  --indent: 20px;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button,
input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #000;
  color: inherit;
  padding: 5px 8px;
}
button,
summary {
  cursor: pointer;
}
button:hover {
  border-color: var(--muted);
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
#app {
  max-width: 640px;
  min-height: 100vh;
  margin: 0 auto;
  border-inline: 1px solid var(--line);
}
.entry {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.entry label,
.thread-tools {
  font-size: 12px;
  line-height: 1.5;
}
.entry label {
  display: block;
  margin-bottom: 4px;
}
.input-row {
  display: flex;
  gap: 6px;
}
.input-row input {
  flex: 1;
  min-width: 0;
}
.thread-tools {
  padding: 8px 12px;
  color: var(--muted);
}
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.toolbar > span {
  margin-right: auto;
}

.thread {
  list-style: none;
  padding: 0;
  margin: 0;
}
.branch {
  position: relative;
  margin-left: calc(var(--level) * var(--indent));
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
  scroll-margin-top: 12px;
}
.branch:last-child {
  border-bottom: 1px solid var(--line);
}
.branch.selected {
  box-shadow: inset 2px 0 var(--blue);
}
.branch:target {
  outline: 1px solid var(--blue);
  outline-offset: -1px;
}
.branch.connected-before::before,
.branch.connected-after::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-left: 2px solid var(--line);
}
.branch.connected-before::before {
  left: calc(31px - var(--join) * var(--indent));
  width: calc(var(--join) * var(--indent));
  top: -1px;
  height: calc(var(--avatar-y) + 1px);
  border-bottom: 2px solid var(--line);
}
.branch.connected-after::after {
  left: 31px;
  top: var(--avatar-y);
  bottom: -1px;
}
.post-context {
  height: 26px;
  display: flex;
  align-items: end;
  gap: 8px;
  margin-left: 64px;
  font-size: 12px;
}
.post-context a,
.branch-note {
  color: var(--muted);
}
.branch-note {
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
}
.post {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 12px;
  padding: 12px;
}
.post-context + .post {
  padding-top: 6px;
}
.post > * {
  grid-column: 2;
  min-width: 0;
}
.post > .avatar {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.avatar {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  background: #000;
  border: 2px solid #000;
  border-radius: 50%;
  overflow: hidden;
}
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.identity {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.author-name {
  color: inherit;
  font-weight: 600;
  flex-shrink: 0;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.handle {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-text {
  white-space: pre-wrap;
  line-height: 1.5;
  margin-top: 2px;
}
.post-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.post-footer a {
  color: var(--muted);
}
.unavailable,
.labels,
.media-description {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}
.quote {
  border: 1px solid var(--line);
  margin-top: 10px;
  padding: 8px;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 4px 8px;
}
.quote .avatar {
  width: 24px;
  height: 24px;
}
.quote .post-text,
.quote > .media,
.quote > .post-footer {
  grid-column: 1 / -1;
}
.quote-link {
  font-size: 13px;
  margin-top: 8px;
}
.media {
  margin-top: 10px;
}
.images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 4px;
}
figure {
  margin: 0;
  min-width: 0;
}
.images img,
video {
  display: block;
  width: 100%;
  max-height: 600px;
  object-fit: contain;
  border: 1px solid var(--line);
}
.alt {
  font-size: 12px;
  color: var(--muted);
}
.alt p {
  white-space: pre-wrap;
}
.external {
  display: block;
  border: 1px solid var(--line);
  color: inherit;
}
.external img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}
.external strong,
.external p,
.external span {
  display: block;
  margin: 8px;
}
.external p,
.external span {
  font-size: 13px;
  color: var(--muted);
}

.image-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
}

.image-viewer {
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 12px;
  border: 0;
  background: #000;
  color: inherit;
}

.image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.image-viewer::backdrop {
  background: #000;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.viewer-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-previous,
.viewer-next {
  position: absolute;
  z-index: 1;
  font-size: 28px;
  padding: 0 12px;
}

.viewer-previous {
  left: 0;
}
.viewer-next {
  right: 0;
}
.viewer-stage button:disabled {
  opacity: 0.3;
  cursor: default;
}

.viewer-alt {
  max-height: 25dvh;
  overflow: auto;
  font-size: 13px;
  color: var(--muted);
}

.viewer-alt p {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

@media (max-width: 480px) {
  :root {
    --indent: 10px;
  }
  #app {
    border-inline: 0;
  }
  .identity {
    display: block;
  }
  .author-name,
  .handle {
    display: block;
    max-width: 100%;
  }
}
