#threads-details {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: #432537;
  background: transparent;
}
#threads-details::backdrop { background: #46283db0; backdrop-filter: blur(8px); }
.threads-reel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3dvh;
  height: 100%;
  overflow-y: auto;
  padding-block: 10dvh;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.threads-reel:focus-visible { outline: 2px solid #fffaf7; outline-offset: -3px; }
.threads-slot {
  width: 80vw;
  height: 80dvh;
  flex: none;
  perspective: 1050px;
  scroll-snap-align: center;
}
.threads-card {
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #fff9f4;
  border-radius: 18px;
  background: #fff7ed;
  box-shadow: 0 18px 45px #35142a52;
  transform: translateZ(var(--depth, -115px)) rotateX(var(--tilt, 12deg));
  opacity: var(--visibility, .7);
}
.thread-board {
  position: relative;
  width: min(100%, calc(79.6dvh * 1128 / 609));
  aspect-ratio: 1128 / 609;
  container-type: inline-size;
  overflow: hidden;
}
.thread-layer {
  position: absolute;
  inset: var(--y) auto auto var(--x);
  width: var(--w);
  height: var(--h);
}
.thread-shape { background: var(--color); }
.thread-image { object-fit: contain; border-radius: 1.5cqw; }
[data-layer="growth-board"] { border-radius: 0; }
.thread-text {
  margin: 0;
  color: var(--color);
  font-size: var(--font-size);
  line-height: var(--line);
  white-space: pre-line;
  overflow: auto;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}
.thread-text ul { margin: 0; padding-inline-start: 1.25em; }
.threads-close, .threads-controls button {
  width: 42px;
  height: 42px;
  border: 1px solid #4325374d;
  border-radius: 50%;
  background: #fffaf7;
  color: #432537;
  font-size: 21px;
  cursor: pointer;
}
.threads-close { position: absolute; top: 12px; right: 14px; }
.threads-controls { position: absolute; right: max(10px, calc(5vw - 21px)); top: 50%; transform: translateY(-50%); display: grid; gap: 7px; }
.threads-controls button:disabled { opacity: .4; cursor: default; }
@media (max-width: 700px) {
  .threads-slot { width: 90vw; }
  .threads-card { display: block; overflow-x: auto; }
  .thread-board { min-width: min(680px, calc(79dvh * 1128 / 609)); margin-block: max(0px, calc((80dvh - 368px) / 2)); }
  .threads-controls { top: auto; bottom: 5px; right: 50%; transform: translateX(50%); display: flex; }
}
@media (prefers-reduced-motion: reduce) { .threads-card { transform: none; } }

.threads-edit-toggle {
  position: absolute;
  top: 12px;
  right: 66px;
}
.threads-layout-editor {
  position: absolute;
  right: 14px;
  top: 62px;
  width: min(290px, calc(100vw - 28px));
  max-height: calc(100dvh - 82px);
  overflow: auto;
  padding: 12px;
  border: 1px solid #83576966;
  border-radius: 12px;
  background: #fff8f4;
  box-shadow: 0 8px 28px #43253733;
  font-size: 13px;
}
.threads-layout-editor label { display: grid; gap: 3px; margin-bottom: 6px; min-width: 0; }
.threads-layout-editor fieldset { margin: 0 0 8px; padding: 6px; border: 1px solid #83576944; min-width: 0; }
.thread-geometry { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 8px; }
.threads-layout-editor :is(input, select, textarea), .threads-layout-editor button, .threads-edit-toggle {
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid #83576977;
  border-radius: 6px;
  color: #432537;
  background: white;
  font: inherit;
}
.threads-layout-editor input[type="color"] { width: 100%; height: 30px; }
.thread-editor-actions { display: flex; gap: 8px; margin-bottom: 5px; }
.threads-layout-editor button, .threads-edit-toggle { cursor: pointer; }
.thread-layer[data-selected] { outline: 2px dashed #a02f62; outline-offset: -2px; }
#threads-details[data-editing] .thread-layer { cursor: move; }
@media (max-width: 700px) {
  .threads-layout-editor { top: auto; bottom: 54px; max-height: 37dvh; }
}
#threadsEditor [hidden] { display: none; }
#threads-details[data-editing] .thread-board { touch-action: none; user-select: none; }
