    * { margin: 0; padding: 0; box-sizing: border-box; }

    html, body { height: 100%; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg-pagina);
      color: var(--texto);
      line-height: 1.6;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    header {
      height: 100px;
      background: linear-gradient(135deg, var(--color-primario), var(--color-primario-b));
      color: #fff;
      box-shadow: 0 2px 8px rgba(0,0,0,.15);
      overflow: hidden;
    }

    .header-inner {
      position: relative;
      max-width: 1200px;
      height: 100%;
      margin: 0 auto;
      padding: 0 1rem;
      display: flex;
      align-items: center;
      gap: 1rem;
      flex-wrap: nowrap;
    }

    /* Avatar editable */
    .avatar-wrap {
      position: relative;
      flex-shrink: 0;
      cursor: pointer;
    }

    .avatar {
      width: 90px;
      height: 90px;
      display: block;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid #fff;
      box-shadow: 0 2px 6px rgba(0,0,0,.25);
    }

    .avatar-overlay {
      position: absolute;
      inset: 0;
      border-radius: 50%;
      background: rgba(0,0,0,.45);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity .2s;
    }

    .avatar-wrap:hover .avatar-overlay {
      opacity: 1;
    }

    .avatar-overlay svg {
      width: 20px;
      height: 20px;
    }

    .avatar-vacio {
      width: 90px;
      height: 90px;
      border-radius: 50%;
      background: rgba(255,255,255,.35);
      border: 2px dashed rgba(255,255,255,.6);
      display: none;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: .5rem;
    }

    .brand h1 {
      font-size: 1.6rem;
      letter-spacing: .5px;
      line-height: 1.1;
      display: flex;
      align-items: center;
      gap: .35rem;
      min-width: 60px;
    }

    .brand p {
      opacity: .85;
      font-size: .9rem;
      line-height: 1.3;
    }

    .brand p .sub-2 {
      font-size: .72rem;
      opacity: .8;
    }

    .titulo-input {
      font-size: 1.6rem;
      font-family: inherit;
      color: #fff;
      background: rgba(0,0,0,.2);
      border: 1px solid #fff;
      border-radius: 6px;
      padding: .1rem .3rem;
      outline: none;
    }

    /* Botón de sesión */
    .sesion {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      flex-shrink: 0;
      z-index: 5;
    }

    .btn-sesion {
      background: rgba(255,255,255,.18);
      color: #fff;
      border: 1px solid rgba(255,255,255,.5);
      padding: .5rem 1rem;
      border-radius: 8px;
      font-size: .9rem;
      font-weight: 600;
      cursor: pointer;
      transition: background .2s;
      white-space: nowrap;
    }

    .btn-sesion:hover { background: rgba(255,255,255,.3); }

    .btn-sesion.activo {
      background: rgba(0,0,0,.25);
      border-color: rgba(255,255,255,.7);
    }

    /* Modal de login/registro */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.5);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }

    .modal {
      background: var(--bg-tarjeta);
      border-radius: 14px;
      padding: 1.75rem;
      width: 320px;
      box-shadow: 0 10px 40px rgba(0,0,0,.3);
      display: flex;
      flex-direction: column;
      gap: .8rem;
    }

    .modal-titulo {
      font-size: 1.3rem;
      font-weight: 700;
      color: var(--color-primario-txt);
      text-align: center;
      margin-bottom: .25rem;
    }

    .modal input {
      width: 100%;
      padding: .7rem;
      font-size: 1rem;
      border: 2px solid var(--borde);
      border-radius: 8px;
      font-family: inherit;
      box-sizing: border-box;
    }

    .modal input:focus {
      outline: none;
      border-color: var(--color-primario-b);
    }

    .modal select {
      width: 100%;
      padding: .7rem;
      font-size: 1rem;
      border: 2px solid var(--borde);
      border-radius: 8px;
      font-family: inherit;
    }

    .modal select:focus {
      outline: none;
      border-color: var(--color-primario-b);
    }

    /* Campo de contraseña con botón de ojo */
    .campo-password {
      position: relative;
      width: 100%;
    }

    .campo-password input {
      width: 100%;
      padding-right: 2.6rem;
      box-sizing: border-box;
    }

    .ojo-btn {
      position: absolute;
      right: 4px;
      top: 50%;
      transform: translateY(-50%);
      background: transparent;
      border: none;
      cursor: pointer;
      padding: 0;          /* sin esto, el padding global de los botones aplasta el icono */
      width: 34px;
      height: 34px;
      flex: none;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--texto-suave);
      border-radius: 6px;
    }

    .ojo-btn:hover { color: var(--color-primario-txt); }

    .ojo-btn svg {
      width: 20px;
      height: 20px;
      flex: none;
    }

    /* Ojo tachado (contraseña visible) */
    .ojo-btn.visible svg { stroke: var(--color-primario); }

    /* Modal para agregar amigo */
    .modal.modal-ancho {
      width: 380px;
    }

    .lista-usuarios {
      display: flex;
      flex-direction: column;
      gap: .5rem;
      max-height: 260px;
      overflow-y: auto;
    }

    .lista-vacia {
      text-align: center;
      color: var(--texto-suave);
      font-size: .9rem;
      padding: 1rem;
    }

    .usuario-fila {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: .5rem;
      padding: .5rem;
      border: 1px solid var(--bg-suave-2);
      border-radius: 8px;
    }

    .uf-nombre {
      font-weight: 600;
      color: var(--texto);
    }

    .uf-acciones {
      display: flex;
      gap: .35rem;
      align-items: center;
    }

    .mini-btn {
      border: none;
      border-radius: 6px;
      padding: .35rem .6rem;
      cursor: pointer;
      font-size: .78rem;
      font-weight: 600;
    }

    .mini-btn.agregar { background: var(--color-primario-b); color: #fff; }
    .mini-btn.agregar:hover { background: var(--color-primario); }
    .mini-btn.aceptar { background: var(--color-primario-b); color: #fff; }
    .mini-btn.rechazar { background: var(--bg-suave-2); color: var(--texto-suave); }

    .badge {
      font-size: .78rem;
      font-weight: 700;
      padding: .25rem .5rem;
      border-radius: 6px;
      white-space: nowrap;
    }

    .badge-amigo { background: var(--bg-suave); color: var(--color-primario-txt); }
    .badge-enviada { background: #fdf3d7; color: #8a6d1a; }

    .login-msj {
      font-size: .85rem;
      color: var(--color-error-txt);
      min-height: 1rem;
      margin: 0;
    }

    .modal-acciones {
      display: flex;
      gap: .6rem;
    }

    .modal .btn {
      flex: 1;
      margin-top: 0;
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      padding: .65rem;
      font-size: 1rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
      transition: background .2s;
    }

    .modal .btn:hover { background: var(--color-primario); }

    .modal .btn-sec {
      background: var(--bg-suave-2);
      color: var(--texto);
    }

    .modal .btn-sec:hover { background: #d5dbd7; }

    .modal-cambio {
      font-size: .85rem;
      color: var(--texto-suave);
      text-align: center;
      margin: 0;
    }

    .modal-cambio a {
      color: var(--color-primario-b);
      font-weight: 600;
      text-decoration: none;
    }

    /* Menú de personalización (color y tema) */
    .tema-menu {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: .5rem;
      flex-shrink: 0;
      z-index: 30;
    }

    .tema-panel {
      position: fixed;
      width: 250px;
      background: var(--bg-tarjeta);
      color: var(--texto);
      border: 1px solid var(--borde);
      border-radius: 10px;
      box-shadow: 0 8px 24px rgba(0,0,0,.22);
      z-index: 210;
      padding: .4rem 0 .6rem;
    }

    .tema-panel-titulo {
      font-weight: 700;
      padding: .55rem .8rem .4rem;
      font-size: .95rem;
      border-bottom: 1px solid var(--bg-suave-2);
      margin-bottom: .3rem;
    }

    .tema-fila {
      display: flex;
      align-items: center;
      gap: .6rem;
      padding: .45rem .8rem;
    }

    .tema-etiqueta {
      flex: 1;
      font-size: .85rem;
    }

    #colorPrincipal {
      width: 40px;
      height: 30px;
      border: 1px solid var(--borde);
      border-radius: 6px;
      padding: 0;
      cursor: pointer;
      background: transparent;
    }

    /* Paleta de colores predefinidos (curados: contraste garantizado) */
    .paleta {
      display: flex;
      flex-wrap: wrap;
      gap: .35rem;
      max-width: 170px;
    }

    .punto-color {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      border: 2px solid var(--borde);
      cursor: pointer;
      padding: 0;
      margin: 0;
      flex-shrink: 0;
      transition: transform .12s;
    }

    .punto-color:hover { transform: scale(1.2); }
    .punto-color.seleccionado { outline: 2px solid var(--texto); outline-offset: 2px; }

    .btn-tema-toggle {
      margin-top: 0;
      background: var(--bg-suave-2);
      color: var(--texto);
      border: 1px solid var(--borde);
      border-radius: 8px;
      padding: .4rem .8rem;
      font-size: .85rem;
      cursor: pointer;
      flex-shrink: 0;
    }

    .btn-tema-toggle:hover { background: var(--borde); }

    /* Layout principal: sidebar + contenido */
    .layout {
      flex: 1;
      min-height: 0;
      width: 100%;
      padding: 1.25rem 0;
      display: grid;
      grid-template-columns: 270px 1fr 270px;
      gap: 1.5rem;
      align-items: stretch;
      overflow: hidden;
    }

    /* Barras laterales (calendario izq, categorías der) */
    .sidebar {
      background: var(--bg-tarjeta);
      border-radius: 12px;
      padding: 1.25rem;
      box-shadow: 0 2px 12px rgba(0,0,0,.06);
      position: relative;
      overflow-y: auto;   /* el sidebar queda fijo; scroll propio si no cabe */
    }
    .sidebar-izq {
      margin-left: 0;
    }
    .sidebar-der {
      margin-right: 0;
    }

    .sidebar h2 {
      font-size: 1.1rem;
      margin-bottom: 1rem;
      color: var(--color-primario-txt);
    }

    /* Panel de amigos */
    .sidebar-der h3 {
      font-size: 1rem;
      margin: 1rem 0 .6rem;
      color: var(--color-primario-txt);
    }

    .sidebar-der h3:first-of-type {
      margin-top: 0;
    }

    .btn-accion {
      width: 100%;
      margin-top: 0;
      margin-bottom: .5rem;
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      padding: .6rem;
      font-size: .9rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
      transition: background .2s;
    }

    .btn-accion:hover { background: var(--color-primario); }

    .btn-accion.btn-agregar {
      background: var(--bg-suave);
      color: var(--color-primario-txt);
      border: 1px solid #a5d8b0;
    }

    .btn-accion.btn-agregar:hover { background: var(--bg-suave); }

    .solicitudes {
      border-top: 1px solid var(--bg-suave-2);
      padding-top: .8rem;
    }

    .amigos-lista {
      display: flex;
      flex-direction: column;
      gap: .5rem;
    }

    .amigo-item {
      position: relative;
      display: flex;
      align-items: center;
      gap: .6rem;
      padding: .5rem .6rem;
      border-radius: 8px;
      background: var(--bg-suave);
      cursor: pointer;
      transition: background .15s;
    }

    .amigo-item:hover { background: var(--bg-suave-2); }

    /* Puntito rojo: el amigo publicó algo nuevo en su muro */
    .amigo-item .punto-nuevo {
      position: absolute;
      top: 6px;
      left: 6px;
      width: 11px;
      height: 11px;
      border-radius: 50%;
      background: #e74c3c;
      border: 2px solid #fff;
      box-shadow: 0 1px 3px rgba(0,0,0,.3);
      animation: pulsoPunto 1.6s ease-in-out infinite;
    }

    @keyframes pulsoPunto {
      0%, 100% { transform: scale(1); }
      50%      { transform: scale(1.25); }
    }

    .amigo-item.activo {
      background: var(--color-primario-b);
      color: #fff;
    }

    .amigo-item.activo .amigo-nombre { color: #fff; }

    .amigo-item.activo .amigo-eliminar { color: #fff; }

    .amigo-item img {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid #cfe3d4;
    }

    .amigo-item .amigo-vacio {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: var(--borde);
      flex-shrink: 0;
    }

    .amigo-item .amigo-nombre {
      font-weight: 600;
      color: var(--texto);
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .amigo-item .amigo-eliminar {
      background: transparent;
      border: none;
      color: var(--texto-suave);
      cursor: pointer;
      font-size: 1rem;
      padding: 0 .2rem;
    }

    .amigo-item .amigo-eliminar:hover { color: var(--color-error-txt); }

    .sin-amigos {
      text-align: center;
      color: var(--texto-suave);
      font-size: .85rem;
      padding: .5rem;
      border: 2px dashed var(--borde);
      border-radius: 8px;
    }

    .solicitud-item {
      display: flex;
      align-items: center;
      gap: .5rem;
      padding: .4rem .2rem;
      border-bottom: 1px solid #eef1ef;
      font-size: .9rem;
    }

    .solicitud-item .nombre {
      flex: 1;
      font-weight: 600;
      color: var(--texto);
    }

    .solicitud-item button {
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: .3rem .6rem;
      cursor: pointer;
      font-size: .78rem;
      font-weight: 600;
    }

    .solicitud-item button.rechazar {
      background: var(--bg-suave-2);
      color: var(--texto-suave);
    }

    .solicitud-item button:hover { opacity: .85; }

    /* Calendario del sidebar */
    .calendario {
      margin-top: 1.5rem;
      border-top: 1px solid var(--bg-suave-2);
      padding-top: 1rem;
    }

    .calendario h3 {
      font-size: 1rem;
      margin-bottom: .8rem;
      color: var(--color-primario-txt);
    }

    .cal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: .5rem;
    }

    .cal-head .mes {
      font-weight: 700;
      font-size: .95rem;
      color: var(--texto);
    }

    .cal-btn {
      border: none;
      background: var(--color-primario-b);
      color: #fff;
      width: 26px;
      height: 26px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 1rem;
      line-height: 1;
      transition: background .15s;
    }

    .cal-btn:hover { background: var(--color-primario); }

    .cal-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 2px;
      text-align: center;
    }

    .cal-dow {
      font-size: .7rem;
      color: var(--texto-suave);
      font-weight: 600;
      padding-bottom: .3rem;
    }

    .cal-num {
      aspect-ratio: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: .82rem;
      border-radius: 6px;
      border: 2px solid transparent;
      cursor: default;
      color: var(--texto);
    }

    .cal-num.vacio {
      cursor: default;
      border: none;
      color: transparent;
    }

    .cal-num.otro-mes {
      color: var(--texto-suave);
    }

    .cal-num.tiene {
      cursor: pointer;
      font-weight: 700;
      color: var(--color-primario-txt);
      background: var(--bg-suave);
      border-color: #a5d8b0;
    }

    .cal-num.tiene:hover {
      background: var(--bg-suave);
    }

    .cal-num.seleccionado {
      background: var(--color-primario-b);
      color: #fff;
      border-color: var(--color-primario);
    }

    .cal-num.hoy {
      box-shadow: 0 0 0 2px var(--color-primario-b);
    }


    .content {
      min-width: 0;
      min-height: 0;
      overflow-y: auto;   /* el scroll de la página ocurre aquí, solo en posts */
      padding-right: .25rem;
    }

    /* Barra de navegación del muro */
    .muro-nav {
      display: flex;
      align-items: center;
      gap: .75rem;
      margin-bottom: 1rem;
    }

    .muro-volver {
      margin-top: 0;
      background: var(--bg-suave);
      color: var(--color-primario-txt);
      border: 1px solid #a5d8b0;
      padding: .45rem .9rem;
      font-size: .85rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
    }

    .muro-volver:hover { background: var(--bg-suave); }

    .muro-titulo {
      font-size: 1.4rem;
      color: var(--color-primario-txt);
      margin: 0;
    }

    main .card {
      background: var(--bg-tarjeta);
      border-radius: 12px;
      padding: 1.25rem;
      box-shadow: 0 2px 12px rgba(0,0,0,.06);
      margin-bottom: 1.5rem;
    }

    .card h2 {
      font-size: 1.1rem;
      margin-bottom: .8rem;
      color: var(--color-primario-txt);
    }

    textarea {
      width: 100%;
      min-height: 40px;       /* una sola línea; crece con auto-expand (JS) */
      padding: .85rem;
      font-size: 1rem;
      font-family: inherit;
      border: 2px solid var(--borde);
      border-radius: 8px;
      resize: none;           /* el crecimiento lo maneja el JS */
      overflow-y: auto;
      transition: border-color .2s;
    }

    textarea:focus {
      outline: none;
      border-color: var(--color-primario-b);
    }

    /* Adjuntar imagen al post */
    .post-adjuntos {
      margin-top: .6rem;
      display: flex;
      align-items: center;
      gap: .75rem;
      flex-wrap: wrap;
    }

    .btn-imagen {
      margin-top: 0;
      background: var(--bg-suave);
      color: var(--color-primario-txt);
      border: 1px solid #a5d8b0;
      padding: .5rem 1rem;
      font-size: .9rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
    }

    .btn-imagen:hover { background: var(--bg-suave); }

    .img-preview {
      position: relative;
      display: none;
    }

    .img-preview img {
      max-width: 200px;
      max-height: 120px;
      border-radius: 8px;
      border: 1px solid var(--borde);
      display: block;
    }

    .img-preview button {
      position: absolute;
      top: -8px;
      right: -8px;
      width: 22px;
      height: 22px;
      padding: 0;
      margin: 0;
      border-radius: 50%;
      background: var(--color-error-txt);
      font-size: .75rem;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Imagen dentro del post */
    .post .post-imagen {
      margin-top: .6rem;
    }

    .post .post-imagen img {
      max-width: 100%;
      max-height: 320px;
      border-radius: 10px;
      display: block;
      border: 1px solid var(--bg-suave-2);
    }

    button {
      margin-top: .8rem;
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      padding: .6rem 1.5rem;
      font-size: 1rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
      transition: background .2s, transform .1s;
    }

    button:hover { background: var(--color-primario); }
    button:active { transform: scale(.97); }

    #status {
      margin-top: .8rem;
      font-size: .9rem;
      color: var(--texto-suave);
      display: none;
    }

    #posts {
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }

    .post {
      background: var(--bg-tarjeta);
      border-radius: 12px;
      padding: 1.25rem 1.5rem;
      box-shadow: 0 2px 12px rgba(0,0,0,.06);
      border-left: 4px solid var(--color-primario-b);
    }

    .post .autor {
      display: flex;
      align-items: center;
      gap: .6rem;
      margin-bottom: .4rem;
    }

    .post .autor img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid var(--bg-suave-2);
    }

    .post .autor .nombre {
      font-weight: 600;
      color: var(--color-primario-txt);
    }

    .post .autor .fecha {
      font-size: .8rem;
      color: var(--texto-suave);
      font-weight: 400;
      display: block;
    }

    .post-toolbar {
      display: flex;
      justify-content: flex-end;
      margin-bottom: .3rem;
    }

    .post-eliminar {
      background: transparent;
      border: none;
      color: var(--color-error-txt);
      font-size: 1rem;
      cursor: pointer;
      padding: .1rem .3rem;
      border-radius: 6px;
    }

    .post-eliminar:hover { background: #fce8e8; }

    .post .texto {
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    .posts-placeholder {
      text-align: center;
      color: var(--texto-suave);
      padding: 1rem;
      border: 2px dashed var(--borde);
      border-radius: 8px;
    }

    footer {
      text-align: center;
      padding: 1.25rem;
      color: var(--texto-suave);
      font-size: .85rem;
    }
    /* Popup de imagen ampliada */
    .post .post-imagen img {
      cursor: zoom-in;
    }

    .img-popup {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.6);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 3000;
    }

    .img-popup.abierto { display: flex; }

    .img-popup-contenedor {
      background: var(--bg-tarjeta);
      border-radius: 12px;
      box-shadow: 0 10px 40px rgba(0,0,0,.4);
      width: 520px;
      max-width: 85vw;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: fixed;   /* para poder arrastrarlo libremente */
      cursor: move;
      user-select: none;
    }

    .img-popup-barra {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: .5rem .8rem;
      background: var(--bg-suave);
      border-bottom: 1px solid var(--bg-suave-2);
      cursor: move;
    }

    .img-popup-zoom-info {
      font-size: .8rem;
      color: var(--texto-suave);
      font-weight: 600;
    }

    .img-popup-cerrar {
      background: transparent;
      border: none;
      font-size: 1.1rem;
      cursor: pointer;
      color: var(--texto-suave);
      width: 26px; height: 26px;
    }

    .img-popup-ver {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 240px;
      max-height: 55vh;
      overflow: hidden;
      cursor: default;
      background: var(--bg-tarjeta);
      padding: .5rem;
    }

    .img-popup-ver img {
      max-width: 100%;
      max-height: 55vh;
      object-fit: contain;
      transition: transform .1s;
      transform-origin: 0 0;   /* escala desde la esquina superior izq para pan predecible */
      user-select: none;
      -webkit-user-drag: none;
    }

    .img-popup-zoom {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: .6rem;
      padding: .5rem;
      border-top: 1px solid var(--bg-suave-2);
    }

    .img-popup-zoom button {
      width: 30px; height: 30px;
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      border-radius: 6px;
      font-size: 1rem;
      cursor: pointer;
      margin: 0;
    }

    .img-popup-zoom button:hover { background: var(--color-primario); }

    .img-popup-zoom span {
      font-weight: 600;
      min-width: 45px;
      text-align: center;
    }

    /* Ventana de chat */
    .chat-window {
      position: fixed;
      bottom: 1rem;
      right: 1rem;
      width: 340px;
      height: 480px;
      background: var(--bg-tarjeta);
      border-radius: 14px;
      box-shadow: 0 8px 30px rgba(0,0,0,.25);
      display: none;
      flex-direction: column;
      overflow: hidden;
      z-index: 2000;
      font-size: .9rem;
    }

    .chat-window.abierto { display: flex; }

    .chat-header {
      background: linear-gradient(135deg, var(--color-primario), var(--color-primario-b));
      color: #fff;
      padding: .7rem 1rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-weight: 700;
    }

    .chat-cerrar {
      background: transparent;
      border: none;
      color: #fff;
      font-size: 1rem;
      cursor: pointer;
      width: 26px; height: 26px;
    }

    .chat-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

    .chat-amigos {
      padding: .5rem;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: .4rem;
    }

    .chat-amigo {
      display: flex;
      align-items: center;
      gap: .5rem;
      padding: .55rem .6rem;
      border-radius: 8px;
      background: var(--bg-suave);
      cursor: pointer;
      font-weight: 600;
    }

    .chat-amigo:hover { background: var(--bg-suave-2); }
    .chat-amigo img, .chat-amigo .amigo-vacio {
      width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
    }

    .chat-sin-amigos {
      text-align: center;
      color: var(--texto-suave);
      padding: 1rem;
      font-size: .85rem;
    }

    .chat-conv { flex: 1; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--bg-suave-2); }

    .chat-conv-titulo {
      padding: .5rem .75rem;
      font-weight: 700;
      color: var(--color-primario-txt);
      background: var(--bg-suave);
      border-bottom: 1px solid var(--bg-suave-2);
      display: flex;
      align-items: center;
      gap: .5rem;
    }

    .chat-volver {
      background: var(--bg-suave);
      color: var(--color-primario-txt);
      border: 1px solid #a5d8b0;
      border-radius: 6px;
      width: 26px;
      height: 26px;
      cursor: pointer;
      font-size: .95rem;
      line-height: 1;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chat-volver:hover { background: var(--bg-suave); }

    .chat-msg {
      flex: 1;
      overflow-y: auto;
      padding: .6rem;
      display: flex;
      flex-direction: column;
      gap: .4rem;
      background: var(--bg-tarjeta);
    }

    .burbuja {
      max-width: 75%;
      padding: .45rem .7rem;
      border-radius: 12px;
      font-size: .85rem;
      word-wrap: break-word;
    }

    .burbuja.mia { align-self: flex-end; background: var(--color-primario-b); color: #fff; }
    .burbuja.suya { align-self: flex-start; background: var(--bg-suave-2); color: var(--texto); }

    .burbuja .hora { display: block; font-size: .65rem; opacity: .7; margin-top: .2rem; }

    .chat-input {
      display: flex;
      gap: .4rem;
      padding: .5rem;
      border-top: 1px solid var(--bg-suave-2);
    }

    .chat-input input {
      flex: 1;
      padding: .5rem .6rem;
      border: 2px solid var(--borde);
      border-radius: 8px;
      font-size: .9rem;
      font-family: inherit;
    }

    .chat-input input:focus { outline: none; border-color: var(--color-primario-b); }

    .chat-input button {
      margin-top: 0;
      background: var(--color-primario-b);
      color: #fff;
      border: none;
      padding: .5rem .9rem;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 600;
    }

/* ===== Notificaciones (campanita) ===== */
/* En el flujo del header (sin transform: un
   transform en el ancestro rompería el position:fixed del panel). */
.notif-wrap {
  display: flex;
  align-items: center;
  margin-left: .6rem;
  flex-shrink: 0;
  z-index: 30;
}
.btn-campana {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  position: relative;
  padding: 0.25rem;
  line-height: 1;
  color: #fff;
}
.btn-campana:hover { transform: scale(1.1); }
.notif-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: #e74c3c;
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 1.05rem;
  height: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.notif-panel {
  position: fixed;
  width: 330px;
  max-height: 430px;
  overflow-y: auto;
  background: var(--bg-tarjeta);
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  z-index: 200;
}
.notif-panel-titulo {
  font-weight: 700;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
  position: sticky;
  top: 0;
  background: var(--bg-tarjeta);
  border-radius: 10px 10px 0 0;
}
.notif-seccion h4 {
  margin: 0;
  padding: 0.5rem 0.8rem 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texto-suave);
}
.notif-lista { padding: 0 0.4rem 0.5rem; }
.notif-item {
  display: flex;
  gap: 0.55rem;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  align-items: flex-start;
}
.notif-item:hover { background: #f2f8f3; }
.notif-item.nueva { background: #e8f5e9; }
.notif-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.notif-cuerpo {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.notif-titulo { font-size: 0.85rem; }
.notif-texto {
  font-size: 0.8rem;
  color: var(--texto-suave);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-hora { font-size: 0.7rem; color: var(--texto-suave); }
.notif-vacio {
  padding: 0.8rem;
  text-align: center;
  color: var(--texto-suave);
  font-size: 0.85rem;
}
.notif-item.vacio {
  cursor: default;
  justify-content: center;
  color: var(--texto-suave);
}

/* ===== Resaltado de post/mensaje nuevo (2 s) ===== */
.post.destacado {
  outline: 3px solid #f1c40f;
  outline-offset: 2px;
  background: #fffbe6;
  animation: destacarNuevo 1s ease-out 2;   /* 2 veces = 2 s */
}
.burbuja.destacado {
  outline: 3px solid #f1c40f;
  outline-offset: 2px;
  animation: destacarNuevo 1s ease-out 2;
}
.solicitud-item button.destacado {
  outline: 3px solid #f1c40f;
  outline-offset: 2px;
  animation: destacarNuevo 1s ease-out 2;
}
@keyframes destacarNuevo {
  0%   { box-shadow: 0 0 0 0 rgba(241,196,15,.75); }
  100% { box-shadow: 0 0 0 12px rgba(241,196,15,0); }
}

/* ===== Variables de tema (claro/oscuro) y color personalizable ===== */
:root {
  --color-primario: #0b5d2e;      /* verde por defecto (cambiable) */
  --color-primario-b: #158a43;    /* tono brillante (calculado en JS) */
  /* Color de MARCA para texto: se oscurece en claro para legibilidad */
  --color-primario-txt: color-mix(in srgb, var(--color-primario) 62%, black);
  --color-error-txt: #c0392b;
  --bg-pagina: #f4f6f5;
  --bg-tarjeta: #ffffff;
  --bg-suave: #eef3ef;
  --bg-suave-2: #e6ebe7;
  --texto: #1a1a1a;
  --texto-suave: #666666;
  --borde: #d9e0dc;
}

/* ===== Paleta de colores predefinidos (curados: contraste garantizado) =====
   Todos son lo bastante oscuros para el texto blanco del header y legibles
   en modo claro y oscuro. El JS solo cambia data-color en <html>. */
[data-color="verde"]   { --color-primario: #0b5d2e; --color-primario-b: #158a43; }
[data-color="azul"]    { --color-primario: #1a4f8b; --color-primario-b: #2f6cb8; }
[data-color="indigo"]  { --color-primario: #3b3a8f; --color-primario-b: #5a58b8; }
[data-color="purpura"] { --color-primario: #6b2d8b; --color-primario-b: #8f4bb5; }
[data-color="magenta"] { --color-primario: #8b2d5e; --color-primario-b: #b54b85; }
[data-color="rojo"]    { --color-primario: #8b2d2d; --color-primario-b: #b84b4b; }
[data-color="naranja"] { --color-primario: #8b542d; --color-primario-b: #b5774b; }
[data-color="teal"]    { --color-primario: #1d6b63; --color-primario-b: #2f8f85; }
[data-color="marino"]  { --color-primario: #1e3a5f; --color-primario-b: #2f5a8f; }
[data-color="gris"]    { --color-primario: #4a4f4d; --color-primario-b: #6b726f; }

body[data-tema="oscuro"] {
  /* Color de MARCA para texto: se aclara en oscuro para legibilidad */
  --color-primario-txt: color-mix(in srgb, var(--color-primario) 52%, white);
  --color-error-txt: #e0695f;
  --bg-pagina: #161a18;
  --bg-tarjeta: #212623;
  --bg-suave: #2a302c;
  --bg-suave-2: #343b37;
  --texto: #e6ece8;
  --texto-suave: #9aa6a0;
  --borde: #3d4540;
}

body[data-tema="oscuro"] .img-popup-contenedor,
body[data-tema="oscuro"] .chat-window,
body[data-tema="oscuro"] .notif-panel,
body[data-tema="oscuro"] .tema-panel { box-shadow: 0 8px 30px rgba(0,0,0,.55); }

/* Transición suave al cambiar de tema/color */
body, header, .post, .card, .sidebar, .modal, .chat-window, .notif-panel,
.tema-panel, .amigo-item, .cal-num, .burbuja, button, input, textarea {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ===== Responsive: pantallas medianas (tablets pequeñas) ===== */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 220px 1fr 220px;
    gap: 1rem;
  }
}

/* ===== Responsive: móviles (vertical y horizontal) ===== */
@media (max-width: 860px) {
  /* --- Header compacto --- */
  header { height: auto; min-height: 64px; }
  .header-inner {
    flex-wrap: wrap;
    padding: .5rem .8rem;
    gap: .4rem .6rem;
  }
  .avatar-wrap { order: 1; }
  .brand { order: 2; flex: 1; min-width: 0; }
  .brand h1 { font-size: 1.15rem; }
  .brand h1 span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .brand .sub { display: none; }          /* se oculta el subtítulo */
  .notif-wrap { order: 3; margin-left: 0; }
  .tema-menu { order: 4; margin-left: 0; }
  .sesion {
    order: 5;
    position: static;
    transform: none;
    margin-left: 0;
  }
  .btn-sesion { margin-top: 0; padding: .4rem .8rem; font-size: .85rem; }
  .btn-campana { font-size: 1.3rem; }

  /* --- Layout de una sola columna: posts primero --- */
  .layout {
    display: flex;
    flex-direction: column;
    overflow: visible;       /* la página hace scroll, no los paneles */
    padding: .8rem;
    gap: 1rem;
  }
  main.content { order: -1; width: 100%; overflow: visible; }
  /* calendario y amigos se mueven al panel del menú ☰ (ver bloque menú móvil) */

  /* --- Avatar compacto en el header --- */
  .avatar { width: 44px; height: 44px; }

  /* --- Chat a pantalla completa --- */
  .chat-window {
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  /* --- Modales y popups --- */
  .modal { width: min(92vw, 340px); }
  .modal.modal-ancho { width: min(94vw, 430px); }
  .img-popup-contenedor { width: 94vw; max-height: 90vh; }
  .notif-panel, .tema-panel { width: min(94vw, 340px); }

  /* --- Ajustes de contenido --- */
  main .card, .post { padding: 1rem; }
  .cal-grid { gap: .2rem; }
  .cal-num { padding: .15rem 0; }
}

/* Pantallas muy pequeñas (verticales angostas) */
@media (max-width: 480px) {
  .layout { padding: .6rem; }
  .btn-accion { width: 100%; }
  .post { padding: .85rem; }
  #entrada { font-size: 1rem; }   /* evita el zoom automático de iOS al enfocar */
}

/* Landscape con poca altura: compactar aún más */
@media (max-height: 480px) and (max-width: 900px) {
  .chat-window { height: 100%; }
  .img-popup-contenedor { max-height: 88vh; }
  header { min-height: 56px; }
}

/* ===== Menú móvil (hamburguesa ☰): calendario y amigos desplegables ===== */
.btn-menu {
  display: none;                       /* solo se ve en móvil */
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: .2rem .35rem;
  margin: 0;
}
.btn-menu:hover { background: rgba(0,0,0,.15); }

.menu-panel { display: none; }         /* desktop: no existe (sidebars en el grid) */
.menu-overlay { display: none; }       /* desktop: no existe */

@media (max-width: 860px) {
  .btn-menu { display: block; order: 0; flex-shrink: 0; }

  .menu-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(86vw, 330px);
    background: var(--bg-tarjeta);
    color: var(--texto);
    z-index: 220;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
    transform: translateX(-100%);      /* oculto: se desliza al abrir */
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .menu-panel.abierto { transform: translateX(0); }

  .menu-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid var(--borde);
    position: sticky;
    top: 0;
    background: var(--bg-tarjeta);
  }

  .menu-cerrar {
    margin: 0;
    background: var(--bg-suave-2);
    color: var(--texto);
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
  }
  .menu-cerrar:hover { background: var(--borde); }

  /* Las sidebars viven dentro del panel en móvil */
  .menu-panel .sidebar {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    overflow-y: visible;
    border-bottom: 1px solid var(--borde);
  }

  .menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 210;
  }
}
