:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #111;
  --muted: #595959;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111;
  --ink: #f5f5f5;
  --muted: #b5b5b5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.7 system-ui, sans-serif;
}
main {
  width: calc(100% - 3rem);
  min-height: 100svh;
  margin: auto;
  padding: clamp(4rem, 18vh, 10rem) 0 3rem;
}
textarea {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: inherit;
  font: inherit;
}
#message {
  min-height: 2em;
  max-height: 45vh;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
}
.actions, .buttons { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem; }
.actions { margin-top: .5rem; }
button {
  border: 0;
  padding: .45rem 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button:hover, #publish { color: var(--ink); }
button:focus-visible { outline: 2px solid currentColor; outline-offset: .2rem; }
#connection { margin: 1.5rem 0; font-size: .9rem; }
#code { margin-top: .5rem; }
.note, output, #peers { color: var(--muted); }
ol { padding: 0; list-style: none; margin: 3rem 0 0; }
ol:empty { margin: 0; }
li { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 1.25rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#write, #connection { max-width: 38rem; margin-inline: auto; }
#posts { position: relative; }
#posts li {
  position: absolute;
  width: max-content;
  min-width: min(8rem, 100%);
  max-width: min(100%, 38rem);
  margin: 0;
}
#posts li.selected { z-index: 1; }
#posts li.dragging { z-index: 2; }
.post-text {
  display: block;
  max-width: 100%;
  padding: 0;
  color: var(--ink);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: grab;
}
.post-text, [data-control="move"] { touch-action: none; user-select: none; }
[data-control="move"] { cursor: grab; }
.dragging button { cursor: grabbing; }
.post-actions { display: flex; gap: 1rem; font-size: .875rem; }
#posts textarea { min-width: min(18rem, calc(100vw - 3rem)); }
#posts textarea ~ button { margin-right: 1rem; font-size: .875rem; }

main {
  position: relative;
  width: auto;
  margin: 0 .6rem;
  padding: 0;
}
#composer {
  position: absolute;
  z-index: 3;
  top: min(17vh, 150px);
  left: 0;
  width: min(100%, 30rem, max(15rem, 80%));
  transition: top 180ms ease-out, left 180ms ease-out;
}
#composer.moving { transition: none; }
#move-composer { cursor: grab; touch-action: none; user-select: none; }
#posts { position: absolute; top: 0; left: 0; right: 0; margin: 0; pointer-events: none; }
#posts li { pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { #composer { transition: none; } }

.type-options { display: inline-flex; flex-wrap: wrap; gap: .75rem; }
.type-options select {
  border: 0;
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  padding: .35rem 0;
}
[data-font="sans"] { font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
[data-font="serif"] { font-family: "Songti SC", SimSun, "Noto Serif CJK SC", Georgia, serif; }
[data-font="kai"] { font-family: "Kaiti SC", KaiTi, STKaiti, "Songti SC", SimSun, serif; }
[data-font="mono"] { font-family: ui-monospace, "Cascadia Mono", "Courier New", monospace; }

.thread-text { min-width: 0; }
.reply-indent { margin: .55rem 0 0 min(1.2rem, 5vw); }
.post-actions { flex-wrap: wrap; gap: .25rem .85rem; }
