/* Header Radar: ≤700px barra ancha (como grid 1 col); ≥701px tarjeta flotante; 3col alineada al feed */
@media (max-width: 700px) {
  .radar-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.96);
    border-bottom: 1px solid rgba(71, 85, 105, 0.45);
    padding: 0;
  }
  .radar-header-inner {
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  body.radar-body-3col .radar-header-inner,
  body.radar-body-feed .radar-header-inner {
    margin-left: 0;
    width: 100%;
    max-width: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    background: rgba(30, 41, 59, 0.98);
  }

  body.radar-body-feed .radar-feed-page-column {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

@media (min-width: 701px) {
  .radar-header {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.75rem 0.75rem 0.5rem;
    box-sizing: border-box;
  }
  /* Centrar la cápsula en la columna central (alineado con .radar-three-cols + padding) */
  body.radar-body-3col .radar-header {
    padding-left: calc(240px + 0.5rem);
    padding-right: calc(220px + 0.5rem);
  }
  /* Feed: padding horizontal del header en feed.html (<style> final del head) + !important */
  .radar-header-inner {
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    border-radius: 1rem;
    background: rgba(30, 41, 59, 0.94);
    border: 1px solid rgba(71, 85, 105, 0.55);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 12px 40px -12px rgba(0, 0, 0, 0.55),
      0 4px 16px -4px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  body.radar-body-3col .radar-header {
    padding-left: calc(200px + 0.5rem);
    padding-right: calc(180px + 0.5rem);
  }
}

.radar-three-cols {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  width: 100%;
  min-height: 0;
}
/* Versión con guía a la derecha más estrecha (~1/4 del ancho original). */
.radar-three-cols.radar-three-cols-guide {
  grid-template-columns: 240px minmax(0, 1fr) 220px;
}
.radar-guide-col {
  width: 220px;
  max-width: 220px;
}
@media (max-width: 900px) {
  .radar-three-cols {
    grid-template-columns: 200px minmax(0, 1fr) 180px;
  }
  .radar-three-cols.radar-three-cols-guide {
    grid-template-columns: 200px minmax(0, 1fr) 180px;
  }
  .radar-guide-col {
    width: 180px;
    max-width: 180px;
  }
}
@media (max-width: 700px) {
  .radar-three-cols {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .radar-left,
  .radar-right {
    display: none !important;
  }
  .radar-center { order: 1; }
  body.radar-body-3col .radar-center {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/*
 * Desktop 3col: scroll solo en .radar-center (#radar-feed-scroll) — la rueda funciona ahí.
 * Laterales position:fixed al viewport, siempre el mismo offset desde el top (debajo del header).
 */
@media (min-width: 701px) {
  body.radar-body-3col .radar-three-cols {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 0.25rem 0.5rem 0.75rem;
    box-sizing: border-box;
    overflow: visible;
    position: relative;
  }

  body.radar-body-3col .radar-three-cols:has(aside.radar-right) .radar-center {
    margin-left: calc(0.5rem + 240px + 0.625rem);
    margin-right: calc(0.5rem + 220px + 0.625rem);
  }
  body.radar-body-3col .radar-three-cols:not(:has(aside.radar-right)) .radar-center {
    margin-left: calc(0.5rem + 240px + 0.625rem);
    margin-right: 0.5rem;
  }

  body.radar-body-3col .radar-center {
    flex: 1;
    min-height: 0;
    width: auto;
    max-width: none;
  }

  body.radar-body-3col .radar-left,
  body.radar-body-3col .radar-right {
    position: fixed;
    z-index: 25;
    min-width: 0;
    width: 240px;
    max-height: calc(100dvh - 6rem - env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    top: calc(env(safe-area-inset-top, 0px) + 5.25rem);
    border-radius: 1rem;
    background: rgba(30, 41, 59, 0.94);
    border: 1px solid rgba(71, 85, 105, 0.55);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 12px 40px -12px rgba(0, 0, 0, 0.55),
      0 4px 16px -4px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  body.radar-body-3col .radar-left {
    left: max(0.5rem, env(safe-area-inset-left, 0px));
  }
  body.radar-body-3col .radar-right {
    width: 220px;
    right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  /* Feed/post: alinear top con padding del #feed-list (p-3 / p-4) */
  body.radar-body-3col .radar-three-cols.radar-feed-flow .radar-left,
  body.radar-body-3col .radar-three-cols.radar-feed-flow .radar-right {
    top: calc(env(safe-area-inset-top, 0px) + 5.25rem + 0.75rem);
    max-height: calc(100dvh - 6.75rem - env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) {
  body.radar-body-3col .radar-three-cols.radar-feed-flow .radar-left,
  body.radar-body-3col .radar-three-cols.radar-feed-flow .radar-right {
    top: calc(env(safe-area-inset-top, 0px) + 5.25rem + 1rem);
    max-height: calc(100dvh - 7rem - env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  body.radar-body-3col .radar-left {
    width: 200px;
  }
  body.radar-body-3col .radar-right {
    width: 180px;
  }
  body.radar-body-3col .radar-three-cols:has(aside.radar-right) .radar-center {
    margin-left: calc(0.5rem + 200px + 0.625rem);
    margin-right: calc(0.5rem + 180px + 0.625rem);
  }
  body.radar-body-3col .radar-three-cols:not(:has(aside.radar-right)) .radar-center {
    margin-left: calc(0.5rem + 200px + 0.625rem);
  }
}

/* Feed: márgenes laterales viven en feed.html (padding en body.radar-body-feed main), no en huecos 3col. */
body.radar-body-feed .radar-feed-page-column {
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

@media (min-width: 701px) {
  body.radar-body-feed .radar-feed-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 0.25rem 0 0.75rem;
    box-sizing: border-box;
    overflow: visible;
  }

  body.radar-body-feed #radar-feed-scroll {
    flex: 1;
    min-height: 0;
    width: auto;
    max-width: none;
  }
}

.radar-left { min-width: 0; }
.radar-right { min-width: 0; }
.radar-card-body { flex: 1; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.radar-like-heart { animation: radar-heart 0.4s ease; }
@keyframes radar-heart { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }
/* Hashtags: texto tras # en amarillo (máx 15 caracteres por hashtag) */
.radar-hashtag { color: #facc15; }

/* Espejo en tiempo real: el texto con # se ve en amarillo mientras escribes */
.radar-hashtag-mirror-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}
.radar-hashtag-mirror-wrap .radar-mirror {
  position: absolute;
  inset: 0;
  z-index: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  pointer-events: none;
  overflow: auto;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: rgb(226 232 240);
  white-space: pre-wrap;
  word-break: break-word;
  background: rgb(51 65 85);
  border: 1px solid rgb(71 85 105);
  box-sizing: border-box;
}
.radar-hashtag-mirror-wrap input.radar-hashtag-input,
.radar-hashtag-mirror-wrap textarea.radar-hashtag-input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  color: transparent !important;
  caret-color: #fbbf24;
  background: transparent !important;
}
.radar-hashtag-mirror-wrap input.radar-hashtag-input::placeholder,
.radar-hashtag-mirror-wrap textarea.radar-hashtag-input::placeholder {
  color: rgb(148 163 184);
}

/* Pie del post: acciones (like, comentarios, compartir) y bloque de comentarios debajo */
.radar-card-footer {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  flex-shrink: 0 !important;
  min-height: 0;
}
.radar-card-footer .radar-card-actions {
  flex-shrink: 0 !important;
}
.radar-comments-inline:not(.hidden) {
  display: block !important;
  width: 100% !important;
  flex-shrink: 0 !important;
  min-height: 4rem;
}

/* Comentarios anidados: cada nivel de respuesta se corre a la derecha */
.radar-comment-children {
  margin-left: 14px;
}

#post-modal { display: none !important; pointer-events: none; }
#post-modal.radar-modal-open { display: flex !important; pointer-events: auto; }

/* Compositor: ocupa altura entera de la vista, empuja el feed hacia abajo */
.radar-composer-full {
  min-height: calc(100vh - 3.5rem);
  display: flex;
  flex-direction: column;
}
.radar-composer {
  padding: 1rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.radar-composer-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-height: 0;
}
.radar-composer-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}
.feed-list-wrap {
  flex-shrink: 0;
}
/* El espacio entre cards lo controla #feed-list (space-y/gap), no margin aquí */
.radar-feed-card {
  margin-bottom: 0;
  position: relative;
  z-index: 0;
}

/*
 * Hilo en el hueco entre posts: línea fina a la izquierda (alineada con px-3 del meta).
 */
#feed-list > .radar-feed-card:not(:first-child)::before,
#related-posts-list > .radar-feed-card:not(:first-child)::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 0;
  transform: translateY(-100%);
  width: clamp(2px, 0.08rem + 0.2vw, 4px);
  height: 0.5rem;
  z-index: 0;
  pointer-events: none;
  border-radius: 0;
  opacity: 1;
  mix-blend-mode: soft-light;
  background: linear-gradient(
    180deg,
    rgba(100, 116, 139, 0.22) 0%,
    rgba(71, 85, 105, 0.14) 50%,
    rgba(100, 116, 139, 0.22) 100%
  );
}
@media (min-width: 768px) {
  #feed-list > .radar-feed-card:not(:first-child)::before,
  #related-posts-list > .radar-feed-card:not(:first-child)::before {
    height: 0.75rem;
  }
}

/* Puente: solo el hueco entre post principal y relacionados */
.radar-feed-thread-bridge {
  position: relative;
  z-index: 0;
  height: 0.5rem;
  pointer-events: none;
}
@media (min-width: 768px) {
  .radar-feed-thread-bridge {
    height: 0.75rem;
  }
}
.radar-feed-thread-bridge::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 0;
  transform: none;
  width: clamp(2px, 0.08rem + 0.2vw, 4px);
  height: 100%;
  border-radius: 0;
  z-index: 0;
  opacity: 1;
  mix-blend-mode: soft-light;
  background: linear-gradient(
    180deg,
    rgba(100, 116, 139, 0.22) 0%,
    rgba(71, 85, 105, 0.14) 50%,
    rgba(100, 116, 139, 0.22) 100%
  );
}
/* Cabecera del post: narrativa + usuario + fecha, alineados a la derecha */
.radar-post-meta.radar-post-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem 1.25rem;
  line-height: 1.35;
  min-width: 0;
}
@media (min-width: 768px) {
  .radar-post-meta.radar-post-meta-row {
    gap: 1rem 1.75rem;
  }
}
/* Contenedor del editor rich text (Quill) */
.radar-editor-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 200px;
  border-radius: 0.75rem;
  background: rgb(51 65 85);
  border: 1px solid rgb(71 85 105);
  overflow: hidden;
}
.radar-editor-toolbar {
  flex-shrink: 0;
}
.radar-editor-container {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
}
/* Quill tema oscuro */
.radar-editor-wrap .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid rgb(71 85 105);
  background: rgb(51 65 85);
  padding: 0.5rem 0.75rem;
}
.radar-editor-wrap .ql-container.ql-snow {
  border: none;
  background: rgb(51 65 85);
  font-size: 0.9375rem;
}
.radar-editor-wrap .ql-editor {
  min-height: 100%;
  color: rgb(226 232 240);
}
.radar-editor-wrap .ql-editor.ql-blank::before {
  color: rgb(148 163 184);
}
.radar-editor-wrap .ql-snow .ql-stroke {
  stroke: rgb(71 85 105);
}
.radar-editor-wrap .ql-snow .ql-fill { fill: rgb(148 163 184); }
.radar-editor-wrap .ql-snow .ql-picker { color: rgb(148 163 184); }
.radar-editor-wrap .ql-snow button:hover .ql-stroke { stroke: rgb(245 158 11); }
.radar-editor-wrap .ql-snow button:hover .ql-fill { fill: rgb(245 158 11); }
.radar-editor-wrap .ql-snow .ql-picker-label:hover { color: rgb(245 158 11); }
/* Columnas en contenido (radar-cols-2) */
.radar-cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0.5rem 0;
}
.radar-cols-2 .radar-col {
  min-width: 0;
}
@media (max-width: 600px) {
  .radar-cols-2 { grid-template-columns: 1fr; }
}

/* Contenido de posts en el feed: densidad en móvil, legibilidad en desktop */
.radar-post-body,
.radar-post-body-full,
.radar-post-body-html {
  font-size: 16px;
  line-height: 1.45;
  color: #d5dbe3;
  word-break: break-word;
}
@media (min-width: 768px) {
  .radar-post-body,
  .radar-post-body-full,
  .radar-post-body-html {
    font-size: 18px;
    line-height: 1.6;
  }
}
.radar-post-body-html p { margin: 0.6em 0; }
.radar-post-body-html p:first-child { margin-top: 0; }
.radar-post-body-html p:last-child { margin-bottom: 0; }
.radar-post-body-html h2 { font-size: 1.25rem; font-weight: 600; margin: 0.75em 0 0.35em; color: rgb(251 191 36); }
.radar-post-body-html h3 { font-size: 1.1rem; font-weight: 600; margin: 0.6em 0 0.25em; }
.radar-post-body-html ul, .radar-post-body-html ol { margin: 0.5em 0; padding-left: 1.5em; }
.radar-post-body-html a { color: rgb(251 191 36); text-decoration: underline; }
.radar-post-body-html a:hover { color: rgb(253 224 71); }
.radar-post-body-html strong { font-weight: 600; }
.radar-composer-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.radar-composer-title {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: rgb(51 65 85 / 0.8);
  border: 1px solid rgb(71 85 105);
  color: #fff;
  font-size: 0.875rem;
  outline: none;
}
.radar-composer-title::placeholder { color: rgb(148 163 184); }
.radar-composer-title:focus { border-color: rgb(245 158 11 / 0.5); }
.radar-composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 0;
}
.radar-composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.radar-composer-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  background: rgb(71 85 105);
  border: 1px solid rgb(100 116 139);
  color: rgb(226 232 240);
  font-size: 0.8125rem;
  cursor: pointer;
}
.radar-composer-btn:hover {
  background: rgb(100 116 139);
}
.radar-gif-search {
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgb(51 65 85);
  border: 1px solid rgb(71 85 105);
}
.radar-gif-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: rgb(30 41 59);
  border: 1px solid rgb(71 85 105);
  color: #fff;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}
.radar-gif-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
}
.radar-gif-results .gif-item {
  cursor: pointer;
  border-radius: 0.375rem;
  border: 2px solid rgb(71 85 105);
  overflow: hidden;
  aspect-ratio: 1;
}
.radar-gif-results .gif-item:hover {
  border-color: rgb(245 158 11 / 0.7);
}
.radar-gif-results .gif-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.radar-composer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.radar-composer-select {
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: rgb(51 65 85);
  border: 1px solid rgb(71 85 105);
  color: #fff;
  font-size: 0.875rem;
}
.radar-composer-refresh {
  padding: 0.25rem 0.5rem;
  color: rgb(100 116 139);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
}
.radar-composer-refresh:hover { color: rgb(245 158 11); }
.radar-composer-submit {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: rgb(245 158 11);
  color: rgb(15 23 42);
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.radar-composer-submit:hover { background: rgb(251 191 36); }
.radar-attachment {
  position: relative;
  flex-shrink: 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid rgb(71 85 105);
}
.radar-attachment img { display: block; max-width: 120px; max-height: 80px; object-fit: cover; }
.radar-attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

/* Campo de puntos Perlin en canvas (radar-atmosphere.js), debajo del contenido */
body.min-h-screen {
  position: relative;
  isolation: isolate;
}

.radar-atmosphere-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: block;
}

body.min-h-screen > header {
  position: relative;
  z-index: 50;
}
body.min-h-screen > main {
  position: relative;
  z-index: 40;
}

